From 34ecb5ed0cebc94865563e1a5bd8e4511769b3fa Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Thu, 11 Jan 2024 13:06:13 +0100 Subject: [PATCH] cleanup JSON creation and improve comments Signed-off-by: Axel Heider --- sel4test-hw/build.py | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/sel4test-hw/build.py b/sel4test-hw/build.py index fe66c7f8..880fd7ed 100644 --- a/sel4test-hw/build.py +++ b/sel4test-hw/build.py @@ -18,6 +18,7 @@ import json import os import sys +import itertools def hw_build(manifest_dir: str, build: Build): @@ -99,36 +100,24 @@ def build_filter(build: Build) -> bool: def to_json(builds: List[Build]) -> str: """Return a GitHub build matrix per enabled hardware platform as GitHub output assignment.""" - def run_for_plat(plat: Platform) -> List[dict]: + def runs_for_plat(plat: Platform) -> List[dict]: if plat.disabled or plat.no_hw_build: return [] - - # separate runs for each compiler on arm - if plat.arch == 'arm': - return [ - {"platform": plat.name, "march": plat.march, "compiler": "gcc"}, - {"platform": plat.name, "march": plat.march, "compiler": "clang"}, - ] - - if plat.arch == 'riscv': - return [ - {"platform": plat.name, "march": plat.march, "compiler": "gcc"}, - {"platform": plat.name, "march": plat.march, "compiler": "clang"}, - ] - - # separate runs for each compiler + mode on x86, because we have more machines available + # Do separate runs for each compiler + mode on x86, because we have more + # machines available. if plat.arch == 'x86': - return [ - {"platform": plat.name, "march": plat.march, "compiler": "gcc", "mode": 32}, - {"platform": plat.name, "march": plat.march, "compiler": "clang", "mode": 32}, - {"platform": plat.name, "march": plat.march, "compiler": "gcc", "mode": 64}, - {"platform": plat.name, "march": plat.march, "compiler": "clang", "mode": 64}, - ] - - platforms = set([b.get_platform() for b in builds]) - matrix = {"include": [run for plat in platforms for run in run_for_plat(plat)]} - - return "matrix=" + json.dumps(matrix) + return [ {"platform": plat.name, "march": plat.march, "compiler": compiler, "mode": mode}, + for mode in [32, 64] + for compiler in ["gcc", "clang"] ] + # Do separate runs for each compiler, the mode it usually implied by + # platform architecture. + return [ { "platform": plat.name, "march": plat.march, "compiler": compiler}, + for compiler in ["gcc", "clang"] ] + + generator = ( runs_for_plat(b.get_platform()) for b in builds ) + runs = itertools.chain.from_iterable(generator) + + return "matrix=" + json.dumps({"include": runs}) # If called as main, run all builds from builds.yml