From c011d42eda4b830ec2a609817b61d166ff0413d4 Mon Sep 17 00:00:00 2001 From: Holger Freyther Date: Tue, 19 May 2009 13:22:30 +0200 Subject: bitbake: [parser] prepare to cache some .bbcclass and .inc files Our parser is shit but instead to replace it now we will see how long we can drive the wave by caching parsed files. This will not go through the feeder again but we can just reevaluate the StatementGroup. Signed-off-by: Richard Purdie --- bitbake/lib/bb/parse/parse_py/BBHandler.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'bitbake/lib') diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index f313009ab8..9b8ad0b9ec 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py @@ -78,6 +78,22 @@ def inherit(files, d): include(fn, file, d, "inherit") __inherit_cache = data.getVar('__inherit_cache', d) or [] +def get_statements(filename, absolsute_filename, base_name, file): + statements = ast.StatementGroup() + + lineno = 0 + while 1: + lineno = lineno + 1 + s = file.readline() + if not s: break + s = s.rstrip() + feeder(lineno, s, filename, base_name, statements) + if __inpython__: + # add a blank line to close out any python definition + feeder(IN_PYTHON_EOF, "", filename, base_name, statements) + + return statements + def handle(fn, d, include): global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__ __body__ = [] @@ -113,17 +129,8 @@ def handle(fn, d, include): if include: bb.parse.mark_dependency(d, abs_fn) - statements = ast.StatementGroup() - lineno = 0 - while 1: - lineno = lineno + 1 - s = f.readline() - if not s: break - s = s.rstrip() - feeder(lineno, s, fn, base_name, statements) - if __inpython__: - # add a blank line to close out any python definition - feeder(IN_PYTHON_EOF, "", fn, base_name, statements) + # actual loading + statements = get_statements(fn, abs_fn, base_name, f) # DONE WITH PARSING... time to evaluate if ext != ".bbclass": -- cgit v1.2.3