diff mbox series

[yocto-autobuilder-helper,master-next,v3,2/3] getproperties: Also extract build properties

Message ID 20251007-contrib-mathieu-build_props-v3-2-0263f52bd682@bootlin.com
State New
Headers show
Series run-config: Export some build properties | expand

Commit Message

Mathieu Dubois-Briand Oct. 7, 2025, 2:37 p.m. UTC
Extract some important build configuration values, allowing to add them
to buildbot properties. This includes MACHINE, DISTRO, SDKMACHINE and
PACKAGE_CLASSES.

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
 scripts/getproperties.py | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/scripts/getproperties.py b/scripts/getproperties.py
index 0d8eab22efbdba65d1ca497a6a28c361c42d5a83..ce1bc2fb45a8fce463fd2e19249833075b9d975b 100755
--- a/scripts/getproperties.py
+++ b/scripts/getproperties.py
@@ -8,8 +8,9 @@  import sys
 
 import utils
 
+# Usage: scripts/getproperties.py <builddir> [builder_name]
 builddir = sys.argv[1]
-
+targetname = sys.argv[2] if len(sys.argv) > 2 else None
 
 with open(builddir + "/../layerinfo.json") as f:
     repos = json.load(f)
@@ -71,5 +72,22 @@  buildid = hashlib.sha1(buildid.encode("utf-8")).hexdigest()
 
 jsonprops['yp_build_revision'] = buildid
 
-print(json.dumps(jsonprops, indent=4, sort_keys=True))
+ourconfig = utils.loadconfig()
+exported_properties = ['DISTRO', 'MACHINE', 'SDKMACHINE', 'PACKAGE_CLASSES']
+if targetname in ourconfig['overrides']:
+    target_props = {}
+    target = ourconfig['overrides'][targetname]
+    maxsteps = 1
+    for v in target:
+        if v.startswith("step"):
+            # 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:
+                        target_props.setdefault(prop, set()).add(propdict[prop])
+                        break
+    for k, v in target_props.items():
+        jsonprops[k] = list(v)[0] if len(v) == 1 else list(v)
 
+print(json.dumps(jsonprops, indent=4, sort_keys=True))