From 72da8b82c14772980956a808e93ed6258c5691ba Mon Sep 17 00:00:00 2001 From: Joseph Dunne Date: Fri, 2 Sep 2016 11:15:56 +0100 Subject: [PATCH] Add rustc version info (git hash + date) to dist tarball fixes #32444 --- mk/dist.mk | 1 + src/bootstrap/dist.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/mk/dist.mk b/mk/dist.mk index e81371037ac2b..cb0bca01e6c4a 100644 --- a/mk/dist.mk +++ b/mk/dist.mk @@ -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 - \ diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 9d18901eb0002..31b7db168b48f 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -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)))) @@ -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)); +}