Skip to content

Commit bf5d585

Browse files
authored
Enable Visual Studio 2019 build by default (#3138)
This PR is switching the default build of DXC to Visual Studio 2019. The build script hctbuild.cmd will error when VS2019 is not installed. Use -vs2017 option to build with VS2017. VS2015 is no longer supported. Removes cmake version checking from hctstart.cmd Fixes cmake detection in Visual Studio installations Fixes DIA SDK lookup - use CMAKE_GENERATOR to detect VS version used and select the corresponding DIA SDK Use environment variable instead of c:\Program Files
1 parent 4397516 commit bf5d585

4 files changed

Lines changed: 41 additions & 109 deletions

File tree

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ before_build:
3838
- cmd: call utils\hct\hctstart %HLSL_SRC_DIR% %HLSL_BLD_DIR%
3939

4040
build_script:
41-
- cmd: call utils\hct\hctbuild -%PLATFORM% -%CONFIGURATION% -spirvtest
41+
- cmd: call utils\hct\hctbuild -%PLATFORM% -%CONFIGURATION% -vs2017 -spirvtest
4242
- sh: mkdir build && cd build
4343
- sh: cmake .. -GNinja $(cat ../utils/cmake-predefined-config-params) -DSPIRV_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=-Werror
4444
- sh: ninja

cmake/modules/FindDiaSDK.cmake

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,27 @@
11
# Find the DIA SDK path.
2-
get_filename_component(VS_PATH32 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0;InstallDir]" ABSOLUTE CACHE)
3-
get_filename_component(VS_PATH64 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\14.0;InstallDir]" ABSOLUTE CACHE)
4-
# VS_PATH32 will be something like C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE
2+
# It will typically look something like this:
3+
# C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\include
54

6-
# Also look for in vs15 or vs16 install.
7-
set(PROGRAMFILES_X86 "ProgramFiles(x86)")
8-
set(VS_PATH32 "$ENV{${PROGRAMFILES_X86}}/Microsoft Visual Studio")
9-
get_filename_component(VS15_C_PATH32 "${VS_PATH32}/2017/Community/Common7/IDE" ABSOLUTE CACHE)
10-
get_filename_component(VS15_P_PATH32 "${VS_PATH32}/2017/Professional/Common7/IDE" ABSOLUTE CACHE)
11-
get_filename_component(VS15_E_PATH32 "${VS_PATH32}/2017/Enterprise/Common7/IDE" ABSOLUTE CACHE)
5+
# CMAKE_GENERATOR_INSTANCE has the location of Visual Studio used
6+
# i.e. C:/Program Files (x86)/Microsoft Visual Studio/2019/Community
7+
set(VS_PATH ${CMAKE_GENERATOR_INSTANCE})
8+
get_filename_component(VS_DIA_INC_PATH "${VS_PATH}/DIA SDK/include" ABSOLUTE CACHE)
129

1310
# Starting in VS 15.2, vswhere is included.
1411
# Unclear what the right component to search for is, might be Microsoft.VisualStudio.Component.VC.DiagnosticTools
1512
# (although the friendly name of that is C++ profiling tools). The toolset is the most likely target.
13+
set(PROGRAMFILES_X86 "ProgramFiles(x86)")
1614
execute_process(
17-
COMMAND "${VS_PATH32}/Installer/vswhere.exe" -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
15+
COMMAND "$ENV{${PROGRAMFILES_X86}}/Microsoft Visual Studio/Installer/vswhere.exe" -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
1816
OUTPUT_VARIABLE VSWHERE_LATEST
1917
ERROR_QUIET
2018
OUTPUT_STRIP_TRAILING_WHITESPACE
2119
)
2220

23-
# Find the DIA SDK path, it will typically look something like this.
24-
# C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\DIA SDK\include
25-
# C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\DIA SDK\include
26-
# C:\Program Files (x86)\Microsoft Visual Studio 14.0\DIA SDK\include
2721
find_path(DIASDK_INCLUDE_DIR # Set variable DIASDK_INCLUDE_DIR
2822
dia2.h # Find a path with dia2.h
23+
HINTS "${VS_DIA_INC_PATH}"
2924
HINTS "${VSWHERE_LATEST}/DIA SDK/include"
30-
HINTS "${VS15_C_PATH32}/../../DIA SDK/include"
31-
HINTS "${VS15_P_PATH32}/../../DIA SDK/include"
32-
HINTS "${VS15_E_PATH32}/../../DIA SDK/include"
33-
HINTS "${VS_PATH64}/../../DIA SDK/include"
34-
HINTS "${VS_PATH32}/../../DIA SDK/include"
3525
DOC "path to DIA SDK header files"
3626
)
3727

utils/hct/hctbuild.cmd

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ if "%BUILD_ARCH%"=="" (
4141
set BUILD_ARCH=Win32
4242
)
4343

44-
set BUILD_GENERATOR=Visual Studio 15 2017
45-
set BUILD_VS_VER=2017
44+
set BUILD_GENERATOR=Visual Studio 16 2019
45+
set BUILD_VS_VER=2019
4646
set BUILD_CONFIG=Debug
4747
set DO_SETUP=1
4848
set DO_BUILD=1
@@ -128,16 +128,11 @@ if "%1"=="-Release" (
128128
shift /1
129129
)
130130
if "%1"=="-vs2017" (
131-
shift /1
132-
)
133-
if "%1"=="-vs2015" (
134-
set BUILD_GENERATOR=Visual Studio 14 2015
135-
set BUILD_VS_VER=2015
131+
set BUILD_GENERATOR=Visual Studio 15 2017
132+
set BUILD_VS_VER=2017
136133
shift /1
137134
)
138135
if "%1"=="-vs2019" (
139-
set BUILD_GENERATOR=Visual Studio 16 2019
140-
set BUILD_VS_VER=2019
141136
shift /1
142137
)
143138

@@ -184,13 +179,19 @@ if "%1"=="-dxc-cmake-ends-include" (
184179
shift /1
185180
)
186181

187-
rem If only VS 2017 is available, pick that by default.
188-
if "%BUILD_VS_VER%"=="2015" (
189-
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\vs\Servicing\14.0\devenv /v Install /reg:32 1>nul 2>nul
190-
if errorlevel 1 (
191-
echo Visual Studio 2015 not available, setting up build for Visual Studio 2017.
192-
set BUILD_GENERATOR=Visual Studio 15 2017
193-
set BUILD_VS_VER=2017
182+
rem If only VS 2019 is available, pick that by default.
183+
if "%BUILD_VS_VER%"=="2017" (
184+
if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017" (
185+
echo "Cannot find Visual Studio 2017 at %ProgramFiles(x86)%\Microsoft Visual Studio\2017."
186+
echo "Use hctbuild without -vs2017 (or with -vs2019) to build with Visual Studio 2019."
187+
exit /b 1
188+
)
189+
)
190+
if "%BUILD_VS_VER%"=="2019" (
191+
if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2019" (
192+
echo "Cannot find Visual Studio 2019 at %ProgramFiles(x86)%\Microsoft Visual Studio\2019."
193+
echo "Use hctbuild -vs2017 to build with Visual Studio 2017."
194+
exit /b 1
194195
)
195196
)
196197

@@ -327,7 +328,7 @@ exit /b 0
327328
echo Builds HLSL solutions and the product and test binaries for the current
328329
echo flavor and architecture.
329330
echo.
330-
echo hctbuild [-s or -b] [-alldef] [-analyze] [-official] [-fv] [-fvloc <path>] [-rel] [-arm or -arm64 or -x86 or -x64] [-Release] [-Debug] [-vs2015] [-ninja] [-tblgen path] [-dont-speak] [-no-parallel] [-no-dxilconv]
331+
echo hctbuild [-s or -b] [-alldef] [-analyze] [-official] [-fv] [-fvloc <path>] [-rel] [-arm or -arm64 or -x86 or -x64] [-Release] [-Debug] [-vs2017] [-vs2019] [-ninja] [-tblgen path] [-dont-speak] [-no-parallel] [-no-dxilconv]
331332
echo.
332333
echo -s creates the projects only, without building
333334
echo -b builds the existing project
@@ -341,6 +342,8 @@ echo -rel builds release rather than debug
341342
echo -dont-speak disables audible build confirmation
342343
echo -no-parallel disables parallel build
343344
echo -no-dxilconv disables build of DXBC to DXIL converter and tools
345+
echo -vs2017 uses Visual Studio 2017 to build
346+
echo -vs2019 uses Visual Studio 2019 to build
344347
echo.
345348
echo current BUILD_ARCH=%BUILD_ARCH%. Override with:
346349
echo -x86 targets an x86 build (aka. Win32)
@@ -354,7 +357,6 @@ echo.
354357
echo AppVeyor Support
355358
echo -Release builds release
356359
echo -Debug builds debug
357-
echo -vs2015 uses Visual Studio 2015 to build; ARM64 not supported
358360
echo.
359361
echo ARM build support
360362
echo -tblgen sets path to x86 or x64 versions of clang-tblgen and llvm-tblgen tools
@@ -420,17 +422,6 @@ if "%DO_BUILD%" neq "1" (
420422
exit /b 0
421423
)
422424

423-
rem Should add support for the non-x86-qualified programfiles.
424-
echo Building solution files for %2 with %1 configuration.
425-
if "%BUILD_GENERATOR%" NEQ "Ninja" (
426-
if "%BUILD_VS_VER%"=="2015" (
427-
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" (
428-
call :buildvs_x86dir %1 %2 %3
429-
goto :donebuild
430-
)
431-
)
432-
)
433-
434425
rem Just defer to cmake for now.
435426
cmake --build . --config %1 -- %PARALLEL_OPT%
436427
goto :donebuild
@@ -445,23 +436,6 @@ if errorlevel 1 (
445436
endlocal
446437
exit /b 0
447438

448-
449-
:buildvs_x86dir
450-
rem Build with the VS tools in the x86 program files directory, maxcpucount makes this goes much faster.
451-
rem 1 - config
452-
rem 2 - platform
453-
rem 3 - build directory
454-
setlocal
455-
call "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %BUILD_TOOLS%
456-
rem Add /ds for a detailed summary at the end.
457-
echo Logging to %3\msbuild-log.txt
458-
MSBuild.exe /nologo /property:Configuration=%1 /property:Platform=%2 /maxcpucount:2 %3\LLVM.sln /consoleloggerparameters:Summary;Verbosity=minimal /fileloggerparameters:LogFile=%3\msbuild-log.txt
459-
if NOT "%ERRORLEVEL%"=="0" (
460-
exit /b 1
461-
)
462-
endlocal
463-
exit /b 0
464-
465439
:verify-tblgen
466440
if exist %1\clang-tblgen.exe (
467441
if exist %1\llvm-tblgen.exe exit /b 0

utils/hct/hctstart.cmd

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ if errorlevel 1 (
8383
call :findcmake
8484
)
8585

86-
call :checkcmake
87-
if errorlevel 1 (
88-
echo WARNING: cmake version is not supported. Your build may fail.
89-
)
90-
9186
where python.exe 1>nul 2>nul
9287
if errorlevel 1 (
9388
call :findpython
@@ -119,20 +114,14 @@ echo.
119114
goto :eof
120115

121116
:findcmake
122-
call :ifexistaddpath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
123-
if "%ERRORLEVEL%"=="0" (
124-
echo Path adjusted to include cmake from Visual Studio 2017 Community
125-
exit /b 0
126-
)
127-
call :ifexistaddpath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
128-
if "%ERRORLEVEL%"=="0" (
129-
echo Path adjusted to include cmake from Visual Studio 2017 Professional
130-
exit /b 0
131-
)
132-
call :ifexistaddpath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
133-
if "%ERRORLEVEL%"=="0" (
134-
echo Path adjusted to include cmake from Visual Studio 2017 Enterprise
135-
exit /b 0
117+
for %%v in (2019 2017) do (
118+
for %%e in (Community Professional Enterprise) do (
119+
if exist "%programfiles(x86)%\Microsoft Visual Studio\%%v\%%e\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" (
120+
set "PATH=%PATH%;%programfiles(x86)%\Microsoft Visual Studio\%%v\%%e\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
121+
echo Path adjusted to include cmake from Visual Studio %%v %%e.
122+
exit /b 0
123+
)
124+
)
136125
)
137126
if errorlevel 1 if exist "%programfiles%\CMake\bin" set path=%path%;%programfiles%\CMake\bin
138127
if errorlevel 1 if exist "%programfiles(x86)%\CMake\bin" set path=%path%;%programfiles(x86)%\CMake\bin
@@ -160,15 +149,9 @@ if errorlevel 1 (
160149
)
161150
echo Path adjusted to include TAEF te.exe.
162151

163-
:ifexistaddpath
164-
rem If the argument exists, add to PATH and return 0, else 1. Useful to avoid parens in values without setlocal changes.
165-
if exist %1 set PATH=%PATH%;%~1
166-
if exist %1 exit /b 0
167-
exit /b 1
168-
169152
:findgit
170-
if exist "C:\Program Files (x86)\Git\cmd\git.exe" set path=%path%;C:\Program Files (x86)\Git\cmd
171-
if exist "C:\Program Files\Git\cmd\git.exe" set path=%path%;C:\Program Files\Git\cmd
153+
if exist "%programfiles(x86)%\Git\cmd\git.exe" set path=%path%;%programfiles(x86)%\Git\cmd
154+
if exist "%programfiles%\Git\cmd\git.exe" set path=%path%;%programfiles%\Git\cmd
172155
if exist "%LOCALAPPDATA%\Programs\Git\cmd\git.exe" set path=%path%;%LOCALAPPDATA%\Programs\Git\cmd
173156
where git 1>nul 2>nul
174157
if errorlevel 1 (
@@ -247,19 +230,4 @@ if ""=="%d3d12_sdk_ver%" (
247230
endlocal
248231
goto :eof
249232

250-
:checkcmake
251-
cmake --version | findstr 3.4.3 1>nul 2>nul
252-
if "0"=="%ERRORLEVEL%" exit /b 0
253-
cmake --version | findstr 3.7.2 1>nul 2>nul
254-
if "0"=="%ERRORLEVEL%" exit /b 0
255-
cmake --version | findstr 3.9.0-MSVC 1>nul 2>nul
256-
if "0"=="%ERRORLEVEL%" exit /b 0
257-
cmake --version | findstr 3.11.2 1>nul 2>nul
258-
if "0"=="%ERRORLEVEL%" exit /b 0
259-
cmake --version | findstr /R 3.*MSVC 1>nul 2>nul
260-
if errorlevel 1 (
261-
echo CMake 3.4.3, 3.7.2, 3.9.0 or 3.11.2 are the currently supported versions for VS 2015 and VS 2017 - your installed cmake is not supported.
262-
echo See README.md at the root for an explanation of dependencies.
263-
exit /b 1
264-
)
265-
goto :eof
233+
endlocal

0 commit comments

Comments
 (0)