Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cmd/v/v.v
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ fn main() {
}
mut args_and_flags := util.join_env_vflags_and_os_args()[1..]
prefs, command := pref.parse_args_and_show_errors(external_tools, args_and_flags, true)
$if windows {
// Check an explicitly selected C compiler before dispatching the command, so
// invalid or missing commands do not hide the more useful `-cc` diagnostic.
if builder.should_find_windows_host_c_compiler(prefs) && prefs.ccompiler_set_by_flag
&& prefs.ccompiler != 'msvc' {
Comment thread
GGRei marked this conversation as resolved.
Outdated
mut probe := builder.Builder{
pref: unsafe { prefs }
}
probe.find_win_cc() or { builder.verror(err.msg()) }
}
}
maybe_delegate_to_vvmrc(command, prefs)
maybe_delegate_to_ownership(command, prefs)
if prefs.use_cache && os.user_os() == 'windows' {
Expand Down
16 changes: 16 additions & 0 deletions cmd/v/v_windows_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module main

import os

fn test_invalid_c_compiler_is_reported_before_command_dispatch() {
$if !windows {
return
}
missing_compiler := 'missing_compiler_27868'
expected_error := 'builder error: C compiler `${missing_compiler}` was requested with `-cc`, but was not found.'
for command in ['', 'not-a-command'] {
result := os.execute('${os.quoted_path(@VEXE)} -cc ${missing_compiler} ${command}')
assert result.exit_code == 1
assert result.output.contains(expected_error), result.output
}
}
Loading