diff --git a/.travis.yml b/.travis.yml index 32f33ef892..b4f890906d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,8 @@ script: - | if [[ "${TRAVIS_OS_NAME}" == "windows" ]]; then choco install openssl.light + echo "Testing msvc bootstrapping" + ./make_msvc.bat echo "Running make_tests.bat..." ./make_tests.bat fi diff --git a/make_msvc.bat b/make_msvc.bat new file mode 100644 index 0000000000..7871ff12ec --- /dev/null +++ b/make_msvc.bat @@ -0,0 +1,48 @@ +@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.c +curl -O https://raw.githubusercontent.com/vlang/vc/master/v.c + +echo build v.c with msvc +cl.exe /w /volatile:ms /D_UNICODE /DUNICODE /Fo.v.c.obj /O2 /MD v.c user32.lib kernel32.lib advapi32.lib shell32.lib /link /NOLOGO /OUT:v2.exe /INCREMENTAL:NO + +if %ERRORLEVEL% GEQ 1 ( + goto :compileerror +) + +echo rebuild from source +v2.exe -o v.exe compiler + +del .v.c.obj +del v.c +del v2.exe + +exit + +: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 Exiting from error +exit /b 1 diff --git a/make_tests.bat b/make_tests.bat index 7b94074683..a0b3a247f2 100644 --- a/make_tests.bat +++ b/make_tests.bat @@ -1,5 +1,10 @@ @echo off +echo Cleanup +del v.exe +del v.c +del v2.exe + echo fetch v.c curl -O https://raw.githubusercontent.com/vlang/vc/master/v.c if %ERRORLEVEL% NEQ 0 goto :fail @@ -13,12 +18,16 @@ echo build v using vc vc.exe -o v.exe compiler if %ERRORLEVEL% NEQ 0 goto :fail -echo build v.msvc using v -v.exe -os msvc -o v.msvc.exe compiler +echo build vc.msvc using vc +vc.exe -os msvc -o v.msvc.exe compiler if %ERRORLEVEL% NEQ 0 goto :fail -echo build v.msvc.2 using v.msvc -v.msvc.exe -os msvc -o v.msvc.2.exe compiler +echo build v.msvc.3 using v +v.exe -os msvc -o v.msvc.2.exe compiler +if %ERRORLEVEL% NEQ 0 goto :fail + +echo build v.msvc.3 using v.msvc +v.msvc.exe -os msvc -o v.msvc.3.exe compiler if %ERRORLEVEL% NEQ 0 goto :fail echo build v.gcc using v.msvc @@ -56,4 +65,4 @@ echo fail exit /b 1 :done -echo pass \ No newline at end of file +echo pass