瀏覽代碼

Remove paths to dxil.dll during testing to test the intended validator (#4995)

If some dxil.dll is reachable on your PATH, the compiler may select it as
the current validator.  This will interfere with testing.

When intentionally testing an external validator, you can supply the
specific one you want to test with by using the
`-dxil-loc <directory-containing-dxil.dll>` option.
Tex Riddell 2 年之前
父節點
當前提交
349a0e5735
共有 1 個文件被更改,包括 29 次插入0 次删除
  1. 29 0
      utils/hct/hcttest.cmd

+ 29 - 0
utils/hct/hcttest.cmd

@@ -1,6 +1,10 @@
 @echo off
 setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
 
+rem Remove entries from PATH that lead to DXIL.dll, otherwise DxCompiler.dll
+rem may load an undesired version from some random location (like an SDK path).
+call :removepathsto dxil.dll
+
 rem Default build config is Debug
 if "%BUILD_CONFIG%"=="" (
   set BUILD_CONFIG=Debug
@@ -583,3 +587,28 @@ if exist "%HLSL_AGILITYSDK_DIR%\build\native\bin\%BUILD_ARCH_DIR%\D3D12Core.dll"
 mkdir "%HLSL_TAEF_DIR%\%BUILD_ARCH_DIR%\D3D12" 1>nul 2>nul
 call %HCT_DIR%\hctcopy.cmd "%FULL_AGILITY_PATH%" "%HLSL_TAEF_DIR%\%BUILD_ARCH_DIR%\D3D12" D3D12Core.dll d3d12SDKLayers.dll
 exit /b %ERRORLEVEL%
+
+:removepathsto
+rem Remove all paths from PATH leading to the specified file
+set _REMAINING_PATH_TO_CHECK_=%PATH%
+set PATH=
+call :addpaths_unlessmatch "%~1"
+exit /b %errorlevel%
+
+:addpaths_unlessmatch
+rem Add path elements to PATH from _REMAINING_PATH_TO_CHECK_ unless it matches arg 1
+for /F "tokens=1,* delims=;" %%f IN ("%_REMAINING_PATH_TO_CHECK_%") DO (
+  rem Strip first item from _REMAINING_PATH_TO_CHECK_ and add if not a match
+  set "_REMAINING_PATH_TO_CHECK_=%%g"
+  if NOT exist "%%f\%~1" (
+    if "%PATH%" == "" (
+      set "PATH=%%f"
+    ) else (
+      set "PATH=%PATH%;%%f"
+    )
+  )
+  break
+)
+rem Loop while items remaining
+if NOT "%_REMAINING_PATH_TO_CHECK_%" == "" goto :addpaths_unlessmatch
+exit /b 0