summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2021-10-13 23:24:09 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-04-12 23:12:17 +0000
commiteca67f364e6c7da698c3164f53c8e12a1e5c9080 (patch)
treec30e7b3c577d96753083a2d0f1d8cf2107a3b305
parent205bf7ab0a862acff1ba964483c651b86e8406e5 (diff)
downloadchrome-ec-eca67f364e6c7da698c3164f53c8e12a1e5c9080.tar.gz
firmware_builder: Call build_with_clang.py script
The util/build_with_clang.py script helps us validate that boards that build successfully with clang continue to do so. As compilation errors are fixed for boards, they can be added to the list. The script is called from firmware_builder.py as part of the CQ process. BRANCH=none BUG=b:172020503 TEST=CQ passes Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I8d9384e04dbfc25191d5ebf93425e6d178631168 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3221785 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rwxr-xr-xfirmware_builder.py8
-rwxr-xr-xutil/build_with_clang.py46
2 files changed, 54 insertions, 0 deletions
diff --git a/firmware_builder.py b/firmware_builder.py
index 6229e87539..625cb5166a 100755
--- a/firmware_builder.py
+++ b/firmware_builder.py
@@ -78,6 +78,14 @@ def build(opts):
with open(opts.metrics, 'w') as f:
f.write(json_format.MessageToJson(metric_list))
+ # Ensure that there are no regressions for boards that build successfully
+ # with clang: b/172020503.
+ cmd = ['./util/build_with_clang.py']
+ print(f'# Running {" ".join(cmd)}.')
+ subprocess.run(cmd,
+ cwd=os.path.dirname(__file__),
+ check=True)
+
UNITS = {
'B': 1,
diff --git a/util/build_with_clang.py b/util/build_with_clang.py
new file mode 100755
index 0000000000..5cc23d1012
--- /dev/null
+++ b/util/build_with_clang.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+
+# Copyright 2021 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Build firmware with clang instead of gcc."""
+import logging
+import os
+import subprocess
+import sys
+
+
+# Add to this list as compilation errors are fixed for boards.
+BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [
+ 'dartmonkey',
+ 'bloonchipper',
+ 'nucleo-f412zg',
+ 'nucleo-h743zi',
+]
+
+
+def build(board_name: str) -> None:
+ """Build with clang for specified board."""
+ logging.debug('Building board: "%s"', board_name)
+
+ cmd = [
+ 'make',
+ 'BOARD=' + board_name,
+ '-j',
+ ]
+
+ logging.debug('Running command: "%s"', ' '.join(cmd))
+ subprocess.run(cmd, env=dict(os.environ, CC='clang'), check=True)
+
+
+def main() -> int:
+ logging.basicConfig(level='DEBUG')
+ for board in BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG:
+ build(board)
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())