Skip to content

Commit

Permalink
cleanup JSON creation and improve comments
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
axel-h committed Jan 11, 2024
1 parent aa77bae commit 34ecb5e
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions sel4test-hw/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import json
import os
import sys
import itertools


def hw_build(manifest_dir: str, build: Build):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 34ecb5e

Please sign in to comment.