2019-08-29 00:18:30 +03:00
|
|
|
@echo off
|
2020-11-25 16:27:52 +03:00
|
|
|
setlocal EnableDelayedExpansion EnableExtensions
|
2019-08-29 00:18:30 +03:00
|
|
|
|
2020-11-25 16:27:52 +03:00
|
|
|
REM Option flags
|
2020-11-28 02:14:14 +03:00
|
|
|
set /a invalid_cc=0
|
2020-11-25 16:27:52 +03:00
|
|
|
set /a shift_counter=0
|
2020-11-28 02:14:14 +03:00
|
|
|
set /a flag_local=0
|
|
|
|
set /a flag_verbose=0
|
2019-08-29 00:18:30 +03:00
|
|
|
|
2020-11-25 16:27:52 +03:00
|
|
|
REM Option variables
|
2020-11-28 02:14:14 +03:00
|
|
|
set "log_file=%TEMP%\v_make.log"
|
|
|
|
set compiler=
|
|
|
|
set subcmd=
|
|
|
|
set target=build
|
2020-11-21 14:02:03 +03:00
|
|
|
|
2020-11-28 02:14:14 +03:00
|
|
|
REM TCC variables
|
2020-11-29 18:18:49 +03:00
|
|
|
set "tcc_url=https://github.com/vlang/tccbin"
|
2020-11-25 16:27:52 +03:00
|
|
|
set "tcc_dir=%~dp0thirdparty\tcc"
|
2021-02-27 21:19:11 +03:00
|
|
|
if "%PROCESSOR_ARCHITECTURE%" == "x86" ( set "tcc_branch=thirdparty-windows-i386" ) else ( set "tcc_branch=thirdparty-windows-amd64" )
|
|
|
|
if "%~1" == "-tcc32" set "tcc_branch=thirdparty-windows-i386"
|
2020-11-29 18:18:49 +03:00
|
|
|
|
|
|
|
REM VC settings
|
|
|
|
set "vc_url=https://github.com/vlang/vc"
|
2020-11-25 16:27:52 +03:00
|
|
|
set "vc_dir=%~dp0vc"
|
2020-07-16 19:33:26 +03:00
|
|
|
|
2021-03-06 13:26:04 +03:00
|
|
|
REM Let a particular environment specify their own TCC and VC repos (to help mirrors)
|
2020-11-25 16:27:52 +03:00
|
|
|
if /I not ["%TCC_GIT%"] == [""] set "tcc_url=%TCC_GIT%"
|
2020-11-29 18:18:49 +03:00
|
|
|
if /I not ["%TCC_BRANCH%"] == [""] set "tcc_branch=%TCC_BRANCH%"
|
2020-07-16 19:33:26 +03:00
|
|
|
|
2021-03-06 13:26:04 +03:00
|
|
|
if /I not ["%VC_GIT%"] == [""] set "vc_url=%VC_GIT%"
|
|
|
|
|
2020-11-21 14:02:03 +03:00
|
|
|
pushd %~dp0
|
2020-07-16 19:33:26 +03:00
|
|
|
|
2020-11-21 14:02:03 +03:00
|
|
|
:verifyopt
|
2020-11-25 16:27:52 +03:00
|
|
|
REM Read stdin EOF
|
2020-11-21 14:02:03 +03:00
|
|
|
if ["%~1"] == [""] goto :init
|
2020-07-16 19:33:26 +03:00
|
|
|
|
2020-11-25 16:27:52 +03:00
|
|
|
REM Target options
|
|
|
|
if !shift_counter! LSS 1 (
|
|
|
|
if "%~1" == "help" (
|
2020-11-28 02:14:14 +03:00
|
|
|
if not ["%~2"] == [""] set "subcmd=%~2"& shift& set /a shift_counter+=1
|
|
|
|
)
|
|
|
|
for %%z in (build clean cleanall help) do (
|
|
|
|
if "%~1" == "%%z" set target=%1& shift& set /a shift_counter+=1& goto :verifyopt
|
2020-11-25 16:27:52 +03:00
|
|
|
)
|
|
|
|
)
|
2020-06-04 15:07:02 +03:00
|
|
|
|
2020-11-25 16:27:52 +03:00
|
|
|
REM Compiler option
|
2021-02-25 14:52:12 +03:00
|
|
|
for %%g in (-gcc -msvc -tcc -tcc32 -clang) do (
|
2020-11-28 02:14:14 +03:00
|
|
|
if "%~1" == "%%g" set compiler=%~1& set compiler=!compiler:~1!& shift& set /a shift_counter+=1& goto :verifyopt
|
|
|
|
)
|
2020-11-25 16:27:52 +03:00
|
|
|
|
|
|
|
REM Standard options
|
2020-11-28 02:14:14 +03:00
|
|
|
if "%~1" == "--verbose" (
|
|
|
|
if !flag_verbose! NEQ 0 (
|
|
|
|
echo The flag %~1 has already been specified. 1>&2
|
|
|
|
exit /b 2
|
|
|
|
)
|
|
|
|
set /a flag_verbose=1
|
2020-11-25 16:27:52 +03:00
|
|
|
set /a shift_counter+=1
|
2020-11-21 14:02:03 +03:00
|
|
|
shift
|
|
|
|
goto :verifyopt
|
|
|
|
)
|
2020-11-28 02:14:14 +03:00
|
|
|
if "%~1" == "--local" (
|
|
|
|
if !flag_local! NEQ 0 (
|
|
|
|
echo The flag %~1 has already been specified. 1>&2
|
|
|
|
exit /b 2
|
|
|
|
)
|
|
|
|
set /a flag_local=1
|
2020-11-25 16:27:52 +03:00
|
|
|
set /a shift_counter+=1
|
2020-11-21 14:02:03 +03:00
|
|
|
shift
|
|
|
|
goto :verifyopt
|
|
|
|
)
|
2020-11-25 16:27:52 +03:00
|
|
|
if "%~1" == "--logfile" (
|
|
|
|
if ["%~2"] == [""] (
|
2020-11-21 14:02:03 +03:00
|
|
|
echo Log file is not specified for -logfile parameter. 1>&2
|
|
|
|
exit /b 2
|
|
|
|
)
|
|
|
|
pushd "%~dp2" 2>NUL || (
|
|
|
|
echo The log file specified for -logfile parameter does not exist. 1>&2
|
|
|
|
exit /b 2
|
|
|
|
)
|
|
|
|
popd
|
2020-11-28 02:14:14 +03:00
|
|
|
set "log_file=%~sf2"
|
2020-11-25 16:27:52 +03:00
|
|
|
set /a shift_counter+=2
|
2020-11-21 14:02:03 +03:00
|
|
|
shift
|
|
|
|
shift
|
|
|
|
goto :verifyopt
|
|
|
|
)
|
2020-11-28 02:14:14 +03:00
|
|
|
|
2020-11-25 16:27:52 +03:00
|
|
|
echo Undefined option: %~1
|
|
|
|
exit /b 2
|
2019-08-29 00:18:30 +03:00
|
|
|
|
2020-11-21 14:02:03 +03:00
|
|
|
:init
|
2020-11-28 02:14:14 +03:00
|
|
|
goto :!target!
|
|
|
|
|
|
|
|
:cleanall
|
|
|
|
call :clean
|
2020-11-30 10:15:52 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%
|
2020-11-28 02:14:14 +03:00
|
|
|
echo.
|
|
|
|
echo Cleanup vc
|
|
|
|
echo ^> Purge TCC binaries
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-11-28 02:14:14 +03:00
|
|
|
echo ^> Purge vc repository
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-11-28 02:14:14 +03:00
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
:clean
|
|
|
|
echo Cleanup build artifacts
|
|
|
|
echo ^> Purge debug symbols
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-11-28 02:14:14 +03:00
|
|
|
echo ^> Delete old V executable
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-11-28 02:14:14 +03:00
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
:help
|
|
|
|
if [!subcmd!] == [] (
|
|
|
|
call :usage 2>NUL
|
|
|
|
) else (
|
|
|
|
call :help_!subcmd! 2>NUL
|
|
|
|
)
|
|
|
|
if %ERRORLEVEL% NEQ 0 echo Invalid subcommand: !subcmd!
|
|
|
|
exit /b %ERRORLEVEL%
|
2020-11-25 16:27:52 +03:00
|
|
|
|
|
|
|
:build
|
2020-11-28 02:14:14 +03:00
|
|
|
if !flag_local! NEQ 1 (
|
2020-12-11 20:24:57 +03:00
|
|
|
call :download_tcc
|
|
|
|
if %ERRORLEVEL% NEQ 0 goto :error
|
|
|
|
del "!log_file!">NUL 2>&1
|
2020-11-28 02:14:14 +03:00
|
|
|
pushd "%vc_dir%" 2>NUL && (
|
2020-11-21 14:02:03 +03:00
|
|
|
echo Updating vc...
|
2020-11-25 16:27:52 +03:00
|
|
|
echo ^> Sync with remote !vc_url!
|
2020-12-11 02:47:27 +03:00
|
|
|
if !flag_verbose! EQU 1 (
|
|
|
|
echo [Debug] cd "%vc_dir%">>"!log_file!"
|
|
|
|
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
|
|
|
|
)
|
2020-11-30 10:15:52 +03:00
|
|
|
popd
|
2020-11-25 16:27:52 +03:00
|
|
|
) || (
|
2020-11-21 14:02:03 +03:00
|
|
|
echo Cloning vc...
|
2020-11-25 16:27:52 +03:00
|
|
|
echo ^> Cloning from remote !vc_url!
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-11-21 14:02:03 +03:00
|
|
|
)
|
2020-11-28 02:14:14 +03:00
|
|
|
echo.
|
2020-11-21 14:02:03 +03:00
|
|
|
)
|
2019-08-30 00:13:53 +03:00
|
|
|
|
2020-11-21 14:02:03 +03:00
|
|
|
echo Building V...
|
2020-11-28 02:14:14 +03:00
|
|
|
if not [!compiler!] == [] goto :!compiler!_strap
|
2020-11-21 14:02:03 +03:00
|
|
|
|
|
|
|
:clang_strap
|
|
|
|
where /q clang
|
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
|
|
|
echo ^> Clang not found
|
2020-11-28 02:14:14 +03:00
|
|
|
if not [!compiler!] == [] goto :error
|
2020-11-21 14:02:03 +03:00
|
|
|
goto :gcc_strap
|
|
|
|
)
|
|
|
|
|
2020-12-09 21:25:00 +03:00
|
|
|
echo ^> Attempting to build v_win.c with Clang
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-11-21 14:02:03 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
|
|
|
REM In most cases, compile errors happen because the version of Clang installed is too old
|
2020-12-11 02:47:27 +03:00
|
|
|
clang --version>>"!log_file!"
|
2020-11-21 14:02:03 +03:00
|
|
|
goto :compile_error
|
|
|
|
)
|
|
|
|
|
|
|
|
echo ^> Compiling with .\v.exe self
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-11-21 14:02:03 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
|
|
|
goto :success
|
2019-08-30 00:13:53 +03:00
|
|
|
|
2020-11-21 14:02:03 +03:00
|
|
|
:gcc_strap
|
2020-06-19 13:54:56 +03:00
|
|
|
where /q gcc
|
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
|
|
|
echo ^> GCC not found
|
2020-11-28 02:14:14 +03:00
|
|
|
if not [!compiler!] == [] goto :error
|
2020-03-18 20:15:33 +03:00
|
|
|
goto :msvc_strap
|
2019-08-30 00:13:53 +03:00
|
|
|
)
|
|
|
|
|
2020-12-09 21:25:00 +03:00
|
|
|
echo ^> Attempting to build v_win.c with GCC
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-07-10 22:50:29 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
2020-11-25 16:27:52 +03:00
|
|
|
REM In most cases, compile errors happen because the version of GCC installed is too old
|
2020-12-11 02:47:27 +03:00
|
|
|
gcc --version>>"!log_File!"
|
2020-07-10 22:50:29 +03:00
|
|
|
goto :compile_error
|
|
|
|
)
|
2019-08-30 00:13:53 +03:00
|
|
|
|
2020-07-16 19:33:26 +03:00
|
|
|
echo ^> Compiling with .\v.exe self
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-06-19 13:54:56 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
2019-08-30 00:13:53 +03:00
|
|
|
goto :success
|
|
|
|
|
2020-03-18 20:15:33 +03:00
|
|
|
:msvc_strap
|
2019-10-16 02:54:35 +03:00
|
|
|
set VsWhereDir=%ProgramFiles(x86)%
|
|
|
|
set HostArch=x64
|
|
|
|
if "%PROCESSOR_ARCHITECTURE%" == "x86" (
|
2020-03-18 20:15:33 +03:00
|
|
|
echo Using x86 Build Tools...
|
|
|
|
set VsWhereDir=%ProgramFiles%
|
|
|
|
set HostArch=x86
|
2019-10-16 02:54:35 +03:00
|
|
|
)
|
2020-06-19 13:54:56 +03:00
|
|
|
|
|
|
|
if not exist "%VsWhereDir%\Microsoft Visual Studio\Installer\vswhere.exe" (
|
|
|
|
echo ^> MSVC not found
|
2020-11-28 02:14:14 +03:00
|
|
|
if not [!compiler!] == [] goto :error
|
2020-06-19 13:54:56 +03:00
|
|
|
goto :tcc_strap
|
|
|
|
)
|
|
|
|
|
2021-02-21 01:00:44 +03:00
|
|
|
for /f "usebackq tokens=*" %%i in (`"%VsWhereDir%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
|
2020-03-18 20:15:33 +03:00
|
|
|
set InstallDir=%%i
|
2019-08-29 00:38:09 +03:00
|
|
|
)
|
2019-08-29 00:18:30 +03:00
|
|
|
|
2019-08-30 00:13:53 +03:00
|
|
|
if exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" (
|
2020-06-19 13:54:56 +03:00
|
|
|
call "%InstallDir%\Common7\Tools\vsdevcmd.bat" -arch=%HostArch% -host_arch=%HostArch% -no_logo > NUL
|
2020-05-06 13:05:52 +03:00
|
|
|
) else if exist "%VsWhereDir%\Microsoft Visual Studio 14.0\Common7\Tools\vsdevcmd.bat" (
|
2020-06-19 13:54:56 +03:00
|
|
|
call "%VsWhereDir%\Microsoft Visual Studio 14.0\Common7\Tools\vsdevcmd.bat" -arch=%HostArch% -host_arch=%HostArch% -no_logo > NUL
|
2019-08-30 00:13:53 +03:00
|
|
|
)
|
|
|
|
|
2019-12-22 22:59:51 +03:00
|
|
|
set ObjFile=.v.c.obj
|
|
|
|
|
2020-12-09 21:25:00 +03:00
|
|
|
echo ^> Attempting to build v_win.c with MSVC
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-11-30 10:15:52 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
|
|
|
REM In some cases, compile errors happen because of the MSVC compiler version
|
2020-12-11 02:47:27 +03:00
|
|
|
cl.exe 1>NUL 2>"!log_file!"
|
2020-11-30 10:15:52 +03:00
|
|
|
goto :compile_error
|
|
|
|
)
|
2019-08-30 00:13:53 +03:00
|
|
|
|
2020-07-16 19:33:26 +03:00
|
|
|
echo ^> Compiling with .\v.exe self
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-11-28 02:14:14 +03:00
|
|
|
del %ObjFile%>>"!log_file!" 2>>&1
|
2020-06-19 13:54:56 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
|
|
|
goto :success
|
|
|
|
|
|
|
|
:tcc_strap
|
2021-02-25 14:52:12 +03:00
|
|
|
:tcc32_strap
|
2020-11-30 18:52:43 +03:00
|
|
|
if [!compiler!] == [] set /a invalid_cc=1
|
2020-12-09 21:25:00 +03:00
|
|
|
echo ^> Attempting to build v_win.c with TCC
|
2020-12-11 02:47:27 +03:00
|
|
|
if !flag_verbose! EQU 1 (
|
2021-01-29 21:21:29 +03:00
|
|
|
echo [Debug] "!tcc_exe!" -ladvapi32 -bt10 -w -o v.exe vc\v_win.c>>"!log_file!"
|
|
|
|
echo "!tcc_exe!" -ladvapi32 -bt10 -w -o v.exe vc\v_win.c
|
2020-12-11 02:47:27 +03:00
|
|
|
)
|
2021-01-29 21:21:29 +03:00
|
|
|
"!tcc_exe!" -ladvapi32 -bt10 -w -o v.exe vc\v_win.c>>"!log_file!" 2>NUL
|
2020-06-19 13:54:56 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
2019-08-29 00:18:30 +03:00
|
|
|
|
2020-07-16 19:33:26 +03:00
|
|
|
echo ^> Compiling with .\v.exe self
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-06-19 13:54:56 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 goto :compile_error
|
|
|
|
goto :success
|
2019-08-30 00:13:53 +03:00
|
|
|
|
2020-11-30 10:15:52 +03:00
|
|
|
:download_tcc
|
|
|
|
pushd %tcc_dir% 2>NUL && (
|
|
|
|
echo Updating TCC
|
|
|
|
echo ^> Syncing TCC from !tcc_url!
|
2020-12-11 02:47:27 +03:00
|
|
|
if !flag_verbose! EQU 1 (
|
|
|
|
echo [Debug] git pull --quiet>>"!log_file!"
|
|
|
|
echo git pull --quiet
|
|
|
|
)
|
|
|
|
git pull --quiet>>"!log_file!" 2>NUL
|
2020-11-30 10:15:52 +03:00
|
|
|
popd
|
|
|
|
) || (
|
|
|
|
echo Bootstraping TCC...
|
|
|
|
echo ^> TCC not found
|
2021-02-27 21:19:11 +03:00
|
|
|
if "!tcc_branch!" == "thirdparty-windows-i386" ( echo ^> Downloading TCC32 from !tcc_url! ) else ( echo ^> Downloading TCC64 from !tcc_url! )
|
2020-12-11 02:47:27 +03:00
|
|
|
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
|
2020-11-30 10:15:52 +03:00
|
|
|
)
|
2020-12-11 02:47:27 +03:00
|
|
|
for /f "usebackq delims=" %%i in (`dir "%tcc_dir%" /b /a /s tcc.exe`) do (
|
2020-11-30 10:15:52 +03:00
|
|
|
set "attrib=%%~ai"
|
|
|
|
set "dattrib=%attrib:~0,1%"
|
2020-12-11 02:47:27 +03:00
|
|
|
if /I not "%dattrib%" == "d" set "tcc_exe=%%~sfi"
|
2020-11-30 10:15:52 +03:00
|
|
|
)
|
|
|
|
if [!tcc_exe!] == [] echo ^> TCC not found, even after cloning& goto :error
|
|
|
|
echo.
|
|
|
|
exit /b 0
|
|
|
|
|
2020-03-18 20:15:33 +03:00
|
|
|
:compile_error
|
2020-07-10 22:50:29 +03:00
|
|
|
echo.
|
2020-11-28 02:14:14 +03:00
|
|
|
type "!log_file!">NUL 2>&1
|
2019-08-30 00:13:53 +03:00
|
|
|
goto :error
|
|
|
|
|
|
|
|
:error
|
2020-06-19 13:54:56 +03:00
|
|
|
echo.
|
2019-08-30 00:13:53 +03:00
|
|
|
echo Exiting from error
|
|
|
|
exit /b 1
|
|
|
|
|
|
|
|
:success
|
2020-06-19 13:54:56 +03:00
|
|
|
echo ^> V built successfully!
|
2020-07-16 19:33:26 +03:00
|
|
|
echo ^> To add V to your PATH, run `.\v.exe symlink`.
|
2020-11-28 02:14:14 +03:00
|
|
|
if !invalid_cc! EQU 1 (
|
2020-11-21 14:02:03 +03:00
|
|
|
echo.
|
|
|
|
echo WARNING: No C compiler was detected in your PATH. `tcc` was used temporarily
|
|
|
|
echo to build V, but it may have some bugs and may not work in all cases.
|
|
|
|
echo A more advanced C compiler like GCC or MSVC is recommended.
|
|
|
|
echo https://github.com/vlang/v/wiki/Installing-a-C-compiler-on-Windows
|
|
|
|
echo.
|
|
|
|
)
|
|
|
|
|
2020-06-19 13:54:56 +03:00
|
|
|
:version
|
|
|
|
echo.
|
|
|
|
echo | set /p="V version: "
|
2020-07-16 19:33:26 +03:00
|
|
|
.\v.exe version
|
2020-11-25 16:27:52 +03:00
|
|
|
goto :eof
|
2020-11-21 14:02:03 +03:00
|
|
|
|
|
|
|
:usage
|
|
|
|
echo Usage:
|
2020-11-25 16:27:52 +03:00
|
|
|
echo make.bat [target] [compiler] [options]
|
2020-11-21 14:02:03 +03:00
|
|
|
echo.
|
2020-11-25 16:27:52 +03:00
|
|
|
echo Compiler:
|
2021-02-25 14:52:12 +03:00
|
|
|
echo -msvc ^| -gcc ^| -tcc ^| -tcc32 ^| -clang Set C compiler
|
2020-11-21 14:02:03 +03:00
|
|
|
echo.
|
2020-11-25 16:27:52 +03:00
|
|
|
echo Target:
|
2021-02-25 14:52:12 +03:00
|
|
|
echo build[default] Compiles V using the given C compiler
|
|
|
|
echo clean Clean build artifacts and debugging symbols
|
|
|
|
echo clean-all Cleanup entire ALL build artifacts and vc repository
|
|
|
|
echo help Display usage help for the given target
|
2020-11-21 14:02:03 +03:00
|
|
|
echo.
|
|
|
|
echo Examples:
|
|
|
|
echo make.bat -msvc
|
|
|
|
echo make.bat -gcc --local --logpath output.log
|
2021-02-25 14:52:12 +03:00
|
|
|
echo make.bat build -tcc --local
|
|
|
|
echo make.bat -tcc32
|
2020-11-25 16:27:52 +03:00
|
|
|
echo make.bat help clean
|
|
|
|
echo.
|
|
|
|
echo Use "make help <target>" for more information about a target, for instance: "make help clean"
|
|
|
|
echo.
|
2020-11-28 02:14:14 +03:00
|
|
|
echo Note: Any undefined/unsupported options will be ignored
|
2020-11-25 16:27:52 +03:00
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
:help_help
|
|
|
|
echo Usage:
|
|
|
|
echo make.bat help [target]
|
2020-11-21 14:02:03 +03:00
|
|
|
echo.
|
2020-11-25 16:27:52 +03:00
|
|
|
echo Target:
|
|
|
|
echo build ^| clean ^| clean-all ^| help Query given target
|
2020-11-21 14:02:03 +03:00
|
|
|
exit /b 0
|
2020-11-25 16:27:52 +03:00
|
|
|
|
|
|
|
:help_clean
|
|
|
|
echo Usage:
|
|
|
|
echo make.bat clean
|
|
|
|
echo.
|
|
|
|
echo Options:
|
|
|
|
echo --logfile PATH Use the specified PATH as the log
|
2020-11-28 02:14:14 +03:00
|
|
|
echo --verbose Output compilation commands to stdout
|
2020-11-25 16:27:52 +03:00
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
:help_cleanall
|
|
|
|
echo Usage:
|
|
|
|
echo make.bat clean-all
|
|
|
|
echo.
|
|
|
|
echo Options:
|
|
|
|
echo --logfile PATH Use the specified PATH as the log
|
2020-11-28 02:14:14 +03:00
|
|
|
echo --verbose Output compilation commands to stdout
|
2020-11-25 16:27:52 +03:00
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
:help_build
|
|
|
|
echo Usage:
|
|
|
|
echo make.bat build [compiler] [options]
|
|
|
|
echo.
|
|
|
|
echo Compiler:
|
2021-02-25 14:52:12 +03:00
|
|
|
echo -msvc ^| -gcc ^| -tcc ^| -tcc32 ^| -clang Set C compiler
|
2020-11-25 16:27:52 +03:00
|
|
|
echo.
|
|
|
|
echo Options:
|
|
|
|
echo --local Use the local vc repository without
|
|
|
|
echo syncing with remote
|
|
|
|
echo --logfile PATH Use the specified PATH as the log
|
|
|
|
echo file
|
2020-11-28 02:14:14 +03:00
|
|
|
echo --verbose Output compilation commands to stdout
|
2020-11-25 16:27:52 +03:00
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
:eof
|
|
|
|
popd
|
|
|
|
endlocal
|
2020-11-29 18:18:49 +03:00
|
|
|
exit /b 0
|