diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3e66a1932..322b2f0907 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,14 +85,14 @@ jobs: # with: # node-version: 12.x - name: Build - env: - VFLAGS: -os msvc + #env: + # VFLAGS: -cc msvc run: | git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries.git thirdparty/freetype/ .\make.bat -msvc - name: Test - env: - VFLAGS: -os msvc + #env: + # VFLAGS: -cc msvc run: | .\v.exe test v ## v.js dosent work on windows diff --git a/.travis.yml b/.travis.yml index 494cecd494..26ac0b5e3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,12 +45,11 @@ script: if [[ "${TRAVIS_JOB_NAME}" == "windows_gcc" ]]; then gcc --version echo "Building V with GCC" - export VFLAGS="-os windows" ./make.bat -gcc fi if [[ "${TRAVIS_JOB_NAME}" == "windows_msvc" ]]; then echo "Building V with MSVC" - export VFLAGS="-os msvc" + #export VFLAGS="-cc msvc" ./make.bat -msvc fi diff --git a/examples/hot_reload/glfw3.dll b/examples/hot_reload/glfw3.dll new file mode 100644 index 0000000000..1ed6f46c8d Binary files /dev/null and b/examples/hot_reload/glfw3.dll differ diff --git a/make.bat b/make.bat index ff85aef4d8..1d1b8a0c3d 100644 --- a/make.bat +++ b/make.bat @@ -69,8 +69,8 @@ if %ERRORLEVEL% NEQ 0 ( ) echo rebuild from source (twice, in case of C definitions changes) -v2.exe -os msvc -o v3.exe v.v -v3.exe -os msvc -o v.exe -prod v.v +v2.exe -o v3.exe v.v +v3.exe -cc msvc -o v.exe -prod v.v if %ERRORLEVEL% NEQ 0 ( echo V failed to build itself goto :compileerror diff --git a/vlib/compiler/cc.v b/vlib/compiler/cc.v index e2f5bcd4ed..0959a9585a 100644 --- a/vlib/compiler/cc.v +++ b/vlib/compiler/cc.v @@ -48,7 +48,7 @@ fn (v mut V) cc() { } } $if windows { - if v.os == .msvc { + if v.pref.ccompiler == 'msvc' { v.cc_msvc() return } @@ -119,7 +119,7 @@ fn (v mut V) cc() { a << ' -rdynamic ' // needed for nicer symbolic backtraces } - if v.os != .msvc && v.os != .freebsd { + if v.pref.ccompiler != 'msvc' && v.os != .freebsd { a << '-Werror=implicit-function-declaration' } @@ -314,7 +314,11 @@ fn (c mut V) cc_windows_cross() { mut args := '-o $c.out_name -w -L. ' cflags := c.get_os_cflags() // -I flags - args += cflags.c_options_before_target() + 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 { libs = '"$v_modules_path/vlib/builtin.o"' @@ -327,7 +331,11 @@ fn (c mut V) cc_windows_cross() { } } args += ' $c.out_name_c ' - args += cflags.c_options_after_target() + 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.dir_exists(winroot) { @@ -372,7 +380,7 @@ fn (c &V) build_thirdparty_obj_files() { for flag in c.get_os_cflags() { if flag.value.ends_with('.o') { rest_of_module_flags := c.get_rest_of_module_cflags( flag ) - if c.os == .msvc { + if c.pref.ccompiler == 'msvc' { build_thirdparty_obj_file_with_msvc(flag.value, rest_of_module_flags) } else { diff --git a/vlib/compiler/cflags.v b/vlib/compiler/cflags.v index da6d4a2cb7..8b6f1cd47a 100644 --- a/vlib/compiler/cflags.v +++ b/vlib/compiler/cflags.v @@ -26,7 +26,7 @@ fn (v &V) get_os_cflags() []CFlag { || (flag.os == 'linux' && v.os == .linux) || (flag.os == 'darwin' && v.os == .mac) || (flag.os == 'freebsd' && v.os == .freebsd) - || (flag.os == 'windows' && (v.os == .windows || v.os == .msvc)) { + || (flag.os == 'windows' && v.os == .windows) { flags << flag } } @@ -140,10 +140,10 @@ fn (table mut Table) parse_cflag(cflag string, mod string) { } //TODO: implement msvc specific c_options_before_target and c_options_after_target ... +fn (cflags []CFlag) c_options_before_target_msvc() string { return '' } +fn (cflags []CFlag) c_options_after_target_msvc() string { return '' } + fn (cflags []CFlag) c_options_before_target() string { - $if msvc { - return '' - } // -I flags, optimization flags and so on mut args:=[]string for flag in cflags { @@ -155,9 +155,6 @@ fn (cflags []CFlag) c_options_before_target() string { } fn (cflags []CFlag) c_options_after_target() string { - $if msvc { - return '' - } // -l flags (libs) mut args:=[]string for flag in cflags { diff --git a/vlib/compiler/fn.v b/vlib/compiler/fn.v index dd88225b07..617ab6b317 100644 --- a/vlib/compiler/fn.v +++ b/vlib/compiler/fn.v @@ -326,7 +326,7 @@ fn (p mut Parser) fn_decl() { p.error_with_token_index('fn main must have no arguments and no return values', f.fn_name_token_idx) } } - dll_export_linkage := if p.os == .msvc && p.attr == 'live' && p.pref.is_so { + dll_export_linkage := if p.pref.ccompiler == 'msvc' && p.attr == 'live' && p.pref.is_so { '__declspec(dllexport) ' } else if p.attr == 'inline' { 'static inline ' @@ -590,7 +590,7 @@ fn (p mut Parser) async_fn_call(f Fn, method_ph int, receiver_var, receiver_type // Create thread object tmp_nr := p.get_tmp_counter() thread_name = '_thread$tmp_nr' - if p.os != .windows && p.os != .msvc { + if p.os != .windows { p.genln('pthread_t $thread_name;') } tmp2 := p.get_tmp() @@ -599,7 +599,7 @@ fn (p mut Parser) async_fn_call(f Fn, method_ph int, receiver_var, receiver_type parg = ' $tmp_struct' } // Call the wrapper - if p.os == .windows || p.os == .msvc { + if p.os == .windows { p.genln(' CreateThread(0,0, $wrapper_name, $parg, 0,0);') } else { diff --git a/vlib/compiler/gen_c.v b/vlib/compiler/gen_c.v index 194b6756a0..abc2664f6c 100644 --- a/vlib/compiler/gen_c.v +++ b/vlib/compiler/gen_c.v @@ -75,7 +75,7 @@ fn (p mut Parser) gen_var_decl(name string, is_static bool) string { } fn (p mut Parser) gen_fn_decl(f Fn, typ, str_args string) { - dll_export_linkage := if p.os == .msvc && p.attr == 'live' && p.pref.is_so { + dll_export_linkage := if p.pref.ccompiler == 'msvc' && p.attr == 'live' && p.pref.is_so { '__declspec(dllexport) ' } else if p.attr == 'inline' { 'static inline ' diff --git a/vlib/compiler/live.v b/vlib/compiler/live.v index f17c6e2ac8..7f286d4d7e 100644 --- a/vlib/compiler/live.v +++ b/vlib/compiler/live.v @@ -19,7 +19,7 @@ fn (v &V) generate_hotcode_reloading_compiler_flags() []string { fn (v &V) generate_hotcode_reloading_declarations() { mut cgen := v.cgen - if v.os != .windows && v.os != .msvc { + if v.os != .windows { if v.pref.is_so { cgen.genln('pthread_mutex_t live_fn_mutex;') } @@ -42,7 +42,7 @@ fn (v &V) generate_hotcode_reloading_main_caller() { mut cgen := v.cgen cgen.genln('') file_base := os.filename(v.dir).replace('.v', '') - if !(v.os == .windows || v.os == .msvc) { + if v.os != .windows { // unix: so_name := file_base + '.so' cgen.genln(' char *live_library_name = "$so_name";') @@ -51,7 +51,7 @@ fn (v &V) generate_hotcode_reloading_main_caller() { cgen.genln(' pthread_create(&_thread_so , NULL, &reload_so, live_library_name);') } else { // windows: - so_name := file_base + if v.os == .msvc {'.dll'} else {'.so'} + so_name := file_base + if v.pref.ccompiler == 'msvc' {'.dll'} else {'.so'} cgen.genln(' char *live_library_name = "$so_name";') cgen.genln(' live_fn_mutex = CreateMutexA(0, 0, 0);') cgen.genln(' load_so(live_library_name);') @@ -78,8 +78,8 @@ fn (v &V) generate_hot_reload_code() { } mut msvc := '' - if v.os == .msvc { - msvc = '-os msvc' + if v.pref.ccompiler == 'msvc' { + msvc = '-cc msvc' } so_debug_flag := if v.pref.is_debug { '-g' } else { '' } @@ -104,7 +104,7 @@ void lfnmutex_print(char *s){ } ') - if v.os != .windows && v.os != .msvc { + if v.os != .windows { cgen.genln(' #include void* live_lib=0; diff --git a/vlib/compiler/msvc.v b/vlib/compiler/msvc.v index 2696b5f6ad..9cd4eee156 100644 --- a/vlib/compiler/msvc.v +++ b/vlib/compiler/msvc.v @@ -396,8 +396,8 @@ fn build_thirdparty_obj_file_with_msvc(path string, moduleflags []CFlag) { //println('cfiles: $cfiles') - btarget := moduleflags.c_options_before_target() - atarget := moduleflags.c_options_after_target() + btarget := moduleflags.c_options_before_target_msvc() + atarget := moduleflags.c_options_after_target_msvc() cmd := '""$msvc.full_cl_exe_path" /volatile:ms /Zi /DNDEBUG $include_string /c $btarget $cfiles $atarget /Fo"$obj_path""' //NB: the quotes above ARE balanced. println('thirdparty cmd line: $cmd') diff --git a/vlib/compiler/vhelp.v b/vlib/compiler/vhelp.v index 69f7d13d1e..afbaa67ae7 100644 --- a/vlib/compiler/vhelp.v +++ b/vlib/compiler/vhelp.v @@ -26,7 +26,7 @@ const ( you don\'t have to repeat them. You can set it like this: `export VFLAGS="-cc clang -debug"` on *nix, - `set VFLAGS=-os msvc` on Windows. + `set VFLAGS=-cc msvc` on Windows. Options/commands: -h, help Display this information. diff --git a/vlib/os/os.v b/vlib/os/os.v index 02cc1ed1ff..df893b5274 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -600,9 +600,6 @@ pub fn user_os() string { $if dragonfly { return 'dragonfly' } - $if msvc { - return 'windows' - } $if android{ return 'android' }