2019-08-28 23:18:30 +02:00
|
|
|
@echo off
|
|
|
|
|
2019-08-29 23:13:53 +02:00
|
|
|
echo Building V
|
2019-08-28 23:18:30 +02:00
|
|
|
|
2020-03-20 16:40:49 +01:00
|
|
|
pushd %~dp0
|
|
|
|
|
2019-08-28 23:18:30 +02:00
|
|
|
if exist "vc" (
|
2020-03-18 18:15:33 +01:00
|
|
|
rd /s /q vc
|
2019-08-28 23:18:30 +02:00
|
|
|
)
|
|
|
|
|
2019-09-01 15:43:40 +02:00
|
|
|
echo Downloading v.c...
|
2019-08-17 18:24:22 +02:00
|
|
|
git clone --depth 1 --quiet https://github.com/vlang/vc
|
2019-08-28 23:18:30 +02:00
|
|
|
|
2019-08-29 23:13:53 +02:00
|
|
|
REM option to force msvc or gcc
|
2020-03-18 18:15:33 +01:00
|
|
|
if "%~1"=="-gcc" goto :gcc_strap
|
|
|
|
if "%~1"=="-msvc" goto :msvc_strap
|
2019-08-29 23:13:53 +02:00
|
|
|
|
|
|
|
|
2020-03-18 18:15:33 +01:00
|
|
|
:gcc_strap
|
2019-09-01 15:43:40 +02:00
|
|
|
echo Attempting to build v.c with GCC...
|
2019-08-29 23:13:53 +02:00
|
|
|
|
|
|
|
for /f "usebackq tokens=*" %%i in (`where gcc`) do (
|
2020-03-18 18:15:33 +01:00
|
|
|
set gcc_path=%%i
|
2019-08-29 23:13:53 +02:00
|
|
|
)
|
|
|
|
|
2020-03-18 18:15:33 +01:00
|
|
|
if not exist "%gcc_path%" (
|
|
|
|
goto :msvc_strap
|
2019-08-29 23:13:53 +02:00
|
|
|
)
|
|
|
|
|
2020-03-18 18:15:33 +01:00
|
|
|
gcc -std=c99 -municode -w -o v.exe vc\v_win.c
|
2019-09-17 13:56:32 +02:00
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
2020-03-18 18:15:33 +01:00
|
|
|
echo gcc failed to compile - Create an issue at 'https://github.com/vlang'
|
|
|
|
rd /s /q vc
|
|
|
|
goto :error
|
2019-08-28 23:18:30 +02:00
|
|
|
)
|
|
|
|
|
2020-04-24 07:19:24 +02:00
|
|
|
REM remove the -prod parameter to shorten compilation time,
|
|
|
|
REM and it will be restored when v is a stable version.
|
|
|
|
v self
|
2019-09-17 13:56:32 +02:00
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
2020-03-18 18:15:33 +01:00
|
|
|
echo v.exe failed to compile itself - Create an issue at 'https://github.com/vlang'
|
|
|
|
rd /s /q vc
|
|
|
|
goto :error
|
2019-08-29 23:13:53 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
rd /s /q vc
|
|
|
|
goto :success
|
|
|
|
|
2020-03-18 18:15:33 +01:00
|
|
|
:msvc_strap
|
2019-09-01 15:43:40 +02:00
|
|
|
echo Attempting to build v.c with MSVC...
|
2019-10-16 01:54:35 +02:00
|
|
|
set VsWhereDir=%ProgramFiles(x86)%
|
|
|
|
set HostArch=x64
|
|
|
|
if "%PROCESSOR_ARCHITECTURE%" == "x86" (
|
2020-03-18 18:15:33 +01:00
|
|
|
echo Using x86 Build Tools...
|
|
|
|
set VsWhereDir=%ProgramFiles%
|
|
|
|
set HostArch=x86
|
2019-10-16 01:54:35 +02:00
|
|
|
)
|
|
|
|
for /f "usebackq tokens=*" %%i in (`"%VsWhereDir%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
|
2020-03-18 18:15:33 +01:00
|
|
|
set InstallDir=%%i
|
2019-08-28 23:38:09 +02:00
|
|
|
)
|
2019-08-28 23:18:30 +02:00
|
|
|
|
2019-08-29 23:13:53 +02:00
|
|
|
if exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" (
|
2020-03-18 18:15:33 +01:00
|
|
|
call "%InstallDir%\Common7\Tools\vsdevcmd.bat" -arch=%HostArch% -host_arch=%HostArch% -no_logo
|
2020-05-06 12:05:52 +02:00
|
|
|
) else if exist "%VsWhereDir%\Microsoft Visual Studio 14.0\Common7\Tools\vsdevcmd.bat" (
|
|
|
|
call "%VsWhereDir%\Microsoft Visual Studio 14.0\Common7\Tools\vsdevcmd.bat" -arch=%HostArch% -host_arch=%HostArch% -no_logo
|
2019-08-29 23:13:53 +02:00
|
|
|
) else (
|
2020-03-18 18:15:33 +01:00
|
|
|
goto :no_compiler
|
2019-08-29 23:13:53 +02:00
|
|
|
)
|
|
|
|
|
2019-12-22 20:59:51 +01:00
|
|
|
set ObjFile=.v.c.obj
|
|
|
|
|
2020-03-18 18:15:33 +01:00
|
|
|
cl.exe /nologo /w /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
|
2019-09-17 13:56:32 +02:00
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
2020-03-18 18:15:33 +01:00
|
|
|
echo cl.exe failed to build V
|
|
|
|
goto :compile_error
|
2019-08-29 23:13:53 +02:00
|
|
|
)
|
|
|
|
|
2020-04-24 07:19:24 +02:00
|
|
|
REM remove the -prod parameter to shorten compilation time,
|
|
|
|
REM and it will be restored when v is a stable version.
|
|
|
|
v self
|
2019-09-17 13:56:32 +02:00
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
2020-03-18 18:15:33 +01:00
|
|
|
echo V failed to build itself with error %ERRORLEVEL%
|
|
|
|
rd /s /q vc
|
2020-04-02 09:27:25 +02:00
|
|
|
del v_old.exe
|
2020-03-18 18:15:33 +01:00
|
|
|
del vc140.pdb
|
|
|
|
del %ObjFile%
|
|
|
|
goto :compile_error
|
2019-08-29 23:13:53 +02:00
|
|
|
)
|
|
|
|
|
2019-08-28 23:38:09 +02:00
|
|
|
rd /s /q vc
|
2020-04-02 09:27:25 +02:00
|
|
|
del v_old.exe
|
2019-12-05 12:41:57 +01:00
|
|
|
del vc140.pdb
|
2019-12-22 20:59:51 +01:00
|
|
|
del %ObjFile%
|
2019-08-28 23:18:30 +02:00
|
|
|
|
2019-08-29 23:13:53 +02:00
|
|
|
goto :success
|
|
|
|
|
2020-03-18 18:15:33 +01:00
|
|
|
:no_compiler
|
2019-08-29 23:13:53 +02:00
|
|
|
echo You do not appear to have a GCC installation on your PATH and also do not have an MSVC installation
|
|
|
|
echo - this means that you cannot bootstrap a V installation at this time...
|
|
|
|
echo.
|
|
|
|
echo Head to 'https://github.com/vlang/v/releases/download/v0.1.10/mingw-w64-install.exe' to download and install GCC
|
|
|
|
echo or head to 'https://visualstudio.microsoft.com/downloads/' to download and install MSVC
|
|
|
|
echo (look for the Build Tools if you don't want to install the Visual Studio IDE)
|
|
|
|
echo.
|
|
|
|
goto :error
|
|
|
|
|
2020-03-18 18:15:33 +01:00
|
|
|
:compile_error
|
2019-08-29 23:13:53 +02:00
|
|
|
echo Failed to compile - Create an issue at 'https://github.com/vlang' and tag '@emily33901'!
|
|
|
|
goto :error
|
|
|
|
|
|
|
|
:error
|
|
|
|
echo Exiting from error
|
2020-03-20 16:40:49 +01:00
|
|
|
popd
|
2019-08-29 23:13:53 +02:00
|
|
|
exit /b 1
|
|
|
|
|
|
|
|
:success
|
2019-12-05 12:41:57 +01:00
|
|
|
echo V build OK!
|
2020-03-06 18:53:29 +01:00
|
|
|
v -version
|
2020-03-20 16:40:49 +01:00
|
|
|
popd
|