如何将编译器标志传递给Rust中的子板条箱?

时间:2018-06-22 09:34:58

标签: rust rust-cargo

我有AB的板条箱。 A取决于B,并且B具有名为some_feature的功能。

我可以通过运行B来使用货运来构建cargo build --features=some_feature,但是如何为A设置相同的功能,我可以选择为基础启用或禁用some_feature编译B时将A放在箱子里吗?

2 个答案:

答案 0 :(得分:1)

您可以简单地转发A中指定的功能:

# A/Cargo.toml

[features]
some-feature = ["B/some-feature"]

[dependencies]
B = "*"

如果您将B传递给--features=some_feature,它将用--features=some_feature编译A

答案 1 :(得分:0)

您只需要配置清单,就像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"]