Index: lldb/CMakeLists.txt =================================================================== --- lldb/CMakeLists.txt +++ lldb/CMakeLists.txt @@ -99,11 +99,13 @@ get_target_property(lldb_bindings_dir swig_wrapper BINARY_DIR) if(LLDB_BUILD_FRAMEWORK) - set(lldb_python_build_path "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb") + set(python_build_path "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python") else() - set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb") + set(python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}") endif() + set(lldb_python_build_path "${python_build_path}/lldb") + # Add a Post-Build Event to copy over Python files and create the symlink # to liblldb.so for the Python API(hardlink on Windows). add_custom_target(finish_swig ALL VERBATIM @@ -115,14 +117,24 @@ add_custom_command(TARGET finish_swig POST_BUILD VERBATIM COMMAND ${CMAKE_COMMAND} -E copy "${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py" - "${lldb_python_build_path}/../six.py") + "${python_build_path}/six.py") endif() + add_custom_command(TARGET finish_swig POST_BUILD VERBATIM + COMMAND ${CMAKE_COMMAND} -E make_directory + "${python_build_path}/lldbconfig") + + add_custom_command(TARGET finish_swig POST_BUILD VERBATIM + COMMAND ${CMAKE_COMMAND} -E copy + "${LLDB_SOURCE_DIR}/bindings/python/lldbconfig.py" + "${python_build_path}/lldbconfig/__init__.py") + add_custom_command(TARGET finish_swig POST_BUILD VERBATIM COMMAND ${CMAKE_COMMAND} -E copy "${lldb_bindings_dir}/lldb.py" "${lldb_python_build_path}/__init__.py") + function(create_python_package pkg_dir) cmake_parse_arguments(ARG "NOINIT" "" "FILES" ${ARGN}) if(ARG_FILES) Index: lldb/bindings/python.swig =================================================================== --- lldb/bindings/python.swig +++ lldb/bindings/python.swig @@ -128,8 +128,15 @@ %include "./python/python-wrapper.swig" %pythoncode%{ +INITIALIZE = True +try: + import lldbconfig + INITIALIZE = lldbconfig.INITIALIZE +except ImportError: + pass debugger_unique_id = 0 -SBDebugger.Initialize() +if INITIALIZE: + SBDebugger.Initialize() debugger = None target = None process = None Index: lldb/bindings/python/lldbconfig.py =================================================================== --- /dev/null +++ lldb/bindings/python/lldbconfig.py @@ -0,0 +1 @@ +INITIALIZE = True Index: lldb/packages/Python/lldbsuite/test/dotest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/dotest.py +++ lldb/packages/Python/lldbsuite/test/dotest.py @@ -954,7 +954,9 @@ setupSysPath() + import lldbconfig import lldb + # Use host platform by default. lldb.selected_platform = lldb.SBPlatform.GetHostPlatform()