All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] more flexible include and require statements
@ 2017-06-07 13:56 Patrick Ohly
  2017-06-07 13:56 ` [PATCH 1/2] ConfHandler.py: allow inherit or include without parameter Patrick Ohly
  2017-06-07 13:56 ` [PATCH 2/2] ConfHandler.py: allow inherit or include with multiple parameters Patrick Ohly
  0 siblings, 2 replies; 7+ messages in thread
From: Patrick Ohly @ 2017-06-07 13:56 UTC (permalink / raw)
  To: bitbake-devel

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-06-08 14:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-07 13:56 [PATCH 0/2] more flexible include and require statements Patrick Ohly
2017-06-07 13:56 ` [PATCH 1/2] ConfHandler.py: allow inherit or include without parameter Patrick Ohly
2017-06-07 14:47   ` Peter Kjellerstedt
2017-06-08  6:24     ` Patrick Ohly
2017-06-08 14:21       ` Mark Hatle
2017-06-07 13:56 ` [PATCH 2/2] ConfHandler.py: allow inherit or include with multiple parameters Patrick Ohly
2017-06-07 14:52   ` Peter Kjellerstedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.