Skip to content

Commit dcc001a

Browse files
committed
refactor with_stamp as add_stamp for incrementality
Signed-off-by: onur-ozkan <[email protected]>
1 parent 99322a5 commit dcc001a

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

src/bootstrap/src/core/build_steps/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn verify_rustfmt_version(build: &Builder<'_>) -> bool {
7474
let Some((version, stamp_file)) = get_rustfmt_version(build) else {
7575
return false;
7676
};
77-
stamp_file.with_stamp(version).is_up_to_date()
77+
stamp_file.add_stamp(version).is_up_to_date()
7878
}
7979

8080
/// Updates the last rustfmt version used.

src/bootstrap/src/core/build_steps/gcc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn prebuilt_gcc_config(builder: &Builder<'_>, target: TargetSelection) -> Gc
5555
)
5656
});
5757

58-
let stamp = BuildStamp::new(&out_dir).with_prefix("gcc").with_stamp(smart_stamp_hash);
58+
let stamp = BuildStamp::new(&out_dir).with_prefix("gcc").add_stamp(smart_stamp_hash);
5959

6060
if stamp.is_up_to_date() {
6161
if stamp.stamp.is_empty() {

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub fn prebuilt_llvm_config(
135135
)
136136
});
137137

138-
let stamp = BuildStamp::new(&out_dir).with_prefix("llvm").with_stamp(smart_stamp_hash);
138+
let stamp = BuildStamp::new(&out_dir).with_prefix("llvm").add_stamp(smart_stamp_hash);
139139

140140
if stamp.is_up_to_date() {
141141
if stamp.stamp.is_empty() {
@@ -921,7 +921,7 @@ impl Step for Enzyme {
921921
});
922922

923923
let out_dir = builder.enzyme_out(target);
924-
let stamp = BuildStamp::new(&out_dir).with_prefix("enzyme").with_stamp(smart_stamp_hash);
924+
let stamp = BuildStamp::new(&out_dir).with_prefix("enzyme").add_stamp(smart_stamp_hash);
925925

926926
if stamp.is_up_to_date() {
927927
if stamp.stamp.is_empty() {
@@ -1137,8 +1137,7 @@ impl Step for Sanitizers {
11371137
)
11381138
});
11391139

1140-
let stamp =
1141-
BuildStamp::new(&out_dir).with_prefix("sanitizers").with_stamp(smart_stamp_hash);
1140+
let stamp = BuildStamp::new(&out_dir).with_prefix("sanitizers").add_stamp(smart_stamp_hash);
11421141

11431142
if stamp.is_up_to_date() {
11441143
if stamp.stamp.is_empty() {

src/bootstrap/src/core/download.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl Config {
428428
let host = self.build;
429429

430430
let clippy_stamp =
431-
BuildStamp::new(&self.initial_sysroot).with_prefix("clippy").with_stamp(date);
431+
BuildStamp::new(&self.initial_sysroot).with_prefix("clippy").add_stamp(date);
432432
let cargo_clippy = self.initial_sysroot.join("bin").join(exe("cargo-clippy", host));
433433
if cargo_clippy.exists() && clippy_stamp.is_up_to_date() {
434434
return cargo_clippy;
@@ -462,7 +462,7 @@ impl Config {
462462
let host = self.build;
463463
let bin_root = self.out.join(host).join("rustfmt");
464464
let rustfmt_path = bin_root.join("bin").join(exe("rustfmt", host));
465-
let rustfmt_stamp = BuildStamp::new(&bin_root).with_prefix("rustfmt").with_stamp(channel);
465+
let rustfmt_stamp = BuildStamp::new(&bin_root).with_prefix("rustfmt").add_stamp(channel);
466466
if rustfmt_path.exists() && rustfmt_stamp.is_up_to_date() {
467467
return Some(rustfmt_path);
468468
}
@@ -569,7 +569,7 @@ impl Config {
569569
) {
570570
let host = self.build.triple;
571571
let bin_root = self.out.join(host).join(sysroot);
572-
let rustc_stamp = BuildStamp::new(&bin_root).with_prefix("rustc").with_stamp(stamp_key);
572+
let rustc_stamp = BuildStamp::new(&bin_root).with_prefix("rustc").add_stamp(stamp_key);
573573

574574
if !bin_root.join("bin").join(exe("rustc", self.build)).exists()
575575
|| !rustc_stamp.is_up_to_date()
@@ -732,7 +732,7 @@ download-rustc = false
732732
let llvm_root = self.ci_llvm_root();
733733
let llvm_sha = detect_llvm_sha(self, self.rust_info.is_managed_git_subrepository());
734734
let stamp_key = format!("{}{}", llvm_sha, self.llvm_assertions);
735-
let llvm_stamp = BuildStamp::new(&llvm_root).with_prefix("llvm").with_stamp(stamp_key);
735+
let llvm_stamp = BuildStamp::new(&llvm_root).with_prefix("llvm").add_stamp(stamp_key);
736736
if !llvm_stamp.is_up_to_date() && !self.dry_run() {
737737
self.download_ci_llvm(&llvm_sha);
738738

src/bootstrap/src/utils/build_stamp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ impl BuildStamp {
4141
}
4242

4343
/// Sets stamp content to the specified value.
44-
pub fn with_stamp<S: ToString>(mut self, stamp: S) -> Self {
45-
self.stamp = stamp.to_string();
44+
pub fn add_stamp<S: ToString>(mut self, stamp: S) -> Self {
45+
self.stamp.push_str(&stamp.to_string());
4646
self
4747
}
4848

src/bootstrap/src/utils/build_stamp/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn test_with_invalid_prefix2() {
2626
fn test_is_up_to_date() {
2727
let dir = temp_dir();
2828

29-
let mut build_stamp = BuildStamp::new(&dir).with_stamp("v1.0.0");
29+
let mut build_stamp = BuildStamp::new(&dir).add_stamp("v1.0.0");
3030
build_stamp.write().unwrap();
3131

3232
assert!(
@@ -47,7 +47,7 @@ fn test_is_up_to_date() {
4747
fn test_with_prefix() {
4848
let dir = temp_dir();
4949

50-
let stamp = BuildStamp::new(&dir).with_stamp("v1.0.0");
50+
let stamp = BuildStamp::new(&dir).add_stamp("v1.0.0");
5151
assert_eq!(stamp.path.file_name().unwrap(), ".stamp");
5252

5353
let stamp = stamp.with_prefix("test");

0 commit comments

Comments
 (0)