From 2f23ee4818f95fd796a4d85b028e9c50004b1809 Mon Sep 17 00:00:00 2001 From: vitalyster Date: Fri, 27 Dec 2019 21:07:31 +0300 Subject: [PATCH] windows: cleanup after bootstrapping with unicode entrypoint --- make.bat | 14 +++----------- vlib/compiler/main.v | 13 ------------- vlib/os/os_windows.v | 10 +--------- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/make.bat b/make.bat index 06457da86c..3114e03ec2 100644 --- a/make.bat +++ b/make.bat @@ -28,18 +28,14 @@ if not exist "%gccpath%" ( goto:msvcstrap ) -gcc -std=c99 -DV_BOOTSTRAP -w -o v2.exe vc\v_win.c +gcc -std=c99 -municode -w -o v2.exe vc\v_win.c if %ERRORLEVEL% NEQ 0 ( echo gcc failed to compile - Create an issue at 'https://github.com/vlang' exit /b 1 ) echo Now using V to build V... -rem TODO: remove when v.c is updated -set VFLAGS=-cflags -DV_BOOTSTRAP -o v3.c v.v -v2.exe -gcc -std=c99 -DV_BOOTSTRAP -w -o v3.exe vc\v_win.c -set VFLAGS= +v2.exe -o v3.exe v.v v3.exe -o v.exe -prod v.v if %ERRORLEVEL% NEQ 0 ( echo v.exe failed to compile itself - Create an issue at 'https://github.com/vlang' @@ -81,11 +77,7 @@ if %ERRORLEVEL% NEQ 0 ( ) echo rebuild from source (twice, in case of C definitions changes) -rem TODO: remove when v.c is updated -set VFLAGS=-cc msvc -cflags /DV_BOOTSTRAP -o v3.c v.v -v2.exe -cl.exe /nologo /w /volatile:ms /Fo%ObjFile% /O2 /MD /D_VBOOTSTRAP v3.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /NOLOGO /OUT:v3.exe /INCREMENTAL:NO -set VFLAGS= +v2.exe -cc msvc -o v3.exe v.v v3.exe -cc msvc -o v -prod v.v if %ERRORLEVEL% NEQ 0 ( echo V failed to build itself with error %ERRORLEVEL% diff --git a/vlib/compiler/main.v b/vlib/compiler/main.v index b0228c3bcb..d68696088a 100644 --- a/vlib/compiler/main.v +++ b/vlib/compiler/main.v @@ -559,9 +559,6 @@ pub fn (v mut V) generate_main() { pub fn (v mut V) gen_main_start(add_os_args bool) { if v.os == .windows { if 'glfw' in v.table.imports { - v.cgen.genln('#ifdef V_BOOTSTRAP') - v.cgen.genln('int main(int argc, char** argv) { ') - v.cgen.genln('#else') // GUI application v.cgen.genln('int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, LPWSTR cmd_line, int show_cmd) { ') v.cgen.genln(' typedef LPWSTR*(WINAPI *cmd_line_to_argv)(LPCWSTR, int*);') @@ -569,15 +566,9 @@ pub fn (v mut V) gen_main_start(add_os_args bool) { v.cgen.genln(' cmd_line_to_argv CommandLineToArgvW = (cmd_line_to_argv)GetProcAddress(shell32_module, "CommandLineToArgvW");') v.cgen.genln(' int argc;') v.cgen.genln(' wchar_t** argv = CommandLineToArgvW(cmd_line, &argc);') - v.cgen.genln(' os__args = os__init_os_args_wide(argc, argv);') - v.cgen.genln('#endif') } else { - v.cgen.genln('#ifdef V_BOOTSTRAP') - v.cgen.genln('int main(int argc, char** argv) { ') - v.cgen.genln('#else') // Console application v.cgen.genln('int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) { ') - v.cgen.genln('#endif') } } else { v.cgen.genln('int main(int argc, char** argv) { ') @@ -585,11 +576,7 @@ pub fn (v mut V) gen_main_start(add_os_args bool) { v.cgen.genln(' init();') if add_os_args && 'os' in v.table.imports { if v.os == .windows { - v.cgen.genln('#ifdef V_BOOTSTRAP') - v.cgen.genln(' os__args = os__init_os_args(argc, (byteptr*)argv);') - v.cgen.genln('#else') v.cgen.genln(' os__args = os__init_os_args_wide(argc, argv);') - v.cgen.genln('#endif') } else { v.cgen.genln(' os__args = os__init_os_args(argc, (byteptr*)argv);') } diff --git a/vlib/os/os_windows.v b/vlib/os/os_windows.v index 236f941542..6533063165 100644 --- a/vlib/os/os_windows.v +++ b/vlib/os/os_windows.v @@ -74,15 +74,7 @@ mut: bInheritHandle bool } -fn init_os_args(argc int, argv &byteptr) []string { - mut args := []string - for i := 0; i < argc; i++ { - args << string(argv[i]) - } - return args -} - -fn init_os_args_wide(argc int, argv &byteptr) []string { +fn init_os_args_wide(argc int, argv &byteptr) []string { mut args := []string for i := 0; i < argc; i++ { args << string_from_wide(&u16(argv[i]))