Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying defaults for build target types #6945

Open
Tracked by #2
dhardy opened this issue May 15, 2019 · 4 comments
Open
Tracked by #2

Allow specifying defaults for build target types #6945

dhardy opened this issue May 15, 2019 · 4 comments
Labels
A-features Area: features — conditional compilation A-manifest Area: Cargo.toml issues A-required-features Area: required-features setting C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-rfc Status: Needs an RFC to make progress.

Comments

@dhardy
Copy link

dhardy commented May 15, 2019

Request: allow a feature flag to be required by all benchmarks (whether this acts like dev-dependencies and affects tests too or only benchmarks does not matter).

From what I understand, currently:

  • Dev-dependencies cannot be optional. source
  • The required-features field can apply to specific targets (e.g. [[bin]] or [[bench]] for a single binary)

Workaround: it appears to be possible to enable the feature for each benchmark independently, as follows:

[[bench]]
name = "distributions"
path = "benches/distributions.rs"
required-features = ["small_rng"]

[[bench]]
name = "generators"
path = "benches/generators.rs"
required-features = ["small_rng"]

...
@dhardy dhardy added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label May 15, 2019
dhardy added a commit to dhardy/rand that referenced this issue May 15, 2019
dhardy added a commit to dhardy/rand that referenced this issue May 23, 2019
dhardy added a commit to dhardy/rand that referenced this issue Jun 3, 2019
@ehuss ehuss added the A-manifest Area: Cargo.toml issues label Jun 24, 2019
@ehuss
Copy link
Contributor

ehuss commented Jun 24, 2019

I've actually wanted a more general mechanism of specifying any default for all targets of a specific kind. Some examples:

  • Set harness = false for all integration tests.
  • Set test = true for all examples.
  • Set doc = false for all binaries.

I have no idea how that would look in TOML, but I think would be useful in a number of circumstances.

@dhardy
Copy link
Author

dhardy commented Jun 24, 2019

I think for this (and several other things I've come across) a real scripting language would work better than a declarative language like TOML. (There are several options: an expanded version of build.rs, Lua, a DSL like CMake.)

@ehuss ehuss added A-features Area: features — conditional compilation A-required-features Area: required-features setting labels Mar 6, 2020
@epage epage changed the title Allow specification of features required by all benchmarks Allow specifying defaults for build target types May 24, 2023
@epage epage added S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. S-needs-rfc Status: Needs an RFC to make progress. and removed S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. labels May 24, 2023
@weihanglo
Copy link
Member

#12430 is a case that could be resolved by a general mechanism mentioned in #6945 (comment). Arguments are:

  • Having a bunch of examples could significantly slow down cargo test.
  • We already have things like doctest = false to address the slow part of testing. Building examples should also be considered as configurable.

@epage
Copy link
Contributor

epage commented Aug 1, 2023

When mapping out a path forward for custom test harnesses, I think this feature becomes critical. I'll be proposing to the test team (rust-lang/rfcs#3455) that this Issue be on our short-list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-features Area: features — conditional compilation A-manifest Area: Cargo.toml issues A-required-features Area: required-features setting C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-rfc Status: Needs an RFC to make progress.
Projects
Status: No status
Development

No branches or pull requests

4 participants