aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
Diffstat (limited to 'xtask')
-rw-r--r--xtask/Cargo.toml2
-rw-r--r--xtask/src/ast_src.rs1
-rw-r--r--xtask/src/dist.rs73
3 files changed, 60 insertions, 16 deletions
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml
index 78a0b54ba..96b4ea448 100644
--- a/xtask/Cargo.toml
+++ b/xtask/Cargo.toml
@@ -15,7 +15,7 @@ flate2 = "1.0"
15pico-args = "0.3.1" 15pico-args = "0.3.1"
16proc-macro2 = "1.0.8" 16proc-macro2 = "1.0.8"
17quote = "1.0.2" 17quote = "1.0.2"
18ungrammar = "1.4" 18ungrammar = "1.5"
19walkdir = "2.3.1" 19walkdir = "2.3.1"
20write-json = "0.1.0" 20write-json = "0.1.0"
21xshell = "0.1" 21xshell = "0.1"
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs
index a69ced5cc..2b8012bdd 100644
--- a/xtask/src/ast_src.rs
+++ b/xtask/src/ast_src.rs
@@ -132,6 +132,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
132 "RANGE_PAT", 132 "RANGE_PAT",
133 "LITERAL_PAT", 133 "LITERAL_PAT",
134 "MACRO_PAT", 134 "MACRO_PAT",
135 "CONST_BLOCK_PAT",
135 // atoms 136 // atoms
136 "TUPLE_EXPR", 137 "TUPLE_EXPR",
137 "ARRAY_EXPR", 138 "ARRAY_EXPR",
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs
index 9e15a5a4c..d59b88131 100644
--- a/xtask/src/dist.rs
+++ b/xtask/src/dist.rs
@@ -58,30 +58,73 @@ fn dist_client(version: &str, release_tag: &str) -> Result<()> {
58} 58}
59 59
60fn dist_server() -> Result<()> { 60fn dist_server() -> Result<()> {
61 if cfg!(target_os = "linux") { 61 let target = get_target();
62 if target.contains("-linux-gnu") {
62 env::set_var("CC", "clang"); 63 env::set_var("CC", "clang");
63 } 64 }
64 cmd!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release").run()?;
65
66 let (src, dst) = if cfg!(target_os = "linux") {
67 ("./target/release/rust-analyzer", "./dist/rust-analyzer-linux")
68 } else if cfg!(target_os = "windows") {
69 ("./target/release/rust-analyzer.exe", "./dist/rust-analyzer-windows.exe")
70 } else if cfg!(target_os = "macos") {
71 ("./target/release/rust-analyzer", "./dist/rust-analyzer-mac")
72 } else {
73 panic!("Unsupported OS")
74 };
75 65
76 let src = Path::new(src); 66 let toolchain = toolchain(&target);
77 let dst = Path::new(dst); 67 cmd!("cargo +{toolchain} build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target} --release").run()?;
78 68
79 cp(&src, &dst)?; 69 let suffix = exe_suffix(&target);
70 let src =
71 Path::new("target").join(&target).join("release").join(format!("rust-analyzer{}", suffix));
72 let dst = Path::new("dist").join(format!("rust-analyzer-{}{}", target, suffix));
80 gzip(&src, &dst.with_extension("gz"))?; 73 gzip(&src, &dst.with_extension("gz"))?;
81 74
75 // FIXME: the old names are temporarily kept for client compatibility, but they should be removed
76 // Remove this block after a couple of releases
77 match target.as_ref() {
78 "x86_64-unknown-linux-gnu" => {
79 cp(&src, "dist/rust-analyzer-linux")?;
80 gzip(&src, Path::new("dist/rust-analyzer-linux.gz"))?;
81 }
82 "x86_64-pc-windows-msvc" => {
83 cp(&src, "dist/rust-analyzer-windows.exe")?;
84 gzip(&src, Path::new("dist/rust-analyzer-windows.gz"))?;
85 }
86 "x86_64-apple-darwin" => {
87 cp(&src, "dist/rust-analyzer-mac")?;
88 gzip(&src, Path::new("dist/rust-analyzer-mac.gz"))?;
89 }
90 _ => {}
91 }
92
82 Ok(()) 93 Ok(())
83} 94}
84 95
96fn get_target() -> String {
97 match env::var("RA_TARGET") {
98 Ok(target) => target,
99 _ => {
100 if cfg!(target_os = "linux") {
101 "x86_64-unknown-linux-gnu".to_string()
102 } else if cfg!(target_os = "windows") {
103 "x86_64-pc-windows-msvc".to_string()
104 } else if cfg!(target_os = "macos") {
105 "x86_64-apple-darwin".to_string()
106 } else {
107 panic!("Unsupported OS, maybe try setting RA_TARGET")
108 }
109 }
110 }
111}
112
113fn exe_suffix(target: &str) -> String {
114 if target.contains("-windows-") {
115 ".exe".into()
116 } else {
117 "".into()
118 }
119}
120
121fn toolchain(target: &str) -> String {
122 match target {
123 "aarch64-apple-darwin" => "beta".to_string(),
124 _ => "stable".to_string(),
125 }
126}
127
85fn gzip(src_path: &Path, dest_path: &Path) -> Result<()> { 128fn gzip(src_path: &Path, dest_path: &Path) -> Result<()> {
86 let mut encoder = GzEncoder::new(File::create(dest_path)?, Compression::best()); 129 let mut encoder = GzEncoder::new(File::create(dest_path)?, Compression::best());
87 let mut input = io::BufReader::new(File::open(src_path)?); 130 let mut input = io::BufReader::new(File::open(src_path)?);