-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conditional compilation of workspace members via features #11526
Comments
Thank you for proposing this feature! Personally, I've got questions on this proposal:
I am not entirely understand your use case. Looks like #5220 can cover it. Could you share more on that? |
Thanks for your response, sorry this isn't so timely. I must have not been thinking very clearly when I wrote that example! Maybe something like this could avoid "workspace features". # /Cargo.toml
[workspace]
members = [
"foo",
]
# /foo/Cargo.toml
# ...
[dependencies]
bar = {version = "0.1.0", path = "../bar", optional = true}
[features]
bar = ["dep:bar", "workspace_member:bar"]
# ...
# /bar/Cargo.toml
# ... Which achieves bar only being compiled and linked in if foo has the "bar" feature specified. It's inline with how you might have a feature depend on a dependency like In addition, would it be clearer if a workspace member had to be declared as "optional" much like a dependency would? I can see three ways of doing this, if at all: # Way 1, /Cargo.toml
[workspace]
members = [ "bar:optional" ]
# Way 2, /Cargo.toml
[workspace]
members = [ "bar" ]
[workspace.bar]
optional = true
# Way 3, /bar/Cargo.toml
optional = true Sorry it wasn't initially clear :) |
Thanks for the understandable examples. Given the feature syntax and possible extension is a bit in flux. I would suggest not extend it meanings to workspace at this moment. Give it a glance on the label
A-features
I can see the proposed solutions to fix things, but I don't really see the "problem". If we can select member via BTW, I feel like we cannot entirely avoid |
From #11987 (comment) epage said,
This is a good argument why this might not be a good idea. Given this reason, and also it is conceptually the same as #5220, I'm going to close due to inactivity for months. Thanks for the proposal anyway! |
Problem
I'm writing a kernel and I want to split out
x86
andx86_64
specific code, so I can publish it to crates.io and possible use it in another project. Best way I can think to do this is through workspaces. However, when compiling my kernel, I don't want to compile thex86
crate, when, for example, building for aarch64 or RISC-V. I'm currently doing something like the below:This obviously isn't optimal. Similar to #5220?
Proposed Solution
I would propose something like below:
or
or something to that affect.
Notes
No response (yet, haha!)
The text was updated successfully, but these errors were encountered: