diff options
author | Jérémy Rosen <jeremy.rosen@smile.fr> | 2016-08-16 14:04:47 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-08-18 10:06:26 +0100 |
commit | 0eb6d709b6c38aa27f33d8b0ef977a33350f0d75 (patch) | |
tree | f4b503fb079669fdc021f9b7a78f6d814862d7f4 /bitbake/lib/bb/parse | |
parent | b50b14e37249fb23b8e4f3a86f9b245cba85ca86 (diff) | |
download | poky-0eb6d709b6c38aa27f33d8b0ef977a33350f0d75.tar.gz |
bitbake: ast/ConfHandler: Add a syntax to clear variable
unset VAR
will clear variable VAR
unset VAR[flag]
will clear flag "flag" from var VAR
(Bitbake rev: bedbd46ece8d1285b5cd2ea07dc64b4875b479aa)
Signed-off-by: Jérémy Rosen <jeremy.rosen@openwide.fr>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/parse')
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 33 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 12 |
2 files changed, 45 insertions, 0 deletions
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 0fc3a9e7a4..d7185b1664 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -69,6 +69,33 @@ class ExportNode(AstNode): | |||
69 | def eval(self, data): | 69 | def eval(self, data): |
70 | data.setVarFlag(self.var, "export", 1, op = 'exported') | 70 | data.setVarFlag(self.var, "export", 1, op = 'exported') |
71 | 71 | ||
72 | class UnsetNode(AstNode): | ||
73 | def __init__(self, filename, lineno, var): | ||
74 | AstNode.__init__(self, filename, lineno) | ||
75 | self.var = var | ||
76 | |||
77 | def eval(self, data): | ||
78 | loginfo = { | ||
79 | 'variable': self.var, | ||
80 | 'file': self.filename, | ||
81 | 'line': self.lineno, | ||
82 | } | ||
83 | data.delVar(self.var,**loginfo) | ||
84 | |||
85 | class UnsetFlagNode(AstNode): | ||
86 | def __init__(self, filename, lineno, var, flag): | ||
87 | AstNode.__init__(self, filename, lineno) | ||
88 | self.var = var | ||
89 | self.flag = flag | ||
90 | |||
91 | def eval(self, data): | ||
92 | loginfo = { | ||
93 | 'variable': self.var, | ||
94 | 'file': self.filename, | ||
95 | 'line': self.lineno, | ||
96 | } | ||
97 | data.delVarFlag(self.var, self.flag, **loginfo) | ||
98 | |||
72 | class DataNode(AstNode): | 99 | class DataNode(AstNode): |
73 | """ | 100 | """ |
74 | Various data related updates. For the sake of sanity | 101 | Various data related updates. For the sake of sanity |
@@ -270,6 +297,12 @@ def handleInclude(statements, filename, lineno, m, force): | |||
270 | def handleExport(statements, filename, lineno, m): | 297 | def handleExport(statements, filename, lineno, m): |
271 | statements.append(ExportNode(filename, lineno, m.group(1))) | 298 | statements.append(ExportNode(filename, lineno, m.group(1))) |
272 | 299 | ||
300 | def handleUnset(statements, filename, lineno, m): | ||
301 | statements.append(UnsetNode(filename, lineno, m.group(1))) | ||
302 | |||
303 | def handleUnsetFlag(statements, filename, lineno, m): | ||
304 | statements.append(UnsetFlagNode(filename, lineno, m.group(1), m.group(2))) | ||
305 | |||
273 | def handleData(statements, filename, lineno, groupd): | 306 | def handleData(statements, filename, lineno, groupd): |
274 | statements.append(DataNode(filename, lineno, groupd)) | 307 | statements.append(DataNode(filename, lineno, groupd)) |
275 | 308 | ||
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index b9712929f3..875250de40 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""" | |||
57 | __include_regexp__ = re.compile( r"include\s+(.+)" ) | 57 | __include_regexp__ = re.compile( r"include\s+(.+)" ) |
58 | __require_regexp__ = re.compile( r"require\s+(.+)" ) | 58 | __require_regexp__ = re.compile( r"require\s+(.+)" ) |
59 | __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/]+)$" ) | 59 | __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/]+)$" ) |
60 | __unset_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/]+)$" ) | ||
61 | __unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/]+)\[([a-zA-Z0-9\-_+.${}/]+)\]$" ) | ||
60 | 62 | ||
61 | def init(data): | 63 | def init(data): |
62 | topdir = data.getVar('TOPDIR', False) | 64 | topdir = data.getVar('TOPDIR', False) |
@@ -185,6 +187,16 @@ def feeder(lineno, s, fn, statements): | |||
185 | ast.handleExport(statements, fn, lineno, m) | 187 | ast.handleExport(statements, fn, lineno, m) |
186 | return | 188 | return |
187 | 189 | ||
190 | m = __unset_regexp__.match(s) | ||
191 | if m: | ||
192 | ast.handleUnset(statements, fn, lineno, m) | ||
193 | return | ||
194 | |||
195 | m = __unset_flag_regexp__.match(s) | ||
196 | if m: | ||
197 | ast.handleUnsetFlag(statements, fn, lineno, m) | ||
198 | return | ||
199 | |||
188 | raise ParseError("unparsed line: '%s'" % s, fn, lineno); | 200 | raise ParseError("unparsed line: '%s'" % s, fn, lineno); |
189 | 201 | ||
190 | # Add us to the handlers list | 202 | # Add us to the handlers list |