summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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())