[OE-core] [PATCH 1/2 V2] oe/utils.py: Add vartrue()

Martin Jansa martin.jansa at gmail.com
Wed Sep 5 10:38:22 UTC 2018


On Wed, Sep 05, 2018 at 03:16:17PM +0800, Robert Yang wrote:
> It can be used to simplify code like:
> "${@['iffalse', 'iftrue'][var]}"
> 
> Signed-off-by: Robert Yang <liezhi.yang at windriver.com>
> ---
>  meta/conf/bitbake.conf | 2 +-
>  meta/lib/oe/utils.py   | 7 +++++++
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index faef771..dbadeb3 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -610,7 +610,7 @@ DEBUG_FLAGS ?= "-g -feliminate-unused-debug-types ${DEBUG_PREFIX_MAP}"
>  # Disabled until the option works properly -feliminate-dwarf2-dups
>  FULL_OPTIMIZATION = "-O2 -pipe ${DEBUG_FLAGS}"
>  DEBUG_OPTIMIZATION = "-O -fno-omit-frame-pointer ${DEBUG_FLAGS} -pipe"
> -SELECTED_OPTIMIZATION = "${@d.getVar(['FULL_OPTIMIZATION', 'DEBUG_OPTIMIZATION'][d.getVar('DEBUG_BUILD') == '1'])}"
> +SELECTED_OPTIMIZATION = "${@d.getVar(oe.utils.vartrue('DEBUG_BUILD', 'DEBUG_OPTIMIZATION', 'FULL_OPTIMIZATION', d))}"
>  SELECTED_OPTIMIZATION[vardeps] += "FULL_OPTIMIZATION DEBUG_OPTIMIZATION"
>  BUILD_OPTIMIZATION = "-O2 -pipe"
>  
> diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
> index f22a6ab..914a6f2 100644
> --- a/meta/lib/oe/utils.py
> +++ b/meta/lib/oe/utils.py
> @@ -464,3 +464,10 @@ class ImageQAFailed(bb.build.FuncFailed):
>              msg = msg + ' (%s)' % self.description
>  
>          return msg
> +
> +def vartrue(var, iftrue, iffalse, d):
> +    import oe.types
> +    if oe.types.boolean(d.getVar(var)):
> +        return iftrue
> +    else:
> +        return iffalse

Shouldn't we update bitbake to track var usage like in oe.utils.conditional:
http://git.openembedded.org/bitbake/commit/?id=5156b4bb6876dac636be9726df22c8ee792714dd
before this gets used more widely?

> -- 
> 2.7.4
> 
> -- 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: Digital signature
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20180905/95eebfb6/attachment-0002.sig>


More information about the Openembedded-core mailing list