summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-20 13:21:14 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-22 00:02:05 +0000
commitc61c1eb26a082c81473a45977cad5f811d2cf598 (patch)
tree724a642220d015c43f34b01df0c36382e923f11b /bitbake/lib/bb/parse
parent2a941943d9d97ea2b09260f9138964d2a56152d2 (diff)
downloadpoky-c61c1eb26a082c81473a45977cad5f811d2cf598.tar.gz
bitbake: BBHandler: Improve IN_PYTHON_EOF handling
Now we're actively using the line numbers for other thins, having magic values like IN_PYTHON_EOF causes problems, in particular, 32 bit overflow on 32 bit machines. There is a neater way to signal eof to feeder(), just using an extra parameter so use this instead and drop the IN_PYTHON_EOF magic values. This has the added bonus that line numbers are then correct for python functions at the end of files. (Bitbake rev: e0f05871c2a6f1e86ae19ad343c7c6f822ddb67e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/parse')
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py18
1 files changed, 4 insertions, 14 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index ec097baf73..97a9ee8dac 100644
--- a/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py
@@ -47,7 +47,6 @@ __addhandler_regexp__ = re.compile( r"addhandler\s+(.+)" )
47__def_regexp__ = re.compile( r"def\s+(\w+).*:" ) 47__def_regexp__ = re.compile( r"def\s+(\w+).*:" )
48__python_func_regexp__ = re.compile( r"(\s+.*)|(^$)" ) 48__python_func_regexp__ = re.compile( r"(\s+.*)|(^$)" )
49 49
50
51__infunc__ = [] 50__infunc__ = []
52__inpython__ = False 51__inpython__ = False
53__body__ = [] 52__body__ = []
@@ -55,15 +54,6 @@ __classname__ = ""
55 54
56cached_statements = {} 55cached_statements = {}
57 56
58# We need to indicate EOF to the feeder. This code is so messy that
59# factoring it out to a close_parse_file method is out of question.
60# We will use the IN_PYTHON_EOF as an indicator to just close the method
61#
62# The two parts using it are tightly integrated anyway
63IN_PYTHON_EOF = -9999999999999
64
65
66
67def supports(fn, d): 57def supports(fn, d):
68 """Return True if fn has a supported extension""" 58 """Return True if fn has a supported extension"""
69 return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"] 59 return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"]
@@ -110,7 +100,7 @@ def get_statements(filename, absolute_filename, base_name):
110 file.close() 100 file.close()
111 if __inpython__: 101 if __inpython__:
112 # add a blank line to close out any python definition 102 # add a blank line to close out any python definition
113 feeder(IN_PYTHON_EOF, "", filename, base_name, statements) 103 feeder(lineno, "", filename, base_name, statements, eof=True)
114 104
115 if filename.endswith(".bbclass") or filename.endswith(".inc"): 105 if filename.endswith(".bbclass") or filename.endswith(".inc"):
116 cached_statements[absolute_filename] = statements 106 cached_statements[absolute_filename] = statements
@@ -171,7 +161,7 @@ def handle(fn, d, include):
171 161
172 return d 162 return d
173 163
174def feeder(lineno, s, fn, root, statements): 164def feeder(lineno, s, fn, root, statements, eof=False):
175 global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__, __infunc__, __body__, bb, __residue__, __classname__ 165 global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__, __infunc__, __body__, bb, __residue__, __classname__
176 if __infunc__: 166 if __infunc__:
177 if s == '}': 167 if s == '}':
@@ -185,7 +175,7 @@ def feeder(lineno, s, fn, root, statements):
185 175
186 if __inpython__: 176 if __inpython__:
187 m = __python_func_regexp__.match(s) 177 m = __python_func_regexp__.match(s)
188 if m and lineno != IN_PYTHON_EOF: 178 if m and not eof:
189 __body__.append(s) 179 __body__.append(s)
190 return 180 return
191 else: 181 else:
@@ -194,7 +184,7 @@ def feeder(lineno, s, fn, root, statements):
194 __body__ = [] 184 __body__ = []
195 __inpython__ = False 185 __inpython__ = False
196 186
197 if lineno == IN_PYTHON_EOF: 187 if eof:
198 return 188 return
199 189
200 if s and s[0] == '#': 190 if s and s[0] == '#':