forked from vlang/v
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.bat
117 lines (93 loc) · 2.65 KB
/
make.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
@echo off
echo Building V
pushd %~dp0
if exist "vc" (
rd /s /q vc
)
git version
echo Downloading v.c...
git clone --depth 1 --quiet https://github.com/vlang/vc
REM option to force msvc or gcc
if "%~1"=="-gcc" goto :gcc_strap
if "%~1"=="-msvc" goto :msvc_strap
:gcc_strap
echo Attempting to build v.c with GCC...
for /f "usebackq tokens=*" %%i in (`where gcc`) do (
set gcc_path=%%i
)
if not exist "%gcc_path%" (
goto :msvc_strap
)
gcc -std=c99 -municode -w -o v.exe vc\v_win.c
if %ERRORLEVEL% NEQ 0 (
echo gcc failed to compile - Create an issue at 'https://github.com/vlang'
rd /s /q vc
goto :error
)
v self -prod
if %ERRORLEVEL% NEQ 0 (
echo v.exe failed to compile itself - Create an issue at 'https://github.com/vlang'
rd /s /q vc
goto :error
)
rd /s /q vc
goto :success
:msvc_strap
echo Attempting to build v.c with MSVC...
set VsWhereDir=%ProgramFiles(x86)%
set HostArch=x64
if "%PROCESSOR_ARCHITECTURE%" == "x86" (
echo Using x86 Build Tools...
set VsWhereDir=%ProgramFiles%
set HostArch=x86
)
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 (
set InstallDir=%%i
)
if exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" (
call "%InstallDir%\Common7\Tools\vsdevcmd.bat" -arch=%HostArch% -host_arch=%HostArch% -no_logo
) else (
goto :no_compiler
)
set ObjFile=.v.c.obj
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
if %ERRORLEVEL% NEQ 0 (
echo cl.exe failed to build V
goto :compile_error
)
v self -prod
if %ERRORLEVEL% NEQ 0 (
echo V failed to build itself with error %ERRORLEVEL%
rd /s /q vc
del v_old.exe
del v2.pdb
del vc140.pdb
del %ObjFile%
goto :compile_error
)
rd /s /q vc
del v_old.exe
del v2.pdb
del vc140.pdb
del %ObjFile%
goto :success
:no_compiler
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
:compile_error
echo Failed to compile - Create an issue at 'https://github.com/vlang' and tag '@emily33901'!
goto :error
:error
echo Exiting from error
popd
exit /b 1
:success
echo V build OK!
v -version
popd