Skip to contentSkip to conversation

bitbake-setup: add descriptions for fragment choices

PATCH Superseded Antonin Godard 1 participant 4 messages Jan 23

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover bitbake-setup: add descriptions for fragment choices

---
Changes in v4:
- setup.py: move the fragments to gizmo-notemplate, add a second option
(that isn't used, but it doesn't make much sense otherwise)
- rebase on top of https://lore.kernel.org/r/[email protected]
- Link to v3: https://patch.msgid.link/20260122-bitbake-setup-choose-builtin-v3-0-c55291acc1a7@bootlin.com

Changes in v3:
- Rework logic as suggested by Alex
- Remove modifications of {oe-nodistro,poky}-whinlatter.conf.json
- Add a test case for oe-fragments-one-of
- Link to v2: https://patch.msgid.link/20260120-bitbake-setup-choose-builtin-v2-0-ade604ff2351@bootlin.com

Changes in v2:
- As suggested by Alex, change the new way of specifying fragments to
remain a dictionary so they can be extended in the future
- Link to v1: https://patch.msgid.link/20260116-bitbake-setup-choose-builtin-v1-0-8d66666a9efd@bootlin.com

---
Antonin Godard (3):
bin/bitbake-setup: add descriptions for fragment choices
default-registry: update fragments choices with descriptions lib/bb/tests/setup.py: add tests for oe-fragments-one-of

 bin/bitbake-setup                                  | 23 +++++++++++-----
 .../configurations/oe-nodistro-master.conf.json    |  6 ++++-
 .../configurations/poky-master.conf.json           | 14 ++++++++--
 .../bitbake-user-manual-environment-setup.rst      | 26 ++++++++++++++++--
 lib/bb/tests/setup.py                              | 31 +++++++++++++++++++---
 setup-schema/bitbake-setup.schema.json             | 21 ++++++++++++++-
 6 files changed, 105 insertions(+), 16 deletions(-)

---
base-commit: f48cd5c7dc58aa95032f19d4d628acb31512d9d6
change-id: 20260116-bitbake-setup-choose-builtin-fb199054cc25

#1 lore raw

PATCH v4 1/3 bin/bitbake-setup: add descriptions for fragment choices

Make it possible to give fragments descriptions as it can help users determine which fragments to pick during bitbake-setup init.

It is still possible to provide a list (with no descriptions) for backwards-compatibility.

Update the documentation accordingly.

---
 bin/bitbake-setup                                  | 23 ++++++++++++++-----
 .../bitbake-user-manual-environment-setup.rst      | 26 ++++++++++++++++++++--
 setup-schema/bitbake-setup.schema.json             | 21 ++++++++++++++++-
 3 files changed, 61 insertions(+), 9 deletions(-)
bin/bitbake-setup +17 -6
index 0cd26814a6e..315f195a4d7 100755
@@ -515,23 +515,34 @@ def choose_fragments(possibilities, parameters, non_interactive, skip_selection)
         if skip_selection and k in skip_selection:
             logger.info("Skipping a selection of {}, as requested on command line. The resulting bitbake configuration may require further manual adjustments.".format(k))
             continue
-        choice = [o for o in v["options"] if o in parameters]
+
+        # options can be a list of strings or a list of dicts
+        options = v["options"]
+        if len(options) > 0 and isinstance(v["options"][0], str):
+            options = [{"name": o, "description": ""} for o in v["options"]]
+
+        choice = [o["name"] for o in options if o["name"] in parameters]
         if len(choice) > 1:
-            raise Exception("Options specified on command line do not allow a single selection from possibilities {}, please remove one or more from {}".format(v["options"], parameters))
+            raise Exception("Options specified on command line do not allow a single selection "
+                            f"from possibilities {[o['name'] for o in options]}, please "
+                            f"remove one or more from {parameters}")
         if len(choice) == 1:
             choices[k] = choice[0]
             continue
 
         if non_interactive:
-            raise Exception("Unable to choose from options in non-interactive mode: {}".format(v["options"]))
+            raise Exception(f"Unable to choose from options in non-interactive mode: {[o['name'] for o in options]}")
 
         logger.plain("\n" + v["description"] + ":")
-        options_enumerated = list(enumerate(v["options"], 1))
+        options_enumerated = list(enumerate(options, 1))
         for n,o in options_enumerated:
-            logger.plain("{}. {}".format(n, o))
+            opt_str = f"{n}. {o['name']}"
+            if o["description"]:
+                opt_str += f"\t{o['description']}"
+            logger.plain(opt_str)
         option_n = int_input([i[0] for i in options_enumerated],
                              "\nPlease select one of the above options by its number: ") - 1
-        choices[k] = options_enumerated[option_n][1]
+        choices[k] = options_enumerated[option_n][1]["name"]
     return choices
 
 def obtain_config(top_dir, registry, args, source_overrides, d):
doc/bitbake-user-manual/bitbake-user-manual-environment-setup.rst +24 -2
index b7212f1af41..93477d71473 100644
@@ -778,11 +778,21 @@ They contain the following sections:
                 "oe-fragments-one-of": {
                     "machine": {
                         "description": "Target machines",
-                        "options" : ["machine/qemux86-64", "machine/qemuarm64", "machine/qemuriscv64", "machine/genericarm64", "machine/genericx86-64"]
+                        "options" : [
+                            { "name": "machine/qemux86-64", "description": "Machine configuration for running an x86-64 system on QEMU" },
+                            { "name": "machine/qemuarm64", "description": "Machine configuration for running an ARMv8 system on QEMU" },
+                            { "name": "machine/qemuriscv64", "description": "Machine configuration for running an RISC-V system on QEMU" },
+                            { "name": "machine/genericarm64", "description": "Machine configuration for Arm64 SystemReady IR/ES platforms" },
+                            { "name": "machine/genericx86-64", "description": "Machine configuration for generic x86_64 (64-bit) PCs and servers" }
+                        ]
                     },
                     "distro": {
                         "description": "Distribution configuration variants",
-                        "options" : ["distro/poky", "distro/poky-altcfg", "distro/poky-tiny"]
+                        "options" : [
+                            { "name": "distro/poky", "description": "Distro configuration for Poky (Yocto Project Reference Distro)" },
+                            { "name": "distro/poky-altcfg", "description": "Distro configuration for Poky (systemd init manager)" },
+                            { "name": "distro/poky-tiny", "description": "Distro configuration for Poky (optimized for size)" }
+                        ]
                     }
                 },
                 "configurations": [
@@ -871,6 +881,18 @@ They contain the following sections:
    -  ``oe-fragments-one-of`` (*optional*, OpenEmbedded specific): the OpenEmbedded
       fragments to select as part of the build.
 
+      This can one of two formats:
+
+      -  A list of dictionaries with ``name`` and a ``description``,
+         corresponding to respectively the fragments names and fragment
+         descriptions (like in the example above).
+
+      -  A list of fragment names. For example:
+
+         .. code-block:: json
+
+            "options" : ["machine/qemux86-64", "machine/qemuarm64", "machine/qemuriscv64", "machine/genericarm64", "machine/genericx86-64"]
+
       This will trigger choices to make during the
       :ref:`ref-bbsetup-command-init` command execution.
 
setup-schema/bitbake-setup.schema.json +20 -1
index e51fef3b97c..be8772db1b2 100644
@@ -64,7 +64,26 @@
                                 "type": "array",
                                 "description": "List of BitBake configuration fragments to enable",
                                 "items": {
-                                    "type": "string"
+                                    "oneOf": [
+                                        {
+                                            "type": "string",
+                                            "description": "Configuration fragment name"
+                                        },
+                                        {
+                                            "type": "object",
+                                            "description": "Dictionary of BitBake configuration fragments to enable (with description)",
+                                            "properties": {
+                                                "name": {
+                                                    "type": "string",
+                                                    "description": "Configuration fragment name"
+                                                },
+                                                "description": {
+                                                    "type": "string",
+                                                    "description": "Human-readable description of the fragment"
+                                                }
+                                            }
+                                        }
+                                    ]
                                 }
                             },
                             "oe-fragments-one-of": {
Signature · 1 line
2.52.0
#2 lore raw

PATCH v4 2/3 default-registry: update fragments choices with descriptions

In reply to Antonin Godard

Give descriptions to the fragment choices to help the user know what to pick during 'bitbake-setup init'. These descriptions were based on the descriptions found in the corresponding configuration files in OE-Core/meta-yocto.

---
 .../configurations/oe-nodistro-master.conf.json            |  6 +++++-
 default-registry/configurations/poky-master.conf.json      | 14 ++++++++++++--
 2 files changed, 17 insertions(+), 3 deletions(-)
default-registry/configurations/oe-nodistro-master.conf.json +5 -1
index 180d2008a72..00c4befb1ac 100644
@@ -45,7 +45,11 @@
             "oe-fragments-one-of": {
                 "machine": {
                     "description": "Target machines",
-                    "options" : ["machine/qemux86-64", "machine/qemuarm64", "machine/qemuriscv64"]
+                    "options" : [
+                        { "name": "machine/qemux86-64", "description": "Machine configuration for running an x86-64 system on QEMU" },
+                        { "name": "machine/qemuarm64", "description": "Machine configuration for running an ARMv8 system on QEMU" },
+                        { "name": "machine/qemuriscv64", "description": "Machine configuration for running an RISC-V system on QEMU" }
+                    ]
                 }
             }
         }
default-registry/configurations/poky-master.conf.json +12 -2
index 1de038babe7..18657ece103 100644
@@ -54,11 +54,21 @@
             "oe-fragments-one-of": {
                 "machine": {
                     "description": "Target machines",
-                    "options" : ["machine/qemux86-64", "machine/qemuarm64", "machine/qemuriscv64", "machine/genericarm64", "machine/genericx86-64"]
+                    "options" : [
+                        { "name": "machine/qemux86-64", "description": "Machine configuration for running an x86-64 system on QEMU" },
+                        { "name": "machine/qemuarm64", "description": "Machine configuration for running an ARMv8 system on QEMU" },
+                        { "name": "machine/qemuriscv64", "description": "Machine configuration for running an RISC-V system on QEMU" },
+                        { "name": "machine/genericarm64", "description": "Machine configuration for Arm64 SystemReady IR/ES platforms" },
+                        { "name": "machine/genericx86-64", "description": "Machine configuration for generic x86_64 (64-bit) PCs and servers" }
+                    ]
                 },
                 "distro": {
                     "description": "Distribution configuration variants",
-                    "options" : ["distro/poky", "distro/poky-altcfg", "distro/poky-tiny"]
+                    "options" : [
+                        { "name": "distro/poky", "description": "Distro configuration for Poky (Yocto Project Reference Distro)" },
+                        { "name": "distro/poky-altcfg", "description": "Distro configuration for Poky (systemd init manager)" },
+                        { "name": "distro/poky-tiny", "description": "Distro configuration for Poky (optimized for size)" }
+                    ]
                 }
             },
             "configurations": [
Signature · 1 line
2.52.0
#3 lore raw

PATCH v4 3/3 lib/bb/tests/setup.py: add tests for oe-fragments-one-of

In reply to Antonin Godard

There were no tests of oe-fragments-one-of so modify gizmo-notemplate to gizmo-notemplate-fragments-one-of, and test both formats for the options (with or without a description).

In get_setup_path(), if the configuration specified on the command-line contains fragments, join everything with "-" as this is what will be the final directory name of the setup. This does not affect other current variants.

---
 lib/bb/tests/setup.py | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)
lib/bb/tests/setup.py +27 -4
index 8b6046c049a..744dfe903ed 100644
@@ -136,10 +136,26 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
                 "oe-fragments": ["test-fragment-1"]
             },
             {
-                "name": "gizmo-notemplate",
+                "name": "gizmo-notemplate-fragments-one-of",
                 "description": "Gizmo notemplate configuration",
                 "bb-layers": ["layerC","layerD/meta-layer"],
-                "oe-fragments": ["test-fragment-2"]
+                "oe-fragments": ["test-fragment-2"],
+                "oe-fragments-one-of": {
+                    "fragment-desc": {
+                        "description": "Test fragments (with description)",
+                        "options" : [
+                            { "name": "fragment-desc-1", "description": "fragment 1 desc" },
+                            { "name": "fragment-desc-2", "description": "fragment 2 desc" }
+                        ]
+                    },
+                    "fragment-nodesc": {
+                        "description": "Test fragments (no description)",
+                        "options" : [
+                            "fragment-nodesc-1",
+                            "fragment-nodesc-2"
+                        ]
+                    }
+                }
             },
             {
                 "name": "gizmo-notemplate-with-filerelative-layers",
@@ -259,7 +275,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
     def get_setup_path(self, cf, c):
         if c == 'gizmo':
             return os.path.join(self.tempdir, 'bitbake-builds', 'this-is-a-custom-gizmo-build')
-        return os.path.join(self.tempdir, 'bitbake-builds', '{}-{}'.format(cf, c))
+        return os.path.join(self.tempdir, 'bitbake-builds', '{}-{}'.format(cf, "-".join(c.split())))
 
     def test_setup(self):
         # unset BBPATH to ensure tests run in isolation from the existing bitbake environment
@@ -327,7 +343,14 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
         # test-config-1 is tested as a registry config and over http, test-config-2 as a local file
         server = HTTPService(self.registrypath, host="127.0.0.1")
         server.start()
-        variants = ('gadget','gizmo','gizmo-env-passthrough','gizmo-no-fragment','gadget-notemplate','gizmo-notemplate')
+        variants = (
+            'gadget',
+            'gizmo',
+            'gizmo-env-passthrough',
+            'gizmo-no-fragment',
+            'gadget-notemplate',
+            'gizmo-notemplate-fragments-one-of fragment-desc-1 fragment-nodesc-1',
+        )
         variants_local = variants + ('gizmo-notemplate-with-filerelative-layers',)
         test_configurations = ({'name':'test-config-1','cmdline': 'test-config-1',
                                                  'buildconfigs': variants},
Signature · 1 line
2.52.0