summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/ast.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/parse/ast.py')
-rw-r--r--bitbake/lib/bb/parse/ast.py100
1 files changed, 50 insertions, 50 deletions
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py
index 3f9065a34c..31c930d9cf 100644
--- a/bitbake/lib/bb/parse/ast.py
+++ b/bitbake/lib/bb/parse/ast.py
@@ -54,7 +54,7 @@ class IncludeNode(AstNode):
54 """ 54 """
55 Include the file and evaluate the statements 55 Include the file and evaluate the statements
56 """ 56 """
57 s = bb.data.expand(self.what_file, data) 57 s = data.expand(self.what_file)
58 logger.debug(2, "CONF %s:%s: including %s", self.filename, self.lineno, s) 58 logger.debug(2, "CONF %s:%s: including %s", self.filename, self.lineno, s)
59 59
60 # TODO: Cache those includes... maybe not here though 60 # TODO: Cache those includes... maybe not here though
@@ -69,7 +69,7 @@ class ExportNode(AstNode):
69 self.var = var 69 self.var = var
70 70
71 def eval(self, data): 71 def eval(self, data):
72 bb.data.setVarFlag(self.var, "export", 1, data) 72 data.setVarFlag(self.var, "export", 1)
73 73
74class DataNode(AstNode): 74class DataNode(AstNode):
75 """ 75 """
@@ -92,7 +92,7 @@ class DataNode(AstNode):
92 groupd = self.groupd 92 groupd = self.groupd
93 key = groupd["var"] 93 key = groupd["var"]
94 if "exp" in groupd and groupd["exp"] != None: 94 if "exp" in groupd and groupd["exp"] != None:
95 bb.data.setVarFlag(key, "export", 1, data) 95 data.setVarFlag(key, "export", 1)
96 if "ques" in groupd and groupd["ques"] != None: 96 if "ques" in groupd and groupd["ques"] != None:
97 val = self.getFunc(key, data) 97 val = self.getFunc(key, data)
98 if val == None: 98 if val == None:
@@ -100,7 +100,7 @@ class DataNode(AstNode):
100 elif "colon" in groupd and groupd["colon"] != None: 100 elif "colon" in groupd and groupd["colon"] != None:
101 e = data.createCopy() 101 e = data.createCopy()
102 bb.data.update_data(e) 102 bb.data.update_data(e)
103 val = bb.data.expand(groupd["value"], e, key + "[:=]") 103 val = e.expand(groupd["value"], key + "[:=]")
104 elif "append" in groupd and groupd["append"] != None: 104 elif "append" in groupd and groupd["append"] != None:
105 val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"]) 105 val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"])
106 elif "prepend" in groupd and groupd["prepend"] != None: 106 elif "prepend" in groupd and groupd["prepend"] != None:
@@ -113,11 +113,11 @@ class DataNode(AstNode):
113 val = groupd["value"] 113 val = groupd["value"]
114 114
115 if 'flag' in groupd and groupd['flag'] != None: 115 if 'flag' in groupd and groupd['flag'] != None:
116 bb.data.setVarFlag(key, groupd['flag'], val, data) 116 data.setVarFlag(key, groupd['flag'], val)
117 elif groupd["lazyques"]: 117 elif groupd["lazyques"]:
118 bb.data.setVarFlag(key, "defaultval", val, data) 118 data.setVarFlag(key, "defaultval", val)
119 else: 119 else:
120 bb.data.setVar(key, val, data) 120 data.setVar(key, val)
121 121
122class MethodNode(AstNode): 122class MethodNode(AstNode):
123 def __init__(self, filename, lineno, func_name, body): 123 def __init__(self, filename, lineno, func_name, body):
@@ -131,12 +131,12 @@ class MethodNode(AstNode):
131 if not funcname in bb.methodpool._parsed_fns: 131 if not funcname in bb.methodpool._parsed_fns:
132 text = "def %s(d):\n" % (funcname) + '\n'.join(self.body) 132 text = "def %s(d):\n" % (funcname) + '\n'.join(self.body)
133 bb.methodpool.insert_method(funcname, text, self.filename) 133 bb.methodpool.insert_method(funcname, text, self.filename)
134 anonfuncs = bb.data.getVar('__BBANONFUNCS', data) or [] 134 anonfuncs = data.getVar('__BBANONFUNCS') or []
135 anonfuncs.append(funcname) 135 anonfuncs.append(funcname)
136 bb.data.setVar('__BBANONFUNCS', anonfuncs, data) 136 data.setVar('__BBANONFUNCS', anonfuncs)
137 else: 137 else:
138 bb.data.setVarFlag(self.func_name, "func", 1, data) 138 data.setVarFlag(self.func_name, "func", 1)
139 bb.data.setVar(self.func_name, '\n'.join(self.body), data) 139 data.setVar(self.func_name, '\n'.join(self.body))
140 140
141class PythonMethodNode(AstNode): 141class PythonMethodNode(AstNode):
142 def __init__(self, filename, lineno, function, define, body): 142 def __init__(self, filename, lineno, function, define, body):
@@ -152,9 +152,9 @@ class PythonMethodNode(AstNode):
152 text = '\n'.join(self.body) 152 text = '\n'.join(self.body)
153 if not bb.methodpool.parsed_module(self.define): 153 if not bb.methodpool.parsed_module(self.define):
154 bb.methodpool.insert_method(self.define, text, self.filename) 154 bb.methodpool.insert_method(self.define, text, self.filename)
155 bb.data.setVarFlag(self.function, "func", 1, data) 155 data.setVarFlag(self.function, "func", 1)
156 bb.data.setVarFlag(self.function, "python", 1, data) 156 data.setVarFlag(self.function, "python", 1)
157 bb.data.setVar(self.function, text, data) 157 data.setVar(self.function, text)
158 158
159class MethodFlagsNode(AstNode): 159class MethodFlagsNode(AstNode):
160 def __init__(self, filename, lineno, key, m): 160 def __init__(self, filename, lineno, key, m):
@@ -163,19 +163,19 @@ class MethodFlagsNode(AstNode):
163 self.m = m 163 self.m = m
164 164
165 def eval(self, data): 165 def eval(self, data):
166 if bb.data.getVar(self.key, data): 166 if data.getVar(self.key):
167 # clean up old version of this piece of metadata, as its 167 # clean up old version of this piece of metadata, as its
168 # flags could cause problems 168 # flags could cause problems
169 bb.data.setVarFlag(self.key, 'python', None, data) 169 data.setVarFlag(self.key, 'python', None)
170 bb.data.setVarFlag(self.key, 'fakeroot', None, data) 170 data.setVarFlag(self.key, 'fakeroot', None)
171 if self.m.group("py") is not None: 171 if self.m.group("py") is not None:
172 bb.data.setVarFlag(self.key, "python", "1", data) 172 data.setVarFlag(self.key, "python", "1")
173 else: 173 else:
174 bb.data.delVarFlag(self.key, "python", data) 174 data.delVarFlag(self.key, "python")
175 if self.m.group("fr") is not None: 175 if self.m.group("fr") is not None:
176 bb.data.setVarFlag(self.key, "fakeroot", "1", data) 176 data.setVarFlag(self.key, "fakeroot", "1")
177 else: 177 else:
178 bb.data.delVarFlag(self.key, "fakeroot", data) 178 data.delVarFlag(self.key, "fakeroot")
179 179
180class ExportFuncsNode(AstNode): 180class ExportFuncsNode(AstNode):
181 def __init__(self, filename, lineno, fns, classes): 181 def __init__(self, filename, lineno, fns, classes):
@@ -197,25 +197,25 @@ class ExportFuncsNode(AstNode):
197 vars.append([allvars[0], allvars[2]]) 197 vars.append([allvars[0], allvars[2]])
198 198
199 for (var, calledvar) in vars: 199 for (var, calledvar) in vars:
200 if bb.data.getVar(var, data) and not bb.data.getVarFlag(var, 'export_func', data): 200 if data.getVar(var) and not data.getVarFlag(var, 'export_func'):
201 continue 201 continue
202 202
203 if bb.data.getVar(var, data): 203 if data.getVar(var):
204 bb.data.setVarFlag(var, 'python', None, data) 204 data.setVarFlag(var, 'python', None)
205 bb.data.setVarFlag(var, 'func', None, data) 205 data.setVarFlag(var, 'func', None)
206 206
207 for flag in [ "func", "python" ]: 207 for flag in [ "func", "python" ]:
208 if bb.data.getVarFlag(calledvar, flag, data): 208 if data.getVarFlag(calledvar, flag):
209 bb.data.setVarFlag(var, flag, bb.data.getVarFlag(calledvar, flag, data), data) 209 data.setVarFlag(var, flag, data.getVarFlag(calledvar, flag))
210 for flag in [ "dirs" ]: 210 for flag in [ "dirs" ]:
211 if bb.data.getVarFlag(var, flag, data): 211 if data.getVarFlag(var, flag):
212 bb.data.setVarFlag(calledvar, flag, bb.data.getVarFlag(var, flag, data), data) 212 data.setVarFlag(calledvar, flag, data.getVarFlag(var, flag))
213 213
214 if bb.data.getVarFlag(calledvar, "python", data): 214 if data.getVarFlag(calledvar, "python"):
215 bb.data.setVar(var, "\tbb.build.exec_func('" + calledvar + "', d)\n", data) 215 data.setVar(var, "\tbb.build.exec_func('" + calledvar + "', d)\n")
216 else: 216 else:
217 bb.data.setVar(var, "\t" + calledvar + "\n", data) 217 data.setVar(var, "\t" + calledvar + "\n")
218 bb.data.setVarFlag(var, 'export_func', '1', data) 218 data.setVarFlag(var, 'export_func', '1')
219 219
220class AddTaskNode(AstNode): 220class AddTaskNode(AstNode):
221 def __init__(self, filename, lineno, func, before, after): 221 def __init__(self, filename, lineno, func, before, after):
@@ -229,25 +229,25 @@ class AddTaskNode(AstNode):
229 if self.func[:3] != "do_": 229 if self.func[:3] != "do_":
230 var = "do_" + self.func 230 var = "do_" + self.func
231 231
232 bb.data.setVarFlag(var, "task", 1, data) 232 data.setVarFlag(var, "task", 1)
233 bbtasks = bb.data.getVar('__BBTASKS', data) or [] 233 bbtasks = data.getVar('__BBTASKS') or []
234 if not var in bbtasks: 234 if not var in bbtasks:
235 bbtasks.append(var) 235 bbtasks.append(var)
236 bb.data.setVar('__BBTASKS', bbtasks, data) 236 data.setVar('__BBTASKS', bbtasks)
237 237
238 existing = bb.data.getVarFlag(var, "deps", data) or [] 238 existing = data.getVarFlag(var, "deps") or []
239 if self.after is not None: 239 if self.after is not None:
240 # set up deps for function 240 # set up deps for function
241 for entry in self.after.split(): 241 for entry in self.after.split():
242 if entry not in existing: 242 if entry not in existing:
243 existing.append(entry) 243 existing.append(entry)
244 bb.data.setVarFlag(var, "deps", existing, data) 244 data.setVarFlag(var, "deps", existing)
245 if self.before is not None: 245 if self.before is not None:
246 # set up things that depend on this func 246 # set up things that depend on this func
247 for entry in self.before.split(): 247 for entry in self.before.split():
248 existing = bb.data.getVarFlag(entry, "deps", data) or [] 248 existing = data.getVarFlag(entry, "deps") or []
249 if var not in existing: 249 if var not in existing:
250 bb.data.setVarFlag(entry, "deps", [var] + existing, data) 250 data.setVarFlag(entry, "deps", [var] + existing)
251 251
252class BBHandlerNode(AstNode): 252class BBHandlerNode(AstNode):
253 def __init__(self, filename, lineno, fns): 253 def __init__(self, filename, lineno, fns):
@@ -255,11 +255,11 @@ class BBHandlerNode(AstNode):
255 self.hs = fns.split() 255 self.hs = fns.split()
256 256
257 def eval(self, data): 257 def eval(self, data):
258 bbhands = bb.data.getVar('__BBHANDLERS', data) or [] 258 bbhands = data.getVar('__BBHANDLERS') or []
259 for h in self.hs: 259 for h in self.hs:
260 bbhands.append(h) 260 bbhands.append(h)
261 bb.data.setVarFlag(h, "handler", 1, data) 261 data.setVarFlag(h, "handler", 1)
262 bb.data.setVar('__BBHANDLERS', bbhands, data) 262 data.setVar('__BBHANDLERS', bbhands)
263 263
264class InheritNode(AstNode): 264class InheritNode(AstNode):
265 def __init__(self, filename, lineno, classes): 265 def __init__(self, filename, lineno, classes):
@@ -308,9 +308,9 @@ def handleInherit(statements, filename, lineno, m):
308 308
309def finalize(fn, d, variant = None): 309def finalize(fn, d, variant = None):
310 all_handlers = {} 310 all_handlers = {}
311 for var in bb.data.getVar('__BBHANDLERS', d) or []: 311 for var in d.getVar('__BBHANDLERS') or []:
312 # try to add the handler 312 # try to add the handler
313 handler = bb.data.getVar(var, d) 313 handler = d.getVar(var)
314 bb.event.register(var, handler) 314 bb.event.register(var, handler)
315 315
316 bb.event.fire(bb.event.RecipePreFinalise(fn), d) 316 bb.event.fire(bb.event.RecipePreFinalise(fn), d)
@@ -318,12 +318,12 @@ def finalize(fn, d, variant = None):
318 bb.data.expandKeys(d) 318 bb.data.expandKeys(d)
319 bb.data.update_data(d) 319 bb.data.update_data(d)
320 code = [] 320 code = []
321 for funcname in bb.data.getVar("__BBANONFUNCS", d) or []: 321 for funcname in d.getVar("__BBANONFUNCS") or []:
322 code.append("%s(d)" % funcname) 322 code.append("%s(d)" % funcname)
323 bb.utils.simple_exec("\n".join(code), {"d": d}) 323 bb.utils.simple_exec("\n".join(code), {"d": d})
324 bb.data.update_data(d) 324 bb.data.update_data(d)
325 325
326 tasklist = bb.data.getVar('__BBTASKS', d) or [] 326 tasklist = d.getVar('__BBTASKS') or []
327 bb.build.add_tasks(tasklist, d) 327 bb.build.add_tasks(tasklist, d)
328 328
329 bb.parse.siggen.finalise(fn, d, variant) 329 bb.parse.siggen.finalise(fn, d, variant)
@@ -378,7 +378,7 @@ def multi_finalize(fn, d):
378 try: 378 try:
379 finalize(fn, d) 379 finalize(fn, d)
380 except bb.parse.SkipPackage as e: 380 except bb.parse.SkipPackage as e:
381 bb.data.setVar("__SKIPPED", e.args[0], d) 381 d.setVar("__SKIPPED", e.args[0])
382 datastores = {"": safe_d} 382 datastores = {"": safe_d}
383 383
384 versions = (d.getVar("BBVERSIONS", True) or "").split() 384 versions = (d.getVar("BBVERSIONS", True) or "").split()
@@ -421,7 +421,7 @@ def multi_finalize(fn, d):
421 try: 421 try:
422 finalize(fn, d) 422 finalize(fn, d)
423 except bb.parse.SkipPackage as e: 423 except bb.parse.SkipPackage as e:
424 bb.data.setVar("__SKIPPED", e.args[0], d) 424 d.setVar("__SKIPPED", e.args[0])
425 425
426 _create_variants(datastores, versions, verfunc) 426 _create_variants(datastores, versions, verfunc)
427 427
@@ -461,7 +461,7 @@ def multi_finalize(fn, d):
461 if not onlyfinalise or variant in onlyfinalise: 461 if not onlyfinalise or variant in onlyfinalise:
462 finalize(fn, variant_d, variant) 462 finalize(fn, variant_d, variant)
463 except bb.parse.SkipPackage as e: 463 except bb.parse.SkipPackage as e:
464 bb.data.setVar("__SKIPPED", e.args[0], variant_d) 464 variant_d.setVar("__SKIPPED", e.args[0])
465 465
466 if len(datastores) > 1: 466 if len(datastores) > 1:
467 variants = filter(None, datastores.iterkeys()) 467 variants = filter(None, datastores.iterkeys())