summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/parse_py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py')
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py28
-rw-r--r--bitbake/lib/bb/parse/parse_py/ConfHandler.py33
2 files changed, 35 insertions, 26 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index c82090fec0..34f4d25996 100644
--- a/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py
@@ -23,7 +23,7 @@
23 23
24import re, bb, os, sys, time 24import re, bb, os, sys, time
25import bb.fetch, bb.build, bb.utils 25import bb.fetch, bb.build, bb.utils
26from bb import debug, data, fetch, fatal, methodpool 26from bb import data, fetch, methodpool
27 27
28from ConfHandler import include, localpath, obtain, init 28from ConfHandler import include, localpath, obtain, init
29from bb.parse import ParseError 29from bb.parse import ParseError
@@ -44,6 +44,13 @@ __bbpath_found__ = 0
44__classname__ = "" 44__classname__ = ""
45classes = [ None, ] 45classes = [ None, ]
46 46
47# We need to indicate EOF to the feeder. This code is so messy that
48# factoring it out to a close_parse_file method is out of question.
49# We will use the IN_PYTHON_EOF as an indicator to just close the method
50#
51# The two parts using it are tightly integrated anyway
52IN_PYTHON_EOF = -9999999999999
53
47__parsed_methods__ = methodpool.get_parsed_dict() 54__parsed_methods__ = methodpool.get_parsed_dict()
48 55
49def supports(fn, d): 56def supports(fn, d):
@@ -60,9 +67,9 @@ def inherit(files, d):
60 file = os.path.join('classes', '%s.bbclass' % file) 67 file = os.path.join('classes', '%s.bbclass' % file)
61 68
62 if not file in __inherit_cache.split(): 69 if not file in __inherit_cache.split():
63 debug(2, "BB %s:%d: inheriting %s" % (fn, lineno, file)) 70 bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file))
64 __inherit_cache += " %s" % file 71 __inherit_cache += " %s" % file
65 include(fn, file, d) 72 include(fn, file, d, "inherit")
66 data.setVar('__inherit_cache', __inherit_cache, d) 73 data.setVar('__inherit_cache', __inherit_cache, d)
67 74
68 75
@@ -75,9 +82,9 @@ def handle(fn, d, include = 0):
75 __residue__ = [] 82 __residue__ = []
76 83
77 if include == 0: 84 if include == 0:
78 debug(2, "BB " + fn + ": handle(data)") 85 bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data)")
79 else: 86 else:
80 debug(2, "BB " + fn + ": handle(data, include)") 87 bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data, include)")
81 88
82 (root, ext) = os.path.splitext(os.path.basename(fn)) 89 (root, ext) = os.path.splitext(os.path.basename(fn))
83 base_name = "%s%s" % (root,ext) 90 base_name = "%s%s" % (root,ext)
@@ -132,7 +139,7 @@ def handle(fn, d, include = 0):
132 feeder(lineno, s, fn, base_name, d) 139 feeder(lineno, s, fn, base_name, d)
133 if __inpython__: 140 if __inpython__:
134 # add a blank line to close out any python definition 141 # add a blank line to close out any python definition
135 feeder(lineno + 1, "", fn, base_name, d) 142 feeder(IN_PYTHON_EOF, "", fn, base_name, d)
136 if ext == ".bbclass": 143 if ext == ".bbclass":
137 classes.remove(__classname__) 144 classes.remove(__classname__)
138 else: 145 else:
@@ -152,7 +159,7 @@ def handle(fn, d, include = 0):
152 if t: 159 if t:
153 data.setVar('T', t, d) 160 data.setVar('T', t, d)
154 except Exception, e: 161 except Exception, e:
155 bb.debug(1, "executing anonymous function: %s" % e) 162 bb.msg.debug(1, bb.msg.domain.Parsing, "executing anonymous function: %s" % e)
156 raise 163 raise
157 data.delVar("__anonqueue", d) 164 data.delVar("__anonqueue", d)
158 data.delVar("__anonfunc", d) 165 data.delVar("__anonfunc", d)
@@ -220,7 +227,7 @@ def feeder(lineno, s, fn, root, d):
220 227
221 if __inpython__: 228 if __inpython__:
222 m = __python_func_regexp__.match(s) 229 m = __python_func_regexp__.match(s)
223 if m: 230 if m and lineno != IN_PYTHON_EOF:
224 __body__.append(s) 231 __body__.append(s)
225 return 232 return
226 else: 233 else:
@@ -240,6 +247,9 @@ def feeder(lineno, s, fn, root, d):
240 __body__ = [] 247 __body__ = []
241 __inpython__ = False 248 __inpython__ = False
242 249
250 if lineno == IN_PYTHON_EOF:
251 return
252
243# fall through 253# fall through
244 254
245 if s == '' or s[0] == '#': return # skip comments and empty lines 255 if s == '' or s[0] == '#': return # skip comments and empty lines
@@ -374,7 +384,7 @@ def vars_from_file(mypkg, d):
374def set_additional_vars(file, d, include): 384def set_additional_vars(file, d, include):
375 """Deduce rest of variables, e.g. ${A} out of ${SRC_URI}""" 385 """Deduce rest of variables, e.g. ${A} out of ${SRC_URI}"""
376 386
377 debug(2,"BB %s: set_additional_vars" % file) 387 bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s: set_additional_vars" % file)
378 388
379 src_uri = data.getVar('SRC_URI', d) 389 src_uri = data.getVar('SRC_URI', d)
380 if not src_uri: 390 if not src_uri:
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py
index 90978300af..4bc2bbc2b7 100644
--- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py
@@ -22,7 +22,6 @@
22 Place, Suite 330, Boston, MA 02111-1307 USA.""" 22 Place, Suite 330, Boston, MA 02111-1307 USA."""
23 23
24import re, bb.data, os, sys 24import re, bb.data, os, sys
25from bb import debug, fatal
26from bb.parse import ParseError 25from bb.parse import ParseError
27 26
28#__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)$") 27#__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)$")
@@ -53,7 +52,7 @@ def localpath(fn, d):
53 localfn = fn 52 localfn = fn
54 return localfn 53 return localfn
55 54
56def obtain(fn, data = bb.data.init()): 55def obtain(fn, data):
57 import sys, bb 56 import sys, bb
58 fn = bb.data.expand(fn, data) 57 fn = bb.data.expand(fn, data)
59 localfn = bb.data.expand(localpath(fn, data), data) 58 localfn = bb.data.expand(localpath(fn, data), data)
@@ -61,30 +60,30 @@ def obtain(fn, data = bb.data.init()):
61 if localfn != fn: 60 if localfn != fn:
62 dldir = bb.data.getVar('DL_DIR', data, 1) 61 dldir = bb.data.getVar('DL_DIR', data, 1)
63 if not dldir: 62 if not dldir:
64 debug(1, "obtain: DL_DIR not defined") 63 bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: DL_DIR not defined")
65 return localfn 64 return localfn
66 bb.mkdirhier(dldir) 65 bb.mkdirhier(dldir)
67 try: 66 try:
68 bb.fetch.init([fn]) 67 bb.fetch.init([fn])
69 except bb.fetch.NoMethodError: 68 except bb.fetch.NoMethodError:
70 (type, value, traceback) = sys.exc_info() 69 (type, value, traceback) = sys.exc_info()
71 debug(1, "obtain: no method: %s" % value) 70 bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: no method: %s" % value)
72 return localfn 71 return localfn
73 72
74 try: 73 try:
75 bb.fetch.go(data) 74 bb.fetch.go(data)
76 except bb.fetch.MissingParameterError: 75 except bb.fetch.MissingParameterError:
77 (type, value, traceback) = sys.exc_info() 76 (type, value, traceback) = sys.exc_info()
78 debug(1, "obtain: missing parameters: %s" % value) 77 bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: missing parameters: %s" % value)
79 return localfn 78 return localfn
80 except bb.fetch.FetchError: 79 except bb.fetch.FetchError:
81 (type, value, traceback) = sys.exc_info() 80 (type, value, traceback) = sys.exc_info()
82 debug(1, "obtain: failed: %s" % value) 81 bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: failed: %s" % value)
83 return localfn 82 return localfn
84 return localfn 83 return localfn
85 84
86 85
87def include(oldfn, fn, data = bb.data.init(), error_out = False): 86def include(oldfn, fn, data, error_out):
88 """ 87 """
89 88
90 error_out If True a ParseError will be reaised if the to be included 89 error_out If True a ParseError will be reaised if the to be included
@@ -101,10 +100,10 @@ def include(oldfn, fn, data = bb.data.init(), error_out = False):
101 ret = handle(fn, data, True) 100 ret = handle(fn, data, True)
102 except IOError: 101 except IOError:
103 if error_out: 102 if error_out:
104 raise ParseError("Could not include required file %(fn)s" % vars() ) 103 raise ParseError("Could not %(error_out)s file %(fn)s" % vars() )
105 debug(2, "CONF file '%s' not found" % fn) 104 bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn)
106 105
107def handle(fn, data = bb.data.init(), include = 0): 106def handle(fn, data, include = 0):
108 if include: 107 if include:
109 inc_string = "including" 108 inc_string = "including"
110 else: 109 else:
@@ -129,13 +128,13 @@ def handle(fn, data = bb.data.init(), include = 0):
129 if os.access(currname, os.R_OK): 128 if os.access(currname, os.R_OK):
130 f = open(currname, 'r') 129 f = open(currname, 'r')
131 abs_fn = currname 130 abs_fn = currname
132 debug(1, "CONF %s %s" % (inc_string, currname)) 131 bb.msg.debug(2, bb.msg.domain.Parsing, "CONF %s %s" % (inc_string, currname))
133 break 132 break
134 if f is None: 133 if f is None:
135 raise IOError("file '%s' not found" % fn) 134 raise IOError("file '%s' not found" % fn)
136 else: 135 else:
137 f = open(fn,'r') 136 f = open(fn,'r')
138 debug(1, "CONF %s %s" % (inc_string,fn)) 137 bb.msg.debug(1, bb.msg.domain.Parsing, "CONF %s %s" % (inc_string,fn))
139 abs_fn = fn 138 abs_fn = fn
140 139
141 if include: 140 if include:
@@ -161,7 +160,7 @@ def handle(fn, data = bb.data.init(), include = 0):
161 bb.data.setVar('FILE', oldfile, data) 160 bb.data.setVar('FILE', oldfile, data)
162 return data 161 return data
163 162
164def feeder(lineno, s, fn, data = bb.data.init()): 163def feeder(lineno, s, fn, data):
165 m = __config_regexp__.match(s) 164 m = __config_regexp__.match(s)
166 if m: 165 if m:
167 groupd = m.groupdict() 166 groupd = m.groupdict()
@@ -185,7 +184,7 @@ def feeder(lineno, s, fn, data = bb.data.init()):
185 else: 184 else:
186 val = groupd["value"] 185 val = groupd["value"]
187 if 'flag' in groupd and groupd['flag'] != None: 186 if 'flag' in groupd and groupd['flag'] != None:
188# bb.note("setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val)) 187 bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val))
189 bb.data.setVarFlag(key, groupd['flag'], val, data) 188 bb.data.setVarFlag(key, groupd['flag'], val, data)
190 else: 189 else:
191 bb.data.setVar(key, val, data) 190 bb.data.setVar(key, val, data)
@@ -194,14 +193,14 @@ def feeder(lineno, s, fn, data = bb.data.init()):
194 m = __include_regexp__.match(s) 193 m = __include_regexp__.match(s)
195 if m: 194 if m:
196 s = bb.data.expand(m.group(1), data) 195 s = bb.data.expand(m.group(1), data)
197# debug(2, "CONF %s:%d: including %s" % (fn, lineno, s)) 196 bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s))
198 include(fn, s, data) 197 include(fn, s, data, False)
199 return 198 return
200 199
201 m = __require_regexp__.match(s) 200 m = __require_regexp__.match(s)
202 if m: 201 if m:
203 s = bb.data.expand(m.group(1), data) 202 s = bb.data.expand(m.group(1), data)
204 include(fn, s, data, True) 203 include(fn, s, data, "include required")
205 return 204 return
206 205
207 raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); 206 raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s));