diff --git a/cmake/caches/PredefinedParams.cmake b/cmake/caches/PredefinedParams.cmake index 0e5421eab..4e432312b 100644 --- a/cmake/caches/PredefinedParams.cmake +++ b/cmake/caches/PredefinedParams.cmake @@ -11,6 +11,15 @@ if (DXC_COVERAGE) set(LLVM_CODE_COVERAGE_TARGETS "dxc;dxcompiler" CACHE STRING "") endif() +if (DXC_USE_LIT) + set(LLVM_TEST_VALUE ON) +else() + set(LLVM_TEST_VALUE OFF) +endif() + +set(LLVM_INCLUDE_TESTS ${LLVM_TEST_VALUE} CACHE BOOL "") +set(CLANG_INCLUDE_TESTS ${LLVM_TEST_VALUE} CACHE BOOL "") + set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "") set(LLVM_APPEND_VC_REV ON CACHE BOOL "") set(LLVM_DEFAULT_TARGET_TRIPLE "dxil-ms-dx" CACHE STRING "") @@ -18,7 +27,6 @@ set(LLVM_ENABLE_EH ON CACHE BOOL "") set(LLVM_ENABLE_RTTI ON CACHE BOOL "") set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "") set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "") -set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "") set(LLVM_OPTIMIZED_TABLEGEN OFF CACHE BOOL "") set(LLVM_REQUIRES_EH ON CACHE BOOL "") set(LLVM_REQUIRES_RTTI ON CACHE BOOL "") @@ -28,7 +36,6 @@ set(CLANG_BUILD_EXAMPLES OFF CACHE BOOL "") set(CLANG_CL OFF CACHE BOOL "") set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "") set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "") -set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "") set(HLSL_INCLUDE_TESTS ON CACHE BOOL "") set(ENABLE_SPIRV_CODEGEN ON CACHE BOOL "") set(SPIRV_BUILD_TESTS ON CACHE BOOL "") \ No newline at end of file diff --git a/projects/dxilconv/test/CMakeLists.txt b/projects/dxilconv/test/CMakeLists.txt index f6be44567..f1fb207b0 100644 --- a/projects/dxilconv/test/CMakeLists.txt +++ b/projects/dxilconv/test/CMakeLists.txt @@ -8,7 +8,7 @@ configure_lit_site_cfg( # HLSL Change Begin - Add taef tests -add_lit_target("check-dxilconv" "Running lit suite dxilconv" +add_lit_testsuite("check-dxilconv" "Running lit suite dxilconv" ${CMAKE_CURRENT_SOURCE_DIR}/taef PARAMS dxilconv_site_config=${CMAKE_CURRENT_BINARY_DIR}/taef/lit.site.cfg diff --git a/projects/dxilconv/test/taef/lit.site.cfg.in b/projects/dxilconv/test/taef/lit.site.cfg.in index 32d2e702d..e17795476 100644 --- a/projects/dxilconv/test/taef/lit.site.cfg.in +++ b/projects/dxilconv/test/taef/lit.site.cfg.in @@ -5,7 +5,7 @@ import sys config.llvm_src_root = "@LLVM_SOURCE_DIR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.build_mode = lit_config.params["build_mode"] -config.arch = "@DXC_BUILD_ARCH@" +config.arch = "@CMAKE_C_COMPILER_ARCHITECTURE_ID@" # Let the main config do the real work. lit_config.load_config(config, "@LLVM_SOURCE_DIR@/projects/dxilconv/test/taef/lit.cfg") diff --git a/tools/clang/test/taef/lit.cfg b/tools/clang/test/taef/lit.cfg index 773c144d2..b6a5aaa5d 100644 --- a/tools/clang/test/taef/lit.cfg +++ b/tools/clang/test/taef/lit.cfg @@ -9,7 +9,7 @@ import lit.formats import lit.util # name: The name of this test suite. -config.name = 'clang-hlsl' +config.name = 'clang-taef' # Check that the object root is known. llvm_obj_root = getattr(config, 'llvm_obj_root', None) @@ -28,7 +28,7 @@ if llvm_obj_root is None: te = os.path.join(config.llvm_obj_root, "TAEF", config.arch, 'te.exe') -test_dll = os.path.join(config.llvm_obj_root, config.build_mode, 'bin', 'clang-hlsl-tests.dll') +test_dll = os.path.join(config.llvm_obj_root, config.build_mode, 'bin', 'ClangHLSLTests.dll') hlsl_data_dir = os.path.join(config.llvm_src_root, 'tools', 'clang', 'test', 'hlsl') diff --git a/tools/clang/test/taef/lit.site.cfg.in b/tools/clang/test/taef/lit.site.cfg.in index 35e60e502..4b22f0e7f 100644 --- a/tools/clang/test/taef/lit.site.cfg.in +++ b/tools/clang/test/taef/lit.site.cfg.in @@ -8,4 +8,4 @@ config.build_mode = lit_config.params["build_mode"] config.arch = "@DXC_BUILD_ARCH@" # Let the main config do the real work. -lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/clang-hlsl/lit.cfg") +lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/taef/lit.cfg") diff --git a/tools/clang/unittests/HLSL/CMakeLists.txt b/tools/clang/unittests/HLSL/CMakeLists.txt index c7648b8ea..eca3829e0 100644 --- a/tools/clang/unittests/HLSL/CMakeLists.txt +++ b/tools/clang/unittests/HLSL/CMakeLists.txt @@ -28,7 +28,7 @@ set(HLSL_IGNORE_SOURCES TestMain.cpp HLSLTestOptions.cpp ) -add_clang_library(clang-hlsl-tests SHARED +add_clang_library(ClangHLSLTests SHARED AllocatorTest.cpp CompilerTest.cpp DxilContainerTest.cpp @@ -61,7 +61,7 @@ set(HLSL_IGNORE_SOURCES ShaderOpTest.cpp ) -add_clang_unittest(clang-hlsl-tests +add_clang_unittest(ClangHLSLTests AllocatorTest.cpp CompilerTest.cpp DxilContainerTest.cpp @@ -82,10 +82,10 @@ add_clang_unittest(clang-hlsl-tests endif(WIN32) -set_target_properties(clang-hlsl-tests PROPERTIES FOLDER "Clang tests") +set_target_properties(ClangHLSLTests PROPERTIES FOLDER "Clang tests") if (WIN32) -target_link_libraries(clang-hlsl-tests PRIVATE +target_link_libraries(ClangHLSLTests PRIVATE dxcompiler HLSLTestLib LLVMDxilContainer @@ -96,7 +96,7 @@ target_link_libraries(clang-hlsl-tests PRIVATE shlwapi ) else(WIN32) -target_link_libraries(clang-hlsl-tests +target_link_libraries(ClangHLSLTests dxcompiler HLSLTestLib ) @@ -113,23 +113,22 @@ endif(WIN32) # Add includes to directly reference intrinsic tables. include_directories(${CLANG_BINARY_DIR}/lib/Sema) -add_dependencies(clang-hlsl-tests dxcompiler) +add_dependencies(ClangHLSLTests dxcompiler) -if(WIN32) -install(TARGETS clang-hlsl-tests - RUNTIME DESTINATION bin) -else(WIN32) -set_output_directory(clang-hlsl-tests - ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR}) -endif(WIN32) +if (NOT CLANG_INCLUDE_TESTS) + set_target_properties(ClangHLSLTests PROPERTIES OUTPUT_NAME clang-hlsl-tests) + set_output_directory(ClangHLSLTests + ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR}) + if (NOT WIN32) + add_test(NAME test-hlsl-codegen + COMMAND $ --HlslDataDir + ${PROJECT_SOURCE_DIR}/tools/clang/test/HLSL) + endif() +endif() if(WIN32) # Add a .user file with settings for te.exe. file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" DOS_STYLE_SOURCE_DIR) file(TO_NATIVE_PATH "${TAEF_BIN_DIR}" DOS_TAEF_BIN_DIR) -configure_file(clang-hlsl-tests.vcxproj.user.txt clang-hlsl-tests.vcxproj.user) +configure_file(ClangHLSLTests.vcxproj.user.txt ClangHLSLTests.vcxproj.user) endif(WIN32) - -add_test(NAME test-hlsl-codegen - COMMAND clang-hlsl-tests --HlslDataDir - ${PROJECT_SOURCE_DIR}/tools/clang/test/HLSL) diff --git a/tools/clang/unittests/HLSL/clang-hlsl-tests.vcxproj.user.txt b/tools/clang/unittests/HLSL/ClangHLSLTests.vcxproj.user.txt similarity index 100% rename from tools/clang/unittests/HLSL/clang-hlsl-tests.vcxproj.user.txt rename to tools/clang/unittests/HLSL/ClangHLSLTests.vcxproj.user.txt diff --git a/tools/clang/unittests/HLSLHost/CMakeLists.txt b/tools/clang/unittests/HLSLHost/CMakeLists.txt index 44b7c522d..52d4d2873 100644 --- a/tools/clang/unittests/HLSLHost/CMakeLists.txt +++ b/tools/clang/unittests/HLSLHost/CMakeLists.txt @@ -12,14 +12,14 @@ add_clang_executable(HLSLHost ) target_link_libraries(HLSLHost - clang-hlsl-tests + ClangHLSLTests ) set_target_properties(HLSLHost PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION}) include_directories(AFTER ${DIASDK_INCLUDE_DIRS}) -add_dependencies(HLSLHost clang-hlsl-tests) +add_dependencies(HLSLHost ClangHLSLTests) if(UNIX) set(CLANGXX_LINK_OR_COPY create_symlink) diff --git a/tools/clang/unittests/SPIRV/CMakeLists.txt b/tools/clang/unittests/SPIRV/CMakeLists.txt index 123950c74..9f97f6414 100644 --- a/tools/clang/unittests/SPIRV/CMakeLists.txt +++ b/tools/clang/unittests/SPIRV/CMakeLists.txt @@ -6,7 +6,7 @@ set(LLVM_LINK_COMPONENTS hlsl ) -add_clang_unittest(clang-spirv-tests +add_clang_unittest(ClangSPIRVTests CodeGenSpirvTest.cpp FileTestFixture.cpp FileTestUtils.cpp @@ -21,7 +21,7 @@ add_clang_unittest(clang-spirv-tests WholeFileTestFixture.cpp ) -target_link_libraries(clang-spirv-tests +target_link_libraries(ClangSPIRVTests clangAST clangBasic clangCodeGen @@ -36,13 +36,16 @@ target_link_libraries(clang-spirv-tests # This is necessary so that the linked dxcompiler is loaded into memory space # first, and in case dxcompiler.so is loaded via 'dlopen', it resolves to the # same memory space, and prevents getting two copies of global static variables. -add_dependencies(clang-spirv-tests dxcompiler) +add_dependencies(ClangSPIRVTests dxcompiler) -target_include_directories(clang-spirv-tests +target_include_directories(ClangSPIRVTests PRIVATE ${SPIRV_TOOLS_INCLUDE_DIR} ${DXC_EFFCEE_DIR}) -set_output_directory(clang-spirv-tests - ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR}) +if (NOT CLANG_INCLUDE_TESTS) + set_target_properties(ClangSPIRVTests PROPERTIES OUTPUT_NAME clang-spirv-tests) + set_output_directory(ClangSPIRVTests + ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR}) +endif() set(SPIRV_TEST_DATA_DIR ${LLVM_SOURCE_DIR}/tools/clang/test/CodeGenSPIRV/) configure_file( @@ -54,6 +57,6 @@ if(WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # otherwise will hit fatal error C1128 on windows x64 endif(WIN32) -add_test(NAME test-spirv-codegen - COMMAND clang-spirv-tests --spirv-test-root - ${PROJECT_SOURCE_DIR}/tools/clang/test/CodeGenSPIRV) +if (NOT CLANG_INCLUDE_TESTS) + add_test(NAME test-spirv-codegen COMMAND $) +endif()