cargo icon indicating copy to clipboard operation
cargo copied to clipboard

A top-level root profile for overriding dev and release profiles simultaneously

Open bstrie opened this issue 2 years ago • 1 comments

Problem

Currently, if you have some profile that needs to always apply regardless of whether the crate is being built in release mode or not, you're required to specify the options twice, once for dev mode and once for release mode:

# rustflags specified via the unstable profile-rustflags option
[profile.dev.package.aes]
# use software implementation
rustflags = ["--cfg", "aes_force_soft"]

[profile.release.package.aes]
# use software implementation
rustflags = ["--cfg", "aes_force_soft"]

Proposed Solution

Since profile inheritance is already a concept, it would be nice if the dev and release profiles inherited from a root profile so that both dev and release could be overridden together:

# rustflags specified via the unstable profile-rustflags option
[profile.root.package.aes]
# use software implementation
rustflags = ["--cfg", "aes_force_soft"]

Notes

According to the Zulip thread here: https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/profile.20wildcards/near/281732406 , the name "root" is already reserved for this purpose.

bstrie avatar Aug 08 '22 23:08 bstrie

For example:

[profile.dev]
implements = "root" # or implement implicitly, but require that root be listed first
# parameters

[profile.release]
implements = "root" # or implement implicitly, but require that root be listed first
# parameters

[profile.root]
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# but not all

Better:

[profile.dev]
implements = [ "root", "custom1", "custom2" ] # or implement 'root' implicitly, but require be listed first
# parameters

[profile.release]
implements = [ "root", "custom1", "custom2" ] # or implement 'root' implicitly, but require be listed first
# parameters

[profile.root]
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# a lot of parameters taking up space
# but not all


[profile.custom1]
# parameters
# parameters

[profile.custom2]
# parameters
# parameters

Zymlex avatar Aug 23 '22 14:08 Zymlex