diff mbox series

[yocto-autobuilder-helper,1/2] run-config: Generate a file with build properties

Message ID 20250904-contrib-mathieu-build_props-v1-1-28de412ac349@bootlin.com
State New
Headers show
Series run-config: Generate a file with build properties | expand

Commit Message

Mathieu Dubois-Briand Sept. 4, 2025, 3:45 p.m. UTC
Extract some important build configuration values, allowing to add them
to buildbot properties.

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
 scripts/run-config | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/scripts/run-config b/scripts/run-config
index 98b48e55473c..4cc688533cef 100755
--- a/scripts/run-config
+++ b/scripts/run-config
@@ -15,6 +15,8 @@  import errno
 
 import utils
 
+exported_properties = ['DISTRO', 'MACHINE', 'SDKMACHINE', 'PACKAGE_CLASSES']
+
 parser = utils.ArgParser(description='Runs configurations in json.conf.')
 
 parser.add_argument('target',
@@ -60,6 +62,10 @@  parser.add_argument('-j', '--json-outputfile',
                     action='store',
                     default="",
                     help="the file to store json information about the build in")
+parser.add_argument('--properties-outputfile',
+                    action='store',
+                    default="",
+                    help="the file to store json information about build properties to add in")
 parser.add_argument('--stepname',
                     action='store',
                     default=None,
@@ -94,17 +100,26 @@  if arch == "qemux86" or arch == "qemux86-64":
 else:
     ourconfig["HELPERSTMACHTARGS"] = "-a -t machine -t toolchain-user"
 
-# Find out the number of steps this target has
+# Find out the number of steps this target has and properties
 maxsteps = 0
 stepnum = 0
+properties = {}
 if args.target in ourconfig['overrides']:
+    target = ourconfig['overrides'][args.target]
     maxsteps = 1
-    for v in ourconfig['overrides'][args.target]:
+    for v in target:
         if v.startswith("step"):
             n = int(v[4:])
-            if n <= maxsteps:
-                continue
-            maxsteps = n
+            if n > maxsteps:
+                maxsteps = n
+
+            # Get properties values for this build step, falling back to
+            # defaults if they are not set.
+            for prop in exported_properties:
+                for propdict in (target[v], target, ourconfig['defaults']):
+                    if prop in propdict:
+                        properties.setdefault(prop, set()).add(propdict[prop])
+                        break
 
 hp.printheader("Target task %s has %d steps" % (args.target, maxsteps))
 
@@ -379,6 +394,12 @@  elif args.phase == "finish" and args.stepname == "builddir-cleanup":
 if args.json_outputfile:
     with open(args.json_outputfile, "w") as f:
         json.dump(jsonconfig, f, indent=4, sort_keys=True)
+if args.properties_outputfile:
+    properties = {k: list(v)[0] if len(v) == 1 else list(v)
+                  for k, v in properties.items()}
+
+    with open(args.properties_outputfile, "w") as f:
+        json.dump(properties, f, indent=4, sort_keys=True)
 
 sys.exit(0)