1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-03 13:49:49 +00:00

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>
This commit is contained in:
Holger Freyther
2009-05-18 19:24:07 +02:00
committed by Richard Purdie
parent 5bac3403d7
commit 4b25b519ae
4 changed files with 92 additions and 79 deletions
+16 -15
View File
@@ -59,7 +59,7 @@ IN_PYTHON_EOF = -9999999999999
def supports(fn, d):
return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc"
def inherit(files, d):
def inherit(statements, files, d):
__inherit_cache = data.getVar('__inherit_cache', d) or []
fn = ""
lineno = 0
@@ -72,7 +72,7 @@ def inherit(files, d):
bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file))
__inherit_cache.append( file )
data.setVar('__inherit_cache', __inherit_cache, d)
include(fn, file, d, "inherit")
include(statements, fn, file, d, "inherit")
__inherit_cache = data.getVar('__inherit_cache', d) or []
@@ -116,13 +116,14 @@ def finalise(fn, d):
bb.event.fire(bb.event.RecipeParsed(fn), d)
def handle(fn, d, include = 0):
def handle(fn, d, include, statements):
global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__
__body__ = []
__infunc__ = ""
__classname__ = ""
__residue__ = []
if include == 0:
bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data)")
else:
@@ -159,10 +160,10 @@ def handle(fn, d, include = 0):
s = f.readline()
if not s: break
s = s.rstrip()
feeder(lineno, s, fn, base_name, d)
feeder(lineno, s, fn, base_name, d, statements)
if __inpython__:
# add a blank line to close out any python definition
feeder(IN_PYTHON_EOF, "", fn, base_name, d)
feeder(IN_PYTHON_EOF, "", fn, base_name, d, statements)
if ext == ".bbclass":
classes.remove(__classname__)
else:
@@ -182,7 +183,7 @@ def handle(fn, d, include = 0):
pn = data.getVar('PN', d, True)
based = bb.data.createCopy(d)
data.setVar('PN', pn + '-' + cls, based)
inherit([cls], based)
inherit(statements, [cls], based)
try:
finalise(fn, based)
except bb.parse.SkipPackage:
@@ -199,12 +200,12 @@ def handle(fn, d, include = 0):
return d
def feeder(lineno, s, fn, root, d):
def feeder(lineno, s, fn, root, d, statements):
global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__,__infunc__, __body__, classes, bb, __residue__
if __infunc__:
if s == '}':
__body__.append('')
ast.handleMethod(__infunc__, __body__, d)
ast.handleMethod(statements, __infunc__, lineno, fn, __body__, d)
__infunc__ = ""
__body__ = []
else:
@@ -217,7 +218,7 @@ def feeder(lineno, s, fn, root, d):
__body__.append(s)
return
else:
ast.handlePythonMethod(root, __body__, fn)
ast.handlePythonMethod(statements, root, __body__, fn)
__body__ = []
__inpython__ = False
@@ -238,7 +239,7 @@ def feeder(lineno, s, fn, root, d):
m = __func_start_regexp__.match(s)
if m:
__infunc__ = m.group("func") or "__anonymous"
ast.handleMethodFlags(__infunc__, m, d)
ast.handleMethodFlags(statements, __infunc__, m, d)
return
m = __def_regexp__.match(s)
@@ -249,26 +250,26 @@ def feeder(lineno, s, fn, root, d):
m = __export_func_regexp__.match(s)
if m:
ast.handleExportFuncs(m, classes, d)
ast.handleExportFuncs(statements, m, classes, d)
return
m = __addtask_regexp__.match(s)
if m:
ast.handleAddTask(m, d )
ast.handleAddTask(statements, m, d)
return
m = __addhandler_regexp__.match(s)
if m:
ast.handleBBHandlers(m, d)
ast.handleBBHandlers(statements, m, d)
return
m = __inherit_regexp__.match(s)
if m:
ast.handleInherit(m, d)
ast.handleInherit(statements, m, d)
return
from bb.parse import ConfHandler
return ConfHandler.feeder(lineno, s, fn, d)
return ConfHandler.feeder(lineno, s, fn, d, statements)
__pkgsplit_cache__={}
def vars_from_file(mypkg, d):
+9 -9
View File
@@ -49,7 +49,7 @@ def init(data):
def supports(fn, d):
return fn[-5:] == ".conf"
def include(oldfn, fn, data, error_out):
def include(statements, oldfn, fn, data, error_out):
"""
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):
from bb.parse import handle
try:
ret = handle(fn, data, True)
ret = handle(fn, data, True, statements)
except IOError:
if error_out:
raise ParseError("Could not %(error_out)s file %(fn)s" % vars() )
bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn)
def handle(fn, data, include = 0):
def handle(fn, data, include, statements):
init(data)
if include == 0:
@@ -103,32 +103,32 @@ def handle(fn, data, include = 0):
s2 = f.readline()[:-1].strip()
lineno = lineno + 1
s = s[:-1] + s2
feeder(lineno, s, fn, data)
feeder(lineno, s, fn, data, statements)
if oldfile:
bb.data.setVar('FILE', oldfile, data)
return data
def feeder(lineno, s, fn, data):
def feeder(lineno, s, fn, data, statements):
m = __config_regexp__.match(s)
if m:
groupd = m.groupdict()
ast.handleData(groupd, data)
ast.handleData(statements, groupd, data)
return
m = __include_regexp__.match(s)
if m:
ast.handleInclude(m, fn, lineno, data, False)
ast.handleInclude(statements, m, fn, lineno, data, False)
return
m = __require_regexp__.match(s)
if m:
ast.handleInclude(m, fn, lineno, data, True)
ast.handleInclude(statements, m, fn, lineno, data, True)
return
m = __export_regexp__.match(s)
if m:
ast.handleExport(m, data)
ast.handleExport(statements, m, data)
return
raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s));