Skip to content

Commit

Permalink
v.builder: cleanup, support V_NO_C_ERROR_INFO=1 for more compact er…
Browse files Browse the repository at this point in the history
…ror messages on cgen errors.
  • Loading branch information
spytheman committed Oct 5, 2023
1 parent 5c37c31 commit beaa33a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
18 changes: 17 additions & 1 deletion vlib/v/builder/cbuilder/cbuilder.v
Expand Up @@ -17,7 +17,23 @@ pub fn compile_c(mut b builder.Builder) {
println('all .v files before:')
}
$if windows {
b.find_win_cc() or { builder.verror(builder.no_compiler_error) }
b.find_win_cc() or {
builder.verror('
==================
Error: no C compiler detected.
You can find instructions on how to install one in the V wiki:
https://github.com/vlang/v/wiki/Installing-a-C-compiler-on-Windows
If you think you have one installed, make sure it is in your PATH.
If you do have one in your PATH, please raise an issue on GitHub:
https://github.com/vlang/v/issues/new/choose
You can also use `v doctor`, to see what V knows about your current environment.
You can also seek #help on Discord: https://discord.gg/vlang
')
}
}
mut files := b.get_builtin_files()
files << b.get_user_files()
Expand Down
41 changes: 13 additions & 28 deletions vlib/v/builder/cc.v
Expand Up @@ -19,33 +19,6 @@ const (

const c_verror_message_marker = 'VERROR_MESSAGE '

const c_error_info = '
==================
C error. This should never happen.
This is a compiler bug, please report it using `v bug file.v`.
https://github.com/vlang/v/issues/new/choose
You can also use #help on Discord: https://discord.gg/vlang
'

pub const no_compiler_error = '
==================
Error: no C compiler detected.
You can find instructions on how to install one in the V wiki:
https://github.com/vlang/v/wiki/Installing-a-C-compiler-on-Windows
If you think you have one installed, make sure it is in your PATH.
If you do have one in your PATH, please raise an issue on GitHub:
https://github.com/vlang/v/issues/new/choose
You can also use `v doctor`, to see what V knows about your current environment.
You can also seek #help on Discord: https://discord.gg/vlang
'

fn (mut v Builder) show_c_compiler_output(res os.Result) {
println('======== C Compiler output ========')
println(res.output)
Expand Down Expand Up @@ -91,7 +64,19 @@ fn (mut v Builder) post_process_c_compiler_output(res os.Result) {
println('(Use `v -cg` to print the entire error message)\n')
}
}
verror(builder.c_error_info)
if os.getenv('V_NO_C_ERROR_INFO') != '' {
exit(1)
}
verror('
==================
C error. This should never happen.
This is a compiler bug, please report it using `v bug file.v`.
https://github.com/vlang/v/issues/new/choose
You can also use #help on Discord: https://discord.gg/vlang
')
}

fn (mut v Builder) show_cc(cmd string, response_file string, response_file_content string) {
Expand Down

0 comments on commit beaa33a

Please sign in to comment.