基于此评论,应该可以使用 Xargo 来管理core
特定目标的自定义 crate 的安装。我已经尝试了以下方法来让它与一个没有其他依赖关系的板条箱一起工作,除了core
:
Cargo.toml
: 没有列出依赖项
[package]
name = "chip8-engine"
version = "0.1.0"
authors = ["Dr. ERDI Gergo <gergo@erdi.hu>"]
[dependencies]
Xargo.toml
:我列出的具体来源core
[target.avr-atmel-none.dependencies]
core = { git = "https://github.com/gergoerdi/rust-avr-libcore-mini", rev = "adda44aa91ac517aab6915447592ee4cad26564c" }
但是,构建 viaxargo build
失败,就好像我只是在使用cargo
:
$ ~/.cargo/bin/xargo build --release -v --target avr-atmel-none
+ "rustc" "--print" "sysroot"
+ "cargo" "build" "--release" "-v" "--target" "avr-atmel-none"
Compiling chip8-engine v0.1.0 (file:///home/cactus/prog/rust/avr/chip8-engine-avr)
Running `stage1/bin/rustc --crate-name chip8_engine src/lib.rs --crate-type lib -C opt-level=3 -C metadata=231962fc6e1bee04 -C extra-filename=-231962fc6e1bee04 --out-dir /home/cactus/prog/rust/avr/chip8-engine-avr/target/avr-atmel-none/release/deps --emit=dep-info,link --target avr-atmel-none -L dependency=/home/cactus/prog/rust/avr/chip8-engine-avr/target/avr-atmel-none/release/deps -L dependency=/home/cactus/prog/rust/avr/chip8-engine-avr/target/release/deps`
error[E0463]: can't find crate for `core`
|
= note: the `avr-atmel-none` target may not be installed
error: aborting due to previous error
error: Could not compile `chip8-engine`.
Caused by:
process didn't exit successfully: `stage1/bin/rustc --crate-name chip8_engine src/lib.rs --crate-type lib -C opt-level=3 -C metadata=231962fc6e1bee04 -C extra-filename=-231962fc6e1bee04 --out-dir /home/cactus/prog/rust/avr/chip8-engine-avr/target/avr-atmel-none/release/deps --emit=dep-info,link --target avr-atmel-none -L dependency=/home/cactus/prog/rust/avr/chip8-engine-avr/target/avr-atmel-none/release/deps -L dependency=/home/cactus/prog/rust/avr/chip8-engine-avr/target/release/deps` (exit code: 101)
请注意,没有任何迹象表明甚至尝试过 Git 流量。
相反,cargo
如果我将core = { git = ...}
行放入Cargo.toml
而不是Xargo.toml
,这是 vanilla 的输出,它按预期工作:
$ cargo build -v --target=avr-atmel-none --release
Compiling core v0.1.0 (https://github.com/gergoerdi/rust-avr-libcore-mini?rev=adda44aa91ac517aab6915447592ee4cad26564c#adda44aa)
Running `stage1/bin/rustc --crate-name core /home/cactus/.cargo/git/checkouts/rust-avr-libcore-mini-37e279d93a70b45a/adda44a/src/lib.rs --crate-type lib -C opt-level=3 -C metadata=47f38a1987c5b284 -C extra-filename=-47f38a1987c5b284 --out-dir /home/cactus/prog/rust/avr/chip8-engine-avr/target/avr-atmel-none/release/deps --emit=dep-info,link --target avr-atmel-none -L dependency=/home/cactus/prog/rust/avr/chip8-engine-avr/target/avr-atmel-none/release/deps -L dependency=/home/cactus/prog/rust/avr/chip8-engine-avr/target/release/deps --cap-lints allow`
Compiling chip8-engine v0.1.0 (file:///home/cactus/prog/rust/avr/chip8-engine-avr)
Running `stage1/bin/rustc --crate-name chip8_engine src/lib.rs --crate-type lib -C opt-level=3 -C metadata=231962fc6e1bee04 -C extra-filename=-231962fc6e1bee04 --out-dir /home/cactus/prog/rust/avr/chip8-engine-avr/target/avr-atmel-none/release/deps --emit=dep-info,link --target avr-atmel-none -L dependency=/home/cactus/prog/rust/avr/chip8-engine-avr/target/avr-atmel-none/release/deps -L dependency=/home/cactus/prog/rust/avr/chip8-engine-avr/target/release/deps --extern core=/home/cactus/prog/rust/avr/chip8-engine-avr/target/avr-atmel-none/release/deps/libcore-47f38a1987c5b284.rlib`
Finished release [optimized] target(s) in 15.21 secs