Skip to contentSkip to conversation

utils: Add getconfiglistfilter() to return config based on regexpr

PATCH In review Aaron Chan 1 participant 3 messages Mar 24, 2020 – Apr 2, 2020

lore
Share & tools
lore

Aaron Chan

author
#0 lore raw

PATCH 1/2 utils: Add getconfiglistfilter() to return config based on regexpr

From: Aaron Chan <[email protected]>

---
 scripts/utils.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
scripts/utils.py +10 -0
index 68652d9..204360d 100644
@@ -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
author
#1 lore raw

PATCH 2/2 setup-config: Add multiconfig setup support

From: Aaron Chan <[email protected]>

---
 scripts/setup-config | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
scripts/setup-config +17 -0
index 3c8862a..c006297 100755
@@ -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