1

基于此评论,应该可以使用 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
4

2 回答 2

1

事实证明,Xargo 目前不支持 pick uprustc的路径.cargo/config,所以无论rustc我想使用什么,都需要安装为rustup link. 引用上面的票:

同时,您可以rustup用来创建指向您的 stage1 的自定义工具链rustc。这是众所周知的工作。

$ cd /home/cactus/prog/rust/rust-avr/build/build/x86_64-unknown-linux-gnu/stage1
$ rustup toolchain link avr-toolchain .
$ rustup default avr-toolchain
$ rustc -V
# should say dev channel
于 2017-06-04T04:32:54.820 回答
1

您可能需要安装 nightly Rust 工具链以允许 xargo 为您的目标构建一些支持代码。我必须做一些类似的事情才能让嵌入式 ARM 设置与 xargo 一起工作。在嵌入式目标的目录中执行此操作:

$ rustup install nightly
$ rustup component add rust-src  # needed for xargo buildup of the target
$ rustup override set nightly    # sets the rustc version to run for this dir
$ xargo build
于 2017-06-04T02:01:13.470 回答