Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid adding '/' or '..' to paths for better Windows compatibility #297

Merged
merged 1 commit into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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