Index: llvm/CMakeLists.txt =================================================================== --- llvm/CMakeLists.txt +++ llvm/CMakeLists.txt @@ -229,7 +229,9 @@ set(CPACK_NSIS_MODIFY_PATH "ON") set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON") set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS - "ExecWait '$INSTDIR/tools/msbuild/install.bat'") + "ExecWait '$INSTDIR/tools/msbuild/install.bat' + WriteRegStr HKLM 'Software\\\\${CPACK_PACKAGE_INSTALL_REGISTRY_KEY}' 'Version' '${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}' + ") set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "ExecWait '$INSTDIR/tools/msbuild/uninstall.bat'") if( CMAKE_CL_64 ) Index: llvm/tools/msbuild/CMakeLists.txt =================================================================== --- llvm/tools/msbuild/CMakeLists.txt +++ llvm/tools/msbuild/CMakeLists.txt @@ -1,69 +1,9 @@ if (MSVC) - # CPack will install a registry key in this format that we wish to reference. - set(REG_KEY "${CPACK_PACKAGE_INSTALL_REGISTRY_KEY}") - set(LIB_PATH_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}") + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/clang-cl.xml" DESTINATION tools/msbuild) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/LLVM.props" DESTINATION tools/msbuild) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/Toolset.props" DESTINATION tools/msbuild) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/Toolset.targets" DESTINATION tools/msbuild) - foreach (platform "Win32" "x64") - set(prop_file_in "Microsoft.Cpp.Win32.llvm.props.in") - set(prop_file_v100 "Microsoft.Cpp.${platform}.LLVM-vs2010.props") - set(prop_file_v110 "Microsoft.Cpp.${platform}.LLVM-vs2012.props") - set(prop_file_v110_xp "Microsoft.Cpp.${platform}.LLVM-vs2012_xp.props") - set(prop_file_v120 "toolset-vs2013.props") - set(prop_file_v120_xp "toolset-vs2013_xp.props") - set(prop_file_v140 "toolset-vs2014.props") - set(prop_file_v140_xp "toolset-vs2014_xp.props") - - if (platform STREQUAL "Win32") - set(mflag "m32") - else() - set(mflag "m64") - endif() - set(VS_VERSION "v100") - set(MSC_VERSION "1600") - configure_file(${prop_file_in} ${platform}/${prop_file_v100}) - set(VS_VERSION "v110") - set(MSC_VERSION "1700") - configure_file(${prop_file_in} ${platform}/${prop_file_v110}) - set(VS_VERSION "v110_xp") - configure_file(${prop_file_in} ${platform}/${prop_file_v110_xp}) - set(VS_VERSION "v120") - set(MSC_VERSION "1800") - configure_file(${prop_file_in} ${platform}/${prop_file_v120}) - set(VS_VERSION "v120_xp") - configure_file(${prop_file_in} ${platform}/${prop_file_v120_xp}) - set(VS_VERSION "v140") - set(MSC_VERSION "1900") - configure_file(${prop_file_in} ${platform}/${prop_file_v140}) - set(VS_VERSION "v140_xp") - configure_file(${prop_file_in} ${platform}/${prop_file_v140_xp}) - set(VS_VERSION) - set(MSC_VERSION) - set(mflag) - - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${platform}/${prop_file_v100}" DESTINATION tools/msbuild/${platform}) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${platform}/${prop_file_v110}" DESTINATION tools/msbuild/${platform}) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${platform}/${prop_file_v110_xp}" DESTINATION tools/msbuild/${platform}) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${platform}/${prop_file_v120}" DESTINATION tools/msbuild/${platform}) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${platform}/${prop_file_v120_xp}" DESTINATION tools/msbuild/${platform}) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${platform}/${prop_file_v140}" DESTINATION tools/msbuild/${platform}) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${platform}/${prop_file_v140_xp}" DESTINATION tools/msbuild/${platform}) - - install(FILES "Microsoft.Cpp.Win32.LLVM-vs2010.targets" DESTINATION "tools/msbuild/${platform}" RENAME "Microsoft.Cpp.${platform}.LLVM-vs2010.targets") - install(FILES "Microsoft.Cpp.Win32.LLVM-vs2012.targets" DESTINATION "tools/msbuild/${platform}" RENAME "Microsoft.Cpp.${platform}.LLVM-vs2012.targets") - install(FILES "Microsoft.Cpp.Win32.LLVM-vs2012_xp.targets" DESTINATION "tools/msbuild/${platform}" RENAME "Microsoft.Cpp.${platform}.LLVM-vs2012_xp.targets") - install(FILES "toolset-vs2013.targets" DESTINATION "tools/msbuild/${platform}") - install(FILES "toolset-vs2013_xp.targets" DESTINATION "tools/msbuild/${platform}") - install(FILES "toolset-vs2014.targets" DESTINATION "tools/msbuild/${platform}") - install(FILES "toolset-vs2014_xp.targets" DESTINATION "tools/msbuild/${platform}") - endforeach() - - set(LIB_PATH_VERSION) - set(REG_KEY) - - install(DIRECTORY . - DESTINATION tools/msbuild - FILES_MATCHING - PATTERN "*.bat" - PATTERN ".svn" EXCLUDE - ) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/install.bat" DESTINATION tools/msbuild) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/uninstall.bat" DESTINATION tools/msbuild) endif() Index: llvm/tools/msbuild/Clang.Cpp.Common.props =================================================================== --- /dev/null +++ llvm/tools/msbuild/Clang.Cpp.Common.props @@ -0,0 +1,81 @@ + + + + + + true + false + + $(IntermediateOutputPath) + $(Configuration)\ + $(SolutionDir)$(Configuration)\ + $(IntDir) + + + + + + + + $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\LLVM@LLVM) + $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LLVM@LLVM) + $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\LLVM@Version) + $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LLVM@Version) + + + 7.0.0 + 6.0.0 + 5.0.0 + + $(LLVMInstallDir)lib\clang\$(LLVMVersion) + + clang-cl.exe + $(LLVMInstallDir)bin + + + $(LLVMLibDir)include;$(IncludePath);$(VC_IncludePath);$(WindowsSDK_IncludePath); + $(WindowsSDK_MetadataPath); + $(VC_SourcePath); + + + + + + + + Default + + -m$(PlatformArchitecture) %(AdditionalOptions) + + + Index: llvm/tools/msbuild/Clang.Toolset.x64.props =================================================================== --- /dev/null +++ llvm/tools/msbuild/Clang.Toolset.x64.props @@ -0,0 +1,11 @@ + + + + + $(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(FxCopDir);$(PATH); + $(VC_ReferencesPath_x64); + $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64 + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(MSBuild_ExecutablePath);$(VC_LibraryPath_x64); + $(VCToolsInstallDir)redist\Debug_NonRedist\x64 + + Index: llvm/tools/msbuild/Clang.Toolset.x86.props =================================================================== --- /dev/null +++ llvm/tools/msbuild/Clang.Toolset.x86.props @@ -0,0 +1,11 @@ + + + + + $(VC_ExecutablePath_x86);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH); + $(VC_ReferencesPath_x86); + $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(MSBuild_ExecutablePath);$(VC_LibraryPath_x86); + $(VCToolsInstallDir)redist\Debug_NonRedist\x86 + + Index: llvm/tools/msbuild/LLVM.props =================================================================== --- /dev/null +++ llvm/tools/msbuild/LLVM.props @@ -0,0 +1,11 @@ + + + + + <_PlatformToolsetShortNameFor_llvm Condition="'$(_PlatformToolsetShortNameFor_llvm)' == ''">clang-cl + + + <_PlatformToolsetFriendlyNameFor_llvm Condition="'$(_PlatformToolsetFriendlyNameFor_llvm)' == ''">Clang for Windows + + + Index: llvm/tools/msbuild/Microsoft.Cpp.Win32.LLVM-vs2010.targets =================================================================== --- llvm/tools/msbuild/Microsoft.Cpp.Win32.LLVM-vs2010.targets +++ /dev/null @@ -1,2 +0,0 @@ - - Index: llvm/tools/msbuild/Microsoft.Cpp.Win32.LLVM-vs2012.targets =================================================================== --- llvm/tools/msbuild/Microsoft.Cpp.Win32.LLVM-vs2012.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - Index: llvm/tools/msbuild/Microsoft.Cpp.Win32.LLVM-vs2012_xp.targets =================================================================== --- llvm/tools/msbuild/Microsoft.Cpp.Win32.LLVM-vs2012_xp.targets +++ /dev/null @@ -1,21 +0,0 @@ - - - - v4.0 - NoSupportCodeAnalysisXP;$(BeforeClCompileTargets) - - - - - - - - - - CheckWindowsSDK71A;$(PrepareForBuildDependsOn) - - - - - - Index: llvm/tools/msbuild/Microsoft.Cpp.Win32.llvm.props.in =================================================================== --- llvm/tools/msbuild/Microsoft.Cpp.Win32.llvm.props.in +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\LLVM\@REG_KEY@) - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LLVM\@REG_KEY@) - $(LLVMInstallDir)\msbuild-bin;$(ExecutablePath) - $(LLVMInstallDir)\lib\clang\@LIB_PATH_VERSION@\lib\windows;$(LibraryPath) - - - - - - -@mflag@ -fmsc-version=@MSC_VERSION@ %(AdditionalOptions) - - - Index: llvm/tools/msbuild/Toolset.targets =================================================================== --- /dev/null +++ llvm/tools/msbuild/Toolset.targets @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OldStyle + OldStyle + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + false + false + false + + + + + + + File + + + + + + + + + + + + + + PropertySheet + + + + + + + + + Project;PropertySheet + + + + + + + + + + + + Project + + + PropertySheet + + + File;BrowseObject + + + + + + + + + + + + + + + + + \ No newline at end of file Index: llvm/tools/msbuild/clang-cl.xml =================================================================== --- /dev/null +++ llvm/tools/msbuild/clang-cl.xml @@ -0,0 +1,347 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: llvm/tools/msbuild/install.bat =================================================================== --- llvm/tools/msbuild/install.bat +++ llvm/tools/msbuild/install.bat @@ -6,110 +6,45 @@ REM Change to the directory of this batch file. cd /d %~dp0 -REM Loop over the two platforms in awkward batch file fashion. -set PLATFORM=None -:PLATFORMLOOPHEAD -IF %PLATFORM% == x64 GOTO PLATFORMLOOPEND -IF %PLATFORM% == Win32 SET PLATFORM=x64 -IF %PLATFORM% == None SET PLATFORM=Win32 +REM Older versions of VS would look for these files in the Program Files\MSBuild directory +REM but with VS2017 it seems to look for these directly in the Visual Studio instance. +REM This means we'll need to do a little extra work to properly detect all the various +REM instances, but in reality we can probably sidestep all of this by just wrapping this +REM in a vsix and calling it a day, as that should handle everything for us. +SET VCTargets=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets -REM Search for the MSBuild toolsets directory. +ECHO Installing Common Files +copy Clang.Cpp.Common.props "%VCTargets%" -SET D="%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\Platforms\%PLATFORM%\PlatformToolsets" -IF EXIST %D% GOTO FOUND_V100 -SET D="%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\Platforms\%PLATFORM%\PlatformToolsets" -IF EXIST %D% GOTO FOUND_V100 - -:TRY_V110 -SET D="%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\%PLATFORM%\PlatformToolsets" -IF EXIST %D% GOTO FOUND_V110 -SET D="%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\%PLATFORM%\PlatformToolsets" -IF EXIST %D% GOTO FOUND_V110 - -:TRY_V120 -SET D="%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\V120\Platforms\%PLATFORM%\PlatformToolsets" -IF EXIST %D% GOTO FOUND_V120 -SET D="%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\V120\Platforms\%PLATFORM%\PlatformToolsets" -IF EXIST %D% GOTO FOUND_V120 - -:TRY_V140 -SET D="%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\%PLATFORM%\PlatformToolsets" -IF EXIST %D% GOTO FOUND_V140 -SET D="%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\%PLATFORM%\PlatformToolsets" -IF EXIST %D% GOTO FOUND_V140 - -:TRY_V150 - -GOTO PLATFORMLOOPHEAD - -:PLATFORMLOOPEND -IF %SUCCESS% == 1 goto DONE -echo Failed to find MSBuild toolsets directory. -goto FAILED - - -:FOUND_V100 -REM Routine for installing v100 toolchain. -IF NOT EXIST %D%\LLVM-vs2010 mkdir %D%\LLVM-vs2010 +ECHO Installing x64 Platform Toolset +SET PlatformToolsets=%VCTargets%\Platforms\x64\PlatformToolsets +IF NOT EXIST "%PlatformToolsets%\llvm" mkdir "%PlatformToolsets%\llvm" IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\Microsoft.Cpp.%PLATFORM%.LLVM-vs2010.props %D%\LLVM-vs2010 +copy Clang.Toolset.x64.props "%PlatformToolsets%\llvm\Toolset.props" IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\Microsoft.Cpp.%PLATFORM%.LLVM-vs2010.targets %D%\LLVM-vs2010 +copy Toolset.targets "%PlatformToolsets%\llvm" IF NOT %ERRORLEVEL% == 0 GOTO FAILED -set SUCCESS=1 -GOTO TRY_V110 -:FOUND_V110 -REM Routine for installing v110 toolchain. -IF NOT EXIST %D%\LLVM-vs2012 mkdir %D%\LLVM-vs2012 -IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\Microsoft.Cpp.%PLATFORM%.LLVM-vs2012.props %D%\LLVM-vs2012 -IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\Microsoft.Cpp.%PLATFORM%.LLVM-vs2012.targets %D%\LLVM-vs2012 +ECHO Installing Win32 Platform Toolset +SET PlatformToolsets=%VCTargets%\Platforms\Win32\PlatformToolsets +IF NOT EXIST "%PlatformToolsets%\llvm" mkdir "%PlatformToolsets%\llvm" IF NOT %ERRORLEVEL% == 0 GOTO FAILED -IF NOT EXIST %D%\LLVM-vs2012_xp mkdir %D%\LLVM-vs2012_xp +copy Clang.Toolset.x86.props "%PlatformToolsets%\llvm\Toolset.props" IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\Microsoft.Cpp.%PLATFORM%.LLVM-vs2012_xp.props %D%\LLVM-vs2012_xp +copy Toolset.targets "%PlatformToolsets%\llvm" IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\Microsoft.Cpp.%PLATFORM%.LLVM-vs2012_xp.targets %D%\LLVM-vs2012_xp -IF NOT %ERRORLEVEL% == 0 GOTO FAILED -set SUCCESS=1 -GOTO TRY_V120 -:FOUND_V120 -REM Routine for installing v120 toolchain. -IF NOT EXIST %D%\LLVM-vs2013 mkdir %D%\LLVM-vs2013 -IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\toolset-vs2013.props %D%\LLVM-vs2013\toolset.props -IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\toolset-vs2013.targets %D%\LLVM-vs2013\toolset.targets -IF NOT %ERRORLEVEL% == 0 GOTO FAILED -IF NOT EXIST %D%\LLVM-vs2013_xp mkdir %D%\LLVM-vs2013_xp -IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\toolset-vs2013_xp.props %D%\LLVM-vs2013_xp\toolset.props +ECHO Installing C++ Settings UI +copy clang-cl.xml "%VCTargets%\1033" IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\toolset-vs2013_xp.targets %D%\LLVM-vs2013_xp\toolset.targets -IF NOT %ERRORLEVEL% == 0 GOTO FAILED -set SUCCESS=1 -GOTO TRY_V140 -:FOUND_V140 -REM Routine for installing v140 toolchain. -IF NOT EXIST %D%\LLVM-vs2014 mkdir %D%\LLVM-vs2014 -IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\toolset-vs2014.props %D%\LLVM-vs2014\toolset.props -IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\toolset-vs2014.targets %D%\LLVM-vs2014\toolset.targets +ECHO Installing MSBuild Hooks +IF NOT EXIST "%VCTargets%\ImportAfter" mkdir "%VCTargets%\ImportAfter" IF NOT %ERRORLEVEL% == 0 GOTO FAILED -IF NOT EXIST %D%\LLVM-vs2014_xp mkdir %D%\LLVM-vs2014_xp +IF NOT EXIST "%VCTargets%\ImportAfter\Default" mkdir "%VCTargets%\ImportAfter\Default" IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\toolset-vs2014_xp.props %D%\LLVM-vs2014_xp\toolset.props +copy LLVM.props "%VCTargets%\ImportAfter\Default" IF NOT %ERRORLEVEL% == 0 GOTO FAILED -copy %PLATFORM%\toolset-vs2014_xp.targets %D%\LLVM-vs2014_xp\toolset.targets -IF NOT %ERRORLEVEL% == 0 GOTO FAILED -set SUCCESS=1 -GOTO TRY_V150 - :DONE echo Done! Index: llvm/tools/msbuild/toolset-vs2013.targets =================================================================== --- llvm/tools/msbuild/toolset-vs2013.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - Index: llvm/tools/msbuild/toolset-vs2013_xp.targets =================================================================== --- llvm/tools/msbuild/toolset-vs2013_xp.targets +++ /dev/null @@ -1,21 +0,0 @@ - - - - v4.0 - NoSupportCodeAnalysisXP;$(BeforeClCompileTargets) - - - - - - - - - - CheckWindowsSDK71A;$(PrepareForBuildDependsOn) - - - - - - Index: llvm/tools/msbuild/toolset-vs2014.targets =================================================================== --- llvm/tools/msbuild/toolset-vs2014.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - Index: llvm/tools/msbuild/toolset-vs2014_xp.targets =================================================================== --- llvm/tools/msbuild/toolset-vs2014_xp.targets +++ /dev/null @@ -1,21 +0,0 @@ - - - - v4.0 - NoSupportCodeAnalysisXP;$(BeforeClCompileTargets) - - - - - - - - - - CheckWindowsSDK71A;$(PrepareForBuildDependsOn) - - - - - -