forked from ARM-software/SCP-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools/check_build: Add check build to a separate file with YAML integ…
…ration This patch introduces a new script, check_build.py, to verify the build process for various products. It modularizes the functionality previously found in the ci_cmake.py test script, which executed a predefined list of products with their respective configurations. Furthermore, it removes all hardcoded product build definitions by replacing them with a YAML configuration file. By default, it is set to use the `product_build.yml` file. Additionally, `*.yml` and `*.yaml` are added to the `FILE_TYPES` in `check_spacing.py` script for consistency. Signed-off-by: Leandro Belli <[email protected]> Change-Id: Ib7df2dc5c2ba122d3154fcf0f48eb7ce75c4ab7a
- Loading branch information
1 parent
6ed64e7
commit 6eb0132
Showing
4 changed files
with
203 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Arm SCP/MCP Software | ||
# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import argparse | ||
import os | ||
import sys | ||
import subprocess | ||
from product import Product, Build, Parameter | ||
from typing import List, Tuple | ||
from utils import Results, banner | ||
|
||
""" | ||
Check for product build | ||
""" | ||
|
||
# | ||
# Default products build configuration file | ||
# | ||
PRODUCTS_BUILD_FILE_DEFAULT = './tools/products_build.yml' | ||
|
||
# | ||
# Default build output directory | ||
# | ||
BUILD_OUTPUT_DIR_DEFAULT = '/tmp/scp/build' | ||
|
||
|
||
def do_build(build_info: List[Build], output_path: str) -> \ | ||
List[Tuple[Build, subprocess.Popen]]: | ||
build_status: List[Tuple[Build, subprocess.Popen]] = [] | ||
results = Results() | ||
|
||
if not os.path.exists(output_path): | ||
os.makedirs(output_path) | ||
|
||
files = [] | ||
for build in build_info: | ||
file_path = os.path.join(output_path, build.file_name()) | ||
files.append(open(file_path, "w", encoding="utf-8")) | ||
|
||
build_cmd = build.command(output_path) | ||
|
||
build_id = subprocess.Popen( | ||
build_cmd, | ||
shell=True, | ||
stdout=files[-1], | ||
stderr=subprocess.STDOUT) | ||
|
||
build_status.append((build, build_id)) | ||
print(f'Test building: \n{build_cmd}') | ||
print(f'Log file: \n\t{build.file_name()}') | ||
print('-----------') | ||
|
||
for i, (build, build_id) in enumerate(build_status): | ||
build_id.communicate() | ||
results.append((build.tag(), build_id.returncode)) | ||
files[i].close() | ||
|
||
return results | ||
|
||
|
||
def build_all(config_file: str, | ||
ignore_errors: bool, | ||
log_level: str, | ||
output_path: str): | ||
|
||
banner('Test building products') | ||
results = Results() | ||
|
||
try: | ||
with open(config_file, 'r') as file: | ||
products = Product.from_yaml(file) | ||
except IOError: | ||
print(f'Error opening {config_file} file') | ||
results.append(("Opening yaml file", 1)) | ||
return results | ||
|
||
for product in products: | ||
if log_level != "": | ||
product.log_level = Parameter(log_level) | ||
results.extend(do_build(product.builds, output_path)) | ||
if not ignore_errors and results.errors: | ||
print('Errors detected! Excecution stopped') | ||
break | ||
|
||
return results | ||
|
||
|
||
def parse_args(argv, prog_name): | ||
parser = argparse.ArgumentParser( | ||
prog=prog_name, | ||
description='Perform basic SCP-Firmware build for all \ | ||
supported platforms, modes and compilers.') | ||
|
||
parser.add_argument('-c', '--config-file', dest='config_file', | ||
required=False, default=PRODUCTS_BUILD_FILE_DEFAULT, | ||
type=str, action='store', help=f'Products build \ | ||
configuration file, if it is not provided, the \ | ||
default location is {PRODUCTS_BUILD_FILE_DEFAULT}') | ||
|
||
parser.add_argument('-i', '--ignore-errors', dest='ignore_errors', | ||
required=False, default=False, action='store_true', | ||
help='Ignore errors and continue testing.') | ||
|
||
parser.add_argument('-ll', '--log-level', dest='log_level', | ||
required=False, default="", type=str, | ||
action='store', help='Build every product with the \ | ||
specified log level.') | ||
|
||
parser.add_argument('-bod', '--build-output-dir', dest='output_path', | ||
required=False, default=BUILD_OUTPUT_DIR_DEFAULT, | ||
type=str, action='store', help=f'Parent directory of \ | ||
the "build-output" directory, the one where the build \ | ||
logs will be stored in.\n If build output directory \ | ||
is not given, the default location is \ | ||
{BUILD_OUTPUT_DIR_DEFAULT}') | ||
|
||
return parser.parse_args(argv) | ||
|
||
|
||
def main(argv=[], prog_name=''): | ||
args = parse_args(argv, prog_name) | ||
|
||
results = Results() | ||
results.extend(build_all(args.config_file, | ||
args.ignore_errors, | ||
args.log_level, | ||
args.output_path)) | ||
print(results) | ||
return 0 if not results.errors else 1 | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main(sys.argv[1:], sys.argv[0])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,8 @@ | |
'*.h', | ||
'*.cmake', | ||
'CMakeLists.txt', | ||
'*.yml', | ||
'*.yaml', | ||
] | ||
|
||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# | ||
# Arm SCP/MCP Software | ||
# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
|
||
- product: host | ||
toolchains: | ||
- name: GNU | ||
|
||
- product: juno | ||
variants: | ||
- name: BOARD | ||
- name: FVP | ||
|
||
- product: morello | ||
|
||
- product: n1sdp | ||
|
||
- product: rcar | ||
toolchains: | ||
- name: GNU | ||
|
||
- product: rdfremont | ||
product_group: neoverse-rd | ||
|
||
- product: rdv1 | ||
product_group: neoverse-rd | ||
|
||
- product: rdv1mc | ||
product_group: neoverse-rd | ||
|
||
- product: rdn1e1 | ||
product_group: neoverse-rd | ||
|
||
- product: rdn2 | ||
variants: | ||
- name: 0 | ||
- name: 1 | ||
- name: 2 | ||
- name: 3 | ||
product_group: neoverse-rd | ||
|
||
- product: sgi575 | ||
product_group: neoverse-rd | ||
|
||
- product: sgm775 | ||
|
||
- product: sgm776 | ||
|
||
- product: synquacer | ||
|
||
- product: tc1 | ||
product_group: totalcompute | ||
|
||
- product: tc2 | ||
variants: | ||
- name: 0 | ||
- name: 1 | ||
product_group: totalcompute |