Message ID | 20240207172121.4044574-1-ross.burton@arm.com |
---|---|
State | New |
Headers | show |
Series | bitbake-layers: add show-machines command | expand |
> -----Original Message----- > From: bitbake-devel@lists.openembedded.org <bitbake- > devel@lists.openembedded.org> On Behalf Of Ross Burton > Sent: den 7 februari 2024 18:21 > To: bitbake-devel@lists.openembedded.org > Subject: [bitbake-devel] [PATCH] bitbake-layers: add show-machines command > > From: Ross Burton <ross.burton@arm.com> > > 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. > > Signed-off-by: Ross Burton <ross.burton@arm.com> > --- > bitbake/lib/bblayers/query.py | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/bitbake/lib/bblayers/query.py b/bitbake/lib/bblayers/query.py > index bfc18a75939..3080763abfd 100644 > --- a/bitbake/lib/bblayers/query.py > +++ b/bitbake/lib/bblayers/query.py > @@ -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)) 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? > + > + > 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 //Peter
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 On Wed, 7 Feb 2024 at 18:21, Ross Burton <ross.burton@arm.com> wrote: > > From: Ross Burton <ross.burton@arm.com> > > 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. > > Signed-off-by: Ross Burton <ross.burton@arm.com> > --- > bitbake/lib/bblayers/query.py | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/bitbake/lib/bblayers/query.py b/bitbake/lib/bblayers/query.py > index bfc18a75939..3080763abfd 100644 > --- a/bitbake/lib/bblayers/query.py > +++ b/bitbake/lib/bblayers/query.py > @@ -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: bitbake-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alex.kanavin@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
On 7 Feb 2024, at 19:49, Alexander Kanavin via lists.openembedded.org <alex.kanavin=gmail.com@lists.openembedded.org> wrote: > > 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
> -----Original Message----- > From: bitbake-devel@lists.openembedded.org <bitbake- > devel@lists.openembedded.org> On Behalf Of Ross Burton > Sent: den 8 februari 2024 11:38 > To: Alexander Kanavin <alex.kanavin@gmail.com> > Cc: bitbake-devel@lists.openembedded.org > Subject: Re: [bitbake-devel] [PATCH] bitbake-layers: add show-machines > command > > On 7 Feb 2024, at 19:49, Alexander Kanavin via lists.openembedded.org > <alex.kanavin=gmail.com@lists.openembedded.org> wrote: > > > > 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 Including the contents of #@NAME and #@DESCRIPTION would definitely make the command more useful. //Peter
On Thu, 2024-02-08 at 11:14 +0000, Peter Kjellerstedt wrote: > > -----Original Message----- > > From: bitbake-devel@lists.openembedded.org <bitbake- > > devel@lists.openembedded.org> On Behalf Of Ross Burton > > Sent: den 8 februari 2024 11:38 > > To: Alexander Kanavin <alex.kanavin@gmail.com> > > Cc: bitbake-devel@lists.openembedded.org > > Subject: Re: [bitbake-devel] [PATCH] bitbake-layers: add show-machines > > command > > > > On 7 Feb 2024, at 19:49, Alexander Kanavin via lists.openembedded.org > > <alex.kanavin=gmail.com@lists.openembedded.org> wrote: > > > > > > 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 > > 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
diff --git a/bitbake/lib/bblayers/query.py b/bitbake/lib/bblayers/query.py index bfc18a75939..3080763abfd 100644 --- a/bitbake/lib/bblayers/query.py +++ b/bitbake/lib/bblayers/query.py @@ -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')