From c30d9cda91c608b29157e5895cd6f4d2dcd1a5c9 Mon Sep 17 00:00:00 2001 From: haixuanTao Date: Wed, 9 Oct 2024 13:56:09 +0200 Subject: [PATCH 1/2] Enable multi-line build for more explicit packaging --- binaries/cli/src/build.rs | 32 ++++++++++++++++-------------- tests/multiline_build/dataflow.yml | 6 ++++++ 2 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 tests/multiline_build/dataflow.yml diff --git a/binaries/cli/src/build.rs b/binaries/cli/src/build.rs index 496402a81..c67975ed8 100644 --- a/binaries/cli/src/build.rs +++ b/binaries/cli/src/build.rs @@ -59,22 +59,24 @@ pub fn build(dataflow: &Path) -> eyre::Result<()> { fn run_build_command(build: Option<&str>, working_dir: &Path) -> eyre::Result<()> { if let Some(build) = build { - let mut split = build.split_whitespace(); - let mut cmd = Command::new( - split - .next() - .ok_or_else(|| eyre!("build command is empty"))?, - ); - cmd.args(split); - cmd.current_dir(working_dir); - let exit_status = cmd - .status() - .wrap_err_with(|| format!("failed to run `{}`", build))?; - if exit_status.success() { - Ok(()) - } else { - Err(eyre!("build command returned an error code")) + let lines = build.lines().collect::>(); + for build_line in lines { + let mut split = build_line.split_whitespace(); + let mut cmd = Command::new( + split + .next() + .ok_or_else(|| eyre!("build command is empty"))?, + ); + cmd.args(split); + cmd.current_dir(working_dir); + let exit_status = cmd + .status() + .wrap_err_with(|| format!("failed to run `{}`", build))?; + if !exit_status.success() { + return Err(eyre!("build command `{build_line}` returned {exit_status}")); + } } + Ok(()) } else { Ok(()) } diff --git a/tests/multiline_build/dataflow.yml b/tests/multiline_build/dataflow.yml new file mode 100644 index 000000000..61e1f8a10 --- /dev/null +++ b/tests/multiline_build/dataflow.yml @@ -0,0 +1,6 @@ +nodes: + - id: dora-microphone + build: | + pip install -e ../../node-hub/dora-microphone + pip install -e ../../node-hub/dora-vad + path: dora-microphone From bf06c5c92fcb39f86992a4c759dfdbf7816f84ad Mon Sep 17 00:00:00 2001 From: haixuanTao Date: Wed, 9 Oct 2024 13:56:23 +0200 Subject: [PATCH 2/2] Add a multiline build example --- tests/multiline_build/dataflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/multiline_build/dataflow.yml b/tests/multiline_build/dataflow.yml index 61e1f8a10..3e977f563 100644 --- a/tests/multiline_build/dataflow.yml +++ b/tests/multiline_build/dataflow.yml @@ -1,6 +1,6 @@ nodes: - id: dora-microphone build: | - pip install -e ../../node-hub/dora-microphone + pip install -e ../../node-hub/dora-microphones pip install -e ../../node-hub/dora-vad path: dora-microphone