Skip to content

Commit a534013

Browse files
bors[bot]RalfJung
andauthored
Merge #297
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 <[email protected]>
2 parents 1414160 + 3874592 commit a534013

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/rustc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ impl Sysroot {
7272
/// Returns the path to Rust source, `$SRC`, where `$SRC/libstd/Carg.toml`
7373
/// exists
7474
pub fn src(&self) -> Result<Src> {
75-
let src = self.path().join("lib/rustlib/src");
75+
let src = self.path().join("lib").join("rustlib").join("src");
7676

77-
if src.join("rust/src/libstd/Cargo.toml").is_file() {
77+
if src.join("rust").join("src").join("libstd").join("Cargo.toml").is_file() {
7878
return Ok(Src {
79-
path: src.join("rust/src"),
79+
path: src.join("rust").join("src"),
8080
});
8181
}
8282

src/sysroot.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ version = "0.0.0"
104104
}
105105

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

@@ -117,7 +118,7 @@ version = "0.0.0"
117118

118119
util::write(&td.join("Cargo.toml"), &stoml)?;
119120
util::mkdir(&td.join("src"))?;
120-
util::write(&td.join("src/lib.rs"), "")?;
121+
util::write(&td.join("src").join("lib.rs"), "")?;
121122

122123
let cargo = || {
123124
let mut cmd = cargo::command();
@@ -337,13 +338,14 @@ pub fn update(
337338
util::cp_r(
338339
&sysroot
339340
.path()
340-
.join("lib/rustlib")
341+
.join("lib")
342+
.join("rustlib")
341343
.join(&meta.host)
342344
.join("lib"),
343345
&dst,
344346
)?;
345347

346-
let bin_src = sysroot.path().join("lib/rustlib").join(&meta.host).join("bin");
348+
let bin_src = sysroot.path().join("lib").join("rustlib").join(&meta.host).join("bin");
347349
// copy the Rust linker if it exists
348350
if bin_src.exists() {
349351
let bin_dst = lock.parent().join("bin");

src/xargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl Home {
5858
}
5959

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

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

0 commit comments

Comments
 (0)