Skip to content

Commit 1bd1a09

Browse files
committed
Auto merge of rust-lang#13876 - lnicola:zip-artifacts, r=lnicola
feat: Package Windows release artifacts as ZIP and add symbols file Closes rust-lang#13872 Closes rust-lang#7747 CC rust-lang#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.
2 parents 7449f9f + 34bc240 commit 1bd1a09

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed

Cargo.lock

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rust-analyzer/tests/slow-tests/tidy.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ MIT OR Apache-2.0
194194
MIT OR Apache-2.0 OR Zlib
195195
MIT OR Zlib OR Apache-2.0
196196
MIT/Apache-2.0
197+
Unlicense OR MIT
197198
Unlicense/MIT
198199
Zlib OR Apache-2.0 OR MIT
199200
"

xtask/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ flate2 = "1.0.24"
1212
write-json = "0.1.2"
1313
xshell = "0.2.2"
1414
xflags = "0.3.0"
15+
zip = { version = "0.6", default-features = false, features = ["deflate", "time"] }
1516
# Avoid adding more dependencies to this crate

xtask/src/dist.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use std::{
22
env,
33
fs::File,
4-
io,
4+
io::{self, BufWriter},
55
path::{Path, PathBuf},
66
};
77

88
use flate2::{write::GzEncoder, Compression};
99
use xshell::{cmd, Shell};
10+
use zip::{write::FileOptions, DateTime, ZipWriter};
1011

1112
use crate::{date_iso, flags, project_root};
1213

@@ -89,6 +90,9 @@ fn dist_server(sh: &Shell, release: &str, target: &Target) -> anyhow::Result<()>
8990

9091
let dst = Path::new("dist").join(&target.artifact_name);
9192
gzip(&target.server_path, &dst.with_extension("gz"))?;
93+
if target_name.contains("-windows-") {
94+
zip(&target.server_path, target.symbols_path.as_ref(), &dst.with_extension("zip"))?;
95+
}
9296

9397
Ok(())
9498
}
@@ -101,6 +105,38 @@ fn gzip(src_path: &Path, dest_path: &Path) -> anyhow::Result<()> {
101105
Ok(())
102106
}
103107

108+
fn zip(src_path: &Path, symbols_path: Option<&PathBuf>, dest_path: &Path) -> anyhow::Result<()> {
109+
let file = File::create(dest_path)?;
110+
let mut writer = ZipWriter::new(BufWriter::new(file));
111+
writer.start_file(
112+
src_path.file_name().unwrap().to_str().unwrap(),
113+
FileOptions::default()
114+
.last_modified_time(
115+
DateTime::from_time(std::fs::metadata(src_path)?.modified()?.into()).unwrap(),
116+
)
117+
.unix_permissions(0o755)
118+
.compression_method(zip::CompressionMethod::Deflated)
119+
.compression_level(Some(9)),
120+
)?;
121+
let mut input = io::BufReader::new(File::open(src_path)?);
122+
io::copy(&mut input, &mut writer)?;
123+
if let Some(symbols_path) = symbols_path {
124+
writer.start_file(
125+
symbols_path.file_name().unwrap().to_str().unwrap(),
126+
FileOptions::default()
127+
.last_modified_time(
128+
DateTime::from_time(std::fs::metadata(src_path)?.modified()?.into()).unwrap(),
129+
)
130+
.compression_method(zip::CompressionMethod::Deflated)
131+
.compression_level(Some(9)),
132+
)?;
133+
let mut input = io::BufReader::new(File::open(symbols_path)?);
134+
io::copy(&mut input, &mut writer)?;
135+
}
136+
writer.finish()?;
137+
Ok(())
138+
}
139+
104140
struct Target {
105141
name: String,
106142
server_path: PathBuf,

0 commit comments

Comments
 (0)