Use new Cargo features & resolver to enable feature-based inclusion of crates #522
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, it was not easy to exclude application or kernel crates from a Theseus build. You had to either manually remove them from the set of workspace
members
or add it to the set of workspaceexclude
s.This PR introduces a dedicated crate used for specifying "global" features across all of the Theseus workspace, which allows one to specify crates that are optional in a Theseus build and thus use Cargo
features
to include them.This works in cooperation with a
default-members
list, which species what subset of themembers
crates should be built by default when--all
or--workspace
is not passed tocargo build
.The current Makefile still builds all crates by default, which is done via the
--workspace
flag being the defaultCARGOFLAGS
value if no other value forCARGOFLAGS
is specified on themake
command line invocation.Thus, to actually use this new build functionality, you simply set
CARGOFLAGS
with the features corresponding to the optional crates you wish to build:This would enable three features,
feat1
,feat2
, andfeat3
, and the ensuing build would include four things:nano_core
and all of its dependenciesfeat1
and all of it's dependenciesfeat2
and all of it's dependenciesfeat3
and all of it's dependenciesYou can also just manually invoke
cargo build --features <...>
but then you'd also have to pass all of the other required arguments that Theseus's Makefile passes to cargo/rustc.Shout-out to @epage for suggesting this technique. It's a bit hacky right now, but will continue to evolve as rust-lang/cargo#9094 progresses.
TODO: document this new cfg method in the Theseus book.