使用 Xargo 从特定来源编译 `core`
Compiling `core` from a specific source using Xargo
Based on this comment,应该可以使用 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" }
但是,通过 xargo 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 流量。
相比之下,如果我将我的 core = { git = ...}
行放在 Cargo.toml
而不是 Xargo.toml
中,这是 vanilla cargo
的输出,它按预期工作:
$ 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
您可能需要安装 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
事实证明 picking up rustc
's path from .cargo/config
is not currently supported by Xargo,因此无论我想使用什么 rustc
,都需要安装为 rustup link
。引用以上票:
In the meantine you could use rustup
to create a custom toolchain that points to your stage1 rustc
. That's known to work.
$ 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
Based on this comment,应该可以使用 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" }
但是,通过 xargo 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 流量。
相比之下,如果我将我的 core = { git = ...}
行放在 Cargo.toml
而不是 Xargo.toml
中,这是 vanilla cargo
的输出,它按预期工作:
$ 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
您可能需要安装 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
事实证明 picking up rustc
's path from .cargo/config
is not currently supported by Xargo,因此无论我想使用什么 rustc
,都需要安装为 rustup link
。引用以上票:
In the meantine you could use
rustup
to create a custom toolchain that points to your stage1rustc
. That's known to work.$ 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