Skip to content

Commit

Permalink
Rollup merge of rust-lang#52729 - ljedrz:bootstrap_tweaks, r=alexcric…
Browse files Browse the repository at this point in the history
…hton

Minor improvements to bootstrap

- prefer `Path`-specific methods to `String` ones
- don't add file extensions if they are removed right afterwards
  • Loading branch information
Mark-Simulacrum committed Jul 27, 2018
2 parents 15bc3ef + db303c1 commit a35af88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ impl Step for StartupObjects {
t!(fs::create_dir_all(dst_dir));

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

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

for obj in ["crt2.o", "dllcrt2.o"].iter() {
Expand Down Expand Up @@ -1141,8 +1141,7 @@ pub fn run_cargo(builder: &Builder, cargo: &mut Command, stamp: &Path, is_check:
None => panic!("no output generated for {:?} {:?}", prefix, extension),
};
if is_dylib(path_to_add) {
let candidate = format!("{}.lib", path_to_add);
let candidate = PathBuf::from(candidate);
let candidate = PathBuf::from(path_to_add).with_extension("lib");
if candidate.exists() {
deps.push(candidate);
}
Expand Down
9 changes: 4 additions & 5 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ impl Step for Src {
builder.run(&mut cmd);

builder.remove_dir(&image);
distdir(builder).join(&format!("{}.tar.gz", name))
distdir(builder).join(PathBuf::from(name).with_extension("tar.gz"))
}
}

Expand Down Expand Up @@ -992,9 +992,8 @@ impl Step for PlainSourceTarball {

// Create plain source tarball
let plain_name = format!("rustc-{}-src", builder.rust_package_vers());
let mut tarball = distdir(builder).join(&format!("{}.tar.gz", plain_name));
tarball.set_extension(""); // strip .gz
tarball.set_extension(""); // strip .tar
let tarball_name = PathBuf::from(&plain_name).with_extension("tar.gz");
let tarball = distdir(builder).join(&plain_name);
if let Some(dir) = tarball.parent() {
builder.create_dir(&dir);
}
Expand All @@ -1006,7 +1005,7 @@ impl Step for PlainSourceTarball {
.arg("--work-dir=.")
.current_dir(tmpdir(builder));
builder.run(&mut cmd);
distdir(builder).join(&format!("{}.tar.gz", plain_name))
distdir(builder).join(&tarball_name)
}
}

Expand Down

0 comments on commit a35af88

Please sign in to comment.