From 7c47f345bea7c8ee5844c9a568ccd8bfc1ed19e2 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 3 Jan 2020 11:38:26 +0100 Subject: [PATCH] mingw on macos --- vlib/compiler/cc.v | 21 ++++++++++++++++++--- vlib/compiler/main.v | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/vlib/compiler/cc.v b/vlib/compiler/cc.v index 431f3d9aa2..6261330352 100644 --- a/vlib/compiler/cc.v +++ b/vlib/compiler/cc.v @@ -400,6 +400,7 @@ start: } fn (c mut V) cc_windows_cross() { + println('Cross compiling for Windows...') if !c.out_name.ends_with('.exe') { c.out_name = c.out_name + '.exe' } @@ -408,7 +409,7 @@ fn (c mut V) cc_windows_cross() { // -I flags args += if c.pref.ccompiler == 'msvc' { cflags.c_options_before_target_msvc() } else { cflags.c_options_before_target() } mut libs := '' - if c.pref.build_mode == .default_mode { + if false && c.pref.build_mode == .default_mode { libs = '"$v_modules_path/vlib/builtin.o"' if !os.exists(libs) { println('`$libs` not found') @@ -419,8 +420,10 @@ fn (c mut V) cc_windows_cross() { } } args += ' $c.out_name_c ' + args += if c.pref.ccompiler == 'msvc' { cflags.c_options_after_target_msvc() } else { cflags.c_options_after_target() } - println('Cross compiling for Windows...') + + /* winroot := '$v_modules_path/winroot' if !os.is_dir(winroot) { winroot_url := 'https://github.com/vlang/v/releases/download/v0.1.10/winroot.zip' @@ -434,7 +437,17 @@ fn (c mut V) cc_windows_cross() { obj_name = obj_name.replace('.exe', '') obj_name = obj_name.replace('.o.o', '.o') include := '-I $winroot/include ' - cmd := 'clang -o $obj_name -w $include -m32 -c -target x86_64-win32 $v_modules_path/$c.out_name_c' + */ + mut cmd := '' + $if macos { + cmd = 'x86_64-w64-mingw32-gcc $args -municode' + } + $else { + panic('your platform is not supported yet') + } + +println(cmd) + //cmd := 'clang -o $obj_name -w $include -m32 -c -target x86_64-win32 $v_modules_path/$c.out_name_c' if c.pref.show_c_cmd { println(cmd) } @@ -442,6 +455,7 @@ fn (c mut V) cc_windows_cross() { println('Cross compilation for Windows failed. Make sure you have clang installed.') exit(1) } + /* if c.pref.build_mode != .build_module { link_cmd := 'lld-link $obj_name $winroot/lib/libcmt.lib ' + '$winroot/lib/libucrt.lib $winroot/lib/kernel32.lib $winroot/lib/libvcruntime.lib ' + '$winroot/lib/uuid.lib' if c.pref.show_c_cmd { @@ -453,6 +467,7 @@ fn (c mut V) cc_windows_cross() { } // os.rm(obj_name) } + */ println('Done!') } diff --git a/vlib/compiler/main.v b/vlib/compiler/main.v index bde0b9f89f..74f3bb1f01 100644 --- a/vlib/compiler/main.v +++ b/vlib/compiler/main.v @@ -201,6 +201,7 @@ pub fn (v mut V) parse(file string, pass Pass) int { } pub fn (v mut V) compile() { + //println('compile()') // Emily: Stop people on linux from being able to build with msvc if os.user_os() != 'windows' && v.pref.ccompiler == 'msvc' { verror('Cannot build with msvc on ${os.user_os()}')