Skip to content

Commit

Permalink
Auto merge of #174 - japaric:cache, r=japaric
Browse files Browse the repository at this point in the history
use recent nightly for macOS

let's see if clearing the cache fixes the problem reported in rust-lang/cargo#4699
  • Loading branch information
homunkulus committed Nov 4, 2017
2 parents 29afc4e + 66cce2b commit f5d02ee
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 243 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@ matrix:
rust: nightly
- env: TARGET=i686-apple-darwin
os: osx
# old nightly to work around rust-lang/cargo#4699
rust: nightly-2017-10-10
- env: TARGET=x86_64-apple-darwin
os: osx
rust: nightly
# old nightly to work around rust-lang/cargo#4699
rust: nightly-2017-10-10

install:
- bash ci/install.sh
Expand Down
60 changes: 20 additions & 40 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ impl Rustflags {
while let Some(flag) = flags.next() {
if flag == "-C" {
if let Some(next) = flags.next() {
if next.starts_with("link-arg=") ||
next.starts_with("link-args=")
{
if next.starts_with("link-arg=") || next.starts_with("link-args=") {
// don't hash linker arguments
} else {
flag.hash(hasher);
Expand All @@ -55,7 +53,6 @@ impl Rustflags {
impl fmt::Display for Rustflags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.flags.join(" "), f)

}
}

Expand All @@ -76,22 +73,15 @@ impl Rustdocflags {
}
}

pub fn rustdocflags(
config: Option<&Config>,
target: &str,
) -> Result<Rustdocflags> {
pub fn rustdocflags(config: Option<&Config>, target: &str) -> Result<Rustdocflags> {
flags(config, target, "rustdocflags").map(|fs| Rustdocflags { flags: fs })
}


/// Returns the flags for `tool` (e.g. rustflags)
///
/// This looks into the environment and into `.cargo/config`
fn flags(
config: Option<&Config>,
target: &str,
tool: &str,
) -> Result<Vec<String>> {
fn flags(config: Option<&Config>, target: &str, tool: &str) -> Result<Vec<String>> {
if let Some(t) = env::var_os(tool.to_uppercase()) {
return Ok(
t.to_string_lossy()
Expand All @@ -109,8 +99,7 @@ fn flags(
.or_else(|| {
build = true;
config.table.lookup(&format!("build.{}", tool))
})
{
}) {
let mut flags = vec![];

let mut error = false;
Expand All @@ -131,13 +120,13 @@ fn flags(
if build {
Err(format!(
".cargo/config: build.{} must be an array \
of strings",
of strings",
tool
))?
} else {
Err(format!(
".cargo/config: target.{}.{} must be an \
array of strings",
array of strings",
target,
tool
))?
Expand All @@ -154,9 +143,9 @@ fn flags(
}

pub fn run(args: &Args, verbose: bool) -> Result<ExitStatus> {
Command::new("cargo").args(args.all()).run_and_get_status(
verbose,
)
Command::new("cargo")
.args(args.all())
.run_and_get_status(verbose)
}

pub struct Config {
Expand All @@ -166,26 +155,21 @@ pub struct Config {
impl Config {
pub fn target(&self) -> Result<Option<&str>> {
if let Some(v) = self.table.lookup("build.target") {
Ok(Some(
v.as_str().ok_or_else(
|| format!(".cargo/config: build.target must be a string"),
)?,
))
Ok(Some(v.as_str()
.ok_or_else(|| format!(".cargo/config: build.target must be a string"))?))
} else {
Ok(None)
}
}
}

pub fn config() -> Result<Option<Config>> {
let cd = env::current_dir().chain_err(
|| "couldn't get the current directory",
)?;
let cd = env::current_dir().chain_err(|| "couldn't get the current directory")?;

if let Some(p) = util::search(&cd, ".cargo/config") {
Ok(Some(
Config { table: util::parse(&p.join(".cargo/config"))? },
))
Ok(Some(Config {
table: util::parse(&p.join(".cargo/config"))?,
}))
} else {
Ok(None)
}
Expand Down Expand Up @@ -237,9 +221,9 @@ pub struct Toml {
impl Toml {
/// `profile.release` part of `Cargo.toml`
pub fn profile(&self) -> Option<Profile> {
self.table.lookup("profile.release").map(
|t| Profile { table: t },
)
self.table
.lookup("profile.release")
.map(|t| Profile { table: t })
}
}

Expand All @@ -258,13 +242,9 @@ impl Root {
}

pub fn root() -> Result<Option<Root>> {
let cd = env::current_dir().chain_err(
|| "couldn't get the current directory",
)?;
let cd = env::current_dir().chain_err(|| "couldn't get the current directory")?;

Ok(
util::search(&cd, "Cargo.toml").map(|p| Root { path: p.to_owned() }),
)
Ok(util::search(&cd, "Cargo.toml").map(|p| Root { path: p.to_owned() }))
}

#[derive(Clone, Copy, PartialEq)]
Expand Down
6 changes: 3 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ impl Args {
}

pub fn verbose(&self) -> bool {
self.all.iter().any(|a| {
a == "--verbose" || a == "-v" || a == "-vv"
})
self.all
.iter()
.any(|a| a == "--verbose" || a == "-v" || a == "-vv")
}

pub fn version(&self) -> bool {
Expand Down
17 changes: 6 additions & 11 deletions src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ impl CommandExt for Command {
writeln!(io::stderr(), "+ {:?}", self).ok();
}

self.status().chain_err(
|| format!("couldn't execute `{:?}`", self),
)
self.status()
.chain_err(|| format!("couldn't execute `{:?}`", self))
}

/// Runs the command to completion and returns its stdout
Expand All @@ -43,16 +42,12 @@ impl CommandExt for Command {
writeln!(io::stderr(), "+ {:?}", self).ok();
}

let out = self.output().chain_err(
|| format!("couldn't execute `{:?}`", self),
)?;
let out = self.output()
.chain_err(|| format!("couldn't execute `{:?}`", self))?;

if out.status.success() {
Ok(
String::from_utf8(out.stdout).chain_err(|| {
format!("`{:?}` output was not UTF-8", self)
})?,
)
Ok(String::from_utf8(out.stdout)
.chain_err(|| format!("`{:?}` output was not UTF-8", self))?)
} else {
Err(format!(
"`{:?}` failed with exit code: {:?}",
Expand Down
31 changes: 11 additions & 20 deletions src/flock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,14 @@ impl Filesystem {
) -> io::Result<FileLock> {
let path = self.path.join(path);

let f = opts.open(&path).or_else(
|e| if e.kind() == io::ErrorKind::NotFound &&
state == State::Exclusive
{
let f = opts.open(&path).or_else(|e| {
if e.kind() == io::ErrorKind::NotFound && state == State::Exclusive {
create_dir_all(path.parent().unwrap())?;
opts.open(&path)
} else {
Err(e)
},
)?;
}
})?;

match state {
State::Exclusive => {
Expand All @@ -117,12 +115,7 @@ impl Filesystem {
)?;
}
State::Shared => {
acquire(
msg,
&path,
&|| f.try_lock_shared(),
&|| f.lock_shared(),
)?;
acquire(msg, &path, &|| f.try_lock_shared(), &|| f.lock_shared())?;
}
}

Expand Down Expand Up @@ -180,23 +173,21 @@ fn acquire(
match try() {
Ok(_) => return Ok(()),
#[cfg(target_os = "macos")]
Err(ref e) if e.raw_os_error() == Some(::libc::ENOTSUP) => {
Err(ref e) if e.raw_os_error() == Some(::libc::ENOTSUP) =>
{
return Ok(())
}
Err(e) => {
if e.raw_os_error() != fs2::lock_contended_error().raw_os_error() {
return Err(e);
}
}
Err(e) => if e.raw_os_error() != fs2::lock_contended_error().raw_os_error() {
return Err(e);
},
}

writeln!(
io::stderr(),
"{:>12} waiting for file lock on {}",
"Blocking",
msg
)
.ok();
).ok();

block()
}
Expand Down
48 changes: 18 additions & 30 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#[macro_use]
extern crate error_chain;
extern crate fs2;
#[cfg(any(all(target_os = "linux", not(target_env = "musl")),
target_os = "macos"))]
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "macos"))]
extern crate libc;
extern crate rustc_version;
extern crate serde_json;
Expand Down Expand Up @@ -93,20 +92,14 @@ pub fn main() {
writeln!(stderr, "{:?}", backtrace).ok();
}
} else {
writeln!(
stderr,
"note: run with `RUST_BACKTRACE=1` for a backtrace"
)
.ok();
writeln!(stderr, "note: run with `RUST_BACKTRACE=1` for a backtrace").ok();
}

process::exit(1)
}
Ok(status) => {
if !status.success() {
process::exit(status.code().unwrap_or(1))
}
}
Ok(status) => if !status.success() {
process::exit(status.code().unwrap_or(1))
},
}
}

Expand All @@ -125,8 +118,7 @@ fn run() -> Result<ExitStatus> {
io::stderr(),
concat!("xargo ", env!("CARGO_PKG_VERSION"), "{}"),
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
)
.ok();
).ok();

return cargo::run(&args, verbose);
}
Expand All @@ -140,21 +132,21 @@ fn run() -> Result<ExitStatus> {
let src = match meta.channel {
Channel::Dev => rustc::Src::from_env().ok_or(
"The XARGO_RUST_SRC env variable must be set and point to the \
Rust source directory when working with the 'dev' channel")?,
Channel::Nightly => {
if let Some(src) = rustc::Src::from_env() {
src
} else {
sysroot.src()?
}
}
Rust source directory when working with the 'dev' channel",
)?,
Channel::Nightly => if let Some(src) = rustc::Src::from_env() {
src
} else {
sysroot.src()?
},
Channel::Stable | Channel::Beta => {
writeln!(
io::stderr(),
"WARNING: the sysroot can't be built for the {:?} channel. \
Switch to nightly.",
meta.channel).ok();
return cargo::run(&args, verbose)
meta.channel
).ok();
return cargo::run(&args, verbose);
}
};

Expand All @@ -167,16 +159,12 @@ fn run() -> Result<ExitStatus> {
} else if triple == meta.host {
Some(CompilationMode::Native(meta.host.clone()))
} else {
Target::new(triple, &cd, verbose)?.map(
CompilationMode::Cross,
)
Target::new(triple, &cd, verbose)?.map(CompilationMode::Cross)
}
} else {
if let Some(ref config) = config {
if let Some(triple) = config.target()? {
Target::new(triple, &cd, verbose)?.map(
CompilationMode::Cross,
)
Target::new(triple, &cd, verbose)?.map(CompilationMode::Cross)
} else {
Some(CompilationMode::Native(meta.host.clone()))
}
Expand Down
Loading

0 comments on commit f5d02ee

Please sign in to comment.