2
2
3
3
echo Building V
4
4
5
+ set log_file = %TEMP% \v_make.bat.log
5
6
set tcc_path = %~dp0 thirdparty\tcc\
6
7
pushd %~dp0
7
8
@@ -19,10 +20,6 @@ if exist "vc" (
19
20
)
20
21
21
22
:compile
22
- REM option to disable adding V to PATH
23
- if " %~1 " == " -skip-path" set skip_path = 1
24
- if " %~2 " == " -skip-path" set skip_path = 1
25
-
26
23
REM option to force msvc, gcc or tcc
27
24
if " %~1 " == " -gcc" set force_gcc = 1 & goto :gcc_strap
28
25
if " %~2 " == " -gcc" set force_gcc = 1 & goto :gcc_strap
@@ -42,10 +39,14 @@ if %ERRORLEVEL% NEQ 0 (
42
39
goto :msvc_strap
43
40
)
44
41
45
- gcc -std=c99 -municode -w -o v.exe vc\v_win.c
46
- if %ERRORLEVEL% NEQ 0 goto :compile_error
42
+ gcc -std=c99 -municode -w -o v.exe vc\v_win.c>> %log_file% 2 >> & 1
43
+ if %ERRORLEVEL% NEQ 0 (
44
+ rem In most cases, compile errors happen because the version of GCC installed is too old
45
+ gcc --version>> %log_file% 2 >> & 1
46
+ goto :compile_error
47
+ )
47
48
48
- v.exe self > NUL
49
+ v.exe self>> %log_file% 2 >> & 1
49
50
if %ERRORLEVEL% NEQ 0 goto :compile_error
50
51
goto :success
51
52
@@ -78,10 +79,10 @@ if exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" (
78
79
79
80
set ObjFile = .v.c.obj
80
81
81
- 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 > NUL
82
+ 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>> %log_file% 2 >> & 1
82
83
if %ERRORLEVEL% NEQ 0 goto :compile_error
83
84
84
- v.exe -cc msvc self
85
+ v.exe -cc msvc self>> %log_file% 2 >> & 1
85
86
del %ObjFile%
86
87
if %ERRORLEVEL% NEQ 0 goto :compile_error
87
88
goto :success
@@ -115,19 +116,24 @@ if exist "%tcc_path%" (
115
116
if " %cloned_tcc% " == " " (
116
117
echo ^ > Updating prebuilt TCC...
117
118
pushd " %tcc_path% "
118
- git pull -q > NUL
119
+ git pull -q
119
120
popd
120
121
)
121
122
)
122
123
call " %tcc_exe% " -std=c99 -municode -lws2_32 -lshell32 -ladvapi32 -bt10 -w -o v.exe vc\v_win.c
123
124
if %ERRORLEVEL% NEQ 0 goto :compile_error
124
125
125
- v.exe -cc " %tcc_exe% " self > NUL
126
+ v.exe -cc " %tcc_exe% " self>> %log_file% 2 >> & 1
126
127
if %ERRORLEVEL% NEQ 0 goto :compile_error
127
128
goto :success
128
129
129
130
:compile_error
130
- echo Failed to compile - Create an issue at 'https://github.com/vlang'
131
+ echo .
132
+ echo .
133
+ echo Failed to compile - Create an issue at 'https://github.com/vlang' with the following info:
134
+ echo .
135
+ type %log_file%
136
+ del %log_file%
131
137
goto :error
132
138
133
139
:error
@@ -138,26 +144,9 @@ exit /b 1
138
144
139
145
:success
140
146
echo ^ > V built successfully!
147
+ echo ^ > To add V to your PATH, run `.\v symlink`.
141
148
del v_old.exe
142
-
143
- :path
144
- if " %skip_path% " NEQ " " goto :version
145
- echo .
146
- echo Adding V to PATH...
147
- v.exe symlink > NUL
148
- if %ERRORLEVEL% NEQ 0 (
149
- echo ^ > Could not add V to %% PATH%% , try rebuilding as admin.
150
- goto :error
151
- )
152
- echo ^ > V added to %% PATH%%
153
-
154
- if " %cloned_tcc% " NEQ " " (
155
- echo @echo off> " %~dp0 .bin\tcc.bat"
156
- echo %tcc_path% tcc %%^ *>> " %~dp0 .bin\tcc.bat"
157
- echo ^ > TCC added to %% PATH%%
158
- )
159
-
160
- echo ^ > Restart your shell/IDE to reload it
149
+ del %log_file%
161
150
162
151
:version
163
152
echo .
0 commit comments