Skip to content

Commit

Permalink
Make VS2017\install.bat works for both Visual Studio 2017 and 2019.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Dec 31, 2018
1 parent c5f2b5e commit 87805fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 27 deletions.
44 changes: 19 additions & 25 deletions VS2017/install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,33 @@
SETLOCAL ENABLEEXTENSIONS

SET "EXIT_ON_ERROR=%~1"
SET SUCCESS=0

FOR /f "delims=" %%A IN (
'"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath'
) DO SET "VS_PATH=%%A"
PUSHD %~dp0

@rem VSINSTALLDIR is set by vsdevcmd_start.bat
IF "%VS_PATH%" == "" (
IF EXIST "%VSINSTALLDIR%" SET "VS_PATH=%VSINSTALLDIR%"
)
IF NOT EXIST "%VS_PATH%" (
IF EXIST "%EXIT_ON_ERROR%" SET "VS_PATH=%EXIT_ON_ERROR%" & SET "EXIT_ON_ERROR=%~2"
SET VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
@rem Visual Studio 2017 and 2019
FOR /f "delims=" %%A IN ('"%VSWHERE%" -property installationPath -prerelease -version ^[15.0^,17.0^)') DO (
IF EXIST "%%A\Common7\IDE\VC\VCTargets\Platforms" CALL :SUB_VS2017 "%%A\Common7\IDE\VC\VCTargets\Platforms"
)

SET VCT_PATH=%VS_PATH%\Common7\IDE\VC\VCTargets\Platforms
IF NOT EXIST "%VCT_PATH%" (
IF %SUCCESS% == 0 (
ECHO Visual C++ 2017 or 2019 NOT Installed.
IF "%EXIT_ON_ERROR%" == "" PAUSE
ENDLOCAL
EXIT /B
)

ECHO VCTargetsPath: %VCT_PATH%

PUSHD %~dp0

XCOPY /Q /Y "LLVM" "%VCT_PATH%\..\LLVM\"
XCOPY /Q /Y "LLVM_v141" "%VCT_PATH%\x64\PlatformToolsets\LLVM_v141\"
XCOPY /Q /Y "LLVM_v141_xp" "%VCT_PATH%\x64\PlatformToolsets\LLVM_v141_xp\"
XCOPY /Q /Y "LLVM_v141" "%VCT_PATH%\Win32\PlatformToolsets\LLVM_v141\"
XCOPY /Q /Y "LLVM_v141_xp" "%VCT_PATH%\Win32\PlatformToolsets\LLVM_v141_xp\"
XCOPY /Q /Y "LLVM_v141" "%VCT_PATH%\ARM64\PlatformToolsets\LLVM_v141\"

IF "%EXIT_ON_ERROR%" == "" PAUSE
POPD
ENDLOCAL
EXIT /B


:SUB_VS2017
ECHO VCTargetsPath: %~1
XCOPY /Q /Y "LLVM" "%~1\..\LLVM\"
XCOPY /Q /Y "LLVM_v141" "%~1\x64\PlatformToolsets\LLVM_v141\"
XCOPY /Q /Y "LLVM_v141_xp" "%~1\x64\PlatformToolsets\LLVM_v141_xp\"
XCOPY /Q /Y "LLVM_v141" "%~1\Win32\PlatformToolsets\LLVM_v141\"
XCOPY /Q /Y "LLVM_v141_xp" "%~1\Win32\PlatformToolsets\LLVM_v141_xp\"
XCOPY /Q /Y "LLVM_v141" "%~1\ARM64\PlatformToolsets\LLVM_v141\"
SET SUCCESS=1
EXIT /B
2 changes: 0 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ please manually copy folder `LLVM_v141` and `LLVM_v141_xp` under `VS2017` to fol

or run `VS2017\install.bat` directly (may require Administrator privilege. In Windows 8 or later, you can quickly open an elevated PowerShell prompt by File -> Open Windows PowerShell -> Open PowerShell as Administrator).

Because `vswhere` doesn't print the installation path for Visual Studio 2019 Preview, please call the script with installation path, e.g: `CALL VS2017\install.bat "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview"` or call vsdevcmd.bat (or vcvarsall.bat, etc.) before this script.

## LLVM for Visual Studio 2010, 2012, 2013 and 2015
Assume `MB_PATH` is the MSBuild path for Visual C++ (e.g.: `C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0` or `C:\Program Files\MSBuild\Microsoft.Cpp\v4.0`), please manually copy `VS2017\LLVM` and related folders under `VS2015` to following target paths.

Expand Down

0 comments on commit 87805fb

Please sign in to comment.