diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 86 |
1 files changed, 48 insertions, 38 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index ce746106a4..b22bbc8af5 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py @@ -33,6 +33,50 @@ __include_regexp__ = re.compile( r"include\s+(.+)" ) __require_regexp__ = re.compile( r"require\s+(.+)" ) __export_regexp__ = re.compile( r"export\s+(.+)" ) +# routines for the parser, to be turned into an AST +def handleInclude(m, fn, lineno, data, force): + s = bb.data.expand(m.group(1), data) + bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s)) + include(fn, s, data, False) + +def handleExport(m, data): + bb.data.setVarFlag(m.group(1), "export", 1, data) + +def handleData(groupd, data): + key = groupd["var"] + if "exp" in groupd and groupd["exp"] != None: + bb.data.setVarFlag(key, "export", 1, data) + if "ques" in groupd and groupd["ques"] != None: + val = getFunc(groupd, key, data) + if val == None: + val = groupd["value"] + elif "colon" in groupd and groupd["colon"] != None: + e = data.createCopy() + bb.data.update_data(e) + val = bb.data.expand(groupd["value"], e) + elif "append" in groupd and groupd["append"] != None: + val = "%s %s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) + elif "prepend" in groupd and groupd["prepend"] != None: + val = "%s %s" % (groupd["value"], (getFunc(groupd, key, data) or "")) + elif "postdot" in groupd and groupd["postdot"] != None: + val = "%s%s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) + elif "predot" in groupd and groupd["predot"] != None: + val = "%s%s" % (groupd["value"], (getFunc(groupd, key, data) or "")) + else: + val = groupd["value"] + if 'flag' in groupd and groupd['flag'] != None: + bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val)) + bb.data.setVarFlag(key, groupd['flag'], val, data) + else: + bb.data.setVar(key, val, data) + +def getFunc(groupd, key, data): + if 'flag' in groupd and groupd['flag'] != None: + return bb.data.getVarFlag(key, groupd['flag'], data) + else: + return bb.data.getVar(key, data) + + def init(data): topdir = bb.data.getVar('TOPDIR', data) if not topdir: @@ -110,59 +154,25 @@ def handle(fn, data, include = 0): return data def feeder(lineno, s, fn, data): - def getFunc(groupd, key, data): - if 'flag' in groupd and groupd['flag'] != None: - return bb.data.getVarFlag(key, groupd['flag'], data) - else: - return bb.data.getVar(key, data) - m = __config_regexp__.match(s) if m: groupd = m.groupdict() - key = groupd["var"] - if "exp" in groupd and groupd["exp"] != None: - bb.data.setVarFlag(key, "export", 1, data) - if "ques" in groupd and groupd["ques"] != None: - val = getFunc(groupd, key, data) - if val == None: - val = groupd["value"] - elif "colon" in groupd and groupd["colon"] != None: - e = data.createCopy() - bb.data.update_data(e) - val = bb.data.expand(groupd["value"], e) - elif "append" in groupd and groupd["append"] != None: - val = "%s %s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) - elif "prepend" in groupd and groupd["prepend"] != None: - val = "%s %s" % (groupd["value"], (getFunc(groupd, key, data) or "")) - elif "postdot" in groupd and groupd["postdot"] != None: - val = "%s%s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) - elif "predot" in groupd and groupd["predot"] != None: - val = "%s%s" % (groupd["value"], (getFunc(groupd, key, data) or "")) - else: - val = groupd["value"] - if 'flag' in groupd and groupd['flag'] != None: - bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val)) - bb.data.setVarFlag(key, groupd['flag'], val, data) - else: - bb.data.setVar(key, val, data) + handleData(groupd, data) return m = __include_regexp__.match(s) if m: - s = bb.data.expand(m.group(1), data) - bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s)) - include(fn, s, data, False) + handleInclude(m, fn, lineno, data, False) return m = __require_regexp__.match(s) if m: - s = bb.data.expand(m.group(1), data) - include(fn, s, data, "include required") + handleInclude(m, fn, lineno, data, True) return m = __export_regexp__.match(s) if m: - bb.data.setVarFlag(m.group(1), "export", 1, data) + handleExport(m, data) return raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); |