mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
build-manifest: allow creating a list of files shipped in a release
This commit is contained in:
parent
9832374f6e
commit
0ee1e91c11
@ -186,6 +186,7 @@ macro_rules! t {
|
||||
|
||||
struct Builder {
|
||||
versions: Versions,
|
||||
shipped_files: HashSet<String>,
|
||||
|
||||
input: PathBuf,
|
||||
output: PathBuf,
|
||||
@ -239,6 +240,7 @@ fn main() {
|
||||
|
||||
Builder {
|
||||
versions: Versions::new(&channel, &input).unwrap(),
|
||||
shipped_files: HashSet::new(),
|
||||
|
||||
input,
|
||||
output,
|
||||
@ -259,16 +261,21 @@ impl Builder {
|
||||
}
|
||||
let manifest = self.build_manifest();
|
||||
|
||||
self.write_channel_files(self.versions.channel(), &manifest);
|
||||
if self.versions.channel() == "stable" {
|
||||
let channel = self.versions.channel().to_string();
|
||||
self.write_channel_files(&channel, &manifest);
|
||||
if channel == "stable" {
|
||||
// channel-rust-1.XX.YY.toml
|
||||
let rust_version = self.versions.rustc_version();
|
||||
self.write_channel_files(rust_version, &manifest);
|
||||
let rust_version = self.versions.rustc_version().to_string();
|
||||
self.write_channel_files(&rust_version, &manifest);
|
||||
|
||||
// channel-rust-1.XX.toml
|
||||
let major_minor = rust_version.split('.').take(2).collect::<Vec<_>>().join(".");
|
||||
self.write_channel_files(&major_minor, &manifest);
|
||||
}
|
||||
|
||||
if let Some(path) = std::env::var_os("BUILD_MANIFEST_SHIPPED_FILES_PATH") {
|
||||
self.write_shipped_files(&Path::new(&path));
|
||||
}
|
||||
}
|
||||
|
||||
/// If a tool does not pass its tests, don't ship it.
|
||||
@ -623,7 +630,7 @@ impl Builder {
|
||||
})
|
||||
}
|
||||
|
||||
fn write_channel_files(&self, channel_name: &str, manifest: &Manifest) {
|
||||
fn write_channel_files(&mut self, channel_name: &str, manifest: &Manifest) {
|
||||
self.write(&toml::to_string(&manifest).unwrap(), channel_name, ".toml");
|
||||
self.write(&manifest.date, channel_name, "-date.txt");
|
||||
self.write(
|
||||
@ -633,14 +640,25 @@ impl Builder {
|
||||
);
|
||||
}
|
||||
|
||||
fn write(&self, contents: &str, channel_name: &str, suffix: &str) {
|
||||
let dst = self.output.join(format!("channel-rust-{}{}", channel_name, suffix));
|
||||
fn write(&mut self, contents: &str, channel_name: &str, suffix: &str) {
|
||||
let name = format!("channel-rust-{}{}", channel_name, suffix);
|
||||
self.shipped_files.insert(name.clone());
|
||||
|
||||
let dst = self.output.join(name);
|
||||
t!(fs::write(&dst, contents));
|
||||
if self.legacy {
|
||||
self.hash(&dst);
|
||||
self.sign(&dst);
|
||||
}
|
||||
}
|
||||
|
||||
fn write_shipped_files(&self, path: &Path) {
|
||||
let mut files = self.shipped_files.iter().map(|s| s.as_str()).collect::<Vec<_>>();
|
||||
files.sort();
|
||||
let content = format!("{}\n", files.join("\n"));
|
||||
|
||||
t!(std::fs::write(path, content.as_bytes()));
|
||||
}
|
||||
}
|
||||
|
||||
fn fetch_hash(path: &Path) -> Result<String, Box<dyn Error>> {
|
||||
|
@ -37,10 +37,10 @@ pub(crate) struct Target {
|
||||
}
|
||||
|
||||
impl Target {
|
||||
pub(crate) fn from_compressed_tar(builder: &Builder, base_path: &str) -> Self {
|
||||
pub(crate) fn from_compressed_tar(builder: &mut Builder, base_path: &str) -> Self {
|
||||
let base_path = builder.input.join(base_path);
|
||||
let gz = Self::tarball_variant(&base_path, "gz");
|
||||
let xz = Self::tarball_variant(&base_path, "xz");
|
||||
let gz = Self::tarball_variant(builder, &base_path, "gz");
|
||||
let xz = Self::tarball_variant(builder, &base_path, "xz");
|
||||
|
||||
if gz.is_none() {
|
||||
return Self::unavailable();
|
||||
@ -59,10 +59,21 @@ impl Target {
|
||||
}
|
||||
}
|
||||
|
||||
fn tarball_variant(base: &Path, ext: &str) -> Option<PathBuf> {
|
||||
fn tarball_variant(builder: &mut Builder, base: &Path, ext: &str) -> Option<PathBuf> {
|
||||
let mut path = base.to_path_buf();
|
||||
path.set_extension(ext);
|
||||
if path.is_file() { Some(path) } else { None }
|
||||
if path.is_file() {
|
||||
builder.shipped_files.insert(
|
||||
path.file_name()
|
||||
.expect("missing filename")
|
||||
.to_str()
|
||||
.expect("non-utf-8 filename")
|
||||
.to_string(),
|
||||
);
|
||||
Some(path)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn unavailable() -> Self {
|
||||
|
Loading…
Reference in New Issue
Block a user