refactor with_stamp as add_stamp for incrementality

Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
onur-ozkan 2025-01-12 08:20:42 +03:00
parent 99322a5158
commit dcc001adbb
6 changed files with 13 additions and 14 deletions

View file

@ -74,7 +74,7 @@ fn verify_rustfmt_version(build: &Builder<'_>) -> bool {
let Some((version, stamp_file)) = get_rustfmt_version(build) else {
return false;
};
stamp_file.with_stamp(version).is_up_to_date()
stamp_file.add_stamp(version).is_up_to_date()
}
/// Updates the last rustfmt version used.

View file

@ -55,7 +55,7 @@ pub fn prebuilt_gcc_config(builder: &Builder<'_>, target: TargetSelection) -> Gc
)
});
let stamp = BuildStamp::new(&out_dir).with_prefix("gcc").with_stamp(smart_stamp_hash);
let stamp = BuildStamp::new(&out_dir).with_prefix("gcc").add_stamp(smart_stamp_hash);
if stamp.is_up_to_date() {
if stamp.stamp.is_empty() {

View file

@ -135,7 +135,7 @@ pub fn prebuilt_llvm_config(
)
});
let stamp = BuildStamp::new(&out_dir).with_prefix("llvm").with_stamp(smart_stamp_hash);
let stamp = BuildStamp::new(&out_dir).with_prefix("llvm").add_stamp(smart_stamp_hash);
if stamp.is_up_to_date() {
if stamp.stamp.is_empty() {
@ -921,7 +921,7 @@ impl Step for Enzyme {
});
let out_dir = builder.enzyme_out(target);
let stamp = BuildStamp::new(&out_dir).with_prefix("enzyme").with_stamp(smart_stamp_hash);
let stamp = BuildStamp::new(&out_dir).with_prefix("enzyme").add_stamp(smart_stamp_hash);
if stamp.is_up_to_date() {
if stamp.stamp.is_empty() {
@ -1137,8 +1137,7 @@ impl Step for Sanitizers {
)
});
let stamp =
BuildStamp::new(&out_dir).with_prefix("sanitizers").with_stamp(smart_stamp_hash);
let stamp = BuildStamp::new(&out_dir).with_prefix("sanitizers").add_stamp(smart_stamp_hash);
if stamp.is_up_to_date() {
if stamp.stamp.is_empty() {

View file

@ -428,7 +428,7 @@ impl Config {
let host = self.build;
let clippy_stamp =
BuildStamp::new(&self.initial_sysroot).with_prefix("clippy").with_stamp(date);
BuildStamp::new(&self.initial_sysroot).with_prefix("clippy").add_stamp(date);
let cargo_clippy = self.initial_sysroot.join("bin").join(exe("cargo-clippy", host));
if cargo_clippy.exists() && clippy_stamp.is_up_to_date() {
return cargo_clippy;
@ -462,7 +462,7 @@ impl Config {
let host = self.build;
let bin_root = self.out.join(host).join("rustfmt");
let rustfmt_path = bin_root.join("bin").join(exe("rustfmt", host));
let rustfmt_stamp = BuildStamp::new(&bin_root).with_prefix("rustfmt").with_stamp(channel);
let rustfmt_stamp = BuildStamp::new(&bin_root).with_prefix("rustfmt").add_stamp(channel);
if rustfmt_path.exists() && rustfmt_stamp.is_up_to_date() {
return Some(rustfmt_path);
}
@ -569,7 +569,7 @@ impl Config {
) {
let host = self.build.triple;
let bin_root = self.out.join(host).join(sysroot);
let rustc_stamp = BuildStamp::new(&bin_root).with_prefix("rustc").with_stamp(stamp_key);
let rustc_stamp = BuildStamp::new(&bin_root).with_prefix("rustc").add_stamp(stamp_key);
if !bin_root.join("bin").join(exe("rustc", self.build)).exists()
|| !rustc_stamp.is_up_to_date()
@ -732,7 +732,7 @@ download-rustc = false
let llvm_root = self.ci_llvm_root();
let llvm_sha = detect_llvm_sha(self, self.rust_info.is_managed_git_subrepository());
let stamp_key = format!("{}{}", llvm_sha, self.llvm_assertions);
let llvm_stamp = BuildStamp::new(&llvm_root).with_prefix("llvm").with_stamp(stamp_key);
let llvm_stamp = BuildStamp::new(&llvm_root).with_prefix("llvm").add_stamp(stamp_key);
if !llvm_stamp.is_up_to_date() && !self.dry_run() {
self.download_ci_llvm(&llvm_sha);

View file

@ -41,8 +41,8 @@ impl BuildStamp {
}
/// Sets stamp content to the specified value.
pub fn with_stamp<S: ToString>(mut self, stamp: S) -> Self {
self.stamp = stamp.to_string();
pub fn add_stamp<S: ToString>(mut self, stamp: S) -> Self {
self.stamp.push_str(&stamp.to_string());
self
}

View file

@ -26,7 +26,7 @@ fn test_with_invalid_prefix2() {
fn test_is_up_to_date() {
let dir = temp_dir();
let mut build_stamp = BuildStamp::new(&dir).with_stamp("v1.0.0");
let mut build_stamp = BuildStamp::new(&dir).add_stamp("v1.0.0");
build_stamp.write().unwrap();
assert!(
@ -47,7 +47,7 @@ fn test_is_up_to_date() {
fn test_with_prefix() {
let dir = temp_dir();
let stamp = BuildStamp::new(&dir).with_stamp("v1.0.0");
let stamp = BuildStamp::new(&dir).add_stamp("v1.0.0");
assert_eq!(stamp.path.file_name().unwrap(), ".stamp");
let stamp = stamp.with_prefix("test");