[bitbake-devel] [PATCH 0/2] more flexible include and require statements

Patrick Ohly patrick.ohly at intel.com
Wed Jun 7 13:56:23 UTC 2017


As discussed in the "[Openembedded-architecture] Yocto Compatible 2.0
+ signature changes" mail thread, some changes in a .bbappend cannot
be made conditional via overrides, like for example manipulating
varflags.

By allowing "require" and "include" without parameter, one can include
those changes depending on some condition with ${@ } which expands to
empty when the condition is not met.

However, this is still not particularly developer-friendly, in
particular when the change is needed under different conditions (like
one of several DISTRO_FEATURES) or more than one include file is
involved.

When allowing also to include more than one file in a single
statement, some helper function could be written which takes a
declaration of the relationship between features and include files and
then a single line covers all cases.

The example in the second commit uses this helper function which
should go into OE-core because of the DISTRO_FEATURES default value:

def optional_includes(d, mapping, key_var="DISTRO_FEATURES"):
    """
    This can be used to generate a list of files to include depending on
    the distro features that are selected. key_var contains the features
    that are set, mapping_var a space-separated set of <feature(s)>:<file(s)>
    entries. Features and files are separated by comma. Each file on the
    right-hand side is included in the result once if any of the features one
    the left-hand side is set.

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

    For DISTRO_FEATURES = "foo xyz" that will include four .inc files in the
    order in which they are listed.
    """
    key = set((d.getVar(key_var) or "").split())
    mapping = mapping.split()
    includes = []
    for entry in mapping:
        parts = entry.split(":", 1)
        if len(parts) != 2:
            bb.fatal("%s must contain entries of the form <feature(s)>:<file(s)>, not %s" % (mapping_var, entry))
        features, files = parts
        for feature in features.split(","):
            if feature in key:
                for file in files.split(","):
                    if file not in includes:
                        includes.append(file)
    return " ".join(includes)

Patrick Ohly (2):
  ConfHandler.py: allow inherit or include without parameter
  ConfHandler.py: allow inherit or include with multiple parameters

 lib/bb/parse/parse_py/ConfHandler.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

base-commit: cf2bf9a0b0d9380025f61c7e7a39e6e19b46a7a1
-- 
git-series 0.9.1



More information about the bitbake-devel mailing list