From e60e8f3b34aa078f267439b65ba97f20a9e3672b Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 13 May 2020 23:02:31 +0200 Subject: [PATCH] builder: bring back cross compilation for windows --- vlib/v/builder/cc.v | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 244a406c1c..4ed10d06fd 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -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() { - /* - QTODO println('Cross compiling for Windows...') if !c.pref.out_name.ends_with('.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') include := '-I $winroot/include ' */ - mut cmd := '' - cmd = '' - $if macos { - cmd = 'x86_64-w64-mingw32-gcc -std=gnu11 $args -municode' - } - $else { + if os.user_os() !in ['mac', 'darwin','linux'] { + println(os.user_os()) panic('your platform is not supported yet') } - - println(cmd) + mut cmd := 'x86_64-w64-mingw32-gcc' + 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' - if c.pref.verbosity.is_higher_or_equal(.level_one) { + if c.pref.is_verbose { println(cmd) } 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) } /* @@ -561,8 +561,7 @@ fn (mut c Builder) cc_windows_cross() { // os.rm(obj_name) } */ - println('Done!') - */ + println(c.pref.out_name + ' has been successfully compiled') } fn (c &Builder) build_thirdparty_obj_files() {