1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

make.bat: improve diagnostics, do not add V to PATH automatically (#5789)

This commit is contained in:
spaceface777 2020-07-10 21:50:29 +02:00 committed by GitHub
parent 7d6ba2d07d
commit 8df8866c5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 35 deletions

View File

@ -265,7 +265,7 @@ jobs:
- name: Build - name: Build
run: | run: |
gcc --version gcc --version
.\make.bat -gcc -skip-path .\make.bat -gcc
- name: Test new v.c - name: Test new v.c
run: .\v.exe -o v.c cmd/v && gcc -municode -w v.c run: .\v.exe -o v.c cmd/v && gcc -municode -w v.c
- name: Install dependencies - name: Install dependencies
@ -300,7 +300,7 @@ jobs:
run: | run: |
echo %VFLAGS% echo %VFLAGS%
echo $VFLAGS echo $VFLAGS
.\make.bat -msvc -skip-path .\make.bat -msvc
- name: Install dependencies - name: Install dependencies
run: | run: |
.\v.exe setup-freetype .\v.exe setup-freetype
@ -331,12 +331,12 @@ jobs:
# with: # with:
# node-version: 12.x # node-version: 12.x
- name: Build - name: Build
# We need to move gcc and msvc, so that V doesn't find a C compiler # We need to move gcc and msvc, so that V can't find an existing C compiler and downloads tcc
run: | run: |
'for /f "usebackq tokens=*" %i in (`where gcc.exe`) do move /Y "%i" "%i.old"' | cmd 'for /f "usebackq tokens=*" %i in (`where gcc.exe`) do move /Y "%i" "%i.old"' | cmd
'for /f "usebackq tokens=*" %i in (`where vswhere.exe`) do move /Y "%i" "%i.old"' | cmd 'for /f "usebackq tokens=*" %i in (`where vswhere.exe`) do move /Y "%i" "%i.old"' | cmd
move "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe.old" move "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe.old"
.\make.bat -skip-path .\make.bat
- name: Test new v.c - name: Test new v.c
run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -w -ladvapi32 -bt10 v.c run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -w -ladvapi32 -bt10 v.c
- name: Install dependencies - name: Install dependencies

View File

@ -2,6 +2,7 @@
echo Building V echo Building V
set log_file=%TEMP%\v_make.bat.log
set tcc_path=%~dp0thirdparty\tcc\ set tcc_path=%~dp0thirdparty\tcc\
pushd %~dp0 pushd %~dp0
@ -19,10 +20,6 @@ if exist "vc" (
) )
:compile :compile
REM option to disable adding V to PATH
if "%~1"=="-skip-path" set skip_path=1
if "%~2"=="-skip-path" set skip_path=1
REM option to force msvc, gcc or tcc REM option to force msvc, gcc or tcc
if "%~1"=="-gcc" set force_gcc=1 & goto :gcc_strap if "%~1"=="-gcc" set force_gcc=1 & goto :gcc_strap
if "%~2"=="-gcc" set force_gcc=1 & goto :gcc_strap if "%~2"=="-gcc" set force_gcc=1 & goto :gcc_strap
@ -42,10 +39,14 @@ if %ERRORLEVEL% NEQ 0 (
goto :msvc_strap goto :msvc_strap
) )
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>>&1
if %ERRORLEVEL% NEQ 0 goto :compile_error if %ERRORLEVEL% NEQ 0 (
rem In most cases, compile errors happen because the version of GCC installed is too old
gcc --version>>%log_file% 2>>&1
goto :compile_error
)
v.exe self > NUL v.exe self>>%log_file% 2>>&1
if %ERRORLEVEL% NEQ 0 goto :compile_error if %ERRORLEVEL% NEQ 0 goto :compile_error
goto :success goto :success
@ -78,10 +79,10 @@ if exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" (
set ObjFile=.v.c.obj 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 > NUL 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
if %ERRORLEVEL% NEQ 0 goto :compile_error if %ERRORLEVEL% NEQ 0 goto :compile_error
v.exe -cc msvc self v.exe -cc msvc self>>%log_file% 2>>&1
del %ObjFile% del %ObjFile%
if %ERRORLEVEL% NEQ 0 goto :compile_error if %ERRORLEVEL% NEQ 0 goto :compile_error
goto :success goto :success
@ -115,19 +116,24 @@ if exist "%tcc_path%" (
if "%cloned_tcc%"=="" ( if "%cloned_tcc%"=="" (
echo ^> Updating prebuilt TCC... echo ^> Updating prebuilt TCC...
pushd "%tcc_path%" pushd "%tcc_path%"
git pull -q > NUL git pull -q
popd popd
) )
) )
call "%tcc_exe%" -std=c99 -municode -lws2_32 -lshell32 -ladvapi32 -bt10 -w -o v.exe vc\v_win.c call "%tcc_exe%" -std=c99 -municode -lws2_32 -lshell32 -ladvapi32 -bt10 -w -o v.exe vc\v_win.c
if %ERRORLEVEL% NEQ 0 goto :compile_error if %ERRORLEVEL% NEQ 0 goto :compile_error
v.exe -cc "%tcc_exe%" self > NUL v.exe -cc "%tcc_exe%" self>>%log_file% 2>>&1
if %ERRORLEVEL% NEQ 0 goto :compile_error if %ERRORLEVEL% NEQ 0 goto :compile_error
goto :success goto :success
:compile_error :compile_error
echo Failed to compile - Create an issue at 'https://github.com/vlang' echo.
echo.
echo Failed to compile - Create an issue at 'https://github.com/vlang' with the following info:
echo.
type %log_file%
del %log_file%
goto :error goto :error
:error :error
@ -138,26 +144,9 @@ exit /b 1
:success :success
echo ^> V built successfully! echo ^> V built successfully!
echo ^> To add V to your PATH, run `.\v symlink`.
del v_old.exe del v_old.exe
del %log_file%
:path
if "%skip_path%" NEQ "" goto :version
echo.
echo Adding V to PATH...
v.exe symlink > NUL
if %ERRORLEVEL% NEQ 0 (
echo ^> Could not add V to %%PATH%%, try rebuilding as admin.
goto :error
)
echo ^> V added to %%PATH%%
if "%cloned_tcc%" NEQ "" (
echo @echo off> "%~dp0.bin\tcc.bat"
echo %tcc_path%tcc %%^*>> "%~dp0.bin\tcc.bat"
echo ^> TCC added to %%PATH%%
)
echo ^> Restart your shell/IDE to reload it
:version :version
echo. echo.