summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/parse_py
diff options
context:
space:
mode:
authorHolger Freyther <ich@tamarin.(none)>2009-05-18 19:24:07 +0200
committerRichard Purdie <rpurdie@linux.intel.com>2010-02-15 17:06:50 +0000
commit4b25b519ae46b283988a1847e56a19b01269b3a4 (patch)
tree00392d149975e64e1c685f7621844b2cc00a8792 /bitbake/lib/bb/parse/parse_py
parent5bac3403d7e51f72ee16c8123c2c8607a1d93ca9 (diff)
downloadpoky-4b25b519ae46b283988a1847e56a19b01269b3a4.tar.gz
bitbake: [parser] Cary a Statement Node through the parsing
When parsing we will collect a number of statements that can be evaluated...The plan is to be evaluate things twice (old+new) and then compare the result, it should be the same. Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py')
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py31
-rw-r--r--bitbake/lib/bb/parse/parse_py/ConfHandler.py18
2 files changed, 25 insertions, 24 deletions
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
59def supports(fn, d): 59def 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
62def inherit(files, d): 62def 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
119def handle(fn, d, include = 0): 119def 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
202def feeder(lineno, s, fn, root, d): 203def 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__={}
274def vars_from_file(mypkg, d): 275def 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):
49def supports(fn, d): 49def supports(fn, d):
50 return fn[-5:] == ".conf" 50 return fn[-5:] == ".conf"
51 51
52def include(oldfn, fn, data, error_out): 52def 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
79def handle(fn, data, include = 0): 79def 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
112def feeder(lineno, s, fn, data): 112def 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));