diff options
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/parse/__init__.py | 8 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 114 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 31 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 18 |
4 files changed, 92 insertions, 79 deletions
diff --git a/bitbake/lib/bb/parse/__init__.py b/bitbake/lib/bb/parse/__init__.py index c6a925c7a8..f97233fc2b 100644 --- a/bitbake/lib/bb/parse/__init__.py +++ b/bitbake/lib/bb/parse/__init__.py | |||
@@ -68,11 +68,15 @@ def supports(fn, data): | |||
68 | return 1 | 68 | return 1 |
69 | return 0 | 69 | return 0 |
70 | 70 | ||
71 | def handle(fn, data, include = 0): | 71 | def handle(fn, data, include = 0, statements = None): |
72 | """Call the handler that is appropriate for this file""" | 72 | """Call the handler that is appropriate for this file""" |
73 | if not statements: | ||
74 | import ast | ||
75 | statements = ast.StatementGroup() | ||
76 | |||
73 | for h in handlers: | 77 | for h in handlers: |
74 | if h['supports'](fn, data): | 78 | if h['supports'](fn, data): |
75 | return h['handle'](fn, data, include) | 79 | return h['handle'](fn, data, include, statements) |
76 | raise ParseError("%s is not a BitBake file" % fn) | 80 | raise ParseError("%s is not a BitBake file" % fn) |
77 | 81 | ||
78 | def init(fn, data): | 82 | def init(fn, data): |
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 032b4961ba..8e7ba7fde8 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -21,23 +21,33 @@ | |||
21 | # with this program; if not, write to the Free Software Foundation, Inc., | 21 | # with this program; if not, write to the Free Software Foundation, Inc., |
22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
23 | 23 | ||
24 | import bb, re | 24 | import bb, re, string |
25 | 25 | ||
26 | __word__ = re.compile(r"\S+") | 26 | __word__ = re.compile(r"\S+") |
27 | __parsed_methods__ = methodpool.get_parsed_dict() | 27 | __parsed_methods__ = bb.methodpool.get_parsed_dict() |
28 | 28 | ||
29 | def handleInclude(m, fn, lineno, data, force): | 29 | class StatementGroup: |
30 | def __init__(self): | ||
31 | self.statements = [] | ||
32 | |||
33 | def eval(self, data): | ||
34 | """ | ||
35 | Apply each statement on the data... in order | ||
36 | """ | ||
37 | map(lambda x: x.eval(data), self.statements) | ||
38 | |||
39 | def handleInclude(statements, m, fn, lineno, data, force): | ||
30 | s = bb.data.expand(m.group(1), data) | 40 | s = bb.data.expand(m.group(1), data) |
31 | bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s)) | 41 | bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s)) |
32 | if force: | 42 | if force: |
33 | include(fn, s, data, "include required") | 43 | bb.parse.ConfHandler.include(statements, fn, s, data, "include required") |
34 | else: | 44 | else: |
35 | include(fn, s, data, False) | 45 | bb.parse.ConfHandler.include(statements, fn, s, data, False) |
36 | 46 | ||
37 | def handleExport(m, data): | 47 | def handleExport(statements, m, data): |
38 | bb.data.setVarFlag(m.group(1), "export", 1, data) | 48 | bb.data.setVarFlag(m.group(1), "export", 1, data) |
39 | 49 | ||
40 | def handleData(groupd, data): | 50 | def handleData(statements, groupd, data): |
41 | key = groupd["var"] | 51 | key = groupd["var"] |
42 | if "exp" in groupd and groupd["exp"] != None: | 52 | if "exp" in groupd and groupd["exp"] != None: |
43 | bb.data.setVarFlag(key, "export", 1, data) | 53 | bb.data.setVarFlag(key, "export", 1, data) |
@@ -71,45 +81,43 @@ def getFunc(groupd, key, data): | |||
71 | else: | 81 | else: |
72 | return bb.data.getVar(key, data) | 82 | return bb.data.getVar(key, data) |
73 | 83 | ||
74 | def handleMethod(func_name, lineno, fn, body, d): | 84 | def handleMethod(statements, func_name, lineno, fn, body, d): |
75 | if func_name == "__anonymous": | 85 | if func_name == "__anonymous": |
76 | funcname = ("__anon_%s_%s" % (lineno, fn.translate(string.maketrans('/.+-', '____')))) | 86 | funcname = ("__anon_%s_%s" % (lineno, fn.translate(string.maketrans('/.+-', '____')))) |
77 | if not funcname in methodpool._parsed_fns: | 87 | if not funcname in bb.methodpool._parsed_fns: |
78 | text = "def %s(d):\n" % (funcname) + '\n'.join(body) | 88 | text = "def %s(d):\n" % (funcname) + '\n'.join(body) |
79 | methodpool.insert_method(funcname, text, fn) | 89 | bb.methodpool.insert_method(funcname, text, fn) |
80 | anonfuncs = data.getVar('__BBANONFUNCS', d) or [] | 90 | anonfuncs = bb.data.getVar('__BBANONFUNCS', d) or [] |
81 | anonfuncs.append(funcname) | 91 | anonfuncs.append(funcname) |
82 | data.setVar('__BBANONFUNCS', anonfuncs, d) | 92 | bb.data.setVar('__BBANONFUNCS', anonfuncs, d) |
83 | else: | 93 | else: |
84 | data.setVarFlag(func_name, "func", 1, d) | 94 | bb.data.setVarFlag(func_name, "func", 1, d) |
85 | data.setVar(func_name, '\n'.join(body), d) | 95 | bb.data.setVar(func_name, '\n'.join(body), d) |
86 | |||
87 | |||
88 | 96 | ||
89 | def handlePythonMethod(root, body, fn): | 97 | def handlePythonMethod(statements, root, body, fn): |
90 | # Note we will add root to parsedmethods after having parse | 98 | # Note we will add root to parsedmethods after having parse |
91 | # 'this' file. This means we will not parse methods from | 99 | # 'this' file. This means we will not parse methods from |
92 | # bb classes twice | 100 | # bb classes twice |
93 | if not root in __parsed_methods__: | 101 | if not root in __parsed_methods__: |
94 | text = '\n'.join(body) | 102 | text = '\n'.join(body) |
95 | methodpool.insert_method(root, text, fn) | 103 | bb.methodpool.insert_method(root, text, fn) |
96 | 104 | ||
97 | def handleMethodFlags(key, m, d): | 105 | def handleMethodFlags(statements, key, m, d): |
98 | if data.getVar(key, d): | 106 | if bb.data.getVar(key, d): |
99 | # Clean up old version of this piece of metadata, as its | 107 | # Clean up old version of this piece of metadata, as its |
100 | # flags could cause problems | 108 | # flags could cause problems |
101 | data.setVarFlag(key, 'python', None, d) | 109 | bb.data.setVarFlag(key, 'python', None, d) |
102 | data.setVarFlag(key, 'fakeroot', None, d) | 110 | bb.data.setVarFlag(key, 'fakeroot', None, d) |
103 | if m.group("py") is not None: | 111 | if m.group("py") is not None: |
104 | data.setVarFlag(key, "python", "1", d) | 112 | bb.data.setVarFlag(key, "python", "1", d) |
105 | else: | 113 | else: |
106 | data.delVarFlag(key, "python", d) | 114 | bb.data.delVarFlag(key, "python", d) |
107 | if m.group("fr") is not None: | 115 | if m.group("fr") is not None: |
108 | data.setVarFlag(key, "fakeroot", "1", d) | 116 | bb.data.setVarFlag(key, "fakeroot", "1", d) |
109 | else: | 117 | else: |
110 | data.delVarFlag(key, "fakeroot", d) | 118 | bb.data.delVarFlag(key, "fakeroot", d) |
111 | 119 | ||
112 | def handleExportFuncs(m, d): | 120 | def handleExportFuncs(statements, m, classes, d): |
113 | fns = m.group(1) | 121 | fns = m.group(1) |
114 | n = __word__.findall(fns) | 122 | n = __word__.findall(fns) |
115 | for f in n: | 123 | for f in n: |
@@ -125,27 +133,27 @@ def handleExportFuncs(m, d): | |||
125 | vars.append([allvars[0], allvars[2]]) | 133 | vars.append([allvars[0], allvars[2]]) |
126 | 134 | ||
127 | for (var, calledvar) in vars: | 135 | for (var, calledvar) in vars: |
128 | if data.getVar(var, d) and not data.getVarFlag(var, 'export_func', d): | 136 | if bb.data.getVar(var, d) and not bb.data.getVarFlag(var, 'export_func', d): |
129 | continue | 137 | continue |
130 | 138 | ||
131 | if data.getVar(var, d): | 139 | if bb.data.getVar(var, d): |
132 | data.setVarFlag(var, 'python', None, d) | 140 | bb.data.setVarFlag(var, 'python', None, d) |
133 | data.setVarFlag(var, 'func', None, d) | 141 | bb.data.setVarFlag(var, 'func', None, d) |
134 | 142 | ||
135 | for flag in [ "func", "python" ]: | 143 | for flag in [ "func", "python" ]: |
136 | if data.getVarFlag(calledvar, flag, d): | 144 | if bb.data.getVarFlag(calledvar, flag, d): |
137 | data.setVarFlag(var, flag, data.getVarFlag(calledvar, flag, d), d) | 145 | bb.data.setVarFlag(var, flag, bb.data.getVarFlag(calledvar, flag, d), d) |
138 | for flag in [ "dirs" ]: | 146 | for flag in [ "dirs" ]: |
139 | if data.getVarFlag(var, flag, d): | 147 | if bb.data.getVarFlag(var, flag, d): |
140 | data.setVarFlag(calledvar, flag, data.getVarFlag(var, flag, d), d) | 148 | bb.data.setVarFlag(calledvar, flag, bb.data.getVarFlag(var, flag, d), d) |
141 | 149 | ||
142 | if data.getVarFlag(calledvar, "python", d): | 150 | if bb.data.getVarFlag(calledvar, "python", d): |
143 | data.setVar(var, "\tbb.build.exec_func('" + calledvar + "', d)\n", d) | 151 | bb.data.setVar(var, "\tbb.build.exec_func('" + calledvar + "', d)\n", d) |
144 | else: | 152 | else: |
145 | data.setVar(var, "\t" + calledvar + "\n", d) | 153 | bb.data.setVar(var, "\t" + calledvar + "\n", d) |
146 | data.setVarFlag(var, 'export_func', '1', d) | 154 | bb.data.setVarFlag(var, 'export_func', '1', d) |
147 | 155 | ||
148 | def handleAddTask(m, d): | 156 | def handleAddTask(statements, m, d): |
149 | func = m.group("func") | 157 | func = m.group("func") |
150 | before = m.group("before") | 158 | before = m.group("before") |
151 | after = m.group("after") | 159 | after = m.group("after") |
@@ -154,38 +162,38 @@ def handleAddTask(m, d): | |||
154 | if func[:3] != "do_": | 162 | if func[:3] != "do_": |
155 | var = "do_" + func | 163 | var = "do_" + func |
156 | 164 | ||
157 | data.setVarFlag(var, "task", 1, d) | 165 | bb.data.setVarFlag(var, "task", 1, d) |
158 | 166 | ||
159 | bbtasks = data.getVar('__BBTASKS', d) or [] | 167 | bbtasks = bb.data.getVar('__BBTASKS', d) or [] |
160 | if not var in bbtasks: | 168 | if not var in bbtasks: |
161 | bbtasks.append(var) | 169 | bbtasks.append(var) |
162 | data.setVar('__BBTASKS', bbtasks, d) | 170 | bb.data.setVar('__BBTASKS', bbtasks, d) |
163 | 171 | ||
164 | existing = data.getVarFlag(var, "deps", d) or [] | 172 | existing = bb.data.getVarFlag(var, "deps", d) or [] |
165 | if after is not None: | 173 | if after is not None: |
166 | # set up deps for function | 174 | # set up deps for function |
167 | for entry in after.split(): | 175 | for entry in after.split(): |
168 | if entry not in existing: | 176 | if entry not in existing: |
169 | existing.append(entry) | 177 | existing.append(entry) |
170 | data.setVarFlag(var, "deps", existing, d) | 178 | bb.data.setVarFlag(var, "deps", existing, d) |
171 | if before is not None: | 179 | if before is not None: |
172 | # set up things that depend on this func | 180 | # set up things that depend on this func |
173 | for entry in before.split(): | 181 | for entry in before.split(): |
174 | existing = data.getVarFlag(entry, "deps", d) or [] | 182 | existing = bb.data.getVarFlag(entry, "deps", d) or [] |
175 | if var not in existing: | 183 | if var not in existing: |
176 | data.setVarFlag(entry, "deps", [var] + existing, d) | 184 | bb.data.setVarFlag(entry, "deps", [var] + existing, d) |
177 | 185 | ||
178 | def handleBBHandlers(m, d): | 186 | def handleBBHandlers(statements, m, d): |
179 | fns = m.group(1) | 187 | fns = m.group(1) |
180 | hs = __word__.findall(fns) | 188 | hs = __word__.findall(fns) |
181 | bbhands = data.getVar('__BBHANDLERS', d) or [] | 189 | bbhands = bb.data.getVar('__BBHANDLERS', d) or [] |
182 | for h in hs: | 190 | for h in hs: |
183 | bbhands.append(h) | 191 | bbhands.append(h) |
184 | data.setVarFlag(h, "handler", 1, d) | 192 | bb.data.setVarFlag(h, "handler", 1, d) |
185 | data.setVar('__BBHANDLERS', bbhands, d) | 193 | bb.data.setVar('__BBHANDLERS', bbhands, d) |
186 | 194 | ||
187 | def handleInherit(m, d): | 195 | def handleInherit(statements, m, d): |
188 | files = m.group(1) | 196 | files = m.group(1) |
189 | n = __word__.findall(files) | 197 | n = __word__.findall(files) |
190 | inherit(n, d) | 198 | bb.parse.BBHandler.inherit(statements, n, d) |
191 | 199 | ||
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 1343ec114f..46413c5dc3 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py | |||
@@ -59,7 +59,7 @@ IN_PYTHON_EOF = -9999999999999 | |||
59 | def supports(fn, d): | 59 | def supports(fn, d): |
60 | return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" | 60 | return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" |
61 | 61 | ||
62 | def inherit(files, d): | 62 | def inherit(statements, files, d): |
63 | __inherit_cache = data.getVar('__inherit_cache', d) or [] | 63 | __inherit_cache = data.getVar('__inherit_cache', d) or [] |
64 | fn = "" | 64 | fn = "" |
65 | lineno = 0 | 65 | lineno = 0 |
@@ -72,7 +72,7 @@ def inherit(files, d): | |||
72 | bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file)) | 72 | bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file)) |
73 | __inherit_cache.append( file ) | 73 | __inherit_cache.append( file ) |
74 | data.setVar('__inherit_cache', __inherit_cache, d) | 74 | data.setVar('__inherit_cache', __inherit_cache, d) |
75 | include(fn, file, d, "inherit") | 75 | include(statements, fn, file, d, "inherit") |
76 | __inherit_cache = data.getVar('__inherit_cache', d) or [] | 76 | __inherit_cache = data.getVar('__inherit_cache', d) or [] |
77 | 77 | ||
78 | 78 | ||
@@ -116,13 +116,14 @@ def finalise(fn, d): | |||
116 | bb.event.fire(bb.event.RecipeParsed(fn), d) | 116 | bb.event.fire(bb.event.RecipeParsed(fn), d) |
117 | 117 | ||
118 | 118 | ||
119 | def handle(fn, d, include = 0): | 119 | def handle(fn, d, include, statements): |
120 | global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__ | 120 | global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__ |
121 | __body__ = [] | 121 | __body__ = [] |
122 | __infunc__ = "" | 122 | __infunc__ = "" |
123 | __classname__ = "" | 123 | __classname__ = "" |
124 | __residue__ = [] | 124 | __residue__ = [] |
125 | 125 | ||
126 | |||
126 | if include == 0: | 127 | if include == 0: |
127 | bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data)") | 128 | bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data)") |
128 | else: | 129 | else: |
@@ -159,10 +160,10 @@ def handle(fn, d, include = 0): | |||
159 | s = f.readline() | 160 | s = f.readline() |
160 | if not s: break | 161 | if not s: break |
161 | s = s.rstrip() | 162 | s = s.rstrip() |
162 | feeder(lineno, s, fn, base_name, d) | 163 | feeder(lineno, s, fn, base_name, d, statements) |
163 | if __inpython__: | 164 | if __inpython__: |
164 | # add a blank line to close out any python definition | 165 | # add a blank line to close out any python definition |
165 | feeder(IN_PYTHON_EOF, "", fn, base_name, d) | 166 | feeder(IN_PYTHON_EOF, "", fn, base_name, d, statements) |
166 | if ext == ".bbclass": | 167 | if ext == ".bbclass": |
167 | classes.remove(__classname__) | 168 | classes.remove(__classname__) |
168 | else: | 169 | else: |
@@ -182,7 +183,7 @@ def handle(fn, d, include = 0): | |||
182 | pn = data.getVar('PN', d, True) | 183 | pn = data.getVar('PN', d, True) |
183 | based = bb.data.createCopy(d) | 184 | based = bb.data.createCopy(d) |
184 | data.setVar('PN', pn + '-' + cls, based) | 185 | data.setVar('PN', pn + '-' + cls, based) |
185 | inherit([cls], based) | 186 | inherit(statements, [cls], based) |
186 | try: | 187 | try: |
187 | finalise(fn, based) | 188 | finalise(fn, based) |
188 | except bb.parse.SkipPackage: | 189 | except bb.parse.SkipPackage: |
@@ -199,12 +200,12 @@ def handle(fn, d, include = 0): | |||
199 | 200 | ||
200 | return d | 201 | return d |
201 | 202 | ||
202 | def feeder(lineno, s, fn, root, d): | 203 | def feeder(lineno, s, fn, root, d, statements): |
203 | global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__,__infunc__, __body__, classes, bb, __residue__ | 204 | global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__,__infunc__, __body__, classes, bb, __residue__ |
204 | if __infunc__: | 205 | if __infunc__: |
205 | if s == '}': | 206 | if s == '}': |
206 | __body__.append('') | 207 | __body__.append('') |
207 | ast.handleMethod(__infunc__, __body__, d) | 208 | ast.handleMethod(statements, __infunc__, lineno, fn, __body__, d) |
208 | __infunc__ = "" | 209 | __infunc__ = "" |
209 | __body__ = [] | 210 | __body__ = [] |
210 | else: | 211 | else: |
@@ -217,7 +218,7 @@ def feeder(lineno, s, fn, root, d): | |||
217 | __body__.append(s) | 218 | __body__.append(s) |
218 | return | 219 | return |
219 | else: | 220 | else: |
220 | ast.handlePythonMethod(root, __body__, fn) | 221 | ast.handlePythonMethod(statements, root, __body__, fn) |
221 | __body__ = [] | 222 | __body__ = [] |
222 | __inpython__ = False | 223 | __inpython__ = False |
223 | 224 | ||
@@ -238,7 +239,7 @@ def feeder(lineno, s, fn, root, d): | |||
238 | m = __func_start_regexp__.match(s) | 239 | m = __func_start_regexp__.match(s) |
239 | if m: | 240 | if m: |
240 | __infunc__ = m.group("func") or "__anonymous" | 241 | __infunc__ = m.group("func") or "__anonymous" |
241 | ast.handleMethodFlags(__infunc__, m, d) | 242 | ast.handleMethodFlags(statements, __infunc__, m, d) |
242 | return | 243 | return |
243 | 244 | ||
244 | m = __def_regexp__.match(s) | 245 | m = __def_regexp__.match(s) |
@@ -249,26 +250,26 @@ def feeder(lineno, s, fn, root, d): | |||
249 | 250 | ||
250 | m = __export_func_regexp__.match(s) | 251 | m = __export_func_regexp__.match(s) |
251 | if m: | 252 | if m: |
252 | ast.handleExportFuncs(m, classes, d) | 253 | ast.handleExportFuncs(statements, m, classes, d) |
253 | return | 254 | return |
254 | 255 | ||
255 | m = __addtask_regexp__.match(s) | 256 | m = __addtask_regexp__.match(s) |
256 | if m: | 257 | if m: |
257 | ast.handleAddTask(m, d ) | 258 | ast.handleAddTask(statements, m, d) |
258 | return | 259 | return |
259 | 260 | ||
260 | m = __addhandler_regexp__.match(s) | 261 | m = __addhandler_regexp__.match(s) |
261 | if m: | 262 | if m: |
262 | ast.handleBBHandlers(m, d) | 263 | ast.handleBBHandlers(statements, m, d) |
263 | return | 264 | return |
264 | 265 | ||
265 | m = __inherit_regexp__.match(s) | 266 | m = __inherit_regexp__.match(s) |
266 | if m: | 267 | if m: |
267 | ast.handleInherit(m, d) | 268 | ast.handleInherit(statements, m, d) |
268 | return | 269 | return |
269 | 270 | ||
270 | from bb.parse import ConfHandler | 271 | from bb.parse import ConfHandler |
271 | return ConfHandler.feeder(lineno, s, fn, d) | 272 | return ConfHandler.feeder(lineno, s, fn, d, statements) |
272 | 273 | ||
273 | __pkgsplit_cache__={} | 274 | __pkgsplit_cache__={} |
274 | def vars_from_file(mypkg, d): | 275 | def vars_from_file(mypkg, d): |
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index 43a3a69bbb..69f2eea1b3 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py | |||
@@ -49,7 +49,7 @@ def init(data): | |||
49 | def supports(fn, d): | 49 | def supports(fn, d): |
50 | return fn[-5:] == ".conf" | 50 | return fn[-5:] == ".conf" |
51 | 51 | ||
52 | def include(oldfn, fn, data, error_out): | 52 | def include(statements, oldfn, fn, data, error_out): |
53 | """ | 53 | """ |
54 | 54 | ||
55 | error_out If True a ParseError will be reaised if the to be included | 55 | error_out If True a ParseError will be reaised if the to be included |
@@ -70,13 +70,13 @@ def include(oldfn, fn, data, error_out): | |||
70 | 70 | ||
71 | from bb.parse import handle | 71 | from bb.parse import handle |
72 | try: | 72 | try: |
73 | ret = handle(fn, data, True) | 73 | ret = handle(fn, data, True, statements) |
74 | except IOError: | 74 | except IOError: |
75 | if error_out: | 75 | if error_out: |
76 | raise ParseError("Could not %(error_out)s file %(fn)s" % vars() ) | 76 | raise ParseError("Could not %(error_out)s file %(fn)s" % vars() ) |
77 | bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn) | 77 | bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn) |
78 | 78 | ||
79 | def handle(fn, data, include = 0): | 79 | def handle(fn, data, include, statements): |
80 | init(data) | 80 | init(data) |
81 | 81 | ||
82 | if include == 0: | 82 | if include == 0: |
@@ -103,32 +103,32 @@ def handle(fn, data, include = 0): | |||
103 | s2 = f.readline()[:-1].strip() | 103 | s2 = f.readline()[:-1].strip() |
104 | lineno = lineno + 1 | 104 | lineno = lineno + 1 |
105 | s = s[:-1] + s2 | 105 | s = s[:-1] + s2 |
106 | feeder(lineno, s, fn, data) | 106 | feeder(lineno, s, fn, data, statements) |
107 | 107 | ||
108 | if oldfile: | 108 | if oldfile: |
109 | bb.data.setVar('FILE', oldfile, data) | 109 | bb.data.setVar('FILE', oldfile, data) |
110 | return data | 110 | return data |
111 | 111 | ||
112 | def feeder(lineno, s, fn, data): | 112 | def feeder(lineno, s, fn, data, statements): |
113 | m = __config_regexp__.match(s) | 113 | m = __config_regexp__.match(s) |
114 | if m: | 114 | if m: |
115 | groupd = m.groupdict() | 115 | groupd = m.groupdict() |
116 | ast.handleData(groupd, data) | 116 | ast.handleData(statements, groupd, data) |
117 | return | 117 | return |
118 | 118 | ||
119 | m = __include_regexp__.match(s) | 119 | m = __include_regexp__.match(s) |
120 | if m: | 120 | if m: |
121 | ast.handleInclude(m, fn, lineno, data, False) | 121 | ast.handleInclude(statements, m, fn, lineno, data, False) |
122 | return | 122 | return |
123 | 123 | ||
124 | m = __require_regexp__.match(s) | 124 | m = __require_regexp__.match(s) |
125 | if m: | 125 | if m: |
126 | ast.handleInclude(m, fn, lineno, data, True) | 126 | ast.handleInclude(statements, m, fn, lineno, data, True) |
127 | return | 127 | return |
128 | 128 | ||
129 | m = __export_regexp__.match(s) | 129 | m = __export_regexp__.match(s) |
130 | if m: | 130 | if m: |
131 | ast.handleExport(m, data) | 131 | ast.handleExport(statements, m, data) |
132 | return | 132 | return |
133 | 133 | ||
134 | raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); | 134 | raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); |