2019-08-29 00:18:30 +03:00
|
|
|
@echo off
|
|
|
|
|
2019-08-30 00:13:53 +03:00
|
|
|
echo Building V
|
2019-08-29 00:18:30 +03:00
|
|
|
|
|
|
|
if exist "vc" (
|
2019-08-30 00:13:53 +03:00
|
|
|
rd /s /q vc
|
2019-08-29 00:18:30 +03:00
|
|
|
)
|
|
|
|
|
2019-08-27 21:08:54 +03:00
|
|
|
git version
|
2019-09-01 16:43:40 +03:00
|
|
|
|
|
|
|
echo Downloading v.c...
|
2019-08-17 19:24:22 +03:00
|
|
|
git clone --depth 1 --quiet https://github.com/vlang/vc
|
2019-08-29 00:18:30 +03:00
|
|
|
|
2019-08-30 00:13:53 +03:00
|
|
|
REM option to force msvc or gcc
|
|
|
|
if "%~1"=="-gcc" goto :gccstrap
|
2019-08-31 10:09:40 +03:00
|
|
|
if "%~1"=="-msvc" goto :msvcstrap
|
2019-08-30 00:13:53 +03:00
|
|
|
|
|
|
|
|
|
|
|
:gccstrap
|
|
|
|
|
2019-09-01 16:43:40 +03:00
|
|
|
echo Attempting to build v.c with GCC...
|
2019-08-30 00:13:53 +03:00
|
|
|
|
|
|
|
for /f "usebackq tokens=*" %%i in (`where gcc`) do (
|
|
|
|
set gccpath=%%i
|
|
|
|
)
|
|
|
|
|
|
|
|
if not exist "%gccpath%" (
|
|
|
|
goto:msvcstrap
|
|
|
|
)
|
|
|
|
|
2019-10-07 23:22:32 +03:00
|
|
|
gcc -std=c99 -w -o v2.exe vc\v_win.c
|
2019-09-17 14:56:32 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
2019-08-30 00:13:53 +03:00
|
|
|
echo gcc failed to compile - Create an issue at 'https://github.com/vlang'
|
|
|
|
exit /b 1
|
2019-08-29 00:18:30 +03:00
|
|
|
)
|
|
|
|
|
2019-10-12 04:19:28 +03:00
|
|
|
echo Now using V to build V...
|
2019-10-14 04:39:45 +03:00
|
|
|
v2.exe -o v3.exe v.v
|
|
|
|
v3.exe -o v.exe -prod v.v
|
2019-09-17 14:56:32 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
2019-09-01 16:43:40 +03:00
|
|
|
echo v.exe failed to compile itself - Create an issue at 'https://github.com/vlang'
|
2019-08-30 00:13:53 +03:00
|
|
|
exit /b 1
|
|
|
|
)
|
|
|
|
|
|
|
|
del v2.exe
|
2019-09-27 21:42:42 +03:00
|
|
|
del v3.exe
|
2019-08-30 00:13:53 +03:00
|
|
|
rd /s /q vc
|
|
|
|
|
|
|
|
goto :success
|
|
|
|
|
|
|
|
|
|
|
|
:msvcstrap
|
2019-09-01 16:43:40 +03:00
|
|
|
echo Attempting to build v.c with MSVC...
|
2019-08-30 00:13:53 +03:00
|
|
|
|
2019-10-06 16:27:50 +03:00
|
|
|
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
|
2019-08-30 00:13:53 +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" (
|
2019-09-03 11:51:16 +03:00
|
|
|
call "%InstallDir%\Common7\Tools\vsdevcmd.bat" -arch=x64 -host_arch=x64 -no_logo
|
2019-08-30 00:13:53 +03:00
|
|
|
) else (
|
|
|
|
goto :nocompiler
|
|
|
|
)
|
|
|
|
|
2019-09-19 00:05:07 +03:00
|
|
|
cl.exe /nologo /w /volatile:ms /Fo.v.c.obj /O2 /MD vc\v_win.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /NOLOGO /OUT:v2.exe /INCREMENTAL:NO
|
2019-09-17 14:56:32 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
2019-08-30 00:13:53 +03:00
|
|
|
echo cl.exe failed to build V
|
|
|
|
goto :compileerror
|
|
|
|
)
|
|
|
|
|
2019-09-20 17:03:13 +03:00
|
|
|
echo rebuild from source (twice, in case of C definitions changes)
|
2019-10-14 08:51:12 +03:00
|
|
|
v2.exe -cc msvc -o v3.exe v.v
|
2019-10-14 08:41:46 +03:00
|
|
|
v3.exe -cc msvc -o v.exe -prod v.v
|
2019-09-17 14:56:32 +03:00
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
2019-08-30 00:13:53 +03:00
|
|
|
echo V failed to build itself
|
|
|
|
goto :compileerror
|
|
|
|
)
|
|
|
|
|
|
|
|
del v2.exe
|
2019-09-20 17:03:13 +03:00
|
|
|
del v3.exe
|
2019-08-29 00:38:09 +03:00
|
|
|
rd /s /q vc
|
2019-08-29 00:18:30 +03:00
|
|
|
|
2019-08-30 00:13:53 +03:00
|
|
|
goto :success
|
|
|
|
|
|
|
|
:nocompiler
|
|
|
|
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
|
|
|
|
|
|
|
|
:compileerror
|
|
|
|
echo Failed to compile - Create an issue at 'https://github.com/vlang' and tag '@emily33901'!
|
|
|
|
goto :error
|
|
|
|
|
|
|
|
:error
|
|
|
|
echo Exiting from error
|
|
|
|
exit /b 1
|
|
|
|
|
|
|
|
:success
|