Skip to content

Commit 2e680f9

Browse files
committed
Add a build-command config option, defaulting to cargo build
1 parent 3f5e718 commit 2e680f9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ use toml::Value;
1212
#[derive(Debug, Clone)]
1313
#[non_exhaustive]
1414
pub struct Config {
15+
/// The command that is used for building the kernel for `cargo bootimage`.
16+
///
17+
/// Defaults to `cargo build`.
18+
pub build_command: Vec<String>,
1519
/// The run command that is invoked on `bootimage run` or `bootimage runner`
1620
///
1721
/// The substring "{}" will be replaced with the path to the bootable disk image.
@@ -75,6 +79,9 @@ fn read_config_inner(manifest_path: &Path) -> Result<Config> {
7579
("test-success-exit-code", Value::Integer(exit_code)) => {
7680
config.test_success_exit_code = Some(exit_code as i32);
7781
}
82+
("build-command", Value::Array(array)) => {
83+
config.build_command = Some(parse_string_array(array, "build-command")?);
84+
}
7885
("run-command", Value::Array(array)) => {
7986
config.run_command = Some(parse_string_array(array, "run-command")?);
8087
}
@@ -110,6 +117,7 @@ fn parse_string_array(array: Vec<Value>, prop_name: &str) -> Result<Vec<String>>
110117

111118
#[derive(Default)]
112119
struct ConfigBuilder {
120+
build_command: Option<Vec<String>>,
113121
run_command: Option<Vec<String>>,
114122
run_args: Option<Vec<String>>,
115123
test_args: Option<Vec<String>>,
@@ -120,6 +128,9 @@ struct ConfigBuilder {
120128
impl Into<Config> for ConfigBuilder {
121129
fn into(self) -> Config {
122130
Config {
131+
build_command: self
132+
.build_command
133+
.unwrap_or(vec!["cargo".into(), "build".into()]),
123134
run_command: self.run_command.unwrap_or_else(|| {
124135
vec![
125136
"qemu-system-x86_64".into(),

0 commit comments

Comments
 (0)