Add a command to bitbake-layers to list the machines available in the
current configuration.

Signed-off-by: Ross Burton <[email protected]>
---
 meta/lib/bblayers/machines.py | 37 +++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 meta/lib/bblayers/machines.py

diff --git a/meta/lib/bblayers/machines.py b/meta/lib/bblayers/machines.py
new file mode 100644
index 00000000000..5fd970af0ec
--- /dev/null
+++ b/meta/lib/bblayers/machines.py
@@ -0,0 +1,37 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+import logging
+import pathlib
+
+from bblayers.common import LayerPlugin
+
+logger = logging.getLogger('bitbake-layers')
+
+def plugin_init(plugins):
+    return ShowMachinesPlugin()
+
+class ShowMachinesPlugin(LayerPlugin):
+    def do_show_machines(self, args):
+        """List the machines available in the currently configured layers."""
+
+        for layer_dir in self.bblayers:
+            layer_name = self.get_layer_name(layer_dir)
+
+            if args.layer and args.layer != layer_name:
+                continue
+
+            for p in 
sorted(pathlib.Path(layer_dir).glob("conf/machine/*.conf")):
+                if args.bare:
+                    logger.plain("%s" % (p.stem))
+                else:
+                    logger.plain("%s (%s)" % (p.stem, layer_name))
+
+
+    def register_commands(self, sp):
+        parser_show_machines = self.add_command(sp, "show-machines", 
self.do_show_machines)
+        parser_show_machines.add_argument('-b', '--bare', help='output just 
the machine names, not the source layer', action='store_true')
+        parser_show_machines.add_argument('-l', '--layer', help='Limit to 
machines in the specified layer')
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#203094): 
https://lists.openembedded.org/g/openembedded-core/message/203094
Mute This Topic: https://lists.openembedded.org/mt/107773225/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to