Skip to content

Commit

Permalink
Add rustc version info (git hash + date) to dist tarball
Browse files Browse the repository at this point in the history
fixes #32444
  • Loading branch information
Joseph Dunne committed Sep 3, 2016
1 parent 147371f commit 72da8b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions mk/dist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ tmp/dist/$$(SRC_PKG_NAME)-image: $(PKG_FILES)
@$(call E, making src image)
$(Q)rm -Rf tmp/dist/$(SRC_PKG_NAME)-image
$(Q)mkdir -p tmp/dist/$(SRC_PKG_NAME)-image/lib/rustlib/src/rust
$(Q)echo "$(CFG_VERSION)" > tmp/dist/$(SRC_PKG_NAME)-image/lib/rustlib/src/rust/version
$(Q)tar \
-C $(S) \
-f - \
Expand Down
8 changes: 8 additions & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ pub fn rust_src(build: &Build) {
// Rename directory, so that root folder of tarball has the correct name
t!(fs::rename(&dst_src, &plain_dst_src));

// Create the version file
write_file(&plain_dst_src.join("version"), build.version.as_bytes());

// Create plain source tarball
let mut cmd = Command::new("tar");
cmd.arg("-czf").arg(sanitize_sh(&distdir(build).join(&format!("{}.tar.gz", plain_name))))
Expand Down Expand Up @@ -431,3 +434,8 @@ fn sanitize_sh(path: &Path) -> String {
Some(format!("/{}/{}", drive, &s[drive.len_utf8() + 2..]))
}
}

fn write_file(path: &Path, data: &[u8]) {
let mut vf = t!(fs::File::create(path));
t!(vf.write_all(data));
}

0 comments on commit 72da8b8

Please sign in to comment.