* [PATCH v2 0/1][resend] Add a syntax to unset variable from bitbake configuration file
@ 2016-08-23 9:44 Jérémy Rosen
2016-08-23 9:44 ` [PATCH v2 1/1] add a syntax to clear variable Jérémy Rosen
2016-09-06 10:44 ` [PATCH v2 0/1][resend] Add a syntax to unset variable from bitbake configuration file Jérémy Rosen
0 siblings, 2 replies; 5+ messages in thread
From: Jérémy Rosen @ 2016-08-23 9:44 UTC (permalink / raw)
To: bitbake-devel
While working on a Yocto project I had a need to reactivate a task that was
disabled (do_fetch[noexec]="1") Currently, bitbake does not check the value
of the noexec flag but only if the flag is set. The only way to unset a flag
is to use an inline python syntax like the one below
python () {
d.delVarFlag("do_fetch","noexec")
}
Using inline python to do something as simple as clearing a flag sounded too
complicated to me so I added a new keyword "unset" to bitbake with the
following syntax :
unset VAR
will call d.delVar("VAR")
unset VAR[flag]
will call d.delVarFlag("VAR","flag")
Documentation has been updated accordingly
---
v2 : fix some wording in documentation
add unit test
Jérémy Rosen (1):
add a syntax to clear variable
bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml | 17 ++++-
bitbake/lib/bb/parse/ast.py | 33 +++++++-
bitbake/lib/bb/parse/parse_py/ConfHandler.py | 12 +++-
bitbake/lib/bb/tests/parse.py | 17 ++++-
4 files changed, 79 insertions(+), 0 deletions(-)
--
git-series 0.8.9
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 1/1] add a syntax to clear variable 2016-08-23 9:44 [PATCH v2 0/1][resend] Add a syntax to unset variable from bitbake configuration file Jérémy Rosen @ 2016-08-23 9:44 ` Jérémy Rosen 2016-09-06 10:44 ` [PATCH v2 0/1][resend] Add a syntax to unset variable from bitbake configuration file Jérémy Rosen 1 sibling, 0 replies; 5+ messages in thread From: Jérémy Rosen @ 2016-08-23 9:44 UTC (permalink / raw) To: bitbake-devel; +Cc: Jérémy Rosen unset VAR will clear variable VAR unset VAR[flag] will clear flag "flag" from var VAR Signed-off-by: Jérémy Rosen <jeremy.rosen@openwide.fr> --- bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml | 17 ++++- bitbake/lib/bb/parse/ast.py | 33 +++++++- bitbake/lib/bb/parse/parse_py/ConfHandler.py | 12 +++- bitbake/lib/bb/tests/parse.py | 17 ++++- 4 files changed, 79 insertions(+), 0 deletions(-) diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml index 7ef848f..47db85b 100644 --- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml +++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml @@ -431,6 +431,23 @@ </para> </section> + <section id='unsetting-variables'> + <title>Unseting variables</title> + + <para> + It is possible to completely remove a variable or a variable flag + from BitBake's internal data dictionary by using the "unset" keyword. + Here is an example: + <literallayout class='monospaced'> + unset DATE + unset do_fetch[noexec] + </literallayout> + These two statements remove the <filename>DATE</filename> and the + <filename>do_fetch[noexec]</filename> flag. + </para> + + </section> + <section id='providing-pathnames'> <title>Providing Pathnames</title> diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 8b9baa7..b407b09 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py @@ -69,6 +69,33 @@ class ExportNode(AstNode): def eval(self, data): data.setVarFlag(self.var, "export", 1, op = 'exported') +class UnsetNode(AstNode): + def __init__(self, filename, lineno, var): + AstNode.__init__(self, filename, lineno) + self.var = var + + def eval(self, data): + loginfo = { + 'variable': self.var, + 'file': self.filename, + 'line': self.lineno, + } + data.delVar(self.var,**loginfo) + +class UnsetFlagNode(AstNode): + def __init__(self, filename, lineno, var, flag): + AstNode.__init__(self, filename, lineno) + self.var = var + self.flag = flag + + def eval(self, data): + loginfo = { + 'variable': self.var, + 'file': self.filename, + 'line': self.lineno, + } + data.delVarFlag(self.var, self.flag, **loginfo) + class DataNode(AstNode): """ Various data related updates. For the sake of sanity @@ -270,6 +297,12 @@ def handleInclude(statements, filename, lineno, m, force): def handleExport(statements, filename, lineno, m): statements.append(ExportNode(filename, lineno, m.group(1))) +def handleUnset(statements, filename, lineno, m): + statements.append(UnsetNode(filename, lineno, m.group(1))) + +def handleUnsetFlag(statements, filename, lineno, m): + statements.append(UnsetFlagNode(filename, lineno, m.group(1), m.group(2))) + def handleData(statements, filename, lineno, groupd): statements.append(DataNode(filename, lineno, groupd)) diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index b971292..875250d 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py @@ -57,6 +57,8 @@ __config_regexp__ = re.compile( r""" __include_regexp__ = re.compile( r"include\s+(.+)" ) __require_regexp__ = re.compile( r"require\s+(.+)" ) __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/]+)$" ) +__unset_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/]+)$" ) +__unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/]+)\[([a-zA-Z0-9\-_+.${}/]+)\]$" ) def init(data): topdir = data.getVar('TOPDIR', False) @@ -185,6 +187,16 @@ def feeder(lineno, s, fn, statements): ast.handleExport(statements, fn, lineno, m) return + m = __unset_regexp__.match(s) + if m: + ast.handleUnset(statements, fn, lineno, m) + return + + m = __unset_flag_regexp__.match(s) + if m: + ast.handleUnsetFlag(statements, fn, lineno, m) + return + raise ParseError("unparsed line: '%s'" % s, fn, lineno); # Add us to the handlers list diff --git a/bitbake/lib/bb/tests/parse.py b/bitbake/lib/bb/tests/parse.py index c296db2..0b2706a 100644 --- a/bitbake/lib/bb/tests/parse.py +++ b/bitbake/lib/bb/tests/parse.py @@ -68,6 +68,23 @@ C = "3" with self.assertRaises(bb.parse.ParseError): d = bb.parse.handle(f.name, self.d)[''] + unsettest = """ +A = "1" +B = "2" +B[flag] = "3" + +unset A +unset B[flag] +""" + + def test_parse_unset(self): + f = self.parsehelper(self.unsettest) + d = bb.parse.handle(f.name, self.d)[''] + self.assertEqual(d.getVar("A", True), None) + self.assertEqual(d.getVarFlag("A","flag", True), None) + self.assertEqual(d.getVar("B", True), "2") + + overridetest = """ RRECOMMENDS_${PN} = "a" RRECOMMENDS_${PN}_libc = "b" -- git-series 0.8.9 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/1][resend] Add a syntax to unset variable from bitbake configuration file 2016-08-23 9:44 [PATCH v2 0/1][resend] Add a syntax to unset variable from bitbake configuration file Jérémy Rosen 2016-08-23 9:44 ` [PATCH v2 1/1] add a syntax to clear variable Jérémy Rosen @ 2016-09-06 10:44 ` Jérémy Rosen 2016-09-06 13:20 ` Richard Purdie 1 sibling, 1 reply; 5+ messages in thread From: Jérémy Rosen @ 2016-09-06 10:44 UTC (permalink / raw) To: bitbake-devel Any news ? On 23/08/2016 11:44, Jérémy Rosen wrote: > While working on a Yocto project I had a need to reactivate a task that was > disabled (do_fetch[noexec]="1") Currently, bitbake does not check the value > of the noexec flag but only if the flag is set. The only way to unset a flag > is to use an inline python syntax like the one below > > python () { > d.delVarFlag("do_fetch","noexec") > } > > Using inline python to do something as simple as clearing a flag sounded too > complicated to me so I added a new keyword "unset" to bitbake with the > following syntax : > > unset VAR > > will call d.delVar("VAR") > > unset VAR[flag] > > will call d.delVarFlag("VAR","flag") > > Documentation has been updated accordingly > > --- > v2 : fix some wording in documentation > add unit test > > Jérémy Rosen (1): > add a syntax to clear variable > > bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml | 17 ++++- > bitbake/lib/bb/parse/ast.py | 33 +++++++- > bitbake/lib/bb/parse/parse_py/ConfHandler.py | 12 +++- > bitbake/lib/bb/tests/parse.py | 17 ++++- > 4 files changed, 79 insertions(+), 0 deletions(-) > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/1][resend] Add a syntax to unset variable from bitbake configuration file 2016-09-06 10:44 ` [PATCH v2 0/1][resend] Add a syntax to unset variable from bitbake configuration file Jérémy Rosen @ 2016-09-06 13:20 ` Richard Purdie 2016-09-06 15:25 ` Jérémy Rosen 0 siblings, 1 reply; 5+ messages in thread From: Richard Purdie @ 2016-09-06 13:20 UTC (permalink / raw) To: Jérémy Rosen, bitbake-devel On Tue, 2016-09-06 at 12:44 +0200, Jérémy Rosen wrote: > Any news ? It merged three weeks ago?: http://git.openembedded.org/bitbake/commit/?id=bedbd46ece8d1285b5cd2ea07dc64b4875b479aa Cheers, Richard ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/1][resend] Add a syntax to unset variable from bitbake configuration file 2016-09-06 13:20 ` Richard Purdie @ 2016-09-06 15:25 ` Jérémy Rosen 0 siblings, 0 replies; 5+ messages in thread From: Jérémy Rosen @ 2016-09-06 15:25 UTC (permalink / raw) To: Richard Purdie, bitbake-devel On 06/09/2016 15:20, Richard Purdie wrote: > On Tue, 2016-09-06 at 12:44 +0200, Jérémy Rosen wrote: >> Any news ? > It merged three weeks ago?: > > http://git.openembedded.org/bitbake/commit/?id=bedbd46ece8d1285b5cd2ea07dc64b4875b479aa > daaaam my bad, thx > Cheers, > > Richard > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-09-06 15:25 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-08-23 9:44 [PATCH v2 0/1][resend] Add a syntax to unset variable from bitbake configuration file Jérémy Rosen 2016-08-23 9:44 ` [PATCH v2 1/1] add a syntax to clear variable Jérémy Rosen 2016-09-06 10:44 ` [PATCH v2 0/1][resend] Add a syntax to unset variable from bitbake configuration file Jérémy Rosen 2016-09-06 13:20 ` Richard Purdie 2016-09-06 15:25 ` Jérémy Rosen
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.