builder: bring back cross compilation for windows

pull/4888/head
Alexander Medvednikov 2020-05-13 23:02:31 +02:00
parent 1bf26a35fa
commit e60e8f3b34
1 changed files with 13 additions and 14 deletions

View File

@ -490,8 +490,6 @@ If you're confident that all of the above is true, please try running V with the
} }
fn (mut c Builder) cc_windows_cross() { fn (mut c Builder) cc_windows_cross() {
/*
QTODO
println('Cross compiling for Windows...') println('Cross compiling for Windows...')
if !c.pref.out_name.ends_with('.exe') { if !c.pref.out_name.ends_with('.exe') {
c.pref.out_name += '.exe' c.pref.out_name += '.exe'
@ -530,22 +528,24 @@ fn (mut c Builder) cc_windows_cross() {
obj_name = obj_name.replace('.o.o', '.o') obj_name = obj_name.replace('.o.o', '.o')
include := '-I $winroot/include ' include := '-I $winroot/include '
*/ */
mut cmd := '' if os.user_os() !in ['mac', 'darwin','linux'] {
cmd = '' println(os.user_os())
$if macos {
cmd = 'x86_64-w64-mingw32-gcc -std=gnu11 $args -municode'
}
$else {
panic('your platform is not supported yet') panic('your platform is not supported yet')
} }
mut cmd := 'x86_64-w64-mingw32-gcc'
println(cmd) cmd += ' -std=gnu11 $args -municode'
//cmd := 'clang -o $obj_name -w $include -m32 -c -target x86_64-win32 ${pref.default_module_path}/$c.out_name_c' //cmd := 'clang -o $obj_name -w $include -m32 -c -target x86_64-win32 ${pref.default_module_path}/$c.out_name_c'
if c.pref.verbosity.is_higher_or_equal(.level_one) { if c.pref.is_verbose {
println(cmd) println(cmd)
} }
if os.system(cmd) != 0 { if os.system(cmd) != 0 {
println('Cross compilation for Windows failed. Make sure you have clang installed.') println('Cross compilation for Windows failed. Make sure you have mingw-w64 installed.')
$if macos {
println('brew install mingw-w64')
}
$if linux {
println('sudo apt install -y mingw-w64')
}
exit(1) exit(1)
} }
/* /*
@ -561,8 +561,7 @@ fn (mut c Builder) cc_windows_cross() {
// os.rm(obj_name) // os.rm(obj_name)
} }
*/ */
println('Done!') println(c.pref.out_name + ' has been successfully compiled')
*/
} }
fn (c &Builder) build_thirdparty_obj_files() { fn (c &Builder) build_thirdparty_obj_files() {