Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -61,12 +61,18 @@ option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS}) +option(LLDB_TEST_USE_CUSTOM_C_COMPILER "Use the C compiler provided via LLDB_TEST_C_COMPILER for building test inferiors (instead of the just-built compiler). Defaults to OFF." OFF) +option(LLDB_TEST_USE_CUSTOM_CXX_COMPILER "Use the C++ compiler provided via LLDB_TEST_CXX_COMPILER for building test inferiors (instead of the just-built compiler). Defaults to OFF." OFF) if(LLDB_INCLUDE_TESTS) - if (TARGET clang) + if (NOT LLDB_TEST_USE_CUSTOM_C_COMPILER AND TARGET clang) set(LLDB_DEFAULT_TEST_C_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}") - set(LLDB_DEFAULT_TEST_CXX_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX}") else() set(LLDB_DEFAULT_TEST_C_COMPILER "") + endif() + + if (NOT LLDB_TEST_USE_CUSTOM_CXX_COMPILER AND TARGET clang) + set(LLDB_DEFAULT_TEST_CXX_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX}") + else() set(LLDB_DEFAULT_TEST_CXX_COMPILER "") endif() Index: lit/CMakeLists.txt =================================================================== --- lit/CMakeLists.txt +++ lit/CMakeLists.txt @@ -1,10 +1,23 @@ -set(LLVM_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}") -set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}") -set(LLVM_BUILD_MODE "%(build_mode)s") -set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s") -set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s") -set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") -set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..") +# Test runner infrastructure for LLDB. This configures the LLDB test trees +# for use by Lit, and delegates to LLVM's lit test handlers. + +if (CMAKE_CFG_INTDIR STREQUAL ".") + set(LLVM_BUILD_MODE ".") +else () + set(LLVM_BUILD_MODE "%(build_mode)s") +endif () + +if (NOT LLDB_TEST_USE_CUSTOM_C_COMPILER) + string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_C_COMPILER ${LLDB_TEST_C_COMPILER}) +endif () + +if (NOT LLDB_TEST_USE_CUSTOM_CXX_COMPILER) + string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_CXX_COMPILER ${LLDB_TEST_CXX_COMPILER}) +endif () + +string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) +string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) + if(BUILD_SHARED_LIBS) set(ENABLE_SHARED 1) else() Index: lit/lit.site.cfg.in =================================================================== --- lit/lit.site.cfg.in +++ lit/lit.site.cfg.in @@ -6,8 +6,8 @@ config.llvm_libs_dir = "@LLVM_LIBS_DIR@" config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.lldb_obj_root = "@LLDB_BINARY_DIR@" -config.lldb_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@" -config.lldb_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@" +config.lldb_libs_dir = "@LLDB_LIBS_DIR@" +config.lldb_tools_dir = "@LLDB_TOOLS_DIR@" config.target_triple = "@TARGET_TRIPLE@" config.python_executable = "@PYTHON_EXECUTABLE@" config.cc = "@LLDB_TEST_C_COMPILER@" @@ -19,6 +19,10 @@ try: config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params + config.lldb_libs_dir = config.lldb_libs_dir % lit_config.params + config.lldb_tools_dir = config.lldb_tools_dir % lit_config.params + config.cc = config.cc % lit_config.params + config.cxx = config.cxx % lit_config.params except KeyError as e: key, = e.args lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))