diff options
| author | Stefan Granitz <stefan.graenitz@gmail.com> | 2019-01-04 12:47:02 +0000 |
|---|---|---|
| committer | Stefan Granitz <stefan.graenitz@gmail.com> | 2019-01-04 12:47:02 +0000 |
| commit | f9ef9e0c19f9672b28db28e708f54a3a7049eb3a (patch) | |
| tree | a8dab03caacf767005dbed0f0fd8c3fb9a1c700f /lldb/scripts | |
| parent | 5d005a856d569f277896a982026fcd898177ddee (diff) | |
| download | bcm5719-llvm-f9ef9e0c19f9672b28db28e708f54a3a7049eb3a.tar.gz bcm5719-llvm-f9ef9e0c19f9672b28db28e708f54a3a7049eb3a.zip | |
[CMake] Python bindings generation polishing
Summary:
Simplify SWIG invocation and handling of generated files.
The `swig_wrapper` target can generate `LLDBWrapPython.cpp` and `lldb.py` in its own binary directory, so we can get rid of a few global variables and their logic. We can use the swig_wrapper's BINARY_DIR target property to refer to it and liblldb's LIBRARY_OUTPUT_DIRECTORY to refer to the framework/shared object output directory.
Reviewers: JDevlieghere, aprantl, stella.stamenova, beanz, zturner, xiaobai
Reviewed By: aprantl
Subscribers: mgorny, lldb-commits, #lldb
Differential Revision: https://reviews.llvm.org/D55332
llvm-svn: 350393
Diffstat (limited to 'lldb/scripts')
| -rw-r--r-- | lldb/scripts/CMakeLists.txt | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/lldb/scripts/CMakeLists.txt b/lldb/scripts/CMakeLists.txt index be5c3db5355..3598247dd61 100644 --- a/lldb/scripts/CMakeLists.txt +++ b/lldb/scripts/CMakeLists.txt @@ -11,31 +11,14 @@ set(SWIG_HEADERS include(FindPythonInterp) -if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") - set(SWIG_PYTHON_DIR - ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) -else() - set(SWIG_PYTHON_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/site-packages) -endif() - -set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX}) - -# Generating the LLDB framework correctly is a bit complicated because the -# framework depends on the swig output. if(LLDB_BUILD_FRAMEWORK) set(framework_arg --framework --target-platform Darwin) - set(SWIG_PYTHON_DIR - ${LLDB_PYTHON_TARGET_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR}/Python) - set(SWIG_INSTALL_DIR - ${LLDB_FRAMEWORK_INSTALL_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR}) endif() -get_filename_component(CFGBLDDIR ${LLDB_WRAP_PYTHON} DIRECTORY) - find_package(SWIG REQUIRED) add_custom_command( - OUTPUT ${LLDB_WRAP_PYTHON} - OUTPUT ${LLDB_PYTHON_TARGET_DIR}/lldb.py + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lldb.py DEPENDS ${SWIG_SOURCES} DEPENDS ${SWIG_INTERFACES} DEPENDS ${SWIG_HEADERS} @@ -44,19 +27,31 @@ add_custom_command( COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/prepare_bindings.py ${framework_arg} --srcRoot=${LLDB_SOURCE_DIR} - --targetDir=${LLDB_PYTHON_TARGET_DIR} - --cfgBldDir=${CFGBLDDIR} + --targetDir=${CMAKE_CURRENT_BINARY_DIR} + --cfgBldDir=${CMAKE_CURRENT_BINARY_DIR} --prefix=${CMAKE_BINARY_DIR} --swigExecutable=${SWIG_EXECUTABLE} VERBATIM COMMENT "Python script building LLDB Python wrapper") -add_custom_target(swig_wrapper ALL DEPENDS ${LLDB_WRAP_PYTHON}) -set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/lldb.py PROPERTIES GENERATED 1) +add_custom_target(swig_wrapper ALL DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp + ${CMAKE_CURRENT_BINARY_DIR}/lldb.py +) + +if(NOT LLDB_BUILD_FRAMEWORK) + if(CMAKE_SYSTEM_NAME MATCHES "Windows") + set(swig_python_subdir site-packages) + else() + set(swig_python_subdir python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) + endif() + set(SWIG_PYTHON_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${swig_python_subdir}) + set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX}) -# Install the LLDB python module -install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR}) + # Install the LLDB python module + install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR}) +endif() # build Python modules add_subdirectory(Python/modules) |

