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

use Cargo.lock file from rust-src if present #166

Merged
merged 2 commits into from
Sep 6, 2017
Merged
Changes from 1 commit
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
Next Next commit
use Cargo.lock file from rust-src if present
RalfJung committed Aug 31, 2017
commit 517a614fca91da9372e370f5468dd8b0b3e202ed
13 changes: 12 additions & 1 deletion src/sysroot.rs
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ use std::hash::{Hash, Hasher};
use std::path::PathBuf;
use std::process::Command;
use std::io::{self, Write};
use std::fs;

use rustc_version::VersionMeta;
use tempdir::TempDir;
@@ -34,6 +35,7 @@ fn build(
ctoml: &cargo::Toml,
home: &Home,
rustflags: &Rustflags,
src: &Src,
hash: u64,
verbose: bool,
) -> Result<()> {
@@ -66,6 +68,15 @@ version = "0.0.0"
stoml.push_str(&profile.to_string())
}

{
// Recent rust-src comes with a lockfile for libstd. Use it.
let lockfile = src.path().join("Cargo.lock");
if lockfile.exists() {
fs::copy(lockfile, &td.join("Cargo.lock")).chain_err(
|| "couldn't copy lock file",
)?;
}
}
util::write(&td.join("Cargo.toml"), &stoml)?;
util::mkdir(&td.join("src"))?;
util::write(&td.join("src/lib.rs"), "")?;
@@ -187,7 +198,7 @@ pub fn update(
let hash = hash(cmode, &blueprint, rustflags, &ctoml, meta)?;

if old_hash(cmode, home)? != Some(hash) {
build(cmode, blueprint, &ctoml, home, rustflags, hash, verbose)?;
build(cmode, blueprint, &ctoml, home, rustflags, src, hash, verbose)?;
}

// copy host artifacts into the sysroot, if necessary