Skip to content

Commit 72b0094

Browse files
committed
ci: add script to generate generic boards to skip
only one generic board kept per variant folders Signed-off-by: Frederic Pillon <[email protected]>
1 parent 9875d7d commit 72b0094

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

Diff for: CI/build/generic_boards_to_skip.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import argparse
2+
from pathlib import Path
3+
4+
5+
script_path = Path(__file__).parent.resolve()
6+
# Base path
7+
core_path = script_path.parent.parent
8+
variant_path = core_path / "variants"
9+
boards_entry_filename = "boards_entry.txt"
10+
output_filemane = script_path / "generic_boards_to_skip.json"
11+
12+
# Parser
13+
parser = argparse.ArgumentParser(
14+
description="Generate list of generic boards to skip for ci core config"
15+
)
16+
17+
parser.add_argument("-f", "--family", metavar="pattern", help="Family name to generate")
18+
19+
args = parser.parse_args()
20+
21+
22+
def main():
23+
if args.family:
24+
filtered_family = args.family.upper()
25+
# Get mcu_family directories
26+
mcu_families = sorted(variant_path.glob("STM32*/"))
27+
boards_list = []
28+
# Parse boards from all
29+
for mcu_family in mcu_families:
30+
if args.family and filtered_family not in str(mcu_family):
31+
continue
32+
# Search all directory with ldscript.ld
33+
variants_list = sorted(mcu_family.glob("**/ldscript.ld"))
34+
for variant in variants_list:
35+
# Opend boards_entry.txt and extract build.board
36+
with open(variant.parent / "boards_entry.txt") as myfile:
37+
for line in myfile:
38+
if "build.board" in line:
39+
boards_list.append(line.partition("=")[-1].strip())
40+
# Remove last board of the boards_entry to not skip it
41+
boards_list.pop()
42+
# Create file
43+
try:
44+
output_file = open(output_filemane, "w", newline="\n")
45+
for count, board in enumerate(sorted(boards_list), start=1):
46+
if count % 4 == 0:
47+
output_file.write(f'"{board}",\n')
48+
else:
49+
output_file.write(f'"{board}", ')
50+
output_file.close()
51+
except IOError:
52+
print(f"Failed to open {output_filemane}")
53+
exit(1)
54+
exit(0)
55+
56+
57+
if __name__ == "__main__":
58+
main()

0 commit comments

Comments
 (0)