summaryrefslogtreecommitdiff
path: root/lldb/CMakeLists.txt
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-12-02 12:25:03 -0800
committerJonas Devlieghere <jonas@devlieghere.com>2019-12-02 13:03:24 -0800
commite5290a06d6c23bd222543cb9b689a199343021a7 (patch)
tree298e81fe2a978adb7b51fc2026bba90e79f6680e /lldb/CMakeLists.txt
parent82039cbc8d2a0f6fb5995f54e0e42919999bcfd0 (diff)
downloadllvm-e5290a06d6c23bd222543cb9b689a199343021a7.tar.gz
[lldb/CMake] Simplify logic for adding example Python packages (NFC)
This simplifies the CMake logic for adding the Python examples to the Python package. It unifies the use of create_python_package by adding the NOINIT option and removes the `target` argument, which is always `finish_swig`.
Diffstat (limited to 'lldb/CMakeLists.txt')
-rw-r--r--lldb/CMakeLists.txt50
1 files changed, 24 insertions, 26 deletions
diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 81d7dd8123bd..6b5f7640b336 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -119,26 +119,20 @@ if (NOT LLDB_DISABLE_PYTHON)
"${lldb_scripts_dir}/lldb.py"
"${lldb_python_build_path}/__init__.py")
- if(APPLE)
- SET(lldb_python_heap_dir "${lldb_python_build_path}/macosx/heap")
- add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
- COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_heap_dir}
- COMMAND ${CMAKE_COMMAND} -E copy
- "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
- "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
- ${lldb_python_heap_dir})
- endif()
-
- function(create_python_package target pkg_dir)
- cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
+ function(create_python_package pkg_dir)
+ cmake_parse_arguments(ARG "NOINIT" "" "FILES" ${ARGN})
if(ARG_FILES)
set(copy_cmd COMMAND ${CMAKE_COMMAND} -E copy ${ARG_FILES} ${pkg_dir})
endif()
- add_custom_command(TARGET ${target} POST_BUILD VERBATIM
+ if(NOT ARG_NOINIT)
+ set(init_cmd COMMAND ${PYTHON_EXECUTABLE}
+ "${LLDB_SOURCE_DIR}/scripts/Python/createPythonInit.py"
+ "${pkg_dir}" ${ARG_FILES})
+ endif()
+ add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
COMMAND ${CMAKE_COMMAND} -E make_directory ${pkg_dir}
${copy_cmd}
- COMMAND ${PYTHON_EXECUTABLE} "${LLDB_SOURCE_DIR}/scripts/Python/createPythonInit.py"
- ${pkg_dir} ${ARG_FILES}
+ ${init_cmd}
WORKING_DIRECTORY ${lldb_python_build_path})
endfunction()
@@ -146,28 +140,32 @@ if (NOT LLDB_DISABLE_PYTHON)
COMMAND ${CMAKE_COMMAND} -E copy
"${LLDB_SOURCE_DIR}/source/Interpreter/embedded_interpreter.py" ${lldb_python_build_path})
- create_python_package(finish_swig "formatters/cpp"
+ # Distribute the examples as python packages.
+ create_python_package("formatters/cpp"
FILES "${LLDB_SOURCE_DIR}/examples/synthetic/gnu_libstdcpp.py"
"${LLDB_SOURCE_DIR}/examples/synthetic/libcxx.py")
- # Make an empty __init__.py in lldb/runtime as this is required for
- # Python to recognize lldb.runtime as a valid package (and hence,
- # lldb.runtime.objc as a valid contained package)
- create_python_package(finish_swig "runtime")
- # Having these files copied here ensure that lldb/formatters is a
- # valid package itself
- create_python_package(finish_swig "formatters"
+
+ create_python_package("formatters"
FILES "${LLDB_SOURCE_DIR}/examples/summaries/cocoa/cache.py"
"${LLDB_SOURCE_DIR}/examples/summaries/synth.py"
"${LLDB_SOURCE_DIR}/examples/summaries/cocoa/metrics.py"
"${LLDB_SOURCE_DIR}/examples/summaries/cocoa/attrib_fromdict.py"
"${LLDB_SOURCE_DIR}/examples/summaries/cocoa/Logger.py")
- create_python_package(finish_swig "utils"
+
+ create_python_package("utils"
FILES "${LLDB_SOURCE_DIR}/examples/python/symbolication.py")
+
if(APPLE)
- create_python_package(finish_swig "macosx"
+ create_python_package("macosx"
FILES "${LLDB_SOURCE_DIR}/examples/python/crashlog.py"
"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap.py")
- create_python_package(finish_swig "diagnose"
+
+ create_python_package("macosx/heap"
+ FILES "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
+ "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
+ NOINIT)
+
+ create_python_package("diagnose"
FILES "${LLDB_SOURCE_DIR}/examples/python/diagnose_unwind.py"
"${LLDB_SOURCE_DIR}/examples/python/diagnose_nsstring.py")
endif()