[OE-core] [PATCH 2/2] utils.py: helper function for optional include files

Richard Purdie richard.purdie at linuxfoundation.org
Thu Jun 8 09:20:53 UTC 2017


On Wed, 2017-06-07 at 17:31 +0200, Patrick Ohly wrote:
> By using oe.utils.optional_includes(), developers can simplify the
> code which selects which additional include files need to be included
> in a .bbappend.
> 
> In the simple case (one distro feature and one include file) the code
> is not shorter, but the intent is clearer than corresponding code
> using bb.utils.contains():
> 
>    require ${@ oe.utils.optional_includes(d, 'foo-feature:bar.inc') }
> 
> More complex cases are also supported, in particular include files
> that are required for one of several distro features or multiple
> different include files.
> 
> To keep the common use case simple, DISTRO_FEATURES are checked by
> default. Checking IMAGE_FEATURES might also be useful.
> 
> The DISTRO_FEATURES default and the intended usage make this more
> suitable for OE-core than bitbake.

I'm honestly not sure this actually aids readability. Taking your
example:

require ${@oe.utils.optional_includes(d, "foo,bar:foo-or-bar.inc xyz:x.inc,y.inc,z.inc")}

I think I actually prefer:

require ${@oe.utils.optional_includes(d, "foo,bar:foo-or-bar.inc")}
require ${@oe.utils.optional_includes(d, "xyz:x.inc,y.inc,z.inc")}

since its more explict. Spelling this out with the existing syntax
isn't so bad either, I probably still think that this is clearer too:

require ${@bb.utils.contains(d, "DISTRO_FEATURES", "foo bar", "foo-or-bar.inc", "")}
require ${@bb.utils.contains(d, "DISTRO_FEATURES", "xyz", "x.inc y.inc z.inc", "")}

How about simply:

require ${@oe.utils.distro_features(d, "foo bar", "foo-or-bar.inc")}
require ${@bb.utils.distro_features(d, "xyz", "x.inc y.inc z.inc")}

?

Cheers,

Richard




More information about the Openembedded-core mailing list