2019-08-13 23:04:20 +03:00
|
|
|
@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
|
|
|
|
)
|
|
|
|
|
2019-08-17 12:56:42 +03:00
|
|
|
echo fetch v_win.c
|
|
|
|
curl -O https://raw.githubusercontent.com/vlang/vc/master/v_win.c
|
2019-08-13 23:04:20 +03:00
|
|
|
|
2019-08-17 12:56:42 +03:00
|
|
|
echo build v_win.c with msvc
|
2019-08-18 17:25:33 +03:00
|
|
|
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
|
2019-08-13 23:04:20 +03:00
|
|
|
|
|
|
|
if %ERRORLEVEL% GEQ 1 (
|
|
|
|
goto :compileerror
|
|
|
|
)
|
|
|
|
|
|
|
|
echo rebuild from source
|
2019-08-18 17:25:33 +03:00
|
|
|
v2.exe -os msvc -o v.exe compiler
|
|
|
|
if %ERRORLEVEL% GEQ 1 (
|
|
|
|
goto :compileerror
|
|
|
|
)
|
2019-08-13 23:04:20 +03:00
|
|
|
|
2019-08-27 21:08:54 +03:00
|
|
|
dir v_win.c v2.exe v.exe
|
|
|
|
|
2019-08-17 12:56:42 +03:00
|
|
|
del .v_win.c.obj
|
|
|
|
del v_win.c
|
2019-08-13 23:04:20 +03:00
|
|
|
del v2.exe
|
|
|
|
|
2019-08-18 17:25:33 +03:00
|
|
|
echo Success
|
2019-08-26 13:51:48 +03:00
|
|
|
goto :done
|
2019-08-18 17:25:33 +03:00
|
|
|
|
2019-08-13 23:04:20 +03:00
|
|
|
|
|
|
|
: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
|
|
|
|
|
2019-08-26 13:51:48 +03:00
|
|
|
|
2019-08-13 23:04:20 +03:00
|
|
|
:error
|
2019-08-26 13:51:48 +03:00
|
|
|
echo fail
|
2019-08-13 23:04:20 +03:00
|
|
|
exit /b 1
|
2019-08-26 13:51:48 +03:00
|
|
|
|
|
|
|
|
|
|
|
:done
|
|
|
|
echo pass
|