aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/parse_py
diff options
context:
space:
mode:
authorHolger Freyther <ich@tamarin.(none)>2009-05-17 15:56:40 +0200
committerRichard Purdie <rpurdie@linux.intel.com>2010-02-10 16:37:43 +0000
commitfb918a758215c7669b4850946280bd58c6e063c4 (patch)
tree9037c2e69c67448933a4a281b488bb60cd6ef99c /bitbake/lib/bb/parse/parse_py
parentb045ab32227baaec940698dad79aac0e41c5ee8a (diff)
downloadopenembedded-core-contrib-fb918a758215c7669b4850946280bd58c6e063c4.tar.gz
bitbake: [parser] Move more stuff out the feeder
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/ConfHandler.py86
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));