commit 93428b0cf81e3daf46d10b8177b8687a67a88709 parent f2e9c9c34301273e045dcf6edae6d6f16c8f7735 Author: cfillion <cfillion@users.noreply.github.com> Date: Mon, 30 Jul 2018 14:05:57 -0700 win32: autodetect visual studio Diffstat:
M | README.md | | | 2 | -- |
M | win32.tup | | | 2 | ++ |
M | wrapper.bat | | | 16 | +++++++++++++--- |
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md @@ -87,8 +87,6 @@ the build dependencies: vendor\vcpkg\vcpkg install --triplet x64-windows-static %vcpkg-deps% vendor\vcpkg\vcpkg install --triplet x86-windows-static %vcpkg-deps% -Always run `tup` using the Developer Command Prompt for VS 2017. - ## Support and feedback Ask any ReaPack-releated questions in the diff --git a/win32.tup b/win32.tup @@ -1,4 +1,6 @@ # wrapper.bat selects which compiler to execute depending on the architecture +export ProgramData +export ProgramFiles(x86) WRAP := cmd /C wrapper.bat @(ARCH) CXX := $(WRAP) cl diff --git a/wrapper.bat b/wrapper.bat @@ -12,13 +12,23 @@ shift goto next_arg :continue -set PATH=%PATH%;%VCINSTALLDIR%\Auxiliary\Build +if defined VCtupINSTALLDIR ( + set ENVTOOLS=%VCINSTALLDIR%\Auxiliary\Build +) else ( + rem https://github.com/Microsoft/vswhere + 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 ENVTOOLS=%%i\VC\Auxiliary\Build + ) +) if "%arch%"=="x86_64" ( - call vcvars64.bat > NUL + call "%ENVTOOLS%\vcvars64.bat" > NUL ) else ( if "%arch%"=="i386" ( rem Using the x86 64-bit cross-compiler to avoid conflicts on the pdb file with tup - call vcvarsamd64_x86.bat > NUL + call "%ENVTOOLS%\vcvarsamd64_x86.bat" > NUL ) else ( echo Unknown Architecture: %arch% exit /b 42