diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2018-11-14 17:46:36 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-11-19 17:03:24 +0000 |
commit | 3de56327b2a50d89399223de5404b3419c2ad309 (patch) | |
tree | aba758602ce43a3f4b248fbf1b9d771d7d7e93f4 | |
parent | 07e1a65f076133da3fa631f315010c32ca42e244 (diff) | |
download | poky-3de56327b2a50d89399223de5404b3419c2ad309.tar.gz |
bitbake: utils: better_compile(): Fix line number when report errors
Fixed:
- Add an error line in base.bbclass, e.g.:
15
16 def oe_import(d):
17 import sys
18 Compile error
19 bbpath = d.getVar("BBPATH").split(":")
[snip]
Note the "Compile error" line, I added it for reporting errors.
$ bitbake -p
ERROR: Error in compiling python function in /buildarea1/lyang1/poky/meta/classes/base.bbclass, line 15:
The code lines resulting in this error were:
0014: import oe.data
0015: for toimport in oe.data.typed_value("OE_IMPORTS", d):
0016: imported = __import__(toimport)
0017: inject(toimport.split(".", 1)[0], imported)
*** 0018:
0019: return ""
0020:
SyntaxError: invalid syntax (base.bbclass, line 18)
There are 2 problems:
- The "line 15" is incorrect, it is a blank line, not the error line.
- The "*** 0018" points to incorrect position.
These two problems would mislead people a lot sometimes.
- Now fix it to:
$ bitbake -p
ERROR: Error in compiling python function in /buildarea1/lyang1/poky/meta/classes/base.bbclass, line 18:
The code lines resulting in this error were:
0001:def oe_import(d):
0002: import sys
*** 0003: Compile error
0004: bbpath = d.getVar("BBPATH").split(":")
[snip]
SyntaxError: invalid syntax (base.bbclass, line 18)
Please see comments in the code for more details on how it is fixed.
(Bitbake rev: bbb3d87d171da38fd8e9bce011d109fba28a75c0)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/utils.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 3b0c9599c4..13bb5f2a05 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -318,10 +318,13 @@ def better_compile(text, file, realfile, mode = "exec", lineno = 0): | |||
318 | error = [] | 318 | error = [] |
319 | # split the text into lines again | 319 | # split the text into lines again |
320 | body = text.split('\n') | 320 | body = text.split('\n') |
321 | error.append("Error in compiling python function in %s, line %s:\n" % (realfile, lineno)) | 321 | error.append("Error in compiling python function in %s, line %s:\n" % (realfile, e.lineno)) |
322 | if hasattr(e, "lineno"): | 322 | if hasattr(e, "lineno"): |
323 | error.append("The code lines resulting in this error were:") | 323 | error.append("The code lines resulting in this error were:") |
324 | error.extend(_print_trace(body, e.lineno)) | 324 | # e.lineno: line's position in reaflile |
325 | # lineno: function name's "position -1" in realfile | ||
326 | # e.lineno - lineno: line's relative position in function | ||
327 | error.extend(_print_trace(body, e.lineno - lineno)) | ||
325 | else: | 328 | else: |
326 | error.append("The function causing this error was:") | 329 | error.append("The function causing this error was:") |
327 | for line in body: | 330 | for line in body: |