about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-01-07 19:19:37 +0000
committerbors <bors@rust-lang.org>2023-01-07 19:19:37 +0000
commit1bd1a095936f2c16493743a05f6f14285c98ec8a (patch)
treefea9489642e2c99ae31fc13e9a197780a6d38371
parent7449f9fa1018b4f3682eb176b65ad5fcd8d56d56 (diff)
parent34bc240e94059e7a66a622ebd7dd9c70624d9a6a (diff)
downloadrust-1bd1a095936f2c16493743a05f6f14285c98ec8a.tar.gz
rust-1bd1a095936f2c16493743a05f6f14285c98ec8a.zip
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.
-rw-r--r--Cargo.lock47
-rw-r--r--crates/rust-analyzer/tests/slow-tests/tidy.rs1
-rw-r--r--xtask/Cargo.toml1
-rw-r--r--xtask/src/dist.rs38
4 files changed, 86 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 59cd66756cd..d27ae416f04 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -113,6 +113,12 @@ 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"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1777,6 +1783,33 @@ dependencies = [
 ]
 
 [[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"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -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",
 ]
diff --git a/crates/rust-analyzer/tests/slow-tests/tidy.rs b/crates/rust-analyzer/tests/slow-tests/tidy.rs
index 745faf42491..a72c7eb91d7 100644
--- a/crates/rust-analyzer/tests/slow-tests/tidy.rs
+++ b/crates/rust-analyzer/tests/slow-tests/tidy.rs
@@ -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
 "
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml
index 95e27beab5d..2dd01796c6e 100644
--- a/xtask/Cargo.toml
+++ b/xtask/Cargo.toml
@@ -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
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs
index 410276bc45b..74715c53eaa 100644
--- a/xtask/src/dist.rs
+++ b/xtask/src/dist.rs
@@ -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,