mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 07:04:22 +00:00
Auto merge of #13876 - lnicola:zip-artifacts, r=lnicola
feat: Package Windows release artifacts as ZIP and add symbols file Closes #13872 Closes #7747 CC #10371 This allows us to ship a format that's easier to handle on Windows. As a bonus, we can also include the PDB, to get useful stack traces. Unfortunately, it adds a couple of dependencies to `xtask`, increasing the debug build times from 1.28 to 1.58 s (release from 1.60s to 2.20s) on my system.
This commit is contained in:
commit
1bd1a09593
4 changed files with 86 additions and 1 deletions
47
Cargo.lock
generated
47
Cargo.lock
generated
|
@ -112,6 +112,12 @@ version = "1.3.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
|
||||
[[package]]
|
||||
name = "camino"
|
||||
version = "1.1.1"
|
||||
|
@ -1776,6 +1782,33 @@ dependencies = [
|
|||
"tikv-jemalloc-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"serde",
|
||||
"time-core",
|
||||
"time-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2"
|
||||
dependencies = [
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.6.0"
|
||||
|
@ -2174,4 +2207,18 @@ dependencies = [
|
|||
"write-json",
|
||||
"xflags",
|
||||
"xshell",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "537ce7411d25e54e8ae21a7ce0b15840e7bfcff15b51d697ec3266cc76bdf080"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"crc32fast",
|
||||
"crossbeam-utils",
|
||||
"flate2",
|
||||
"time",
|
||||
]
|
||||
|
|
|
@ -194,6 +194,7 @@ MIT OR Apache-2.0
|
|||
MIT OR Apache-2.0 OR Zlib
|
||||
MIT OR Zlib OR Apache-2.0
|
||||
MIT/Apache-2.0
|
||||
Unlicense OR MIT
|
||||
Unlicense/MIT
|
||||
Zlib OR Apache-2.0 OR MIT
|
||||
"
|
||||
|
|
|
@ -12,4 +12,5 @@ flate2 = "1.0.24"
|
|||
write-json = "0.1.2"
|
||||
xshell = "0.2.2"
|
||||
xflags = "0.3.0"
|
||||
zip = { version = "0.6", default-features = false, features = ["deflate", "time"] }
|
||||
# Avoid adding more dependencies to this crate
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use std::{
|
||||
env,
|
||||
fs::File,
|
||||
io,
|
||||
io::{self, BufWriter},
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use flate2::{write::GzEncoder, Compression};
|
||||
use xshell::{cmd, Shell};
|
||||
use zip::{write::FileOptions, DateTime, ZipWriter};
|
||||
|
||||
use crate::{date_iso, flags, project_root};
|
||||
|
||||
|
@ -89,6 +90,9 @@ fn dist_server(sh: &Shell, release: &str, target: &Target) -> anyhow::Result<()>
|
|||
|
||||
let dst = Path::new("dist").join(&target.artifact_name);
|
||||
gzip(&target.server_path, &dst.with_extension("gz"))?;
|
||||
if target_name.contains("-windows-") {
|
||||
zip(&target.server_path, target.symbols_path.as_ref(), &dst.with_extension("zip"))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -101,6 +105,38 @@ fn gzip(src_path: &Path, dest_path: &Path) -> anyhow::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn zip(src_path: &Path, symbols_path: Option<&PathBuf>, dest_path: &Path) -> anyhow::Result<()> {
|
||||
let file = File::create(dest_path)?;
|
||||
let mut writer = ZipWriter::new(BufWriter::new(file));
|
||||
writer.start_file(
|
||||
src_path.file_name().unwrap().to_str().unwrap(),
|
||||
FileOptions::default()
|
||||
.last_modified_time(
|
||||
DateTime::from_time(std::fs::metadata(src_path)?.modified()?.into()).unwrap(),
|
||||
)
|
||||
.unix_permissions(0o755)
|
||||
.compression_method(zip::CompressionMethod::Deflated)
|
||||
.compression_level(Some(9)),
|
||||
)?;
|
||||
let mut input = io::BufReader::new(File::open(src_path)?);
|
||||
io::copy(&mut input, &mut writer)?;
|
||||
if let Some(symbols_path) = symbols_path {
|
||||
writer.start_file(
|
||||
symbols_path.file_name().unwrap().to_str().unwrap(),
|
||||
FileOptions::default()
|
||||
.last_modified_time(
|
||||
DateTime::from_time(std::fs::metadata(src_path)?.modified()?.into()).unwrap(),
|
||||
)
|
||||
.compression_method(zip::CompressionMethod::Deflated)
|
||||
.compression_level(Some(9)),
|
||||
)?;
|
||||
let mut input = io::BufReader::new(File::open(symbols_path)?);
|
||||
io::copy(&mut input, &mut writer)?;
|
||||
}
|
||||
writer.finish()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
struct Target {
|
||||
name: String,
|
||||
server_path: PathBuf,
|
||||
|
|
Loading…
Reference in a new issue