Skip to content

Commit

Permalink
Merge #297
Browse files Browse the repository at this point in the history
297: avoid adding '/' or '..' to paths for better Windows compatibility r=jethrogb a=RalfJung

This should help with issues such as [this one](rust-lang/rust#74146 (comment)).

Co-authored-by: Ralf Jung <post@ralfj.de>
  • Loading branch information
bors[bot] and RalfJung committed Jul 9, 2020
2 parents 1414160 + 3874592 commit a534013
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ impl Sysroot {
/// Returns the path to Rust source, `$SRC`, where `$SRC/libstd/Carg.toml`
/// exists
pub fn src(&self) -> Result<Src> {
let src = self.path().join("lib/rustlib/src");
let src = self.path().join("lib").join("rustlib").join("src");

if src.join("rust/src/libstd/Cargo.toml").is_file() {
if src.join("rust").join("src").join("libstd").join("Cargo.toml").is_file() {
return Ok(Src {
path: src.join("rust/src"),
path: src.join("rust").join("src"),
});
}

Expand Down
10 changes: 6 additions & 4 deletions src/sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ version = "0.0.0"
}

// rust-src comes with a lockfile for libstd. Use it.
let lockfile = src.path().join("..").join("Cargo.lock");
let src_parent = src.path().parent().map(Path::to_path_buf).unwrap_or_else(|| src.path().join(".."));
let lockfile = src_parent.join("Cargo.lock");
let target_lockfile = td.join("Cargo.lock");
fs::copy(lockfile, &target_lockfile).chain_err(|| "Cargo.lock file is missing from source dir")?;

Expand All @@ -117,7 +118,7 @@ version = "0.0.0"

util::write(&td.join("Cargo.toml"), &stoml)?;
util::mkdir(&td.join("src"))?;
util::write(&td.join("src/lib.rs"), "")?;
util::write(&td.join("src").join("lib.rs"), "")?;

let cargo = || {
let mut cmd = cargo::command();
Expand Down Expand Up @@ -337,13 +338,14 @@ pub fn update(
util::cp_r(
&sysroot
.path()
.join("lib/rustlib")
.join("lib")
.join("rustlib")
.join(&meta.host)
.join("lib"),
&dst,
)?;

let bin_src = sysroot.path().join("lib/rustlib").join(&meta.host).join("bin");
let bin_src = sysroot.path().join("lib").join("rustlib").join(&meta.host).join("bin");
// copy the Rust linker if it exists
if bin_src.exists() {
let bin_dst = lock.parent().join("bin");
Expand Down
2 changes: 1 addition & 1 deletion src/xargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl Home {
}

fn path(&self, triple: &str) -> Filesystem {
self.path.join("lib/rustlib").join(triple)
self.path.join("lib").join("rustlib").join(triple)
}

pub fn lock_ro(&self, triple: &str) -> Result<FileLock> {
Expand Down

0 comments on commit a534013

Please sign in to comment.