mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
bootstrap: single make.bat, default msvc option for forcing gcc
This commit is contained in:
parent
b17bf5843c
commit
7fc899dfd6
@ -46,8 +46,8 @@ script:
|
||||
./v.exe test v
|
||||
##echo "Running only the repl tests directly"
|
||||
##./v.exe ./compiler/tests/repl/repl_test.v
|
||||
echo "Testing msvc bootstrapping"
|
||||
./make_msvc.bat
|
||||
echo "Testing gcc bootstrapping"
|
||||
./make.bat -gcc
|
||||
fi
|
||||
- |
|
||||
if [[ "${TRAVIS_OS_NAME}" != "windows" ]]; then
|
||||
|
@ -228,7 +228,7 @@ pub fn (v mut V) cc_msvc() {
|
||||
// -w: no warnings
|
||||
// 2 unicode defines
|
||||
// /Fo sets the object file name - needed so we can clean up after ourselves properly
|
||||
mut a := ['-w', '/volatile:ms', '/D_UNICODE', '/DUNICODE', '/Fo$out_name_obj']
|
||||
mut a := ['-w', '/we4013', '/volatile:ms', '/D_UNICODE', '/DUNICODE', '/Fo$out_name_obj']
|
||||
|
||||
if v.pref.is_prod {
|
||||
a << '/O2'
|
||||
|
91
make.bat
91
make.bat
@ -1,35 +1,106 @@
|
||||
set exiterror=0
|
||||
@echo off
|
||||
|
||||
echo Building V for Windows...
|
||||
echo Building V
|
||||
|
||||
if exist "vc" (
|
||||
rd /s /q vc
|
||||
rd /s /q vc
|
||||
)
|
||||
|
||||
git version
|
||||
git clone --depth 1 --quiet https://github.com/vlang/vc
|
||||
|
||||
echo Building v.c...
|
||||
gcc -std=gnu11 -DUNICODE -D_UNICODE -w -o v2.exe vc/v_win.c 2>&1
|
||||
REM option to force msvc or gcc
|
||||
if "%~1"=="-gcc" goto :gccstrap
|
||||
if "%~1"=="-msvc" goto :gccstrap
|
||||
|
||||
goto :msvcstrap
|
||||
|
||||
:gccstrap
|
||||
|
||||
echo attempting to bootstrap with GCC
|
||||
|
||||
for /f "usebackq tokens=*" %%i in (`where gcc`) do (
|
||||
set gccpath=%%i
|
||||
)
|
||||
|
||||
if not exist "%gccpath%" (
|
||||
goto:msvcstrap
|
||||
)
|
||||
|
||||
gcc -std=gnu11 -DUNICODE -D_UNICODE -w -o v2.exe vc\v_win.c
|
||||
if %ERRORLEVEL% GEQ 1 (
|
||||
echo gcc failed to compile - Create an issue at 'https://github.com/vlang'
|
||||
exit /b 1
|
||||
echo gcc failed to compile - Create an issue at 'https://github.com/vlang'
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Building v.v...
|
||||
v2.exe -o v.exe compiler
|
||||
if %ERRORLEVEL% GEQ 1 (
|
||||
echo v.exe failed to compile itself - Create an issue at 'https://github.com/vlang'
|
||||
exit /b 1
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Cleaning up...
|
||||
rem del v2.exe
|
||||
del v2.exe
|
||||
rd /s /q vc
|
||||
|
||||
goto :success
|
||||
|
||||
|
||||
:msvcstrap
|
||||
echo Attempting to bootstrap with MSVC
|
||||
|
||||
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -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=x64 -host_arch=x64
|
||||
) else (
|
||||
goto :nocompiler
|
||||
)
|
||||
|
||||
cl.exe /w /volatile:ms /D_UNICODE /DUNICODE /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
|
||||
|
||||
if %ERRORLEVEL% GEQ 1 (
|
||||
echo cl.exe failed to build V
|
||||
goto :compileerror
|
||||
)
|
||||
|
||||
echo rebuild from source
|
||||
v2.exe -o v.exe compiler
|
||||
if %ERRORLEVEL% GEQ 1 (
|
||||
echo V failed to build itself
|
||||
goto :compileerror
|
||||
)
|
||||
|
||||
del v2.exe
|
||||
rd /s /q vc
|
||||
|
||||
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
|
||||
dir
|
||||
if exist "v.exe" (
|
||||
echo V has been successfully built
|
||||
exit
|
||||
) else (
|
||||
echo v.exe was not generated - Create an issue at 'https://github.com/vlang'
|
||||
exit /b 1
|
||||
|
@ -1,60 +0,0 @@
|
||||
@echo off
|
||||
|
||||
set exiterror=0
|
||||
|
||||
echo finding an MSVC installation
|
||||
|
||||
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
|
||||
set InstallDir=%%i
|
||||
)
|
||||
|
||||
REM set up a devcmd
|
||||
|
||||
if exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" (
|
||||
call "%InstallDir%\Common7\Tools\vsdevcmd.bat" -arch=x64 -host_arch=x64
|
||||
) else (
|
||||
goto :nomsvc
|
||||
)
|
||||
|
||||
echo fetch v_win.c
|
||||
curl -O https://raw.githubusercontent.com/vlang/vc/master/v_win.c
|
||||
|
||||
echo build v_win.c with msvc
|
||||
cl.exe /w /volatile:ms /D_UNICODE /DUNICODE /D_BOOTSTRAP_NO_UNICODE_STREAM /Fo.v_win.c.obj /O2 /MD v_win.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /DEBUG:NONE /NOLOGO /OUT:v2.exe /INCREMENTAL:NO
|
||||
|
||||
if %ERRORLEVEL% GEQ 1 (
|
||||
goto :compileerror
|
||||
)
|
||||
|
||||
echo rebuild from source
|
||||
v2.exe -os msvc -o v.exe compiler
|
||||
if %ERRORLEVEL% GEQ 1 (
|
||||
goto :compileerror
|
||||
)
|
||||
|
||||
dir v_win.c v2.exe v.exe
|
||||
|
||||
del .v_win.c.obj
|
||||
del v_win.c
|
||||
del v2.exe
|
||||
|
||||
echo Success
|
||||
goto :done
|
||||
|
||||
|
||||
:nomsvc
|
||||
echo Cannot find an msvc installation
|
||||
goto :error
|
||||
|
||||
:compileerror
|
||||
echo Failed to compile - Create an issue at 'https://github.com/vlang' and tag '@emily33901'!
|
||||
goto :error
|
||||
|
||||
|
||||
:error
|
||||
echo fail
|
||||
exit /b 1
|
||||
|
||||
|
||||
:done
|
||||
echo pass
|
Loading…
Reference in New Issue
Block a user