diff options
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 191 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 139 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 57 |
3 files changed, 207 insertions, 180 deletions
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py new file mode 100644 index 0000000000..032b4961ba --- /dev/null +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -0,0 +1,191 @@ | |||
1 | # ex:ts=4:sw=4:sts=4:et | ||
2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
3 | """ | ||
4 | AbstractSyntaxTree classes for the Bitbake language | ||
5 | """ | ||
6 | |||
7 | # Copyright (C) 2003, 2004 Chris Larson | ||
8 | # Copyright (C) 2003, 2004 Phil Blundell | ||
9 | # Copyright (C) 2009 Holger Hans Peter Freyther | ||
10 | # | ||
11 | # This program is free software; you can redistribute it and/or modify | ||
12 | # it under the terms of the GNU General Public License version 2 as | ||
13 | # published by the Free Software Foundation. | ||
14 | # | ||
15 | # This program is distributed in the hope that it will be useful, | ||
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | # GNU General Public License for more details. | ||
19 | # | ||
20 | # You should have received a copy of the GNU General Public License along | ||
21 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
22 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
23 | |||
24 | import bb, re | ||
25 | |||
26 | __word__ = re.compile(r"\S+") | ||
27 | __parsed_methods__ = methodpool.get_parsed_dict() | ||
28 | |||
29 | def handleInclude(m, fn, lineno, data, force): | ||
30 | 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)) | ||
32 | if force: | ||
33 | include(fn, s, data, "include required") | ||
34 | else: | ||
35 | include(fn, s, data, False) | ||
36 | |||
37 | def handleExport(m, data): | ||
38 | bb.data.setVarFlag(m.group(1), "export", 1, data) | ||
39 | |||
40 | def handleData(groupd, data): | ||
41 | key = groupd["var"] | ||
42 | if "exp" in groupd and groupd["exp"] != None: | ||
43 | bb.data.setVarFlag(key, "export", 1, data) | ||
44 | if "ques" in groupd and groupd["ques"] != None: | ||
45 | val = getFunc(groupd, key, data) | ||
46 | if val == None: | ||
47 | val = groupd["value"] | ||
48 | elif "colon" in groupd and groupd["colon"] != None: | ||
49 | e = data.createCopy() | ||
50 | bb.data.update_data(e) | ||
51 | val = bb.data.expand(groupd["value"], e) | ||
52 | elif "append" in groupd and groupd["append"] != None: | ||
53 | val = "%s %s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) | ||
54 | elif "prepend" in groupd and groupd["prepend"] != None: | ||
55 | val = "%s %s" % (groupd["value"], (getFunc(groupd, key, data) or "")) | ||
56 | elif "postdot" in groupd and groupd["postdot"] != None: | ||
57 | val = "%s%s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) | ||
58 | elif "predot" in groupd and groupd["predot"] != None: | ||
59 | val = "%s%s" % (groupd["value"], (getFunc(groupd, key, data) or "")) | ||
60 | else: | ||
61 | val = groupd["value"] | ||
62 | if 'flag' in groupd and groupd['flag'] != None: | ||
63 | bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val)) | ||
64 | bb.data.setVarFlag(key, groupd['flag'], val, data) | ||
65 | else: | ||
66 | bb.data.setVar(key, val, data) | ||
67 | |||
68 | def getFunc(groupd, key, data): | ||
69 | if 'flag' in groupd and groupd['flag'] != None: | ||
70 | return bb.data.getVarFlag(key, groupd['flag'], data) | ||
71 | else: | ||
72 | return bb.data.getVar(key, data) | ||
73 | |||
74 | def handleMethod(func_name, lineno, fn, body, d): | ||
75 | if func_name == "__anonymous": | ||
76 | funcname = ("__anon_%s_%s" % (lineno, fn.translate(string.maketrans('/.+-', '____')))) | ||
77 | if not funcname in methodpool._parsed_fns: | ||
78 | text = "def %s(d):\n" % (funcname) + '\n'.join(body) | ||
79 | methodpool.insert_method(funcname, text, fn) | ||
80 | anonfuncs = data.getVar('__BBANONFUNCS', d) or [] | ||
81 | anonfuncs.append(funcname) | ||
82 | data.setVar('__BBANONFUNCS', anonfuncs, d) | ||
83 | else: | ||
84 | data.setVarFlag(func_name, "func", 1, d) | ||
85 | data.setVar(func_name, '\n'.join(body), d) | ||
86 | |||
87 | |||
88 | |||
89 | def handlePythonMethod(root, body, fn): | ||
90 | # Note we will add root to parsedmethods after having parse | ||
91 | # 'this' file. This means we will not parse methods from | ||
92 | # bb classes twice | ||
93 | if not root in __parsed_methods__: | ||
94 | text = '\n'.join(body) | ||
95 | methodpool.insert_method(root, text, fn) | ||
96 | |||
97 | def handleMethodFlags(key, m, d): | ||
98 | if data.getVar(key, d): | ||
99 | # Clean up old version of this piece of metadata, as its | ||
100 | # flags could cause problems | ||
101 | data.setVarFlag(key, 'python', None, d) | ||
102 | data.setVarFlag(key, 'fakeroot', None, d) | ||
103 | if m.group("py") is not None: | ||
104 | data.setVarFlag(key, "python", "1", d) | ||
105 | else: | ||
106 | data.delVarFlag(key, "python", d) | ||
107 | if m.group("fr") is not None: | ||
108 | data.setVarFlag(key, "fakeroot", "1", d) | ||
109 | else: | ||
110 | data.delVarFlag(key, "fakeroot", d) | ||
111 | |||
112 | def handleExportFuncs(m, d): | ||
113 | fns = m.group(1) | ||
114 | n = __word__.findall(fns) | ||
115 | for f in n: | ||
116 | allvars = [] | ||
117 | allvars.append(f) | ||
118 | allvars.append(classes[-1] + "_" + f) | ||
119 | |||
120 | vars = [[ allvars[0], allvars[1] ]] | ||
121 | if len(classes) > 1 and classes[-2] is not None: | ||
122 | allvars.append(classes[-2] + "_" + f) | ||
123 | vars = [] | ||
124 | vars.append([allvars[2], allvars[1]]) | ||
125 | vars.append([allvars[0], allvars[2]]) | ||
126 | |||
127 | for (var, calledvar) in vars: | ||
128 | if data.getVar(var, d) and not data.getVarFlag(var, 'export_func', d): | ||
129 | continue | ||
130 | |||
131 | if data.getVar(var, d): | ||
132 | data.setVarFlag(var, 'python', None, d) | ||
133 | data.setVarFlag(var, 'func', None, d) | ||
134 | |||
135 | for flag in [ "func", "python" ]: | ||
136 | if data.getVarFlag(calledvar, flag, d): | ||
137 | data.setVarFlag(var, flag, data.getVarFlag(calledvar, flag, d), d) | ||
138 | for flag in [ "dirs" ]: | ||
139 | if data.getVarFlag(var, flag, d): | ||
140 | data.setVarFlag(calledvar, flag, data.getVarFlag(var, flag, d), d) | ||
141 | |||
142 | if data.getVarFlag(calledvar, "python", d): | ||
143 | data.setVar(var, "\tbb.build.exec_func('" + calledvar + "', d)\n", d) | ||
144 | else: | ||
145 | data.setVar(var, "\t" + calledvar + "\n", d) | ||
146 | data.setVarFlag(var, 'export_func', '1', d) | ||
147 | |||
148 | def handleAddTask(m, d): | ||
149 | func = m.group("func") | ||
150 | before = m.group("before") | ||
151 | after = m.group("after") | ||
152 | if func is None: | ||
153 | return | ||
154 | if func[:3] != "do_": | ||
155 | var = "do_" + func | ||
156 | |||
157 | data.setVarFlag(var, "task", 1, d) | ||
158 | |||
159 | bbtasks = data.getVar('__BBTASKS', d) or [] | ||
160 | if not var in bbtasks: | ||
161 | bbtasks.append(var) | ||
162 | data.setVar('__BBTASKS', bbtasks, d) | ||
163 | |||
164 | existing = data.getVarFlag(var, "deps", d) or [] | ||
165 | if after is not None: | ||
166 | # set up deps for function | ||
167 | for entry in after.split(): | ||
168 | if entry not in existing: | ||
169 | existing.append(entry) | ||
170 | data.setVarFlag(var, "deps", existing, d) | ||
171 | if before is not None: | ||
172 | # set up things that depend on this func | ||
173 | for entry in before.split(): | ||
174 | existing = data.getVarFlag(entry, "deps", d) or [] | ||
175 | if var not in existing: | ||
176 | data.setVarFlag(entry, "deps", [var] + existing, d) | ||
177 | |||
178 | def handleBBHandlers(m, d): | ||
179 | fns = m.group(1) | ||
180 | hs = __word__.findall(fns) | ||
181 | bbhands = data.getVar('__BBHANDLERS', d) or [] | ||
182 | for h in hs: | ||
183 | bbhands.append(h) | ||
184 | data.setVarFlag(h, "handler", 1, d) | ||
185 | data.setVar('__BBHANDLERS', bbhands, d) | ||
186 | |||
187 | def handleInherit(m, d): | ||
188 | files = m.group(1) | ||
189 | n = __word__.findall(files) | ||
190 | inherit(n, d) | ||
191 | |||
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 76deb6b453..1343ec114f 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py | |||
@@ -27,10 +27,10 @@ | |||
27 | 27 | ||
28 | import re, bb, os, sys, time, string | 28 | import re, bb, os, sys, time, string |
29 | import bb.fetch, bb.build, bb.utils | 29 | import bb.fetch, bb.build, bb.utils |
30 | from bb import data, fetch, methodpool | 30 | from bb import data, fetch |
31 | 31 | ||
32 | from ConfHandler import include, init | 32 | from ConfHandler import include, init |
33 | from bb.parse import ParseError, resolve_file | 33 | from bb.parse import ParseError, resolve_file, ast |
34 | 34 | ||
35 | __func_start_regexp__ = re.compile( r"(((?P<py>python)|(?P<fr>fakeroot))\s*)*(?P<func>[\w\.\-\+\{\}\$]+)?\s*\(\s*\)\s*{$" ) | 35 | __func_start_regexp__ = re.compile( r"(((?P<py>python)|(?P<fr>fakeroot))\s*)*(?P<func>[\w\.\-\+\{\}\$]+)?\s*\(\s*\)\s*{$" ) |
36 | __inherit_regexp__ = re.compile( r"inherit\s+(.+)" ) | 36 | __inherit_regexp__ = re.compile( r"inherit\s+(.+)" ) |
@@ -39,7 +39,7 @@ __addtask_regexp__ = re.compile("addtask\s+(?P<func>\w+)\s*((before\s*(?P< | |||
39 | __addhandler_regexp__ = re.compile( r"addhandler\s+(.+)" ) | 39 | __addhandler_regexp__ = re.compile( r"addhandler\s+(.+)" ) |
40 | __def_regexp__ = re.compile( r"def\s+(\w+).*:" ) | 40 | __def_regexp__ = re.compile( r"def\s+(\w+).*:" ) |
41 | __python_func_regexp__ = re.compile( r"(\s+.*)|(^$)" ) | 41 | __python_func_regexp__ = re.compile( r"(\s+.*)|(^$)" ) |
42 | __word__ = re.compile(r"\S+") | 42 | |
43 | 43 | ||
44 | __infunc__ = "" | 44 | __infunc__ = "" |
45 | __inpython__ = False | 45 | __inpython__ = False |
@@ -54,124 +54,7 @@ classes = [ None, ] | |||
54 | # The two parts using it are tightly integrated anyway | 54 | # The two parts using it are tightly integrated anyway |
55 | IN_PYTHON_EOF = -9999999999999 | 55 | IN_PYTHON_EOF = -9999999999999 |
56 | 56 | ||
57 | __parsed_methods__ = methodpool.get_parsed_dict() | ||
58 | 57 | ||
59 | # parsing routines, to be moved into AST classes | ||
60 | def handleMethod(func_name, lineno, fn, body, d): | ||
61 | if func_name == "__anonymous": | ||
62 | funcname = ("__anon_%s_%s" % (lineno, fn.translate(string.maketrans('/.+-', '____')))) | ||
63 | if not funcname in methodpool._parsed_fns: | ||
64 | text = "def %s(d):\n" % (funcname) + '\n'.join(body) | ||
65 | methodpool.insert_method(funcname, text, fn) | ||
66 | anonfuncs = data.getVar('__BBANONFUNCS', d) or [] | ||
67 | anonfuncs.append(funcname) | ||
68 | data.setVar('__BBANONFUNCS', anonfuncs, d) | ||
69 | else: | ||
70 | data.setVarFlag(func_name, "func", 1, d) | ||
71 | data.setVar(func_name, '\n'.join(body), d) | ||
72 | |||
73 | def handlePythonMethod(root, body, fn): | ||
74 | # Note we will add root to parsedmethods after having parse | ||
75 | # 'this' file. This means we will not parse methods from | ||
76 | # bb classes twice | ||
77 | if not root in __parsed_methods__: | ||
78 | text = '\n'.join(body) | ||
79 | methodpool.insert_method(root, text, fn) | ||
80 | |||
81 | def handleMethodFlags(key, m, d): | ||
82 | if data.getVar(key, d): | ||
83 | # Clean up old version of this piece of metadata, as its | ||
84 | # flags could cause problems | ||
85 | data.setVarFlag(key, 'python', None, d) | ||
86 | data.setVarFlag(key, 'fakeroot', None, d) | ||
87 | if m.group("py") is not None: | ||
88 | data.setVarFlag(key, "python", "1", d) | ||
89 | else: | ||
90 | data.delVarFlag(key, "python", d) | ||
91 | if m.group("fr") is not None: | ||
92 | data.setVarFlag(key, "fakeroot", "1", d) | ||
93 | else: | ||
94 | data.delVarFlag(key, "fakeroot", d) | ||
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 | |||
171 | def handleInherit(m, d): | ||
172 | files = m.group(1) | ||
173 | n = __word__.findall(files) | ||
174 | inherit(n, d) | ||
175 | 58 | ||
176 | def supports(fn, d): | 59 | def supports(fn, d): |
177 | 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" |
@@ -312,7 +195,7 @@ def handle(fn, d, include = 0): | |||
312 | 195 | ||
313 | # we have parsed the bb class now | 196 | # we have parsed the bb class now |
314 | if ext == ".bbclass" or ext == ".inc": | 197 | if ext == ".bbclass" or ext == ".inc": |
315 | __parsed_methods__[base_name] = 1 | 198 | bb.methodpool.get_parsed_dict()[base_name] = 1 |
316 | 199 | ||
317 | return d | 200 | return d |
318 | 201 | ||
@@ -321,7 +204,7 @@ def feeder(lineno, s, fn, root, d): | |||
321 | if __infunc__: | 204 | if __infunc__: |
322 | if s == '}': | 205 | if s == '}': |
323 | __body__.append('') | 206 | __body__.append('') |
324 | handleMethod(__infunc__, lineno, fn, __body__, d) | 207 | ast.handleMethod(__infunc__, __body__, d) |
325 | __infunc__ = "" | 208 | __infunc__ = "" |
326 | __body__ = [] | 209 | __body__ = [] |
327 | else: | 210 | else: |
@@ -334,7 +217,7 @@ def feeder(lineno, s, fn, root, d): | |||
334 | __body__.append(s) | 217 | __body__.append(s) |
335 | return | 218 | return |
336 | else: | 219 | else: |
337 | handlePythonMethod(root, __body__, fn) | 220 | ast.handlePythonMethod(root, __body__, fn) |
338 | __body__ = [] | 221 | __body__ = [] |
339 | __inpython__ = False | 222 | __inpython__ = False |
340 | 223 | ||
@@ -355,7 +238,7 @@ def feeder(lineno, s, fn, root, d): | |||
355 | m = __func_start_regexp__.match(s) | 238 | m = __func_start_regexp__.match(s) |
356 | if m: | 239 | if m: |
357 | __infunc__ = m.group("func") or "__anonymous" | 240 | __infunc__ = m.group("func") or "__anonymous" |
358 | handleMethodFlags(__infunc__, m, d) | 241 | ast.handleMethodFlags(__infunc__, m, d) |
359 | return | 242 | return |
360 | 243 | ||
361 | m = __def_regexp__.match(s) | 244 | m = __def_regexp__.match(s) |
@@ -366,22 +249,22 @@ def feeder(lineno, s, fn, root, d): | |||
366 | 249 | ||
367 | m = __export_func_regexp__.match(s) | 250 | m = __export_func_regexp__.match(s) |
368 | if m: | 251 | if m: |
369 | handleExportFuncs(m, d) | 252 | ast.handleExportFuncs(m, classes, d) |
370 | return | 253 | return |
371 | 254 | ||
372 | m = __addtask_regexp__.match(s) | 255 | m = __addtask_regexp__.match(s) |
373 | if m: | 256 | if m: |
374 | handleAddTask(m, d) | 257 | ast.handleAddTask(m, d ) |
375 | return | 258 | return |
376 | 259 | ||
377 | m = __addhandler_regexp__.match(s) | 260 | m = __addhandler_regexp__.match(s) |
378 | if m: | 261 | if m: |
379 | handleBBHandlers(m, d) | 262 | ast.handleBBHandlers(m, d) |
380 | return | 263 | return |
381 | 264 | ||
382 | m = __inherit_regexp__.match(s) | 265 | m = __inherit_regexp__.match(s) |
383 | if m: | 266 | if m: |
384 | handleInherit(m, d) | 267 | ast.handleInherit(m, d) |
385 | return | 268 | return |
386 | 269 | ||
387 | from bb.parse import ConfHandler | 270 | from bb.parse import ConfHandler |
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index 86d052a7c3..43a3a69bbb 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py | |||
@@ -25,7 +25,7 @@ | |||
25 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 25 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
26 | 26 | ||
27 | import re, bb.data, os, sys | 27 | import re, bb.data, os, sys |
28 | from bb.parse import ParseError, resolve_file | 28 | from bb.parse import ParseError, resolve_file, ast |
29 | 29 | ||
30 | #__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}]+)\s*(?P<colon>:)?(?P<ques>\?)?=\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") | 30 | #__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}]+)\s*(?P<colon>:)?(?P<ques>\?)?=\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") |
31 | __config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") | 31 | __config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") |
@@ -33,53 +33,6 @@ __include_regexp__ = re.compile( r"include\s+(.+)" ) | |||
33 | __require_regexp__ = re.compile( r"require\s+(.+)" ) | 33 | __require_regexp__ = re.compile( r"require\s+(.+)" ) |
34 | __export_regexp__ = re.compile( r"export\s+(.+)" ) | 34 | __export_regexp__ = re.compile( r"export\s+(.+)" ) |
35 | 35 | ||
36 | # routines for the parser, to be turned into an AST | ||
37 | def handleInclude(m, fn, lineno, data, force): | ||
38 | s = bb.data.expand(m.group(1), data) | ||
39 | bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s)) | ||
40 | if force: | ||
41 | include(fn, s, data, "include required") | ||
42 | else: | ||
43 | include(fn, s, data, False) | ||
44 | |||
45 | def handleExport(m, data): | ||
46 | bb.data.setVarFlag(m.group(1), "export", 1, data) | ||
47 | |||
48 | def handleData(groupd, data): | ||
49 | key = groupd["var"] | ||
50 | if "exp" in groupd and groupd["exp"] != None: | ||
51 | bb.data.setVarFlag(key, "export", 1, data) | ||
52 | if "ques" in groupd and groupd["ques"] != None: | ||
53 | val = getFunc(groupd, key, data) | ||
54 | if val == None: | ||
55 | val = groupd["value"] | ||
56 | elif "colon" in groupd and groupd["colon"] != None: | ||
57 | e = data.createCopy() | ||
58 | bb.data.update_data(e) | ||
59 | val = bb.data.expand(groupd["value"], e) | ||
60 | elif "append" in groupd and groupd["append"] != None: | ||
61 | val = "%s %s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) | ||
62 | elif "prepend" in groupd and groupd["prepend"] != None: | ||
63 | val = "%s %s" % (groupd["value"], (getFunc(groupd, key, data) or "")) | ||
64 | elif "postdot" in groupd and groupd["postdot"] != None: | ||
65 | val = "%s%s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) | ||
66 | elif "predot" in groupd and groupd["predot"] != None: | ||
67 | val = "%s%s" % (groupd["value"], (getFunc(groupd, key, data) or "")) | ||
68 | else: | ||
69 | val = groupd["value"] | ||
70 | if 'flag' in groupd and groupd['flag'] != None: | ||
71 | bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val)) | ||
72 | bb.data.setVarFlag(key, groupd['flag'], val, data) | ||
73 | else: | ||
74 | bb.data.setVar(key, val, data) | ||
75 | |||
76 | def getFunc(groupd, key, data): | ||
77 | if 'flag' in groupd and groupd['flag'] != None: | ||
78 | return bb.data.getVarFlag(key, groupd['flag'], data) | ||
79 | else: | ||
80 | return bb.data.getVar(key, data) | ||
81 | |||
82 | |||
83 | def init(data): | 36 | def init(data): |
84 | topdir = bb.data.getVar('TOPDIR', data) | 37 | topdir = bb.data.getVar('TOPDIR', data) |
85 | if not topdir: | 38 | if not topdir: |
@@ -160,22 +113,22 @@ def feeder(lineno, s, fn, data): | |||
160 | m = __config_regexp__.match(s) | 113 | m = __config_regexp__.match(s) |
161 | if m: | 114 | if m: |
162 | groupd = m.groupdict() | 115 | groupd = m.groupdict() |
163 | handleData(groupd, data) | 116 | ast.handleData(groupd, data) |
164 | return | 117 | return |
165 | 118 | ||
166 | m = __include_regexp__.match(s) | 119 | m = __include_regexp__.match(s) |
167 | if m: | 120 | if m: |
168 | handleInclude(m, fn, lineno, data, False) | 121 | ast.handleInclude(m, fn, lineno, data, False) |
169 | return | 122 | return |
170 | 123 | ||
171 | m = __require_regexp__.match(s) | 124 | m = __require_regexp__.match(s) |
172 | if m: | 125 | if m: |
173 | handleInclude(m, fn, lineno, data, True) | 126 | ast.handleInclude(m, fn, lineno, data, True) |
174 | return | 127 | return |
175 | 128 | ||
176 | m = __export_regexp__.match(s) | 129 | m = __export_regexp__.match(s) |
177 | if m: | 130 | if m: |
178 | handleExport(m, data) | 131 | ast.handleExport(m, data) |
179 | return | 132 | return |
180 | 133 | ||
181 | raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); | 134 | raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); |