summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/parse_py/ConfHandler.py
diff options
context:
space:
mode:
authorHolger Freyther <ich@tamarin.(none)>2010-02-12 14:14:49 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-02-15 17:06:36 +0000
commit5bac3403d7e51f72ee16c8123c2c8607a1d93ca9 (patch)
treec1de610084eaee1f305b3ac60f0bb7cc1046ba90 /bitbake/lib/bb/parse/parse_py/ConfHandler.py
parente9d8dd2abf220cc28c7346768516d847b257f532 (diff)
downloadpoky-5bac3403d7e51f72ee16c8123c2c8607a1d93ca9.tar.gz
bitbake: [parser] Move evaluating into the ast class...
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py/ConfHandler.py')
-rw-r--r--bitbake/lib/bb/parse/parse_py/ConfHandler.py57
1 files changed, 5 insertions, 52 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py
index 86d052a7c3..43a3a69bbb 100644
--- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py
@@ -25,7 +25,7 @@
25# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 25# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 26
27import re, bb.data, os, sys 27import re, bb.data, os, sys
28from bb.parse import ParseError, resolve_file 28from bb.parse import ParseError, resolve_file, ast
29 29
30#__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}]+)\s*(?P<colon>:)?(?P<ques>\?)?=\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") 30#__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}]+)\s*(?P<colon>:)?(?P<ques>\?)?=\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$")
31__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") 31__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$")
@@ -33,53 +33,6 @@ __include_regexp__ = re.compile( r"include\s+(.+)" )
33__require_regexp__ = re.compile( r"require\s+(.+)" ) 33__require_regexp__ = re.compile( r"require\s+(.+)" )
34__export_regexp__ = re.compile( r"export\s+(.+)" ) 34__export_regexp__ = re.compile( r"export\s+(.+)" )
35 35
36# routines for the parser, to be turned into an AST
37def handleInclude(m, fn, lineno, data, force):
38 s = bb.data.expand(m.group(1), data)
39 bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s))
40 if force:
41 include(fn, s, data, "include required")
42 else:
43 include(fn, s, data, False)
44
45def handleExport(m, data):
46 bb.data.setVarFlag(m.group(1), "export", 1, data)
47
48def handleData(groupd, data):
49 key = groupd["var"]
50 if "exp" in groupd and groupd["exp"] != None:
51 bb.data.setVarFlag(key, "export", 1, data)
52 if "ques" in groupd and groupd["ques"] != None:
53 val = getFunc(groupd, key, data)
54 if val == None:
55 val = groupd["value"]
56 elif "colon" in groupd and groupd["colon"] != None:
57 e = data.createCopy()
58 bb.data.update_data(e)
59 val = bb.data.expand(groupd["value"], e)
60 elif "append" in groupd and groupd["append"] != None:
61 val = "%s %s" % ((getFunc(groupd, key, data) or ""), groupd["value"])
62 elif "prepend" in groupd and groupd["prepend"] != None:
63 val = "%s %s" % (groupd["value"], (getFunc(groupd, key, data) or ""))
64 elif "postdot" in groupd and groupd["postdot"] != None:
65 val = "%s%s" % ((getFunc(groupd, key, data) or ""), groupd["value"])
66 elif "predot" in groupd and groupd["predot"] != None:
67 val = "%s%s" % (groupd["value"], (getFunc(groupd, key, data) or ""))
68 else:
69 val = groupd["value"]
70 if 'flag' in groupd and groupd['flag'] != None:
71 bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val))
72 bb.data.setVarFlag(key, groupd['flag'], val, data)
73 else:
74 bb.data.setVar(key, val, data)
75
76def getFunc(groupd, key, data):
77 if 'flag' in groupd and groupd['flag'] != None:
78 return bb.data.getVarFlag(key, groupd['flag'], data)
79 else:
80 return bb.data.getVar(key, data)
81
82
83def init(data): 36def init(data):
84 topdir = bb.data.getVar('TOPDIR', data) 37 topdir = bb.data.getVar('TOPDIR', data)
85 if not topdir: 38 if not topdir:
@@ -160,22 +113,22 @@ def feeder(lineno, s, fn, data):
160 m = __config_regexp__.match(s) 113 m = __config_regexp__.match(s)
161 if m: 114 if m:
162 groupd = m.groupdict() 115 groupd = m.groupdict()
163 handleData(groupd, data) 116 ast.handleData(groupd, data)
164 return 117 return
165 118
166 m = __include_regexp__.match(s) 119 m = __include_regexp__.match(s)
167 if m: 120 if m:
168 handleInclude(m, fn, lineno, data, False) 121 ast.handleInclude(m, fn, lineno, data, False)
169 return 122 return
170 123
171 m = __require_regexp__.match(s) 124 m = __require_regexp__.match(s)
172 if m: 125 if m:
173 handleInclude(m, fn, lineno, data, True) 126 ast.handleInclude(m, fn, lineno, data, True)
174 return 127 return
175 128
176 m = __export_regexp__.match(s) 129 m = __export_regexp__.match(s)
177 if m: 130 if m:
178 handleExport(m, data) 131 ast.handleExport(m, data)
179 return 132 return
180 133
181 raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); 134 raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s));