aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/dist.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/dist.rs')
-rw-r--r--xtask/src/dist.rs31
1 files changed, 23 insertions, 8 deletions
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs
index aef68089e..b8f68027c 100644
--- a/xtask/src/dist.rs
+++ b/xtask/src/dist.rs
@@ -1,4 +1,10 @@
1use std::path::PathBuf; 1use flate2::{write::GzEncoder, Compression};
2use std::{
3 env,
4 fs::File,
5 io,
6 path::{Path, PathBuf},
7};
2 8
3use anyhow::Result; 9use anyhow::Result;
4 10
@@ -16,7 +22,7 @@ pub fn run_dist(nightly: bool, client_version: Option<String>) -> Result<()> {
16 let release_tag = if nightly { "nightly".to_string() } else { date_iso()? }; 22 let release_tag = if nightly { "nightly".to_string() } else { date_iso()? };
17 dist_client(&version, &release_tag)?; 23 dist_client(&version, &release_tag)?;
18 } 24 }
19 dist_server(nightly)?; 25 dist_server()?;
20 Ok(()) 26 Ok(())
21} 27}
22 28
@@ -46,17 +52,14 @@ fn dist_client(version: &str, release_tag: &str) -> Result<()> {
46 Ok(()) 52 Ok(())
47} 53}
48 54
49fn dist_server(nightly: bool) -> Result<()> { 55fn dist_server() -> Result<()> {
50 if cfg!(target_os = "linux") { 56 if cfg!(target_os = "linux") {
51 std::env::set_var("CC", "clang"); 57 env::set_var("CC", "clang");
52 run!( 58 run!(
53 "cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release" 59 "cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release"
54 // We'd want to add, but that requires setting the right linker somehow 60 // We'd want to add, but that requires setting the right linker somehow
55 // --features=jemalloc 61 // --features=jemalloc
56 )?; 62 )?;
57 if !nightly {
58 run!("strip ./target/release/rust-analyzer")?;
59 }
60 } else { 63 } else {
61 run!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release")?; 64 run!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release")?;
62 } 65 }
@@ -71,8 +74,20 @@ fn dist_server(nightly: bool) -> Result<()> {
71 panic!("Unsupported OS") 74 panic!("Unsupported OS")
72 }; 75 };
73 76
74 fs2::copy(src, dst)?; 77 let src = Path::new(src);
78 let dst = Path::new(dst);
79
80 fs2::copy(&src, &dst)?;
81 gzip(&src, &dst.with_extension("gz"))?;
82
83 Ok(())
84}
75 85
86fn gzip(src_path: &Path, dest_path: &Path) -> Result<()> {
87 let mut encoder = GzEncoder::new(File::create(dest_path)?, Compression::best());
88 let mut input = io::BufReader::new(File::open(src_path)?);
89 io::copy(&mut input, &mut encoder)?;
90 encoder.finish()?;
76 Ok(()) 91 Ok(())
77} 92}
78 93