diff options
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 73 |
1 files changed, 70 insertions, 3 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index e2319aa123..5b3cb38d81 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -86,10 +86,77 @@ def explode_deps(s): | |||
86 | j = [] | 86 | j = [] |
87 | if flag: | 87 | if flag: |
88 | j.append(i) | 88 | j.append(i) |
89 | if i.endswith(')'): | 89 | else: |
90 | r.append(i) | ||
91 | if flag and i.endswith(')'): | ||
90 | flag = False | 92 | flag = False |
91 | # Ignore version | 93 | # Ignore version |
92 | #r[-1] += ' ' + ' '.join(j) | 94 | #r[-1] += ' ' + ' '.join(j) |
93 | else: | ||
94 | r.append(i) | ||
95 | return r | 95 | return r |
96 | |||
97 | |||
98 | |||
99 | def _print_trace(body, line): | ||
100 | """ | ||
101 | Print the Environment of a Text Body | ||
102 | """ | ||
103 | import bb | ||
104 | |||
105 | # print the environment of the method | ||
106 | bb.error("Printing the environment of the function") | ||
107 | min_line = max(1,line-4) | ||
108 | max_line = min(line+4,len(body)-1) | ||
109 | for i in range(min_line,max_line+1): | ||
110 | bb.error("\t%.4d:%s" % (i, body[i-1]) ) | ||
111 | |||
112 | |||
113 | def better_compile(text, file, realfile): | ||
114 | """ | ||
115 | A better compile method. This method | ||
116 | will print the offending lines. | ||
117 | """ | ||
118 | try: | ||
119 | return compile(text, file, "exec") | ||
120 | except Exception, e: | ||
121 | import bb,sys | ||
122 | |||
123 | # split the text into lines again | ||
124 | body = text.split('\n') | ||
125 | bb.error("Error in compiling: ", realfile) | ||
126 | bb.error("The lines resulting into this error were:") | ||
127 | bb.error("\t%d:%s:'%s'" % (e.lineno, e.__class__.__name__, body[e.lineno-1])) | ||
128 | |||
129 | _print_trace(body, e.lineno) | ||
130 | |||
131 | # exit now | ||
132 | sys.exit(1) | ||
133 | |||
134 | def better_exec(code, context, text, realfile): | ||
135 | """ | ||
136 | Similiar to better_compile, better_exec will | ||
137 | print the lines that are responsible for the | ||
138 | error. | ||
139 | """ | ||
140 | import bb,sys | ||
141 | try: | ||
142 | exec code in context | ||
143 | except: | ||
144 | (t,value,tb) = sys.exc_info() | ||
145 | |||
146 | if t in [bb.parse.SkipPackage, bb.build.FuncFailed]: | ||
147 | raise | ||
148 | |||
149 | # print the Header of the Error Message | ||
150 | bb.error("Error in executing: ", realfile) | ||
151 | bb.error("Exception:%s Message:%s" % (t,value) ) | ||
152 | |||
153 | # let us find the line number now | ||
154 | while tb.tb_next: | ||
155 | tb = tb.tb_next | ||
156 | |||
157 | import traceback | ||
158 | line = traceback.tb_lineno(tb) | ||
159 | |||
160 | _print_trace( text.split('\n'), line ) | ||
161 | |||
162 | raise | ||