diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2009-01-02 23:49:18 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2009-01-02 23:49:18 +0000 |
commit | 250b02115454d4754b734209daa45d894f76039e (patch) | |
tree | c108ce8c79b6a33cbc7d6adaeb99deb689166e61 /bitbake-dev/lib/bb | |
parent | bb802877629316f80069aea8731c258ee203e5a7 (diff) | |
download | poky-250b02115454d4754b734209daa45d894f76039e.tar.gz |
bitbake/BBHandler.py: Move handler finalisation code into a separate function
Diffstat (limited to 'bitbake-dev/lib/bb')
-rw-r--r-- | bitbake-dev/lib/bb/parse/parse_py/BBHandler.py | 92 |
1 files changed, 35 insertions, 57 deletions
diff --git a/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py b/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py index e9b950acbd..00ad6ef4fe 100644 --- a/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py | |||
@@ -76,6 +76,40 @@ def inherit(files, d): | |||
76 | include(fn, file, d, "inherit") | 76 | include(fn, file, d, "inherit") |
77 | __inherit_cache = data.getVar('__inherit_cache', d) or [] | 77 | __inherit_cache = data.getVar('__inherit_cache', d) or [] |
78 | 78 | ||
79 | |||
80 | def finalise(fn, d): | ||
81 | data.expandKeys(d) | ||
82 | data.update_data(d) | ||
83 | anonqueue = data.getVar("__anonqueue", d, 1) or [] | ||
84 | body = [x['content'] for x in anonqueue] | ||
85 | flag = { 'python' : 1, 'func' : 1 } | ||
86 | data.setVar("__anonfunc", "\n".join(body), d) | ||
87 | data.setVarFlags("__anonfunc", flag, d) | ||
88 | from bb import build | ||
89 | try: | ||
90 | t = data.getVar('T', d) | ||
91 | data.setVar('T', '${TMPDIR}/anonfunc/', d) | ||
92 | build.exec_func("__anonfunc", d) | ||
93 | data.delVar('T', d) | ||
94 | if t: | ||
95 | data.setVar('T', t, d) | ||
96 | except Exception, e: | ||
97 | bb.msg.debug(1, bb.msg.domain.Parsing, "Exception when executing anonymous function: %s" % e) | ||
98 | raise | ||
99 | data.delVar("__anonqueue", d) | ||
100 | data.delVar("__anonfunc", d) | ||
101 | data.update_data(d) | ||
102 | |||
103 | all_handlers = {} | ||
104 | for var in data.getVar('__BBHANDLERS', d) or []: | ||
105 | # try to add the handler | ||
106 | handler = data.getVar(var,d) | ||
107 | bb.event.register(var, handler) | ||
108 | |||
109 | tasklist = data.getVar('__BBTASKS', d) or [] | ||
110 | bb.build.add_tasks(tasklist, d) | ||
111 | |||
112 | |||
79 | def handle(fn, d, include = 0): | 113 | def handle(fn, d, include = 0): |
80 | global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__ | 114 | global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__ |
81 | __body__ = [] | 115 | __body__ = [] |
@@ -147,37 +181,7 @@ def handle(fn, d, include = 0): | |||
147 | classes.remove(__classname__) | 181 | classes.remove(__classname__) |
148 | else: | 182 | else: |
149 | if include == 0: | 183 | if include == 0: |
150 | data.expandKeys(d) | 184 | finalise(fn, d) |
151 | data.update_data(d) | ||
152 | anonqueue = data.getVar("__anonqueue", d, 1) or [] | ||
153 | body = [x['content'] for x in anonqueue] | ||
154 | flag = { 'python' : 1, 'func' : 1 } | ||
155 | data.setVar("__anonfunc", "\n".join(body), d) | ||
156 | data.setVarFlags("__anonfunc", flag, d) | ||
157 | from bb import build | ||
158 | try: | ||
159 | t = data.getVar('T', d) | ||
160 | data.setVar('T', '${TMPDIR}/anonfunc/', d) | ||
161 | build.exec_func("__anonfunc", d) | ||
162 | data.delVar('T', d) | ||
163 | if t: | ||
164 | data.setVar('T', t, d) | ||
165 | except Exception, e: | ||
166 | bb.msg.debug(1, bb.msg.domain.Parsing, "Exception when executing anonymous function: %s" % e) | ||
167 | raise | ||
168 | data.delVar("__anonqueue", d) | ||
169 | data.delVar("__anonfunc", d) | ||
170 | set_additional_vars(fn, d, include) | ||
171 | data.update_data(d) | ||
172 | |||
173 | all_handlers = {} | ||
174 | for var in data.getVar('__BBHANDLERS', d) or []: | ||
175 | # try to add the handler | ||
176 | handler = data.getVar(var,d) | ||
177 | bb.event.register(var, handler) | ||
178 | |||
179 | tasklist = data.getVar('__BBTASKS', d) or [] | ||
180 | bb.build.add_tasks(tasklist, d) | ||
181 | 185 | ||
182 | bbpath.pop(0) | 186 | bbpath.pop(0) |
183 | if oldfile: | 187 | if oldfile: |
@@ -384,32 +388,6 @@ def vars_from_file(mypkg, d): | |||
384 | parts.extend(tmplist) | 388 | parts.extend(tmplist) |
385 | return parts | 389 | return parts |
386 | 390 | ||
387 | def set_additional_vars(file, d, include): | ||
388 | """Deduce rest of variables, e.g. ${A} out of ${SRC_URI}""" | ||
389 | |||
390 | return | ||
391 | # Nothing seems to use this variable | ||
392 | #bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s: set_additional_vars" % file) | ||
393 | |||
394 | #src_uri = data.getVar('SRC_URI', d, 1) | ||
395 | #if not src_uri: | ||
396 | # return | ||
397 | |||
398 | #a = (data.getVar('A', d, 1) or '').split() | ||
399 | |||
400 | #from bb import fetch | ||
401 | #try: | ||
402 | # ud = fetch.init(src_uri.split(), d) | ||
403 | # a += fetch.localpaths(d, ud) | ||
404 | #except fetch.NoMethodError: | ||
405 | # pass | ||
406 | #except bb.MalformedUrl,e: | ||
407 | # raise ParseError("Unable to generate local paths for SRC_URI due to malformed uri: %s" % e) | ||
408 | #del fetch | ||
409 | |||
410 | #data.setVar('A', " ".join(a), d) | ||
411 | |||
412 | |||
413 | # Add us to the handlers list | 391 | # Add us to the handlers list |
414 | from bb.parse import handlers | 392 | from bb.parse import handlers |
415 | handlers.append({'supports': supports, 'handle': handle, 'init': init}) | 393 | handlers.append({'supports': supports, 'handle': handle, 'init': init}) |