Skip to content

Commit cac026a

Browse files
committed
v.builder: show the last line of the C compiler output, in case of errors, in addition to the truncated first lines (the last line is useful, since it usually has an error counter)
1 parent f8b70b7 commit cac026a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

vlib/v/builder/cc.v

+6-2
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,18 @@ fn (mut v Builder) post_process_c_compiler_output(ccompiler string, res os.Resul
5959
} else {
6060
trimmed_output := res.output.trim_space()
6161
original_elines := trimmed_output.split_into_lines()
62-
elines := error_context_lines(trimmed_output, 'error:', 1, 12)
62+
mlines := 12
63+
cut_off_limit := if original_elines.len > mlines + 3 { mlines } else { mlines + 3 }
64+
elines := error_context_lines(trimmed_output, 'error:', 1, cut_off_limit)
6365
header := '================== ${c_compilation_error_title} (from ${ccompiler}): =============='
6466
println(header)
6567
for eline in elines {
6668
println('cc: ${eline}')
6769
}
6870
if original_elines.len != elines.len {
69-
println('... (the original output was ${original_elines.len} lines long, and was truncated to ${elines.len} lines)')
71+
println('...')
72+
println('cc: ${original_elines#[-1..][0]}')
73+
println('(note: the original output was ${original_elines.len} lines long; it was truncated to its first ${elines.len} lines + the last line)')
7074
}
7175
println('='.repeat(header.len))
7276
println('(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).')

0 commit comments

Comments
 (0)