Make task config only readable from task crate build script#2444
Open
Make task config only readable from task crate build script#2444
Conversation
6a64cb7 to
87b28b9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Right now, dispatching
cargoonce per task is a reason why incremental rebuilds are slow. I would like to live in a world where we dispatchcargoonce to build multiple (compatible†) tasks.One issue with this plan: build scripts for library crates are free to read
HUBRIS_TASK_CONFIGand react accordingly. In a world where multiple tasks are built in a singlecargoinvocation, there's no singleHUBRIS_TASK_CONFIGto read.The PR eliminates that behavior: build scripts that read
HUBRIS_TASK_CONFIGmust have aCARGO_PKG_NAMEthat matches the task crate name. In other words, only a task's build script may read the task config. Otherwise, thebuild_util::*task*configfunction will panic.This is useful because it also works in the opposite direction: when this property is true, we can use
CARGO_PKG_NAMEto unambiguously‡ pick which task config to use.It turns out that we almost had this property already! The one exception is the
drv-stm32h7-spi-server-corecrate, which had a build script that read the parent task configuration to pick which SPI peripheral to codegen. In this PR, I make that codegen the parent crate's responsibility;drv_stm32h7_spi_server_core::SpiServerCore::initnow takes a configuration from the caller, instead of baking it into a global variable.The build script for
drv-stm32h7-spi-server-coreis moved to a separatebuild-stm32h7-spi-server-core, so that all of the parent crates can invoke it themselves.† "compatible" means that they enable the exact same set of features in their dependencies, to avoid feature unification surprises
‡ We will still be unable to simultaneously build multiple tasks that use the same crate, e.g.
spi2andspi3, but that's fine