1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cc.v: use msvc on Windows by default if gcc is not installed

This commit is contained in:
Alexander Medvednikov 2019-11-08 21:15:14 +03:00
parent c4ff0d565b
commit 6f95be60a1
2 changed files with 27 additions and 3 deletions

2
v.v
View File

@ -42,7 +42,7 @@ fn main() {
compiler.launch_tool('vup')
return
}
else if ('search' in commands) || ('install' in commands) || ('update' in commands) || ('remove' in commands){
else if 'search' in commands || 'install' in commands || 'update' in commands || 'remove' in commands {
compiler.launch_tool('vpm')
return
}

View File

@ -14,6 +14,17 @@ fn todo() {
}
fn no_mingw_installed() bool {
$if !windows {
panic('no_mingw_installed() can only run on Windows')
}
os.exec('gcc -v') or {
println('mingw not found, trying to build with msvc...')
return true
}
return false
}
fn (v mut V) cc() {
v.build_thirdparty_obj_files()
vexe := vexe_path()
@ -57,7 +68,7 @@ fn (v mut V) cc() {
}
}
$if windows {
if v.pref.ccompiler == 'msvc' {
if v.pref.ccompiler == 'msvc' || no_mingw_installed() {
v.cc_msvc()
return
}
@ -257,7 +268,20 @@ start:
println(cmd)
}
ticks := time.ticks()
res := os.exec(cmd) or { verror(err) return }
res := os.exec(cmd) or {
// C compilation failed.
// If we are on Windows, try msvc
println('C compilation failed.')
/*
if os.user_os() == 'windows' && v.pref.ccompiler != 'msvc' {
println('Trying to build with MSVC')
v.cc_msvc()
return
}
*/
verror(err)
return
}
if res.exit_code != 0 {
// the command could not be found by the system
if res.exit_code == 127 {