From 8df8866c5a8f72d03a091f540e7dd1f9b4c418c4 Mon Sep 17 00:00:00 2001 From: spaceface777 Date: Fri, 10 Jul 2020 21:50:29 +0200 Subject: [PATCH] make.bat: improve diagnostics, do not add V to PATH automatically (#5789) --- .github/workflows/ci.yml | 8 +++---- make.bat | 51 ++++++++++++++++------------------------ 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cd962e584..9f9534e842 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -265,7 +265,7 @@ jobs: - name: Build run: | gcc --version - .\make.bat -gcc -skip-path + .\make.bat -gcc - name: Test new v.c run: .\v.exe -o v.c cmd/v && gcc -municode -w v.c - name: Install dependencies @@ -300,7 +300,7 @@ jobs: run: | echo %VFLAGS% echo $VFLAGS - .\make.bat -msvc -skip-path + .\make.bat -msvc - name: Install dependencies run: | .\v.exe setup-freetype @@ -331,12 +331,12 @@ jobs: # with: # node-version: 12.x - 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: | '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 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 run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -w -ladvapi32 -bt10 v.c - name: Install dependencies diff --git a/make.bat b/make.bat index 07b0700999..869a5eb0a9 100644 --- a/make.bat +++ b/make.bat @@ -2,6 +2,7 @@ echo Building V +set log_file=%TEMP%\v_make.bat.log set tcc_path=%~dp0thirdparty\tcc\ pushd %~dp0 @@ -19,10 +20,6 @@ if exist "vc" ( ) :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 if "%~1"=="-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 ) -gcc -std=c99 -municode -w -o v.exe vc\v_win.c -if %ERRORLEVEL% NEQ 0 goto :compile_error +gcc -std=c99 -municode -w -o v.exe vc\v_win.c>>%log_file% 2>>&1 +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 goto :success @@ -78,10 +79,10 @@ if exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" ( 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 -v.exe -cc msvc self +v.exe -cc msvc self>>%log_file% 2>>&1 del %ObjFile% if %ERRORLEVEL% NEQ 0 goto :compile_error goto :success @@ -115,19 +116,24 @@ if exist "%tcc_path%" ( if "%cloned_tcc%"=="" ( echo ^> Updating prebuilt TCC... pushd "%tcc_path%" - git pull -q > NUL + git pull -q popd ) ) 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 -v.exe -cc "%tcc_exe%" self > NUL +v.exe -cc "%tcc_exe%" self>>%log_file% 2>>&1 if %ERRORLEVEL% NEQ 0 goto :compile_error goto :success :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 :error @@ -138,26 +144,9 @@ exit /b 1 :success echo ^> V built successfully! +echo ^> To add V to your PATH, run `.\v symlink`. del v_old.exe - -: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 +del %log_file% :version echo.