Hide output of pw_exec programs by default
This change updates the pw_exec GN template and wrapper script to hide
the output of the program unless it exits unsuccessfully.
Sample output:
20200103 13:40:06 ERR
20200103 13:40:06 ERR Command failed with exit code 2 in GN build.
20200103 13:40:06 ERR
20200103 13:40:06 ERR Build target:
20200103 13:40:06 ERR
20200103 13:40:06 ERR pw_target_runner_client_pw_go_get
20200103 13:40:06 ERR
20200103 13:40:06 ERR Full command:
20200103 13:40:06 ERR
20200103 13:40:06 ERR go got github.com/golang/protobuf/proto google.golang.org/grpc
20200103 13:40:06 ERR
20200103 13:40:06 ERR Process output:
go got: unknown command
Run 'go help' for usage.
20200103 13:40:06 ERR
Bug: 34
Change-Id: I7e7b2a6d359ecf1eeff6918d56defb909141cbfd
diff --git a/pw_build/exec.gni b/pw_build/exec.gni
index 7c8765d..3e51d57 100644
--- a/pw_build/exec.gni
+++ b/pw_build/exec.gni
@@ -45,6 +45,9 @@
# running the program if the file is empty. Used to avoid running commands
# which error when called without arguments.
#
+# capture_output: If true, output from the program is hidden unless the program
+# exits with an error. Defaults to true.
+#
# Example:
#
# pw_exec("hello_world") {
@@ -61,7 +64,10 @@
template("pw_exec") {
assert(defined(invoker.program), "pw_exec requires a program to run")
- _script_args = []
+ _script_args = [
+ "--target",
+ target_name,
+ ]
if (defined(invoker.env_file)) {
_script_args += [
@@ -90,6 +96,10 @@
}
}
+ if (!defined(invoker.capture_output) || invoker.capture_output) {
+ _script_args += [ "--capture-output" ]
+ }
+
_script_args += [
"--",
invoker.program,