Message ID | 1497033695-138298-1-git-send-email-denis@denix.org |
---|---|
State | Superseded |
Headers | show |
On Fri, Jun 9, 2017 at 11:41 AM, Denys Dmytriyenko <denis@denix.org> wrote: > + ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split() > > - if not ubootmachine and not ubootconfigflags: > + if not ubootmachine and len(ubootconfig) == 0: > There’s no need for len() here, just `if not ubootmachine and not ubootconfig:` should do, since a string is falsy when it’s empty. -- Christopher Larson kergoth at gmail dot com Founder - BitBake, OpenEmbedded, OpenZaurus Senior Software Engineer, Mentor Graphics -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
On Fri, Jun 09, 2017 at 03:42:28PM -0700, Christopher Larson wrote: > On Fri, Jun 9, 2017 at 11:41 AM, Denys Dmytriyenko <denis@denix.org> wrote: > > > + ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split() > > > > - if not ubootmachine and not ubootconfigflags: > > + if not ubootmachine and len(ubootconfig) == 0: > > > > There’s no need for len() here, just `if not ubootmachine and not > ubootconfig:` should do, since a string is falsy when it’s empty. Thanks, Chris, I was just using the same syntax that was already there: - ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split() if len(ubootconfig) > 0: - elif len(ubootconfig) == 0: - raise bb.parse.SkipPackage('You must set a default in UBOOT_CONFIG.') I can submit v2, if it would make more sense.
diff --git a/meta/classes/uboot-config.bbclass b/meta/classes/uboot-config.bbclass index 10013b7..8f1ded4 100644 --- a/meta/classes/uboot-config.bbclass +++ b/meta/classes/uboot-config.bbclass @@ -20,24 +20,21 @@ python () { ubootbinaries = d.getVar('UBOOT_BINARIES') # The "doc" varflag is special, we don't want to see it here ubootconfigflags.pop('doc', None) + ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split() - if not ubootmachine and not ubootconfigflags: + if not ubootmachine and len(ubootconfig) == 0: PN = d.getVar("PN") FILE = os.path.basename(d.getVar("FILE")) bb.debug(1, "To build %s, see %s for instructions on \ setting up your machine config" % (PN, FILE)) raise bb.parse.SkipPackage("Either UBOOT_MACHINE or UBOOT_CONFIG must be set in the %s machine configuration." % d.getVar("MACHINE")) - if ubootmachine and ubootconfigflags: + if ubootmachine and len(ubootconfig) > 0: raise bb.parse.SkipPackage("You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.") if ubootconfigflags and ubootbinaries: raise bb.parse.SkipPackage("You cannot use UBOOT_BINARIES as it is internal to uboot_config.bbclass.") - if not ubootconfigflags: - return - - ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split() if len(ubootconfig) > 0: for config in ubootconfig: for f, v in ubootconfigflags.items(): @@ -57,6 +54,4 @@ python () { bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % ubootbinary) d.appendVar('UBOOT_BINARIES', ' ' + ubootbinary) break - elif len(ubootconfig) == 0: - raise bb.parse.SkipPackage('You must set a default in UBOOT_CONFIG.') }