Skip to content

Commit 546d449

Browse files
authored
Merge pull request #6514 from bulbazord/cherrypick/20221013/103194447
[lldb] Introduce CMake variable LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS
2 parents ab2b421 + 8ea9444 commit 546d449

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

lldb/cmake/modules/AddLLDB.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,25 @@ function(lldb_find_system_debugserver path)
404404
endif()
405405
endfunction()
406406

407+
function(lldb_find_python_module module)
408+
set(MODULE_FOUND PY_${module}_FOUND)
409+
if (DEFINED ${MODULE_FOUND})
410+
return()
411+
endif()
412+
413+
execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import ${module}"
414+
RESULT_VARIABLE status
415+
ERROR_QUIET)
416+
417+
if (status)
418+
set(${MODULE_FOUND} OFF CACHE BOOL "Failed to find python module '${module}'")
419+
message(STATUS "Could NOT find Python module '${module}'")
420+
else()
421+
set(${MODULE_FOUND} ON CACHE BOOL "Found python module '${module}'")
422+
message(STATUS "Found Python module '${module}'")
423+
endif()
424+
endfunction()
425+
407426
# Removes all module flags from the current CMAKE_CXX_FLAGS. Used for
408427
# the Objective-C++ code in lldb which we don't want to build with modules.
409428
# Reasons for this are that modules with Objective-C++ would require that

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ option(LLDB_NO_INSTALL_DEFAULT_RPATH "Disable default RPATH settings in binaries
8282
option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver for testing (Darwin only)." OFF)
8383
option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries when installing lldb." OFF)
8484
option(LLDB_SKIP_DSYM "Whether to skip generating a dSYM when installing lldb." OFF)
85+
option(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS
86+
"Fail to configure if certain requirements are not met for testing." OFF)
8587

8688
# BEGIN SWIFT MOD
8789
option(LLDB_ENABLE_SWIFT_SUPPORT "Enable swift support" ON)

lldb/test/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Test runner infrastructure for LLDB. This configures the LLDB test trees
22
# for use by Lit, and delegates to LLVM's lit test handlers.
3+
# Lit requires a Python3 interpreter, let's be careful and fail early if it's
4+
# not present.
5+
if (NOT DEFINED Python3_EXECUTABLE)
6+
message(FATAL_ERROR
7+
"LLDB test suite requires a Python3 interpreter but none "
8+
"was found. Please install Python3 or disable tests with "
9+
"`LLDB_INCLUDE_TESTS=OFF`.")
10+
endif()
11+
12+
if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
13+
message(STATUS "Enforcing strict test requirements for LLDB")
14+
set(useful_python_modules
15+
psutil # Lit uses psutil to do per-test timeouts.
16+
)
17+
foreach(module ${useful_python_modules})
18+
lldb_find_python_module(${module})
19+
if (NOT PY_${module}_FOUND)
20+
message(FATAL_ERROR
21+
"Python module '${module}' not found. Please install it via pip or via "
22+
"your operating system's package manager. Alternatively, disable "
23+
"strict testing requirements with "
24+
"`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
25+
endif()
26+
endforeach()
27+
endif()
328

429
if(LLDB_BUILT_STANDALONE)
530
# In order to run check-lldb-* we need the correct map_config directives in

0 commit comments

Comments
 (0)