Skip to content

Commit bcbf4a8

Browse files
authored
Update cargo-xbuild to new rust directory layout (#87)
1 parent 07d6581 commit bcbf4a8

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ In addition to the above configuration keys, `cargo-xbuild` can be also configur
8181
If you want to use a local Rust source instead of `rust-src` rustup component, you can set the `XARGO_RUST_SRC` environment variable.
8282

8383
```
84-
# The source of the `core` crate must be in `$XARGO_RUST_SRC/libcore`
84+
# The source of the `core` crate must be in `$XARGO_RUST_SRC/core`
8585
$ export XARGO_RUST_SRC=/path/to/rust/src
8686
8787
$ cargo xbuild --target msp430-none-elf.json

src/rustc.rs

+3-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::env;
2-
use std::ffi::OsStr;
32
use std::hash::{Hash, Hasher};
43
use std::path::{Path, PathBuf};
54
use std::process::Command;
@@ -8,7 +7,6 @@ pub use rustc_version::version_meta as version;
87

98
use serde_json;
109
use serde_json::Value;
11-
use walkdir::WalkDir;
1210

1311
use errors::*;
1412
use extensions::CommandExt;
@@ -65,38 +63,17 @@ impl Sysroot {
6563
&self.path
6664
}
6765

68-
/// Returns the path to Rust source, `$SRC`, where `$SRC/libstd/Carg.toml`
66+
/// Returns the path to Rust source, `$SRC`, where `$SRC/std/Cargo.toml`
6967
/// exists
7068
pub fn src(&self) -> Result<Src> {
7169
let src = self.path().join("lib").join("rustlib").join("src");
7270

73-
if src.join("rust/src/libstd/Cargo.toml").is_file() {
71+
if src.join("rust/library/std/Cargo.toml").is_file() {
7472
return Ok(Src {
75-
path: src.join("rust/src"),
73+
path: src.join("rust/library"),
7674
});
7775
}
7876

79-
if src.exists() {
80-
for e in WalkDir::new(src) {
81-
let e = e.chain_err(|| "couldn't walk the sysroot")?;
82-
83-
// Looking for $SRC/libstd/Cargo.toml
84-
if e.file_type().is_file() && e.file_name() == "Cargo.toml" {
85-
let toml = e.path();
86-
87-
if let Some(std) = toml.parent() {
88-
if let Some(src) = std.parent() {
89-
if std.file_name() == Some(OsStr::new("libstd")) {
90-
return Ok(Src {
91-
path: src.to_owned(),
92-
});
93-
}
94-
}
95-
}
96-
}
97-
}
98-
}
99-
10077
Err("`rust-src` component not found. Run `rustup component add \
10178
rust-src`.")?
10279
}

src/sysroot.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ version = "0.1.0"
177177
stoml.push_str("[dependencies.core]\n");
178178
stoml.push_str(&format!(
179179
"path = '{}'\n",
180-
src.path().join("libcore").display()
180+
src.path().join("core").display()
181181
));
182182

183183
if config.panic_immediate_abort {
@@ -187,10 +187,10 @@ version = "0.1.0"
187187
stoml.push_str("[patch.crates-io.rustc-std-workspace-core]\n");
188188
stoml.push_str(&format!(
189189
"path = '{}'\n",
190-
src.path().join("tools/rustc-std-workspace-core").display()
190+
src.path().join("rustc-std-workspace-core").display()
191191
));
192192

193-
let path = src.path().join("liballoc/lib.rs").display().to_string();
193+
let path = src.path().join("alloc/src/lib.rs").display().to_string();
194194
let mut map = Table::new();
195195
let mut lib = Table::new();
196196
lib.insert("name".to_owned(), Value::String("alloc".to_owned()));

0 commit comments

Comments
 (0)