Skip to content

Commit

Permalink
builder: do not search for msvc when it is not needed (#23386)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbkpbot authored Jan 6, 2025
1 parent e983d75 commit 8ec8cf0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
13 changes: 6 additions & 7 deletions vlib/v/builder/builder.v
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ pub fn new_builder(pref_ &pref.Preferences) Builder {
}
table.pointer_size = if pref_.m64 { 8 } else { 4 }
mut msvc := MsvcResult{}
$if windows {
msvc = find_msvc(pref_.m64) or {
if pref_.ccompiler == 'msvc' {
// verror('cannot find MSVC on this OS')
}
MsvcResult{
valid: false
if pref_.ccompiler == 'msvc' {
$if windows {
msvc = find_msvc(pref_.m64) or {
MsvcResult{
valid: false
}
}
}
}
Expand Down
27 changes: 15 additions & 12 deletions vlib/v/builder/cc_windows.v
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ pub fn (mut v Builder) find_win_cc() ! {
println('failed command: `${cmd_version}`')
println('${v.pref.ccompiler} not found, looking for msvc...')
}
find_msvc(v.pref.m64) or {
if v.pref.is_verbose {
println('msvc not found, looking for thirdparty/tcc...')
}
thirdparty_tcc := os.join_path(v.pref.vroot, 'thirdparty', 'tcc', 'tcc.exe')
tcc_version_res := os.execute('${os.quoted_path(thirdparty_tcc)} -v')
if tcc_version_res.exit_code != 0 {
if !v.cached_msvc.valid {
msvc := find_msvc(v.pref.m64) or {
if v.pref.is_verbose {
println('tcc not found')
println('msvc not found, looking for thirdparty/tcc...')
}
thirdparty_tcc := os.join_path(v.pref.vroot, 'thirdparty', 'tcc', 'tcc.exe')
tcc_version_res := os.execute('${os.quoted_path(thirdparty_tcc)} -v')
if tcc_version_res.exit_code != 0 {
if v.pref.is_verbose {
println('tcc not found')
}
return error('tcc not found')
}
return error('tcc not found')
v.pref.ccompiler = thirdparty_tcc
v.pref.ccompiler_type = .tinyc
return
}
v.pref.ccompiler = thirdparty_tcc
v.pref.ccompiler_type = .tinyc
return
v.cached_msvc = msvc
}
v.pref.ccompiler = 'msvc'
v.pref.ccompiler_type = .msvc
Expand Down

0 comments on commit 8ec8cf0

Please sign in to comment.