Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Martin Jansa <martin.jansa@gmail.com>
To: Robert Yang <liezhi.yang@windriver.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 1/2 V2] oe/utils.py: Add vartrue()
Date: Wed, 5 Sep 2018 12:38:22 +0200	[thread overview]
Message-ID: <20180905103822.GE1795@jama> (raw)
In-Reply-To: <568c7b051fd166a653c943d618027f7b59e436b5.1536130313.git.liezhi.yang@windriver.com>

[-- Attachment #1: Type: text/plain, Size: 2128 bytes --]

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@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@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 201 bytes --]

  parent reply	other threads:[~2018-09-05 10:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05  7:16 [PATCH 0/2 V2] Add oe.utils.vartrue() and update BUILD_OPTIMIZATION Robert Yang
2018-09-05  7:16 ` [PATCH 1/2 V2] oe/utils.py: Add vartrue() Robert Yang
2018-09-05  7:33   ` Peter Kjellerstedt
2018-09-05  8:11     ` Robert Yang
2018-09-05 19:22       ` Peter Kjellerstedt
2018-09-05 19:31       ` Richard Purdie
2018-09-05 10:38   ` Martin Jansa [this message]
2018-09-05 10:56     ` Richard Purdie
2018-09-05  7:16 ` [PATCH 2/2 V2] bitbake.conf: Make BUILD_OPTIMIZATION respect to DEBUG_BUILD Robert Yang
2018-09-14 13:25   ` Martin Jansa
2018-09-17  5:50     ` Martin Jansa
2018-09-17  9:57       ` Robert Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180905103822.GE1795@jama \
    --to=martin.jansa@gmail.com \
    --cc=liezhi.yang@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox