Skip to contentSkip to conversation

bitbake-layers: add show-machines command

PATCH In review [email protected] 4 participants 6 messages Feb 7, 2024 – Feb 8, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake-layers: add show-machines command

From: Ross Burton <[email protected]>

Add a show-machines command to list all of the available machines in the currently configured layers.

By default it includes the layer name, but for machine-readable uses this can be hidden by passing --bare.

---
 bitbake/lib/bblayers/query.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
bitbake/lib/bblayers/query.py +17 -0
index bfc18a75939..3080763abfd 100644
@@ -10,6 +10,7 @@ import logging
 import sys
 import os
 import re
+import pathlib
 
 import bb.utils
 
@@ -515,6 +516,19 @@ NOTE: .bbappend files can impact the dependencies.
 
             logger.plain("%s %s %s" % (f, keyword, best_realfn))
 
+    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)
+
+            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):
         self.add_command(sp, 'show-layers', self.do_show_layers, parserecipes=False)
 
@@ -540,3 +554,6 @@ NOTE: .bbappend files can impact the dependencies.
         parser_show_cross_depends = self.add_command(sp, 'show-cross-depends', self.do_show_cross_depends)
         parser_show_cross_depends.add_argument('-f', '--filenames', help='show full file path', action='store_true')
         parser_show_cross_depends.add_argument('-i', '--ignore', help='ignore dependencies on items in the specified layer(s) (split multiple layer names with commas, no spaces)', metavar='LAYERNAME')
+
+        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')
Signature · 1 line
2.34.1
#1 lore raw
Quoted 37 lines

-----Original Message-----
From: [email protected] <bitbake- [email protected]> On Behalf Of Ross Burton
Sent: den 7 februari 2024 18:21
To: [email protected]
Subject: [bitbake-devel] [PATCH] bitbake-layers: add show-machines command

From: Ross Burton <[email protected]>

Add a show-machines command to list all of the available machines in the currently configured layers.

By default it includes the layer name, but for machine-readable uses this can be hidden by passing --bare.

---
 bitbake/lib/bblayers/query.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
bitbake/lib/bblayers/query.py +2 -0
index bfc18a75939..3080763abfd 100644
@@ -10,6 +10,7 @@ import logging
 import sys
 import os
 import re
+import pathlib
 
 import bb.utils
 
@@ -515,6 +516,19 @@ NOTE: .bbappend files can impact the dependencies.
 
             logger.plain("%s %s %s" % (f, keyword, best_realfn))
 
+    def do_show_machines(self, args):

bitbake/lib/bblayers/query.py NOTE: .bbappend files can impact the dependencies. · line 529

Quoted 10 lines
bitbake/lib/bblayers/query.py +10 -0
+        """List the machines available in the currently configured layers."""
+
+        for layer_dir in self.bblayers:
+            layer_name = self.get_layer_name(layer_dir)
+
+            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))

If --bare is specified, then the machines should be sorted over the whole list. Otherwise the output will seem random. And the same is probably true also when --bare is not specified, since the layer name is in the second position. You might also want to format the output in columns to make it easier to read.

And one more, if the same machine is available from multiple layers, should the output include them all (when --bare is not specified), or just the one that will actually be used?

Quoted 13 lines
bitbake/lib/bblayers/query.py +5 -1
+
+
     def register_commands(self, sp):
         self.add_command(sp, 'show-layers', self.do_show_layers, parserecipes=False)
 
@@ -540,3 +554,6 @@ NOTE: .bbappend files can impact the dependencies.
         parser_show_cross_depends = self.add_command(sp, 'show-cross-depends', self.do_show_cross_depends)
         parser_show_cross_depends.add_argument('-f', '--filenames', help='show full file path', action='store_true')
         parser_show_cross_depends.add_argument('-i', '--ignore', help='ignore dependencies on items in the specified layer(s) (split multiple layer names with commas, no spaces)', metavar='LAYERNAME')
+
+        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')
--
Quoted 1 line

2.34.1

//Peter

#2 lore raw
In reply to [email protected]

I have to ask. How useful is this really, if it's a bare list of .conf files with no help for choosing from them?

Sample output :)
https://www.irccloud.com/pastebin/3MmYNuAD/

Should we think of useful metadata to go with this, similar to templates improvements I posted a few days ago?

Alex

Quoted 65 lines · Ross Burton

From: Ross Burton <[email protected]>

Add a show-machines command to list all of the available machines in the currently configured layers.

By default it includes the layer name, but for machine-readable uses this can be hidden by passing --bare.

---
 bitbake/lib/bblayers/query.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
bitbake/lib/bblayers/query.py +17 -1
index bfc18a75939..3080763abfd 100644
@@ -10,6 +10,7 @@ import logging
 import sys
 import os
 import re
+import pathlib
 
 import bb.utils
 
@@ -515,6 +516,19 @@ NOTE: .bbappend files can impact the dependencies.
 
             logger.plain("%s %s %s" % (f, keyword, best_realfn))
 
+    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)
+
+            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):
         self.add_command(sp, 'show-layers', self.do_show_layers, parserecipes=False)
 
@@ -540,3 +554,6 @@ NOTE: .bbappend files can impact the dependencies.
         parser_show_cross_depends = self.add_command(sp, 'show-cross-depends', self.do_show_cross_depends)
         parser_show_cross_depends.add_argument('-f', '--filenames', help='show full file path', action='store_true')
         parser_show_cross_depends.add_argument('-i', '--ignore', help='ignore dependencies on items in the specified layer(s) (split multiple layer names with commas, no spaces)', metavar='LAYERNAME')
+
+        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')
--

2.34.1

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

#3 lore raw
Quoted 6 lines · Alexander Kanavin via lists.openembedded.org

I have to ask. How useful is this really, if it's a bare list of .conf files with no help for choosing from them?

Sample output :)
https://www.irccloud.com/pastebin/3MmYNuAD/

Considering how often we get asked “how do I list the machines I can pick from”, it’s fairly useful to people who don’t know exactly where to look.

Also I’ve written the same script in shell or python repeatedly to automatically build for all available machines.

Many machine configuration already have machine-readable comments so that could be extracted and displayed.

Ross

#4 lore raw
Quoted 21 lines

-----Original Message-----
From: [email protected] <bitbake- [email protected]> On Behalf Of Ross Burton
Sent: den 8 februari 2024 11:38
To: Alexander Kanavin <[email protected]>
Cc: [email protected]
Subject: Re: [bitbake-devel] [PATCH] bitbake-layers: add show-machines command

Quoted 6 lines · Alexander Kanavin via lists.openembedded.org

I have to ask. How useful is this really, if it's a bare list of .conf files with no help for choosing from them?

Sample output :)
https://www.irccloud.com/pastebin/3MmYNuAD/

Considering how often we get asked “how do I list the machines I can pick from”, it’s fairly useful to people who don’t know exactly where to look.

Quoted 7 lines

Also I’ve written the same script in shell or python repeatedly to automatically build for all available machines.

Many machine configuration already have machine-readable comments so that could be extracted and displayed.

Ross

Including the contents of #@NAME and #@DESCRIPTION would definitely make the command more useful.

//Peter

#5 lore raw
Quoted 24 lines · Peter Kjellerstedt
Quoted 24 lines

-----Original Message-----
From: [email protected] <bitbake- [email protected]> On Behalf Of Ross Burton
Sent: den 8 februari 2024 11:38
To: Alexander Kanavin <[email protected]>
Cc: [email protected]
Subject: Re: [bitbake-devel] [PATCH] bitbake-layers: add show-machines command

Quoted 6 lines · Alexander Kanavin via lists.openembedded.org

I have to ask. How useful is this really, if it's a bare list of .conf files with no help for choosing from them?

Sample output :)
https://www.irccloud.com/pastebin/3MmYNuAD/

Considering how often we get asked “how do I list the machines I can pick from”, it’s fairly useful to people who don’t know exactly where to look.

Also I’ve written the same script in shell or python repeatedly to automatically build for all available machines.

Quoted 7 lines
Quoted 4 lines

Many machine configuration already have machine-readable comments so that could be extracted and displayed.

Ross

Including the contents of #@NAME and #@DESCRIPTION would definitely make the command more useful.

My 'drive by' thought was that we should use a proper variable to set these. I know the files have machine readable markup but I'd prefer not to perpetuate a new syntax.

We could parse them out just be reading that single file using the standard parser.

Cheers,

Richard