utils: Add getconfiglistfilter() to return config based on regexpr
PATCH 1/2 utils: Add getconfiglistfilter() to return config based on regexpr
From: Aaron Chan <[email protected]>
Signed-off-by Aaron Chan <[email protected]>
--- scripts/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+)
scripts/utils.py +10 -0
@@ -119,6 +119,16 @@ def getconfiglistfilter(name, config, target, stepnum): merge(ret, config['defaults'][name]) return expandresult(ret, config) +# Return a list of configuration keys based on regular expressions +def getconfigexpr(name, config, target, stepnum): + ret = [] + step = "step" + str(stepnum) + if target in config['overrides'] and step in config['overrides'][target]: + for i in config['overrides'][target][step].keys(): + if re.search(name, i): + ret.append(i) + return ret + # # Expand 'templates' with the configuration #
Signature · 1 line
2.21.0.windows.1
PATCH 2/2 setup-config: Add multiconfig setup support
From: Aaron Chan <[email protected]>
Signed-off-by Aaron Chan <[email protected]>
--- scripts/setup-config | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
scripts/setup-config +17 -0
@@ -9,6 +9,7 @@ import sys import subprocess import errno import copy +import re import utils
@@ -119,3 +120,19 @@ with open(sdkextraconf, "w") as f: print(" " + v) f.write(v + "\n") +# Add multiconfig setup support +multivars=utils.getconfigexpr("multi-(.*)", ourconfig, args.target, stepnum) +if multivars: + for conf in multivars: + mvars=utils.getconfiglistfilter(conf, ourconfig, args.target, stepnum) + m=re.search("multi-(.*)", conf) + mpath=os.path.join(args.builddir, "conf", "multiconfig") + mfile=os.path.join(mpath, "%s.conf" % m.group(1)) + os.makedirs(mpath, exist_ok=True) + if os.path.exists(mfile): + os.remove(mfile) + utils.printheader("Writing %s with contents:" % mfile) + with open(mfile, 'w') as f: + for v in mvars: + print(" " + v) + f.write(v + "\n")
Signature · 1 line
2.21.0.windows.1
Could someone please review my patches ? Thanks.