mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
make.bat: fix regression for directory path with spaces (#7253)
This commit is contained in:
parent
aedd1d17b8
commit
255f27b4d8
127
make.bat
127
make.bat
@ -97,17 +97,33 @@ if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%
|
|||||||
echo.
|
echo.
|
||||||
echo Cleanup vc
|
echo Cleanup vc
|
||||||
echo ^> Purge TCC binaries
|
echo ^> Purge TCC binaries
|
||||||
call :buildcmd "rmdir /s /q "%tcc_dir%"" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] rmdir /s /q "%tcc_dir%">>"!log_file!"
|
||||||
|
echo rmdir /s /q "%tcc_dir%"
|
||||||
|
)
|
||||||
|
rmdir /s /q "%tcc_dir%">>"!log_file!" 2>NUL
|
||||||
echo ^> Purge vc repository
|
echo ^> Purge vc repository
|
||||||
call :buildcmd "rmdir /s /q "%vc_dir%"" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] rmdir /s /q "%vc_dir%">>"!log_file!"
|
||||||
|
echo rmdir /s /q "%vc_dir%"
|
||||||
|
)
|
||||||
|
rmdir /s /q "%vc_dir%">>"!log_file!" 2>NUL
|
||||||
exit /b 0
|
exit /b 0
|
||||||
|
|
||||||
:clean
|
:clean
|
||||||
echo Cleanup build artifacts
|
echo Cleanup build artifacts
|
||||||
echo ^> Purge debug symbols
|
echo ^> Purge debug symbols
|
||||||
call :buildcmd "del *.pdb *.lib *.bak *.out *.ilk *.exp *.obj *.o *.a *.so" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] del *.pdb *.lib *.bak *.out *.ilk *.exp *.obj *.o *.a *.so>>"!log_file!"
|
||||||
|
echo del *.pdb *.lib *.bak *.out *.ilk *.exp *.obj *.o *.a *.so
|
||||||
|
)
|
||||||
|
del *.pdb *.lib *.bak *.out *.ilk *.exp *.obj *.o *.a *.so>>"!log_file!" 2>NUL
|
||||||
echo ^> Delete old V executable
|
echo ^> Delete old V executable
|
||||||
call :buildcmd "del v_old.exe v*.exe" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] del v_old.exe v*.exe>>"!log_file!"
|
||||||
|
echo del v_old.exe v*.exe
|
||||||
|
)
|
||||||
|
del v_old.exe v*.exe>>"!log_file!" 2>NUL
|
||||||
exit /b 0
|
exit /b 0
|
||||||
|
|
||||||
:help
|
:help
|
||||||
@ -127,14 +143,30 @@ if !flag_local! NEQ 1 (
|
|||||||
pushd "%vc_dir%" 2>NUL && (
|
pushd "%vc_dir%" 2>NUL && (
|
||||||
echo Updating vc...
|
echo Updating vc...
|
||||||
echo ^> Sync with remote !vc_url!
|
echo ^> Sync with remote !vc_url!
|
||||||
call :buildcmd "cd "%vc_dir%"" " "
|
if !flag_verbose! EQU 1 (
|
||||||
call :buildcmd "git pull --quiet" " "
|
echo [Debug] cd "%vc_dir%">>"!log_file!"
|
||||||
call :buildcmd "cd .." " "
|
echo cd "%vc_dir%"
|
||||||
|
cd "%vc_dir%">>"!log_file!" 2>NUL
|
||||||
|
echo [Debug] git pull --quiet>>"!log_file!"
|
||||||
|
echo git pull --quiet
|
||||||
|
git pull --quiet>>"!log_file!" 2>NUL
|
||||||
|
echo [Debug] cd ..>>"!log_file!"
|
||||||
|
echo cd ..
|
||||||
|
cd ..>>"!log_file!" 2>NUL
|
||||||
|
) else (
|
||||||
|
cd "%vc_dir%">>"!log_file!" 2>NUL
|
||||||
|
git pull --quiet>>"!log_file!" 2>NUL
|
||||||
|
cd ..>>"!log_file!" 2>NUL
|
||||||
|
)
|
||||||
popd
|
popd
|
||||||
) || (
|
) || (
|
||||||
echo Cloning vc...
|
echo Cloning vc...
|
||||||
echo ^> Cloning from remote !vc_url!
|
echo ^> Cloning from remote !vc_url!
|
||||||
call :buildcmd "git clone --depth 1 --quiet "%vc_url%"" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] git clone --depth 1 --quiet %vc_url%>>"!log_file!"
|
||||||
|
echo git clone --depth 1 --quiet %vc_url%
|
||||||
|
)
|
||||||
|
git clone --depth 1 --quiet %vc_url%>>"!log_file!" 2>NUL
|
||||||
)
|
)
|
||||||
echo.
|
echo.
|
||||||
)
|
)
|
||||||
@ -151,15 +183,23 @@ if %ERRORLEVEL% NEQ 0 (
|
|||||||
)
|
)
|
||||||
|
|
||||||
echo ^> Attempting to build v_win.c with Clang
|
echo ^> Attempting to build v_win.c with Clang
|
||||||
call :buildcmd "clang -std=c99 -municode -w -o v.exe .\vc\v_win.c" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] clang -std=c99 -municode -w -o v.exe .\vc\v_win.c>>"!log_File!"
|
||||||
|
echo clang -std=c99 -municode -w -o v.exe .\vc\v_win.c
|
||||||
|
)
|
||||||
|
clang -std=c99 -municode -w -o v.exe .\vc\v_win.c>>"!log_file!" 2>NUL
|
||||||
if %ERRORLEVEL% NEQ 0 (
|
if %ERRORLEVEL% NEQ 0 (
|
||||||
REM In most cases, compile errors happen because the version of Clang installed is too old
|
REM In most cases, compile errors happen because the version of Clang installed is too old
|
||||||
call :buildcmd "clang --version" " " 1
|
clang --version>>"!log_file!"
|
||||||
goto :compile_error
|
goto :compile_error
|
||||||
)
|
)
|
||||||
|
|
||||||
echo ^> Compiling with .\v.exe self
|
echo ^> Compiling with .\v.exe self
|
||||||
call :buildcmd "v.exe -cc clang self" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] v.exe -cc clang self>>"!log_file!"
|
||||||
|
echo v.exe -cc clang self
|
||||||
|
)
|
||||||
|
v.exe -cc clang self>>"!log_file!" 2>NUL
|
||||||
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
||||||
goto :success
|
goto :success
|
||||||
|
|
||||||
@ -172,15 +212,23 @@ if %ERRORLEVEL% NEQ 0 (
|
|||||||
)
|
)
|
||||||
|
|
||||||
echo ^> Attempting to build v_win.c with GCC
|
echo ^> Attempting to build v_win.c with GCC
|
||||||
call :buildcmd "gcc -std=c99 -municode -w -o v.exe .\vc\v_win.c" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] gcc -std=c99 -municode -w -o v.exe .\vc\v_win.c>>"!log_File!"
|
||||||
|
echo gcc -std=c99 -municode -w -o v.exe .\vc\v_win.c
|
||||||
|
)
|
||||||
|
gcc -std=c99 -municode -w -o v.exe .\vc\v_win.c>>"!log_File!" 2>NUL
|
||||||
if %ERRORLEVEL% NEQ 0 (
|
if %ERRORLEVEL% NEQ 0 (
|
||||||
REM In most cases, compile errors happen because the version of GCC installed is too old
|
REM In most cases, compile errors happen because the version of GCC installed is too old
|
||||||
call :buildcmd "gcc --version" " " 1
|
gcc --version>>"!log_File!"
|
||||||
goto :compile_error
|
goto :compile_error
|
||||||
)
|
)
|
||||||
|
|
||||||
echo ^> Compiling with .\v.exe self
|
echo ^> Compiling with .\v.exe self
|
||||||
call :buildcmd "v.exe self" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] v.exe -cc gcc self>>"!log_file!"
|
||||||
|
echo v.exe -cc gcc self
|
||||||
|
)
|
||||||
|
v.exe -cc gcc self>>"!log_file!" 2>NUL
|
||||||
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
||||||
goto :success
|
goto :success
|
||||||
|
|
||||||
@ -212,15 +260,23 @@ if exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" (
|
|||||||
set ObjFile=.v.c.obj
|
set ObjFile=.v.c.obj
|
||||||
|
|
||||||
echo ^> Attempting to build v_win.c with MSVC
|
echo ^> Attempting to build v_win.c with MSVC
|
||||||
call :buildcmd "cl.exe /volatile:ms /Fo%ObjFile% /O2 /MD /D_VBOOTSTRAP vc\v_win.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /nologo /out:v.exe /incremental:no" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] cl.exe /volatile:ms /Fo%ObjFile% /O2 /MD /D_VBOOTSTRAP vc\v_win.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /nologo /out:v.exe /incremental:no>>"!log_file!"
|
||||||
|
echo cl.exe /volatile:ms /Fo%ObjFile% /O2 /MD /D_VBOOTSTRAP vc\v_win.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /nologo /out:v.exe /incremental:no
|
||||||
|
)
|
||||||
|
cl.exe /volatile:ms /Fo%ObjFile% /O2 /MD /D_VBOOTSTRAP vc\v_win.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /nologo /out:v.exe /incremental:no>>"!log_file!" 2>NUL
|
||||||
if %ERRORLEVEL% NEQ 0 (
|
if %ERRORLEVEL% NEQ 0 (
|
||||||
REM In some cases, compile errors happen because of the MSVC compiler version
|
REM In some cases, compile errors happen because of the MSVC compiler version
|
||||||
call :buildcmd "cl.exe 1>NUL" " " 1
|
cl.exe 1>NUL 2>"!log_file!"
|
||||||
goto :compile_error
|
goto :compile_error
|
||||||
)
|
)
|
||||||
|
|
||||||
echo ^> Compiling with .\v.exe self
|
echo ^> Compiling with .\v.exe self
|
||||||
call :buildcmd "v.exe -cc msvc self" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] v.exe -cc msvc self>>"!log_file!"
|
||||||
|
echo v.exe -cc msvc self
|
||||||
|
)
|
||||||
|
v.exe -cc msvc self>>"!log_file!" 2>NUL
|
||||||
del %ObjFile%>>"!log_file!" 2>>&1
|
del %ObjFile%>>"!log_file!" 2>>&1
|
||||||
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
||||||
goto :success
|
goto :success
|
||||||
@ -228,11 +284,19 @@ goto :success
|
|||||||
:tcc_strap
|
:tcc_strap
|
||||||
if [!compiler!] == [] set /a invalid_cc=1
|
if [!compiler!] == [] set /a invalid_cc=1
|
||||||
echo ^> Attempting to build v_win.c with TCC
|
echo ^> Attempting to build v_win.c with TCC
|
||||||
call :buildcmd ""!tcc_exe!" -std=c99 -municode -lws2_32 -lshell32 -ladvapi32 -bt10 -w -o v.exe vc\v_win.c" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] "!tcc_exe!" -std=c99 -municode -lws2_32 -lshell32 -ladvapi32 -bt10 -w -o v.exe vc\v_win.c>>"!log_file!"
|
||||||
|
echo "!tcc_exe!" -std=c99 -municode -lws2_32 -lshell32 -ladvapi32 -bt10 -w -o v.exe vc\v_win.c
|
||||||
|
)
|
||||||
|
"!tcc_exe!" -std=c99 -municode -lws2_32 -lshell32 -ladvapi32 -bt10 -w -o v.exe vc\v_win.c>>"!log_file!" 2>NUL
|
||||||
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
||||||
|
|
||||||
echo ^> Compiling with .\v.exe self
|
echo ^> Compiling with .\v.exe self
|
||||||
call :buildcmd "v.exe -cc "!tcc_exe!" self" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] v.exe -cc "!tcc_exe!" self>>"!log_file!"
|
||||||
|
echo v.exe -cc "!tcc_exe!" self
|
||||||
|
)
|
||||||
|
v.exe -cc "!tcc_exe!" self>>"!log_file!" 2>NUL
|
||||||
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
||||||
goto :success
|
goto :success
|
||||||
|
|
||||||
@ -240,18 +304,26 @@ goto :success
|
|||||||
pushd %tcc_dir% 2>NUL && (
|
pushd %tcc_dir% 2>NUL && (
|
||||||
echo Updating TCC
|
echo Updating TCC
|
||||||
echo ^> Syncing TCC from !tcc_url!
|
echo ^> Syncing TCC from !tcc_url!
|
||||||
call :buildcmd "git pull --quiet" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] git pull --quiet>>"!log_file!"
|
||||||
|
echo git pull --quiet
|
||||||
|
)
|
||||||
|
git pull --quiet>>"!log_file!" 2>NUL
|
||||||
popd
|
popd
|
||||||
) || (
|
) || (
|
||||||
echo Bootstraping TCC...
|
echo Bootstraping TCC...
|
||||||
echo ^> TCC not found
|
echo ^> TCC not found
|
||||||
echo ^> Downloading TCC from !tcc_url!
|
echo ^> Downloading TCC from !tcc_url!
|
||||||
call :buildcmd "git clone --depth 1 --quiet --single-branch --branch "!tcc_branch!" "!tcc_url!" "%tcc_dir%"" " "
|
if !flag_verbose! EQU 1 (
|
||||||
|
echo [Debug] git clone --depth 1 --quiet --single-branch --branch !tcc_branch! !tcc_url! "%tcc_dir%">>"!log_file!"
|
||||||
|
echo git clone --depth 1 --quiet --single-branch --branch !tcc_branch! !tcc_url! "%tcc_dir%"
|
||||||
|
)
|
||||||
|
git clone --depth 1 --quiet --single-branch --branch !tcc_branch! !tcc_url! "%tcc_dir%">>"!log_file!" 2>NUL
|
||||||
)
|
)
|
||||||
for /f "usebackq delims=" %%i in (`dir %tcc_dir% /b /a /s tcc.exe`) do (
|
for /f "usebackq delims=" %%i in (`dir "%tcc_dir%" /b /a /s tcc.exe`) do (
|
||||||
set "attrib=%%~ai"
|
set "attrib=%%~ai"
|
||||||
set "dattrib=%attrib:~0,1%"
|
set "dattrib=%attrib:~0,1%"
|
||||||
if /I not "%dattrib%" == "d" set "tcc_exe=%%i"
|
if /I not "%dattrib%" == "d" set "tcc_exe=%%~sfi"
|
||||||
)
|
)
|
||||||
if [!tcc_exe!] == [] echo ^> TCC not found, even after cloning& goto :error
|
if [!tcc_exe!] == [] echo ^> TCC not found, even after cloning& goto :error
|
||||||
echo.
|
echo.
|
||||||
@ -288,15 +360,6 @@ echo | set /p="V version: "
|
|||||||
.\v.exe version
|
.\v.exe version
|
||||||
goto :eof
|
goto :eof
|
||||||
|
|
||||||
:buildcmd
|
|
||||||
if !flag_verbose! EQU 1 (
|
|
||||||
echo [Debug] %~1>>"!log_file!"
|
|
||||||
echo %~2 %~1
|
|
||||||
)
|
|
||||||
if not [%~3] == [] echo.& %~1
|
|
||||||
%~1>>"!log_file!" 2>>&1
|
|
||||||
exit /b %ERRORLEVEL%
|
|
||||||
|
|
||||||
:usage
|
:usage
|
||||||
echo Usage:
|
echo Usage:
|
||||||
echo make.bat [target] [compiler] [options]
|
echo make.bat [target] [compiler] [options]
|
||||||
|
Loading…
Reference in New Issue
Block a user