Skip to content

Commit 7a5038f

Browse files
committed
write git-commit-{sha,info} for Cargo in source tarballs
This will allow Cargo's build script to pick it up, and populate the correct git information in its version output.
1 parent f973a15 commit 7a5038f

File tree

1 file changed

+12
-5
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+12
-5
lines changed

src/bootstrap/src/core/build_steps/dist.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::core::build_steps::llvm;
2525
use crate::core::build_steps::tool::{self, Tool};
2626
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
2727
use crate::core::config::TargetSelection;
28-
use crate::utils::channel;
28+
use crate::utils::channel::{self, Info};
2929
use crate::utils::helpers::{exe, is_dylib, output, t, target_supports_cranelift_backend, timeit};
3030
use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball};
3131
use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS};
@@ -991,10 +991,17 @@ impl Step for PlainSourceTarball {
991991

992992
// Create the version file
993993
builder.create(&plain_dst_src.join("version"), &builder.rust_version());
994-
if let Some(info) = builder.rust_info().info() {
995-
channel::write_commit_hash_file(plain_dst_src, &info.sha);
996-
channel::write_commit_info_file(plain_dst_src, info);
997-
}
994+
995+
// Create the files containing git info, to ensure --version outputs the same.
996+
let write_git_info = |info: Option<&Info>, path: &Path| {
997+
if let Some(info) = info {
998+
t!(std::fs::create_dir_all(path));
999+
channel::write_commit_hash_file(path, &info.sha);
1000+
channel::write_commit_info_file(path, info);
1001+
}
1002+
};
1003+
write_git_info(builder.rust_info().info(), plain_dst_src);
1004+
write_git_info(builder.cargo_info.info(), &plain_dst_src.join("./src/tools/cargo"));
9981005

9991006
// If we're building from git or tarball sources, we need to vendor
10001007
// a complete distribution.

0 commit comments

Comments
 (0)