Skip to content

Commit e52ff06

Browse files
committed
makev.bat: msvc fixes
1 parent 18d117f commit e52ff06

1 file changed

Lines changed: 27 additions & 6 deletions

File tree

makev.bat

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set V_EXE=./v.exe
1515
set V_BOOTSTRAP=./v_win_bootstrap.exe
1616
set V_OLD=./v_old.exe
1717
set V_UPDATED=./v_up.exe
18+
set V_STAGE=./v_stage.exe
1819
set V_C_FILE=./vc/v_win.c
1920
set where_exe=where.exe
2021
if not ["%SystemRoot%"] == [""] if exist "%SystemRoot%\System32\where.exe" set where_exe=%SystemRoot%\System32\where.exe
@@ -221,19 +222,39 @@ if exist "%InstallDir%/Common7/Tools/vsdevcmd.bat" (
221222
set ObjFile=.v.c.obj
222223

223224
echo ^> Bootstrapping "%V_BOOTSTRAP%" before compiling "%V_EXE%" with MSVC
225+
set stage_vflags=
224226
call :build_bootstrap_with_clang
225-
if %ERRORLEVEL% NEQ 0 call :build_bootstrap_with_gcc
226-
if %ERRORLEVEL% NEQ 0 call :build_bootstrap_with_tcc
227-
if %ERRORLEVEL% NEQ 0 (
227+
if %ERRORLEVEL% EQU 0 (
228+
set stage_vflags=-cc clang -cflags "--target=!clang_target!"
229+
) else (
230+
call :build_bootstrap_with_gcc
231+
if %ERRORLEVEL% EQU 0 (
232+
set stage_vflags=-cc "!gcc_exe!"
233+
) else (
234+
call :build_bootstrap_with_tcc
235+
if %ERRORLEVEL% EQU 0 set stage_vflags=-cc "!tcc_exe!" -cflags -Bthirdparty/tcc
236+
)
237+
)
238+
if not defined stage_vflags (
228239
echo Could not build a bootstrap compiler before compiling with MSVC
229240
if exist %ObjFile% del %ObjFile%
230241
goto :compile_error
231242
)
232243

233-
echo ^> Compiling "%V_EXE%" with "%V_BOOTSTRAP%"
234-
"%V_BOOTSTRAP%" -keepc -g -showcc -cc msvc -o "%V_UPDATED%" cmd/v
244+
echo ^> Compiling "%V_STAGE%" with "%V_BOOTSTRAP%"
245+
"%V_BOOTSTRAP%" -keepc -g -showcc !stage_vflags! -o "%V_STAGE%" cmd/v
246+
if %ERRORLEVEL% NEQ 0 (
247+
if exist %ObjFile% del %ObjFile%
248+
if exist "%V_STAGE%" del "%V_STAGE%"
249+
goto :compile_error
250+
)
251+
252+
echo ^> Compiling "%V_EXE%" with "%V_STAGE%"
253+
"%V_STAGE%" -keepc -g -showcc -cc msvc -o "%V_UPDATED%" cmd/v
254+
set msvc_error=%ERRORLEVEL%
235255
if exist %ObjFile% del %ObjFile%
236-
if %ERRORLEVEL% NEQ 0 goto :compile_error
256+
if exist "%V_STAGE%" del "%V_STAGE%"
257+
if %msvc_error% NEQ 0 goto :compile_error
237258
call :move_updated_to_v
238259
goto :success
239260

0 commit comments

Comments
 (0)