diff options
author | Holger Freyther <ich@tamarin.(none)> | 2009-05-17 12:55:18 +0200 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-02-10 16:32:14 +0000 |
commit | 7477c0d89a84994f78a1cf1a7ac973bead72073a (patch) | |
tree | 80be4923f8ef395d982d5dc94fec43ef0497d507 /bitbake | |
parent | e3c9a340dc95092a400778d3a461045b146ec812 (diff) | |
download | poky-7477c0d89a84994f78a1cf1a7ac973bead72073a.tar.gz |
bitbake: [parsers] Move out more functions
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 148 |
1 files changed, 78 insertions, 70 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 4580d5ee5b..6cb8d560f2 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py | |||
@@ -93,6 +93,81 @@ def handleMethodFlags(key, m, d): | |||
93 | else: | 93 | else: |
94 | data.delVarFlag(key, "fakeroot", d) | 94 | data.delVarFlag(key, "fakeroot", d) |
95 | 95 | ||
96 | def handleExportFuncs(m, d): | ||
97 | fns = m.group(1) | ||
98 | n = __word__.findall(fns) | ||
99 | for f in n: | ||
100 | allvars = [] | ||
101 | allvars.append(f) | ||
102 | allvars.append(classes[-1] + "_" + f) | ||
103 | |||
104 | vars = [[ allvars[0], allvars[1] ]] | ||
105 | if len(classes) > 1 and classes[-2] is not None: | ||
106 | allvars.append(classes[-2] + "_" + f) | ||
107 | vars = [] | ||
108 | vars.append([allvars[2], allvars[1]]) | ||
109 | vars.append([allvars[0], allvars[2]]) | ||
110 | |||
111 | for (var, calledvar) in vars: | ||
112 | if data.getVar(var, d) and not data.getVarFlag(var, 'export_func', d): | ||
113 | continue | ||
114 | |||
115 | if data.getVar(var, d): | ||
116 | data.setVarFlag(var, 'python', None, d) | ||
117 | data.setVarFlag(var, 'func', None, d) | ||
118 | |||
119 | for flag in [ "func", "python" ]: | ||
120 | if data.getVarFlag(calledvar, flag, d): | ||
121 | data.setVarFlag(var, flag, data.getVarFlag(calledvar, flag, d), d) | ||
122 | for flag in [ "dirs" ]: | ||
123 | if data.getVarFlag(var, flag, d): | ||
124 | data.setVarFlag(calledvar, flag, data.getVarFlag(var, flag, d), d) | ||
125 | |||
126 | if data.getVarFlag(calledvar, "python", d): | ||
127 | data.setVar(var, "\tbb.build.exec_func('" + calledvar + "', d)\n", d) | ||
128 | else: | ||
129 | data.setVar(var, "\t" + calledvar + "\n", d) | ||
130 | data.setVarFlag(var, 'export_func', '1', d) | ||
131 | |||
132 | def handleAddTask(m, d): | ||
133 | func = m.group("func") | ||
134 | before = m.group("before") | ||
135 | after = m.group("after") | ||
136 | if func is None: | ||
137 | return | ||
138 | if func[:3] != "do_": | ||
139 | var = "do_" + func | ||
140 | |||
141 | data.setVarFlag(var, "task", 1, d) | ||
142 | |||
143 | bbtasks = data.getVar('__BBTASKS', d) or [] | ||
144 | if not var in bbtasks: | ||
145 | bbtasks.append(var) | ||
146 | data.setVar('__BBTASKS', bbtasks, d) | ||
147 | |||
148 | existing = data.getVarFlag(var, "deps", d) or [] | ||
149 | if after is not None: | ||
150 | # set up deps for function | ||
151 | for entry in after.split(): | ||
152 | if entry not in existing: | ||
153 | existing.append(entry) | ||
154 | data.setVarFlag(var, "deps", existing, d) | ||
155 | if before is not None: | ||
156 | # set up things that depend on this func | ||
157 | for entry in before.split(): | ||
158 | existing = data.getVarFlag(entry, "deps", d) or [] | ||
159 | if var not in existing: | ||
160 | data.setVarFlag(entry, "deps", [var] + existing, d) | ||
161 | |||
162 | def handleBBHandlers(m, d): | ||
163 | fns = m.group(1) | ||
164 | hs = __word__.findall(fns) | ||
165 | bbhands = data.getVar('__BBHANDLERS', d) or [] | ||
166 | for h in hs: | ||
167 | bbhands.append(h) | ||
168 | data.setVarFlag(h, "handler", 1, d) | ||
169 | data.setVar('__BBHANDLERS', bbhands, d) | ||
170 | |||
96 | def supports(fn, d): | 171 | def supports(fn, d): |
97 | return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" | 172 | return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" |
98 | 173 | ||
@@ -286,84 +361,17 @@ def feeder(lineno, s, fn, root, d): | |||
286 | 361 | ||
287 | m = __export_func_regexp__.match(s) | 362 | m = __export_func_regexp__.match(s) |
288 | if m: | 363 | if m: |
289 | fns = m.group(1) | 364 | handleExportFuncs(m, d) |
290 | n = __word__.findall(fns) | ||
291 | for f in n: | ||
292 | allvars = [] | ||
293 | allvars.append(f) | ||
294 | allvars.append(classes[-1] + "_" + f) | ||
295 | |||
296 | vars = [[ allvars[0], allvars[1] ]] | ||
297 | if len(classes) > 1 and classes[-2] is not None: | ||
298 | allvars.append(classes[-2] + "_" + f) | ||
299 | vars = [] | ||
300 | vars.append([allvars[2], allvars[1]]) | ||
301 | vars.append([allvars[0], allvars[2]]) | ||
302 | |||
303 | for (var, calledvar) in vars: | ||
304 | if data.getVar(var, d) and not data.getVarFlag(var, 'export_func', d): | ||
305 | continue | ||
306 | |||
307 | if data.getVar(var, d): | ||
308 | data.setVarFlag(var, 'python', None, d) | ||
309 | data.setVarFlag(var, 'func', None, d) | ||
310 | |||
311 | for flag in [ "func", "python" ]: | ||
312 | if data.getVarFlag(calledvar, flag, d): | ||
313 | data.setVarFlag(var, flag, data.getVarFlag(calledvar, flag, d), d) | ||
314 | for flag in [ "dirs" ]: | ||
315 | if data.getVarFlag(var, flag, d): | ||
316 | data.setVarFlag(calledvar, flag, data.getVarFlag(var, flag, d), d) | ||
317 | |||
318 | if data.getVarFlag(calledvar, "python", d): | ||
319 | data.setVar(var, "\tbb.build.exec_func('" + calledvar + "', d)\n", d) | ||
320 | else: | ||
321 | data.setVar(var, "\t" + calledvar + "\n", d) | ||
322 | data.setVarFlag(var, 'export_func', '1', d) | ||
323 | |||
324 | return | 365 | return |
325 | 366 | ||
326 | m = __addtask_regexp__.match(s) | 367 | m = __addtask_regexp__.match(s) |
327 | if m: | 368 | if m: |
328 | func = m.group("func") | 369 | handleAddTask(m, d) |
329 | before = m.group("before") | ||
330 | after = m.group("after") | ||
331 | if func is None: | ||
332 | return | ||
333 | if func[:3] != "do_": | ||
334 | var = "do_" + func | ||
335 | |||
336 | data.setVarFlag(var, "task", 1, d) | ||
337 | |||
338 | bbtasks = data.getVar('__BBTASKS', d) or [] | ||
339 | if not var in bbtasks: | ||
340 | bbtasks.append(var) | ||
341 | data.setVar('__BBTASKS', bbtasks, d) | ||
342 | |||
343 | existing = data.getVarFlag(var, "deps", d) or [] | ||
344 | if after is not None: | ||
345 | # set up deps for function | ||
346 | for entry in after.split(): | ||
347 | if entry not in existing: | ||
348 | existing.append(entry) | ||
349 | data.setVarFlag(var, "deps", existing, d) | ||
350 | if before is not None: | ||
351 | # set up things that depend on this func | ||
352 | for entry in before.split(): | ||
353 | existing = data.getVarFlag(entry, "deps", d) or [] | ||
354 | if var not in existing: | ||
355 | data.setVarFlag(entry, "deps", [var] + existing, d) | ||
356 | return | 370 | return |
357 | 371 | ||
358 | m = __addhandler_regexp__.match(s) | 372 | m = __addhandler_regexp__.match(s) |
359 | if m: | 373 | if m: |
360 | fns = m.group(1) | 374 | handleBBHandlers(m, d) |
361 | hs = __word__.findall(fns) | ||
362 | bbhands = data.getVar('__BBHANDLERS', d) or [] | ||
363 | for h in hs: | ||
364 | bbhands.append(h) | ||
365 | data.setVarFlag(h, "handler", 1, d) | ||
366 | data.setVar('__BBHANDLERS', bbhands, d) | ||
367 | return | 375 | return |
368 | 376 | ||
369 | m = __inherit_regexp__.match(s) | 377 | m = __inherit_regexp__.match(s) |