Skip to content

Commit a35af88

Browse files
Rollup merge of rust-lang#52729 - ljedrz:bootstrap_tweaks, r=alexcrichton
Minor improvements to bootstrap - prefer `Path`-specific methods to `String` ones - don't add file extensions if they are removed right afterwards
2 parents 15bc3ef + db303c1 commit a35af88

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/bootstrap/compile.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ impl Step for StartupObjects {
305305
t!(fs::create_dir_all(dst_dir));
306306

307307
for file in &["rsbegin", "rsend"] {
308-
let src_file = &src_dir.join(file.to_string() + ".rs");
309-
let dst_file = &dst_dir.join(file.to_string() + ".o");
308+
let src_file = &src_dir.join(file).with_extension("rs");
309+
let dst_file = &dst_dir.join(file).with_extension("o");
310310
if !up_to_date(src_file, dst_file) {
311311
let mut cmd = Command::new(&builder.initial_rustc);
312312
builder.run(cmd.env("RUSTC_BOOTSTRAP", "1")
@@ -317,7 +317,7 @@ impl Step for StartupObjects {
317317
.arg(src_file));
318318
}
319319

320-
builder.copy(dst_file, &sysroot_dir.join(file.to_string() + ".o"));
320+
builder.copy(dst_file, &sysroot_dir.join(file).with_extension("o"));
321321
}
322322

323323
for obj in ["crt2.o", "dllcrt2.o"].iter() {
@@ -1141,8 +1141,7 @@ pub fn run_cargo(builder: &Builder, cargo: &mut Command, stamp: &Path, is_check:
11411141
None => panic!("no output generated for {:?} {:?}", prefix, extension),
11421142
};
11431143
if is_dylib(path_to_add) {
1144-
let candidate = format!("{}.lib", path_to_add);
1145-
let candidate = PathBuf::from(candidate);
1144+
let candidate = PathBuf::from(path_to_add).with_extension("lib");
11461145
if candidate.exists() {
11471146
deps.push(candidate);
11481147
}

src/bootstrap/dist.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ impl Step for Src {
892892
builder.run(&mut cmd);
893893

894894
builder.remove_dir(&image);
895-
distdir(builder).join(&format!("{}.tar.gz", name))
895+
distdir(builder).join(PathBuf::from(name).with_extension("tar.gz"))
896896
}
897897
}
898898

@@ -992,9 +992,8 @@ impl Step for PlainSourceTarball {
992992

993993
// Create plain source tarball
994994
let plain_name = format!("rustc-{}-src", builder.rust_package_vers());
995-
let mut tarball = distdir(builder).join(&format!("{}.tar.gz", plain_name));
996-
tarball.set_extension(""); // strip .gz
997-
tarball.set_extension(""); // strip .tar
995+
let tarball_name = PathBuf::from(&plain_name).with_extension("tar.gz");
996+
let tarball = distdir(builder).join(&plain_name);
998997
if let Some(dir) = tarball.parent() {
999998
builder.create_dir(&dir);
1000999
}
@@ -1006,7 +1005,7 @@ impl Step for PlainSourceTarball {
10061005
.arg("--work-dir=.")
10071006
.current_dir(tmpdir(builder));
10081007
builder.run(&mut cmd);
1009-
distdir(builder).join(&format!("{}.tar.gz", plain_name))
1008+
distdir(builder).join(&tarball_name)
10101009
}
10111010
}
10121011

0 commit comments

Comments
 (0)