Skip to content

Commit

Permalink
v.builder: show the last line of the C compiler output, in case of er…
Browse files Browse the repository at this point in the history
…rors, in addition to the truncated first lines (the last line is useful, since it usually has an error counter)
  • Loading branch information
spytheman committed Mar 6, 2025
1 parent f8b70b7 commit cac026a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions vlib/v/builder/cc.v
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ fn (mut v Builder) post_process_c_compiler_output(ccompiler string, res os.Resul
} else {
trimmed_output := res.output.trim_space()
original_elines := trimmed_output.split_into_lines()
elines := error_context_lines(trimmed_output, 'error:', 1, 12)
mlines := 12
cut_off_limit := if original_elines.len > mlines + 3 { mlines } else { mlines + 3 }
elines := error_context_lines(trimmed_output, 'error:', 1, cut_off_limit)
header := '================== ${c_compilation_error_title} (from ${ccompiler}): =============='
println(header)
for eline in elines {
println('cc: ${eline}')
}
if original_elines.len != elines.len {
println('... (the original output was ${original_elines.len} lines long, and was truncated to ${elines.len} lines)')
println('...')
println('cc: ${original_elines#[-1..][0]}')
println('(note: the original output was ${original_elines.len} lines long; it was truncated to its first ${elines.len} lines + the last line)')
}
println('='.repeat(header.len))
println('(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).')
Expand Down

0 comments on commit cac026a

Please sign in to comment.