From 0afeba0c863087c68aa5597765475652bc84e063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 11 Apr 2023 20:10:54 +0200 Subject: [PATCH] generate dynamic device array for use in CI scripts Usage: generate_ci_matrix.py platform [extra] e.g. generate_ci_matrix.py esp32 or generate_ci_matrix.py esp32 extra --- bin/generate_ci_matrix.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 bin/generate_ci_matrix.py diff --git a/bin/generate_ci_matrix.py b/bin/generate_ci_matrix.py new file mode 100755 index 00000000..74ff8937 --- /dev/null +++ b/bin/generate_ci_matrix.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +"""Generate the CI matrix""" + +import os, sys, configparser, json + +rootdir = 'variants/' + +options = sys.argv[1:] + +outlist=[] + +if len(options) < 1: + print(json.dumps(outlist)) + exit() + +for subdir, dirs, files in os.walk(rootdir): + for file in files: + if file == 'platformio.ini': + config = configparser.ConfigParser() + config.read(subdir + '/' + file) + for c in config.sections(): + if c.startswith('env:'): + section = config[c].name[4:] + if 'extends' in config[config[c].name]: + if config[config[c].name]['extends'] == options[0] + '_base': + if 'board_level' in config[config[c].name]: + if ((config[config[c].name]['board_level'] == 'extra') & ('extra' in options)): + outlist.append(section) + else: + outlist.append(section) + +print(json.dumps(outlist)) \ No newline at end of file