summaryrefslogtreecommitdiff
path: root/zephyr/zmake/zmake/zmake.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-28 15:55:40 +1300
committerCommit Bot <commit-bot@chromium.org>2021-04-02 19:58:15 +0000
commit14e99084528dbb6dc4277530f574cd256da9f819 (patch)
tree2861240f1a7eb54558398b3dc3658dccfb1a4c54 /zephyr/zmake/zmake/zmake.py
parentdc951654138d3f8547765b328308a7fc86c5e7b6 (diff)
downloadchrome-ec-14e99084528dbb6dc4277530f574cd256da9f819.tar.gz
zephyr: zmake: Allow warnings to break the build
Now that we are showing warnings by default (and not requiring -l DEBUG) they are more likely to receive action. But for the commit queue it seems useful to fail the build if there are any warnings, just in case people are not very observant in their local builds. Add a -w flag for this. It works by checking for any output in the ERROR log, which is safer now that we have cleaned up the error output to just include actual errors. Put the check in a separate function since it will be called from a different place in a future CL. BUG=b:177096315 BRANCH=none TEST=manually test by running zmake build / configure FEATURE=test sudo -E emerge zephyr-build-tools Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I4c0ec53d2836ce0ba67b3c8bcf39b53fa1af2945 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2789797 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/zmake/zmake/zmake.py')
-rw-r--r--zephyr/zmake/zmake/zmake.py39
1 files changed, 32 insertions, 7 deletions
diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py
index 0d9f9ee33c..addf422d11 100644
--- a/zephyr/zmake/zmake/zmake.py
+++ b/zephyr/zmake/zmake/zmake.py
@@ -257,12 +257,37 @@ class Zmake:
elif build_after_configure:
return self.build(build_dir=build_dir)
- def build(self, build_dir, output_files_out=None):
+ def build(self, build_dir, output_files_out=None, fail_on_warnings=False):
"""Build a pre-configured build directory."""
- project = zmake.project.Project(build_dir / 'project')
+ def wait_and_check_success(procs, writers):
+ """Wait for processes to complete and check for errors
+
+ Args:
+ procs: List of subprocess.Popen objects to check
+ writers: List of LogWriter objects to check
+
+ Returns:
+ True if all if OK
+ False if an error was found (so that zmake should exit)
+ """
+ for proc in procs:
+ if proc.wait():
+ raise OSError(get_process_failure_msg(proc))
+
+ if (fail_on_warnings and
+ any(w.has_written(logging.WARNING) or
+ w.has_written(logging.ERROR) for w in writers)):
+ self.logger.warning(
+ "zmake: Warnings detected in build: aborting")
+ return False
+ return True
procs = []
+ log_writers = []
dirs = {}
+
+ project = zmake.project.Project(build_dir / 'project')
+
for build_name, build_config in project.iter_builds():
dirs[build_name] = build_dir / 'build-{}'.format(build_name)
cmd = ['/usr/bin/ninja', '-C', dirs[build_name].as_posix()]
@@ -277,21 +302,21 @@ class Zmake:
stderr=subprocess.PIPE,
encoding='utf-8',
errors='replace')
- zmake.multiproc.log_output(
+ out = zmake.multiproc.log_output(
logger=self.logger,
log_level=logging.INFO,
file_descriptor=proc.stdout,
log_level_override_func=ninja_log_level_override)
- zmake.multiproc.log_output(
+ err = zmake.multiproc.log_output(
self.logger,
logging.ERROR,
proc.stderr,
log_level_override_func=cmake_log_level_override)
procs.append(proc)
+ log_writers += [out, err]
- for proc in procs:
- if proc.wait():
- raise OSError(get_process_failure_msg(proc))
+ if not wait_and_check_success(procs, log_writers):
+ return 2
# Run the packer.
packer_work_dir = build_dir / 'packer'