From 3e5e97f113c63601abaf3d4c8d7e71390376e823 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 2 Aug 2020 12:29:43 +0200 Subject: [PATCH] Update cargo-xbuild to new rust directory layout --- README.md | 2 +- src/rustc.rs | 29 +++-------------------------- src/sysroot.rs | 6 +++--- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index a301c50..b4b124e 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ In addition to the above configuration keys, `cargo-xbuild` can be also configur If you want to use a local Rust source instead of `rust-src` rustup component, you can set the `XARGO_RUST_SRC` environment variable. ``` -# The source of the `core` crate must be in `$XARGO_RUST_SRC/libcore` +# The source of the `core` crate must be in `$XARGO_RUST_SRC/core` $ export XARGO_RUST_SRC=/path/to/rust/src $ cargo xbuild --target msp430-none-elf.json diff --git a/src/rustc.rs b/src/rustc.rs index 44618c5..a12d125 100644 --- a/src/rustc.rs +++ b/src/rustc.rs @@ -1,5 +1,4 @@ use std::env; -use std::ffi::OsStr; use std::hash::{Hash, Hasher}; use std::path::{Path, PathBuf}; use std::process::Command; @@ -8,7 +7,6 @@ pub use rustc_version::version_meta as version; use serde_json; use serde_json::Value; -use walkdir::WalkDir; use errors::*; use extensions::CommandExt; @@ -65,38 +63,17 @@ impl Sysroot { &self.path } - /// Returns the path to Rust source, `$SRC`, where `$SRC/libstd/Carg.toml` + /// Returns the path to Rust source, `$SRC`, where `$SRC/std/Cargo.toml` /// exists pub fn src(&self) -> Result { let src = self.path().join("lib").join("rustlib").join("src"); - if src.join("rust/src/libstd/Cargo.toml").is_file() { + if src.join("rust/library/std/Cargo.toml").is_file() { return Ok(Src { - path: src.join("rust/src"), + path: src.join("rust/library"), }); } - if src.exists() { - for e in WalkDir::new(src) { - let e = e.chain_err(|| "couldn't walk the sysroot")?; - - // Looking for $SRC/libstd/Cargo.toml - if e.file_type().is_file() && e.file_name() == "Cargo.toml" { - let toml = e.path(); - - if let Some(std) = toml.parent() { - if let Some(src) = std.parent() { - if std.file_name() == Some(OsStr::new("libstd")) { - return Ok(Src { - path: src.to_owned(), - }); - } - } - } - } - } - } - Err("`rust-src` component not found. Run `rustup component add \ rust-src`.")? } diff --git a/src/sysroot.rs b/src/sysroot.rs index feb447e..1f3c8d1 100644 --- a/src/sysroot.rs +++ b/src/sysroot.rs @@ -177,7 +177,7 @@ version = "0.1.0" stoml.push_str("[dependencies.core]\n"); stoml.push_str(&format!( "path = '{}'\n", - src.path().join("libcore").display() + src.path().join("core").display() )); if config.panic_immediate_abort { @@ -187,10 +187,10 @@ version = "0.1.0" stoml.push_str("[patch.crates-io.rustc-std-workspace-core]\n"); stoml.push_str(&format!( "path = '{}'\n", - src.path().join("tools/rustc-std-workspace-core").display() + src.path().join("rustc-std-workspace-core").display() )); - let path = src.path().join("liballoc/lib.rs").display().to_string(); + let path = src.path().join("alloc/src/lib.rs").display().to_string(); let mut map = Table::new(); let mut lib = Table::new(); lib.insert("name".to_owned(), Value::String("alloc".to_owned()));