如何将编译器标志传递给 Rust 中的子板条箱?
How to pass compiler flags to a sub crate in Rust?
我有板条箱 A
和 B
。 A
依赖于 B
,B
有一个名为 some_feature
的功能。
我可以通过 运行 cargo build --features=some_feature
使用 cargo 构建 B
,但是如何为 A
设置相同的功能,我可以选择启用或禁用 some_feature
在编译时用于基础板条箱 B
A
?
你只需要配置清单,就像doc说的一样简单:
[dependencies.awesome]
version = "1.3.5"
default-features = false # do not include the default features, and optionally
# cherry-pick individual features
features = ["secure-password", "civet"]
您可以简单转发A
中指定的功能:
# A/Cargo.toml
[features]
some-feature = ["B/some-feature"]
[dependencies]
B = "*"
如果您将 --features=some_feature
传递给 A
,这将使用 --features=some_feature
编译 B
。
我有板条箱 A
和 B
。 A
依赖于 B
,B
有一个名为 some_feature
的功能。
我可以通过 运行 cargo build --features=some_feature
使用 cargo 构建 B
,但是如何为 A
设置相同的功能,我可以选择启用或禁用 some_feature
在编译时用于基础板条箱 B
A
?
你只需要配置清单,就像doc说的一样简单:
[dependencies.awesome]
version = "1.3.5"
default-features = false # do not include the default features, and optionally
# cherry-pick individual features
features = ["secure-password", "civet"]
您可以简单转发A
中指定的功能:
# A/Cargo.toml
[features]
some-feature = ["B/some-feature"]
[dependencies]
B = "*"
如果您将 --features=some_feature
传递给 A
,这将使用 --features=some_feature
编译 B
。