diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2018-09-05 15:16:17 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-09-13 07:42:28 +0100 |
commit | 285b9a0d8eb3c931287e1f3af5c03d8f83a418e4 (patch) | |
tree | c72b1418a1428111d77fff3f9f137d2d7a570081 /meta/lib | |
parent | cb4134f7982b339c85460efb40fa640db963988a (diff) | |
download | poky-285b9a0d8eb3c931287e1f3af5c03d8f83a418e4.tar.gz |
oe/utils.py: Add vartrue()
It can be used to simplify code like:
"${@['iffalse', 'iftrue'][var]}"
(From OE-Core rev: fc5a5af7bc3619f575988a75efc0c4fe15478b2d)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oe/utils.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index fbda7035f1..93b0763b0a 100644 --- a/meta/lib/oe/utils.py +++ b/meta/lib/oe/utils.py | |||
@@ -25,6 +25,13 @@ def conditional(variable, checkvalue, truevalue, falsevalue, d): | |||
25 | else: | 25 | else: |
26 | return falsevalue | 26 | return falsevalue |
27 | 27 | ||
28 | def vartrue(var, iftrue, iffalse, d): | ||
29 | import oe.types | ||
30 | if oe.types.boolean(d.getVar(var)): | ||
31 | return iftrue | ||
32 | else: | ||
33 | return iffalse | ||
34 | |||
28 | def less_or_equal(variable, checkvalue, truevalue, falsevalue, d): | 35 | def less_or_equal(variable, checkvalue, truevalue, falsevalue, d): |
29 | if float(d.getVar(variable)) <= float(checkvalue): | 36 | if float(d.getVar(variable)) <= float(checkvalue): |
30 | return truevalue | 37 | return truevalue |
@@ -467,3 +474,4 @@ class ImageQAFailed(bb.build.FuncFailed): | |||
467 | msg = msg + ' (%s)' % self.description | 474 | msg = msg + ' (%s)' % self.description |
468 | 475 | ||
469 | return msg | 476 | return msg |
477 | |||