Skip to content

Commit

Permalink
xtask: Allow tasks & the kernel to specify default features.
Browse files Browse the repository at this point in the history
tasks & kernels that want to disable default features can do so using
the `no-default-features` boolean in the task / kernel config sections
of the relevant `app.toml` files.
  • Loading branch information
flihp committed Jul 22, 2024
1 parent c1166cf commit bb63797
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/demo-stm32h7-nucleo/app-h753.toml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ extern-regions = [ "sram2", "sram3", "sram4" ]

[tasks.fmc_demo]
name = "drv-stm32h7-fmc-demo-server"
# drv/stmh32h7-fmc-demo-server includes the `h743` feature in its defaults
no-default-features = true
features = ["h753"]
priority = 4
start = true
Expand Down
14 changes: 9 additions & 5 deletions build/xtask/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ impl Config {
&self,
verbose: bool,
crate_name: &str,
no_default_features: bool,
features: &[String],
sysroot: Option<&'a Path>,
) -> BuildConfig<'a> {
let mut args = vec![
"--no-default-features".to_string(),
"--target".to_string(),
self.target.to_string(),
];
let mut args = vec!["--target".to_string(), self.target.to_string()];
if no_default_features {
args.push("--no-default-features".to_string());
}
if verbose {
args.push("-v".to_string());
}
Expand Down Expand Up @@ -305,6 +305,7 @@ impl Config {
let mut out = self.common_build_config(
verbose,
&self.kernel.name,
self.kernel.no_default_features,
&self.kernel.features,
sysroot,
);
Expand All @@ -327,6 +328,7 @@ impl Config {
let mut out = self.common_build_config(
verbose,
&task_toml.name,
task_toml.no_default_features,
&task_toml.features,
sysroot,
);
Expand Down Expand Up @@ -626,6 +628,8 @@ pub struct Kernel {
pub stacksize: Option<u32>,
#[serde(default)]
pub features: Vec<String>,
#[serde(default)]
pub no_default_features: bool,
}

fn default_name() -> String {
Expand Down
2 changes: 2 additions & 0 deletions lib/toml-task/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ pub struct Task<T = ordered_toml::Value> {
pub sections: IndexMap<String, String>,
#[serde(default)]
pub max_sizes: IndexMap<String, u32>,
#[serde(default)]
pub no_default_features: bool,
}

impl<T> Task<T> {
Expand Down

0 comments on commit bb63797

Please sign in to comment.