Skip to content

Commit 0a2034d

Browse files
committed
bootstrap: add the dist.compression-formats option
The option allows to add or remove compression formats used while producing dist tarballs.
1 parent c482ffd commit 0a2034d

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -669,3 +669,7 @@ changelog-seen = 2
669669

670670
# Whether to allow failures when building tools
671671
#missing-tools = false
672+
673+
# List of compression formats to use when generating dist tarballs. The list of
674+
# formats is provided to rust-installer, which must support all of them.
675+
#compression-formats = ["gz", "xz"]

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ pub struct Config {
148148
pub dist_sign_folder: Option<PathBuf>,
149149
pub dist_upload_addr: Option<String>,
150150
pub dist_gpg_password_file: Option<PathBuf>,
151+
pub dist_compression_formats: Option<Vec<String>>,
151152

152153
// libstd features
153154
pub backtrace: bool, // support for RUST_BACKTRACE
@@ -438,6 +439,7 @@ struct Dist {
438439
upload_addr: Option<String>,
439440
src_tarball: Option<bool>,
440441
missing_tools: Option<bool>,
442+
compression_formats: Option<Vec<String>>,
441443
}
442444

443445
#[derive(Deserialize)]
@@ -936,6 +938,7 @@ impl Config {
936938
config.dist_sign_folder = t.sign_folder.map(PathBuf::from);
937939
config.dist_gpg_password_file = t.gpg_password_file.map(PathBuf::from);
938940
config.dist_upload_addr = t.upload_addr;
941+
config.dist_compression_formats = t.compression_formats;
939942
set(&mut config.rust_dist_src, t.src_tarball);
940943
set(&mut config.missing_tools, t.missing_tools);
941944
}

src/bootstrap/configure.py

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ def v(*args):
147147
"experimental LLVM targets to build")
148148
v("release-channel", "rust.channel", "the name of the release channel to build")
149149
v("release-description", "rust.description", "optional descriptive string for version output")
150+
v("dist-compression-formats", None,
151+
"comma-separated list of compression formats to use")
150152

151153
# Used on systems where "cc" is unavailable
152154
v("default-linker", "rust.default-linker", "the default linker")
@@ -349,6 +351,8 @@ def set(key, value):
349351
elif option.name == 'option-checking':
350352
# this was handled above
351353
pass
354+
elif option.name == 'dist-compression-formats':
355+
set('dist.compression-formats', value.split(','))
352356
else:
353357
raise RuntimeError("unhandled option {}".format(option.name))
354358

src/bootstrap/tarball.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,25 @@ impl<'a> Tarball<'a> {
288288

289289
build_cli(&self, &mut cmd);
290290
cmd.arg("--work-dir").arg(&self.temp_dir);
291+
if let Some(formats) = &self.builder.config.dist_compression_formats {
292+
assert!(!formats.is_empty(), "dist.compression-formats can't be empty");
293+
cmd.arg("--compression-formats").arg(formats.join(","));
294+
}
291295
self.builder.run(&mut cmd);
292296
if self.delete_temp_dir {
293297
t!(std::fs::remove_dir_all(&self.temp_dir));
294298
}
295299

296-
crate::dist::distdir(self.builder).join(format!("{}.tar.gz", package_name))
300+
// Use either the first compression format defined, or "gz" as the default.
301+
let ext = self
302+
.builder
303+
.config
304+
.dist_compression_formats
305+
.as_ref()
306+
.and_then(|formats| formats.get(0))
307+
.map(|s| s.as_str())
308+
.unwrap_or("gz");
309+
310+
crate::dist::distdir(self.builder).join(format!("{}.tar.{}", package_name, ext))
297311
}
298312
}

0 commit comments

Comments
 (0)