mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-20 13:06:33 +00:00
Add config
option for CargoArgs
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
0c60a2a667
commit
94550dd5c6
@ -190,6 +190,12 @@ pub struct CargoArgs {
|
||||
pub release: bool,
|
||||
#[arg(long, value_name = "FEATURES", help = "List of features to activate")]
|
||||
pub features: Vec<String>,
|
||||
#[arg(
|
||||
long = "config",
|
||||
help = "Override a configuration value",
|
||||
value_name = "KEY=VALUE"
|
||||
)]
|
||||
pub override_configs: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
|
@ -148,6 +148,10 @@ fn build_kernel_elf(
|
||||
.arg(cargo_target_directory.as_ref());
|
||||
command.args(COMMON_CARGO_ARGS);
|
||||
command.arg("--profile=".to_string() + &args.profile);
|
||||
for override_config in &args.override_configs {
|
||||
command.arg("--config").arg(override_config);
|
||||
}
|
||||
|
||||
let status = command.status().unwrap();
|
||||
if !status.success() {
|
||||
error_msg!("Cargo build failed");
|
||||
|
@ -147,15 +147,13 @@ fn load_osdk_manifest<S: AsRef<str>>(cargo_args: &CargoArgs, selection: Option<S
|
||||
/// 1. Split `features` in `cargo_args` to ensure each string contains exactly one feature.
|
||||
/// 2. Change `profile` to `release` if `--release` is set.
|
||||
fn parse_cargo_args(cargo_args: &CargoArgs) -> CargoArgs {
|
||||
let mut features = Vec::new();
|
||||
|
||||
for feature in cargo_args.features.iter() {
|
||||
for feature in feature.split(',') {
|
||||
if !feature.is_empty() {
|
||||
features.push(feature.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
let features = cargo_args
|
||||
.features
|
||||
.iter()
|
||||
.flat_map(|feature| feature.split(','))
|
||||
.filter(|feature| !feature.is_empty())
|
||||
.map(|feature| feature.to_string())
|
||||
.collect();
|
||||
|
||||
let profile = if cargo_args.release {
|
||||
"release".to_string()
|
||||
@ -167,6 +165,7 @@ fn parse_cargo_args(cargo_args: &CargoArgs) -> CargoArgs {
|
||||
profile,
|
||||
release: cargo_args.release,
|
||||
features,
|
||||
override_configs: cargo_args.override_configs.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user