summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/parse_py/BBHandler.py
diff options
context:
space:
mode:
authorHolger Freyther <ich@tamarin.(none)>2009-05-19 12:10:37 +0200
committerRichard Purdie <rpurdie@linux.intel.com>2010-02-15 17:07:51 +0000
commit793c88dd92747890e910c598e19f1778865883d2 (patch)
treed34ec6e00aa689a985a0bb5f45050530c7234fd1 /bitbake/lib/bb/parse/parse_py/BBHandler.py
parent3eb2e6cf02155c3fce0a49bd967545cacfc08fb3 (diff)
downloadpoky-793c88dd92747890e910c598e19f1778865883d2.tar.gz
bitbake: [parser] Remove the "data" from feeder, evaluate after parsing a file
Evaluate the statements after having parsed one file. This is referred to as "entwirren" and we can remove the direct evaluation and postpone a bit, in the future we can use a cached copy instead of parsing the original. Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py/BBHandler.py')
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py39
1 files changed, 22 insertions, 17 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index 32e0901e25..f313009ab8 100644
--- a/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py
@@ -62,7 +62,7 @@ IN_PYTHON_EOF = -9999999999999
62def supports(fn, d): 62def supports(fn, d):
63 return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" 63 return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc"
64 64
65def inherit(statements, files, d): 65def inherit(files, d):
66 __inherit_cache = data.getVar('__inherit_cache', d) or [] 66 __inherit_cache = data.getVar('__inherit_cache', d) or []
67 fn = "" 67 fn = ""
68 lineno = 0 68 lineno = 0
@@ -75,10 +75,10 @@ def inherit(statements, files, d):
75 bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file)) 75 bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file))
76 __inherit_cache.append( file ) 76 __inherit_cache.append( file )
77 data.setVar('__inherit_cache', __inherit_cache, d) 77 data.setVar('__inherit_cache', __inherit_cache, d)
78 include(statements, fn, file, d, "inherit") 78 include(fn, file, d, "inherit")
79 __inherit_cache = data.getVar('__inherit_cache', d) or [] 79 __inherit_cache = data.getVar('__inherit_cache', d) or []
80 80
81def handle(fn, d, include, statements): 81def handle(fn, d, include):
82 global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__ 82 global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__
83 __body__ = [] 83 __body__ = []
84 __infunc__ = "" 84 __infunc__ = ""
@@ -113,19 +113,24 @@ def handle(fn, d, include, statements):
113 if include: 113 if include:
114 bb.parse.mark_dependency(d, abs_fn) 114 bb.parse.mark_dependency(d, abs_fn)
115 115
116 if ext != ".bbclass": 116 statements = ast.StatementGroup()
117 data.setVar('FILE', fn, d)
118
119 lineno = 0 117 lineno = 0
120 while 1: 118 while 1:
121 lineno = lineno + 1 119 lineno = lineno + 1
122 s = f.readline() 120 s = f.readline()
123 if not s: break 121 if not s: break
124 s = s.rstrip() 122 s = s.rstrip()
125 feeder(lineno, s, fn, base_name, d, statements) 123 feeder(lineno, s, fn, base_name, statements)
126 if __inpython__: 124 if __inpython__:
127 # add a blank line to close out any python definition 125 # add a blank line to close out any python definition
128 feeder(IN_PYTHON_EOF, "", fn, base_name, d, statements) 126 feeder(IN_PYTHON_EOF, "", fn, base_name, statements)
127
128 # DONE WITH PARSING... time to evaluate
129 if ext != ".bbclass":
130 data.setVar('FILE', fn, d)
131
132 statements.eval(d)
133
129 if ext == ".bbclass": 134 if ext == ".bbclass":
130 classes.remove(__classname__) 135 classes.remove(__classname__)
131 else: 136 else:
@@ -145,7 +150,7 @@ def handle(fn, d, include, statements):
145 pn = data.getVar('PN', d, True) 150 pn = data.getVar('PN', d, True)
146 based = bb.data.createCopy(d) 151 based = bb.data.createCopy(d)
147 data.setVar('PN', pn + '-' + cls, based) 152 data.setVar('PN', pn + '-' + cls, based)
148 inherit(statements, [cls], based) 153 inherit([cls], based)
149 try: 154 try:
150 ast.finalise(fn, based) 155 ast.finalise(fn, based)
151 except bb.parse.SkipPackage: 156 except bb.parse.SkipPackage:
@@ -162,12 +167,12 @@ def handle(fn, d, include, statements):
162 167
163 return d 168 return d
164 169
165def feeder(lineno, s, fn, root, d, statements): 170def feeder(lineno, s, fn, root, statements):
166 global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__,__infunc__, __body__, classes, bb, __residue__ 171 global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__,__infunc__, __body__, classes, bb, __residue__
167 if __infunc__: 172 if __infunc__:
168 if s == '}': 173 if s == '}':
169 __body__.append('') 174 __body__.append('')
170 ast.handleMethod(statements, __infunc__, lineno, fn, __body__, d) 175 ast.handleMethod(statements, __infunc__, lineno, fn, __body__)
171 __infunc__ = "" 176 __infunc__ = ""
172 __body__ = [] 177 __body__ = []
173 else: 178 else:
@@ -201,7 +206,7 @@ def feeder(lineno, s, fn, root, d, statements):
201 m = __func_start_regexp__.match(s) 206 m = __func_start_regexp__.match(s)
202 if m: 207 if m:
203 __infunc__ = m.group("func") or "__anonymous" 208 __infunc__ = m.group("func") or "__anonymous"
204 ast.handleMethodFlags(statements, __infunc__, m, d) 209 ast.handleMethodFlags(statements, __infunc__, m)
205 return 210 return
206 211
207 m = __def_regexp__.match(s) 212 m = __def_regexp__.match(s)
@@ -212,26 +217,26 @@ def feeder(lineno, s, fn, root, d, statements):
212 217
213 m = __export_func_regexp__.match(s) 218 m = __export_func_regexp__.match(s)
214 if m: 219 if m:
215 ast.handleExportFuncs(statements, m, classes, d) 220 ast.handleExportFuncs(statements, m, classes)
216 return 221 return
217 222
218 m = __addtask_regexp__.match(s) 223 m = __addtask_regexp__.match(s)
219 if m: 224 if m:
220 ast.handleAddTask(statements, m, d) 225 ast.handleAddTask(statements, m)
221 return 226 return
222 227
223 m = __addhandler_regexp__.match(s) 228 m = __addhandler_regexp__.match(s)
224 if m: 229 if m:
225 ast.handleBBHandlers(statements, m, d) 230 ast.handleBBHandlers(statements, m)
226 return 231 return
227 232
228 m = __inherit_regexp__.match(s) 233 m = __inherit_regexp__.match(s)
229 if m: 234 if m:
230 ast.handleInherit(statements, m, d) 235 ast.handleInherit(statements, m)
231 return 236 return
232 237
233 from bb.parse import ConfHandler 238 from bb.parse import ConfHandler
234 return ConfHandler.feeder(lineno, s, fn, d, statements) 239 return ConfHandler.feeder(lineno, s, fn, statements)
235 240
236# Add us to the handlers list 241# Add us to the handlers list
237from bb.parse import handlers 242from bb.parse import handlers