浏览代码

Support -ninja in hcttest (#223)

Now we can run `hctbuild -s -ninja` to configure to use Ninja as
the generator, run `hctbuild -b` to build the artifacts with Ninja,
and then run `hcttest -ninja` to run the tests.

Also fixes the wrong order in hcttest help message.
Lei Zhang 8 年之前
父节点
当前提交
6a254ae8b2
共有 2 个文件被更改,包括 39 次插入10 次删除
  1. 13 4
      utils/hct/hctbuild.cmd
  2. 26 6
      utils/hct/hcttest.cmd

+ 13 - 4
utils/hct/hctbuild.cmd

@@ -160,7 +160,11 @@ if "%BUILD_ARCH%"=="Win32" (
 call :configandbuild %BUILD_CONFIG% %BUILD_ARCH% %HLSL_BLD_DIR% "%BUILD_GENERATOR%"
 if errorlevel 1 exit /b 1
 
-echo Success - files are available at %HLSL_BLD_DIR%\%BUILD_CONFIG%\bin
+if "%BUILD_GENERATOR%"=="Ninja" (
+  echo Success - files are available at %HLSL_BLD_DIR%\bin
+) else (
+  echo Success - files are available at %HLSL_BLD_DIR%\%BUILD_CONFIG%\bin
+)
 call :handlesuccess
 exit /b 0
 
@@ -215,10 +219,15 @@ if not exist %3 (
 )
 cd /d %3
 if "%DO_SETUP%"=="1" (
-  rem -DCMAKE_BUILD_TYPE:STRING=%1 is not necessary for multi-config generators like VS
   echo Creating solution files for %2, logging to %3\cmake-log.txt
-  echo Running cmake %CMAKE_OPTS% -G %4 %HLSL_SRC_DIR% > %3\cmake-log.txt
-  cmake %CMAKE_OPTS% -G %4 %HLSL_SRC_DIR% >> %3\cmake-log.txt 2>&1
+  if "%BUILD_GENERATOR%"=="Ninja" (
+    echo Running cmake -DCMAKE_BUILD_TYPE:STRING=%1 %CMAKE_OPTS% -G %4 %HLSL_SRC_DIR% > %3\cmake-log.txt
+    cmake -DCMAKE_BUILD_TYPE:STRING=%1 %CMAKE_OPTS% -G %4 %HLSL_SRC_DIR% >> %3\cmake-log.txt 2>&1
+  ) else (
+    rem -DCMAKE_BUILD_TYPE:STRING=%1 is not necessary for multi-config generators like VS
+    echo Running cmake %CMAKE_OPTS% -G %4 %HLSL_SRC_DIR% > %3\cmake-log.txt
+    cmake %CMAKE_OPTS% -G %4 %HLSL_SRC_DIR% >> %3\cmake-log.txt 2>&1
+  )
   if errorlevel 1 (
     echo Failed to configure cmake projects.
     echo ===== begin cmake-log.txt =====

+ 26 - 6
utils/hct/hcttest.cmd

@@ -10,6 +10,9 @@ set TEST_EXEC=1
 set TEST_CLANG_VERIF=0
 set TEST_EXTRAS=1
 
+rem Whether we built the project using ninja as the generator.
+set GENERATOR_NINJA=0
+
 if "%BUILD_CONFIG%"=="" (
   set BUILD_CONFIG=Debug
 )
@@ -57,6 +60,11 @@ if "%1"=="none" (
   shift /1
 )
 
+if "%1"=="-ninja" (
+  set GENERATOR_NINJA=1
+  shift /1
+)
+
 if "%1"=="-rel" (
   set BUILD_CONFIG=Release
   shift /1
@@ -75,8 +83,6 @@ if "%1"=="-x86" (
 shift /1
 :donearch
 
-set TEST_DIR=%HLSL_BLD_DIR%\%BUILD_CONFIG%\test
-
 if "%1"=="/?" goto :showhelp
 if "%1"=="-?" goto :showhelp
 if "%1"=="-help" goto :showhelp
@@ -88,7 +94,12 @@ if errorlevel 1 (
   exit /b 1
 )
 
-set TEST_DIR=%HLSL_BLD_DIR%\%BUILD_CONFIG%\test
+if "%GENERATOR_NINJA%"=="1" (
+  set TEST_DIR=%HLSL_BLD_DIR%\test
+) else (
+  set TEST_DIR=%HLSL_BLD_DIR%\%BUILD_CONFIG%\test
+)
+
 if exist %TEST_DIR% (
   echo Cleaning %TEST_DIR% ...
   rmdir /q /s %TEST_DIR%
@@ -102,7 +113,15 @@ if "%TEST_CLEAN%"=="1" (
 )
 
 echo Copying binaries to test to %TEST_DIR%:
-robocopy %HLSL_BLD_DIR%\%BUILD_CONFIG%\bin %TEST_DIR% *.exe *.dll
+
+Rem For the Ninja generator, artifacts are not generated into a directory
+Rem matching the current build configuration; instead, they are generated
+Rem directly into bin/ under the build root directory.
+if "%GENERATOR_NINJA%"=="1" (
+  robocopy %HLSL_BLD_DIR%\bin %TEST_DIR% *.exe *.dll
+) else (
+  robocopy %HLSL_BLD_DIR%\%BUILD_CONFIG%\bin %TEST_DIR% *.exe *.dll
+)
 
 echo Running HLSL tests ...
 
@@ -178,7 +197,7 @@ exit /b 0
 :showhelp
 
 echo Usage:
-echo   hcttest [-rel] [-arm or -x86 or -x64] [target]
+echo   hcttest [target] [-ninja] [-rel] [-arm or -x86 or -x64]
 echo.
 echo target can be empty or a specific subset.
 echo.
@@ -188,7 +207,8 @@ echo 'clang' will only run clang tests.
 echo 'exec' will only run execution tests.
 echo 'v' will run the clang tests that are verified-based.
 echo.
-echo   -rel builds release rather than debug
+echo   -rel   builds release rather than debug
+echo   -ninja artifacts were built using the Ninja generator
 echo.
 echo current BUILD_ARCH=%BUILD_ARCH%.  Override with:
 echo   -x86 targets an x86 build (aka. Win32)