aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/dist.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-07 21:36:18 +0100
committerGitHub <[email protected]>2020-07-07 21:36:18 +0100
commit56ade20380a028026eeb71af2a8a81e37ede7efb (patch)
treefbf0e24250cc36eaa122904e78cd7cb50fe1c665 /xtask/src/dist.rs
parent980a67f44629ed67a54b603aaf9d015a81d61f7a (diff)
parentf92bfb580780cda02f9ba8a935538f984d8a4c0d (diff)
Merge #4972
4972: Gzip artifacts r=Veetaha a=Veetaha [Here is the test release](https://github.com/Veetaha/rust-analyzer/releases/tag/2020-06-21) Change in size: `~ 25 MB -> ~ 8 MB (gzipped)` The time to gzip during the dist build takes a somewhat considerable amount of time tho. Having already compiled artifacts this takes in debug mode: ``` ~/dev/rust-analyzer (feat/gzip-binaries) $ time cargo xtask dist Finished dev [unoptimized] target(s) in 0.06s Running `target/debug/xtask dist` > cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release Finished release [optimized] target(s) in 0.05s > strip ./target/release/rust-analyzer real 0m34.331s user 0m34.245s sys 0m0.078s ``` In release mode this is much faster: ``` ~/dev/rust-analyzer (feat/gzip-binaries) $ time cargo run -p xtask --release -- dist Finished release [optimized] target(s) in 0.04s Running `target/release/xtask dist` > cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release Finished release [optimized] target(s) in 0.06s > strip ./target/release/rust-analyzer real 0m2.401s ``` **[UPD]** adding a profile override for `miniz_oxide` does the thing to ensure good performrance We might need to notify all other ra plugins' maintainers about the change in our GH releases if we merge this PR, or we could leave uncompressed files along with gzipped for a while until everyone migrates. Co-authored-by: Veetaha <[email protected]>
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