diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-22 10:30:57 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-07-12 22:50:45 +0100 |
commit | 933e19697b680637e5af8131cf5fc833943f68f7 (patch) | |
tree | 380e8c3b71b4fdfd233b947ba45317824ebde9d8 /bitbake/lib | |
parent | 95be16f428ae4cf4254da0b814a327459a983ef5 (diff) | |
download | poky-933e19697b680637e5af8131cf5fc833943f68f7.tar.gz |
bitbake: parse/ast/data_smart: Add parsing flag to getVar/setVar
When parsing we find problems if we clear prepends/appends when
setting variables during the initial parsing phases. Later, we actively
want to do this (in what would be post finalisation previously).
To handle this, pass a parsing flag to the operations to control
the correct behaviour for the context.
(Bitbake rev: ae87f5b8bf16191b3201cfb445062938eab992a0)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 36 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 14 |
2 files changed, 28 insertions, 22 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 28ea2aef63..68efc7bb1c 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py | |||
@@ -386,6 +386,10 @@ class DataSmart(MutableMapping): | |||
386 | 386 | ||
387 | def setVar(self, var, value, **loginfo): | 387 | def setVar(self, var, value, **loginfo): |
388 | #print("var=" + str(var) + " val=" + str(value)) | 388 | #print("var=" + str(var) + " val=" + str(value)) |
389 | parsing=False | ||
390 | if 'parsing' in loginfo: | ||
391 | parsing=True | ||
392 | |||
389 | if 'op' not in loginfo: | 393 | if 'op' not in loginfo: |
390 | loginfo['op'] = "set" | 394 | loginfo['op'] = "set" |
391 | self.expand_cache = {} | 395 | self.expand_cache = {} |
@@ -421,12 +425,13 @@ class DataSmart(MutableMapping): | |||
421 | if not var in self.dict: | 425 | if not var in self.dict: |
422 | self._makeShadowCopy(var) | 426 | self._makeShadowCopy(var) |
423 | 427 | ||
424 | if "_append" in self.dict[var]: | 428 | if not parsing: |
425 | del self.dict[var]["_append"] | 429 | if "_append" in self.dict[var]: |
426 | if "_prepend" in self.dict[var]: | 430 | del self.dict[var]["_append"] |
427 | del self.dict[var]["_prepend"] | 431 | if "_prepend" in self.dict[var]: |
428 | if "_overrides" in self.dict[var]: | 432 | del self.dict[var]["_prepend"] |
429 | del self.dict[var]["_overrides"] | 433 | if "_overrides" in self.dict[var]: |
434 | del self.dict[var]["_overrides"] | ||
430 | 435 | ||
431 | # more cookies for the cookie monster | 436 | # more cookies for the cookie monster |
432 | if '_' in var: | 437 | if '_' in var: |
@@ -464,20 +469,20 @@ class DataSmart(MutableMapping): | |||
464 | if len(shortvar) == 0: | 469 | if len(shortvar) == 0: |
465 | override = None | 470 | override = None |
466 | 471 | ||
467 | def getVar(self, var, expand=False, noweakdefault=False): | 472 | def getVar(self, var, expand=False, noweakdefault=False, parsing=False): |
468 | return self.getVarFlag(var, "_content", expand, noweakdefault) | 473 | return self.getVarFlag(var, "_content", expand, noweakdefault, parsing) |
469 | 474 | ||
470 | def renameVar(self, key, newkey, **loginfo): | 475 | def renameVar(self, key, newkey, **loginfo): |
471 | """ | 476 | """ |
472 | Rename the variable key to newkey | 477 | Rename the variable key to newkey |
473 | """ | 478 | """ |
474 | val = self.getVar(key, 0) | 479 | val = self.getVar(key, 0, parsing=True) |
475 | if val is not None: | 480 | if val is not None: |
476 | loginfo['variable'] = newkey | 481 | loginfo['variable'] = newkey |
477 | loginfo['op'] = 'rename from %s' % key | 482 | loginfo['op'] = 'rename from %s' % key |
478 | loginfo['detail'] = val | 483 | loginfo['detail'] = val |
479 | self.varhistory.record(**loginfo) | 484 | self.varhistory.record(**loginfo) |
480 | self.setVar(newkey, val, ignore=True) | 485 | self.setVar(newkey, val, ignore=True, parsing=True) |
481 | 486 | ||
482 | for i in (__setvar_keyword__): | 487 | for i in (__setvar_keyword__): |
483 | src = self.getVarFlag(key, i) | 488 | src = self.getVarFlag(key, i) |
@@ -545,11 +550,10 @@ class DataSmart(MutableMapping): | |||
545 | self.dict["__exportlist"]["_content"] = set() | 550 | self.dict["__exportlist"]["_content"] = set() |
546 | self.dict["__exportlist"]["_content"].add(var) | 551 | self.dict["__exportlist"]["_content"].add(var) |
547 | 552 | ||
548 | def getVarFlag(self, var, flag, expand=False, noweakdefault=False): | 553 | def getVarFlag(self, var, flag, expand=False, noweakdefault=False, parsing=False): |
549 | local_var = self._findVar(var) | 554 | local_var = self._findVar(var) |
550 | value = None | 555 | value = None |
551 | 556 | if flag == "_content" and local_var is not None and "_overrides" in local_var and not parsing: | |
552 | if flag == "_content" and local_var is not None and "_overrides" in local_var: | ||
553 | match = False | 557 | match = False |
554 | active = {} | 558 | active = {} |
555 | for (r, o) in local_var["_overrides"]: | 559 | for (r, o) in local_var["_overrides"]: |
@@ -580,7 +584,8 @@ class DataSmart(MutableMapping): | |||
580 | elif flag == "_content" and "_defaultval" in local_var and not noweakdefault: | 584 | elif flag == "_content" and "_defaultval" in local_var and not noweakdefault: |
581 | value = copy.copy(local_var["_defaultval"]) | 585 | value = copy.copy(local_var["_defaultval"]) |
582 | 586 | ||
583 | if flag == "_content" and local_var is not None and "_append" in local_var: | 587 | |
588 | if flag == "_content" and local_var is not None and "_append" in local_var and not parsing: | ||
584 | if not value: | 589 | if not value: |
585 | value = "" | 590 | value = "" |
586 | for (r, o) in local_var["_append"]: | 591 | for (r, o) in local_var["_append"]: |
@@ -592,10 +597,11 @@ class DataSmart(MutableMapping): | |||
592 | if match: | 597 | if match: |
593 | value = value + r | 598 | value = value + r |
594 | 599 | ||
595 | if flag == "_content" and local_var is not None and "_prepend" in local_var: | 600 | if flag == "_content" and local_var is not None and "_prepend" in local_var and not parsing: |
596 | if not value: | 601 | if not value: |
597 | value = "" | 602 | value = "" |
598 | for (r, o) in local_var["_prepend"]: | 603 | for (r, o) in local_var["_prepend"]: |
604 | |||
599 | match = True | 605 | match = True |
600 | if o: | 606 | if o: |
601 | for o2 in o.split("_"): | 607 | for o2 in o.split("_"): |
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 1130b1474c..bd42bd3a7a 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -85,7 +85,7 @@ class DataNode(AstNode): | |||
85 | if 'flag' in self.groupd and self.groupd['flag'] != None: | 85 | if 'flag' in self.groupd and self.groupd['flag'] != None: |
86 | return data.getVarFlag(key, self.groupd['flag'], noweakdefault=True) | 86 | return data.getVarFlag(key, self.groupd['flag'], noweakdefault=True) |
87 | else: | 87 | else: |
88 | return data.getVar(key, False, noweakdefault=True) | 88 | return data.getVar(key, False, noweakdefault=True, parsing=True) |
89 | 89 | ||
90 | def eval(self, data): | 90 | def eval(self, data): |
91 | groupd = self.groupd | 91 | groupd = self.groupd |
@@ -136,7 +136,7 @@ class DataNode(AstNode): | |||
136 | if flag: | 136 | if flag: |
137 | data.setVarFlag(key, flag, val, **loginfo) | 137 | data.setVarFlag(key, flag, val, **loginfo) |
138 | else: | 138 | else: |
139 | data.setVar(key, val, **loginfo) | 139 | data.setVar(key, val, parsing=True, **loginfo) |
140 | 140 | ||
141 | class MethodNode(AstNode): | 141 | class MethodNode(AstNode): |
142 | tr_tbl = string.maketrans('/.+-@%&', '_______') | 142 | tr_tbl = string.maketrans('/.+-@%&', '_______') |
@@ -155,10 +155,10 @@ class MethodNode(AstNode): | |||
155 | anonfuncs = data.getVar('__BBANONFUNCS', False) or [] | 155 | anonfuncs = data.getVar('__BBANONFUNCS', False) or [] |
156 | anonfuncs.append(funcname) | 156 | anonfuncs.append(funcname) |
157 | data.setVar('__BBANONFUNCS', anonfuncs) | 157 | data.setVar('__BBANONFUNCS', anonfuncs) |
158 | data.setVar(funcname, text) | 158 | data.setVar(funcname, text, parsing=True) |
159 | else: | 159 | else: |
160 | data.setVarFlag(self.func_name, "func", 1) | 160 | data.setVarFlag(self.func_name, "func", 1) |
161 | data.setVar(self.func_name, text) | 161 | data.setVar(self.func_name, text, parsing=True) |
162 | 162 | ||
163 | class PythonMethodNode(AstNode): | 163 | class PythonMethodNode(AstNode): |
164 | def __init__(self, filename, lineno, function, modulename, body): | 164 | def __init__(self, filename, lineno, function, modulename, body): |
@@ -175,7 +175,7 @@ class PythonMethodNode(AstNode): | |||
175 | bb.methodpool.insert_method(self.modulename, text, self.filename) | 175 | bb.methodpool.insert_method(self.modulename, text, self.filename) |
176 | data.setVarFlag(self.function, "func", 1) | 176 | data.setVarFlag(self.function, "func", 1) |
177 | data.setVarFlag(self.function, "python", 1) | 177 | data.setVarFlag(self.function, "python", 1) |
178 | data.setVar(self.function, text) | 178 | data.setVar(self.function, text, parsing=True) |
179 | 179 | ||
180 | class MethodFlagsNode(AstNode): | 180 | class MethodFlagsNode(AstNode): |
181 | def __init__(self, filename, lineno, key, m): | 181 | def __init__(self, filename, lineno, key, m): |
@@ -224,11 +224,11 @@ class ExportFuncsNode(AstNode): | |||
224 | data.setVarFlag(calledfunc, flag, data.getVarFlag(func, flag)) | 224 | data.setVarFlag(calledfunc, flag, data.getVarFlag(func, flag)) |
225 | 225 | ||
226 | if data.getVarFlag(calledfunc, "python"): | 226 | if data.getVarFlag(calledfunc, "python"): |
227 | data.setVar(func, " bb.build.exec_func('" + calledfunc + "', d)\n") | 227 | data.setVar(func, " bb.build.exec_func('" + calledfunc + "', d)\n", parsing=True) |
228 | else: | 228 | else: |
229 | if "-" in self.classname: | 229 | if "-" in self.classname: |
230 | bb.fatal("The classname %s contains a dash character and is calling an sh function %s using EXPORT_FUNCTIONS. Since a dash is illegal in sh function names, this cannot work, please rename the class or don't use EXPORT_FUNCTIONS." % (self.classname, calledfunc)) | 230 | bb.fatal("The classname %s contains a dash character and is calling an sh function %s using EXPORT_FUNCTIONS. Since a dash is illegal in sh function names, this cannot work, please rename the class or don't use EXPORT_FUNCTIONS." % (self.classname, calledfunc)) |
231 | data.setVar(func, " " + calledfunc + "\n") | 231 | data.setVar(func, " " + calledfunc + "\n", parsing=True) |
232 | data.setVarFlag(func, 'export_func', '1') | 232 | data.setVarFlag(func, 'export_func', '1') |
233 | 233 | ||
234 | class AddTaskNode(AstNode): | 234 | class AddTaskNode(AstNode): |