1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

windows: cleanup after bootstrapping with unicode entrypoint

This commit is contained in:
vitalyster 2019-12-27 21:07:31 +03:00 committed by Alexander Medvednikov
parent 796c376408
commit 2f23ee4818
3 changed files with 4 additions and 33 deletions

View File

@ -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%

View File

@ -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);')
}

View File

@ -74,14 +74,6 @@ 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 {
mut args := []string
for i := 0; i < argc; i++ {