From eca67f364e6c7da698c3164f53c8e12a1e5c9080 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 13 Oct 2021 23:24:09 +0000 Subject: 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 Change-Id: I8d9384e04dbfc25191d5ebf93425e6d178631168 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3221785 Reviewed-by: Abe Levkoy Reviewed-by: Jack Rosenthal --- firmware_builder.py | 8 ++++++++ util/build_with_clang.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100755 util/build_with_clang.py 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()) -- cgit v1.2.1