Author: Jonas Devlieghere Date: 2019-12-02T13:03:24-08:00 New Revision: e5290a06d6c23bd222543cb9b689a199343021a7
URL: https://github.com/llvm/llvm-project/commit/e5290a06d6c23bd222543cb9b689a199343021a7 DIFF: https://github.com/llvm/llvm-project/commit/e5290a06d6c23bd222543cb9b689a199343021a7.diff LOG: [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`. Added: Modified: lldb/CMakeLists.txt Removed: ################################################################################ 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() _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits