[Lldb-commits] [lldb] r375024 - [lldb] move more things from python to cmake
Haibo Huang via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 16 11:00:22 PDT 2019
Author: hhb
Date: Wed Oct 16 11:00:21 2019
New Revision: 375024
URL: http://llvm.org/viewvc/llvm-project?rev=375024&view=rev
Log:
[lldb] move more things from python to cmake
Summary: Move the copy of six.py, lldb.py and macosx/heap
Reviewers: labath
Subscribers: mgorny, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D69016
Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/scripts/Python/finishSwigPythonLLDB.py
Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=375024&r1=375023&r2=375024&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Wed Oct 16 11:00:21 2019
@@ -208,6 +208,7 @@ if (NOT LLDB_DISABLE_PYTHON)
# 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
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_build_path}
COMMAND
${PYTHON_EXECUTABLE} ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
--srcRoot=${LLDB_SOURCE_DIR}
@@ -224,6 +225,28 @@ if (NOT LLDB_DISABLE_PYTHON)
DEPENDS ${lldb_scripts_dir}/lldb.py
COMMENT "Python script sym-linking LLDB Python API")
+ if(NOT LLDB_USE_SYSTEM_SIX)
+ 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")
+ endif()
+
+ add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
+ COMMAND ${CMAKE_COMMAND} -E copy
+ "${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_relative_symlink target dest_file output_dir output_name)
get_filename_component(dest_file ${dest_file} ABSOLUTE)
get_filename_component(output_dir ${output_dir} ABSOLUTE)
Modified: lldb/trunk/scripts/Python/finishSwigPythonLLDB.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/finishSwigPythonLLDB.py?rev=375024&r1=375023&r2=375024&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/finishSwigPythonLLDB.py (original)
+++ lldb/trunk/scripts/Python/finishSwigPythonLLDB.py Wed Oct 16 11:00:21 2019
@@ -74,56 +74,6 @@ strMsgCopySixPy = "Copying six.py from '
strErrMsgCopySixPyFailed = "Unable to copy '%s' to '%s'"
-def is_debug_interpreter():
- return hasattr(sys, 'gettotalrefcount')
-
-#++---------------------------------------------------------------------------
-# Details: Copy files needed by lldb/macosx/heap.py to build libheap.dylib.
-# Args: vDictArgs - (R) Program input parameters.
-# vstrFrameworkPythonDir - (R) Python framework directory.
-# Returns: Bool - True = function success, False = failure.
-# Str - Error description on task failure.
-# Throws: None.
-#--
-
-
-def macosx_copy_file_for_heap(vDictArgs, vstrFrameworkPythonDir):
- dbg = utilsDebug.CDebugFnVerbose(
- "Python script macosx_copy_file_for_heap()")
- bOk = True
- strMsg = ""
-
- eOSType = utilsOsType.determine_os_type()
- if eOSType != utilsOsType.EnumOsType.Darwin:
- return (bOk, strMsg)
-
- strHeapDir = os.path.join(vstrFrameworkPythonDir, "macosx", "heap")
- strHeapDir = os.path.normcase(strHeapDir)
- if os.path.exists(strHeapDir) and os.path.isdir(strHeapDir):
- return (bOk, strMsg)
-
- os.makedirs(strHeapDir)
-
- strRoot = os.path.normpath(vDictArgs["--srcRoot"])
- strSrc = os.path.join(
- strRoot,
- "examples",
- "darwin",
- "heap_find",
- "heap",
- "heap_find.cpp")
- shutil.copy(strSrc, strHeapDir)
- strSrc = os.path.join(
- strRoot,
- "examples",
- "darwin",
- "heap_find",
- "heap",
- "Makefile")
- shutil.copy(strSrc, strHeapDir)
-
- return (bOk, strMsg)
-
#++---------------------------------------------------------------------------
# Details: Create Python packages and Python __init__ files.
# Args: vDictArgs - (R) Program input parameters.
@@ -198,142 +148,6 @@ def create_py_pkg(
return (bOk, strMsg)
-#++---------------------------------------------------------------------------
-# Details: Copy the lldb.py file into the lldb package directory and rename
-# to __init_.py.
-# Args: vDictArgs - (R) Program input parameters.
-# vstrFrameworkPythonDir - (R) Python framework directory.
-# vstrCfgBldDir - (R) Config directory path.
-# Returns: Bool - True = function success, False = failure.
-# Str - Error description on task failure.
-# Throws: None.
-#--
-
-
-def copy_lldbpy_file_to_lldb_pkg_dir(
- vDictArgs,
- vstrFrameworkPythonDir,
- vstrCfgBldDir):
- dbg = utilsDebug.CDebugFnVerbose(
- "Python script copy_lldbpy_file_to_lldb_pkg_dir()")
- bOk = True
- bDbg = "-d" in vDictArgs
- strMsg = ""
-
- strSrc = os.path.join(vstrCfgBldDir, "lldb.py")
- strSrc = os.path.normcase(strSrc)
- strDst = os.path.join(vstrFrameworkPythonDir, "__init__.py")
- strDst = os.path.normcase(strDst)
-
- if not os.path.exists(strSrc):
- strMsg = strErrMsgLLDBPyFileNotNotFound % strSrc
- return (bOk, strMsg)
-
- try:
- if bDbg:
- print((strMsgCopyLLDBPy % (strSrc, strDst)))
- shutil.copyfile(strSrc, strDst)
- except IOError as e:
- bOk = False
- strMsg = "I/O error(%d): %s %s" % (e.errno,
- e.strerror, strErrMsgCpLldbpy)
- if e.errno == 2:
- strMsg += " Src:'%s' Dst:'%s'" % (strSrc, strDst)
- except:
- bOk = False
- strMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
- return (bOk, strMsg)
-
-
-def copy_six(vDictArgs, vstrFrameworkPythonDir):
- dbg = utilsDebug.CDebugFnVerbose("Python script copy_six()")
- bDbg = "-d" in vDictArgs
- bOk = True
- strMsg = ""
- site_packages_dir = os.path.dirname(vstrFrameworkPythonDir)
- six_module_filename = "six.py"
- src_file = os.path.join(
- vDictArgs['--srcRoot'],
- "third_party",
- "Python",
- "module",
- "six",
- six_module_filename)
- src_file = os.path.normpath(src_file)
- target = os.path.join(site_packages_dir, six_module_filename)
-
- if bDbg:
- print((strMsgCopySixPy % (src_file, target)))
- try:
- shutil.copyfile(src_file, target)
- except:
- bOk = False
- strMsg = strErrMsgCopySixPyFailed % (src_file, target)
-
- return (bOk, strMsg)
-
-#++---------------------------------------------------------------------------
-# Details: Look for the directory in which to put the Python files if it
-# does not already exist, attempt to make it.
-# Args: vDictArgs - (R) Program input parameters.
-# vstrFrameworkPythonDir - (R) Python framework directory.
-# Returns: Bool - True = function success, False = failure.
-# Str - Error description on task failure.
-# Throws: None.
-#--
-
-
-def find_or_create_python_dir(vDictArgs, vstrFrameworkPythonDir):
- dbg = utilsDebug.CDebugFnVerbose(
- "Python script find_or_create_python_dir()")
- bOk = True
- strMsg = ""
- bDbg = "-d" in vDictArgs
-
- if os.path.isdir(vstrFrameworkPythonDir):
- if bDbg:
- print((strMsgFrameWkPyExists % vstrFrameworkPythonDir))
- return (bOk, strMsg)
-
- if bDbg:
- print((strMsgFrameWkPyMkDir % vstrFrameworkPythonDir))
-
- try:
- os.makedirs(vstrFrameworkPythonDir)
- except OSError as exception:
- bOk = False
- strMsg = strErrMsgCreateFrmWkPyDirFailed % (
- vstrFrameworkPythonDir, os.strerror(exception.errno))
-
- return (bOk, strMsg)
-
-#++---------------------------------------------------------------------------
-# Details: Retrieve the configuration build path if present and valid (using
-# parameter --cfgBlddir or copy the Python Framework directory.
-# Args: vDictArgs - (R) Program input parameters.
-# vstrFrameworkPythonDir - (R) Python framework directory.
-# Returns: Bool - True = function success, False = failure.
-# Str - Config directory path.
-# strErrMsg - Error description on task failure.
-# Throws: None.
-#--
-
-
-def get_config_build_dir(vDictArgs, vstrFrameworkPythonDir):
- dbg = utilsDebug.CDebugFnVerbose("Python script get_config_build_dir()")
- bOk = True
- strErrMsg = ""
-
- strConfigBldDir = ""
- bHaveConfigBldDir = "--cfgBldDir" in vDictArgs
- if bHaveConfigBldDir:
- strConfigBldDir = vDictArgs["--cfgBldDir"]
- if (bHaveConfigBldDir == False) or (strConfigBldDir.__len__() == 0):
- strConfigBldDir = vstrFrameworkPythonDir
-
- return (bOk, strConfigBldDir, strErrMsg)
-
#++---------------------------------------------------------------------------
# Details: Retrieve the directory path for Python's dist_packages/
@@ -355,30 +169,6 @@ def get_framework_python_dir(vDictArgs):
strWkDir = os.path.normpath(vDictArgs["--lldbPythonPath"])
return (bOk, strWkDir, strErrMsg)
-#++---------------------------------------------------------------------------
-# Details: Retrieve the liblldb directory path, if it exists and is valid.
-# Args: vDictArgs - (R) Program input parameters.
-# Returns: Bool - True = function success, False = failure.
-# Str - liblldb directory path.
-# strErrMsg - Error description on task failure.
-# Throws: None.
-#--
-
-
-def get_liblldb_dir(vDictArgs):
- dbg = utilsDebug.CDebugFnVerbose("Python script get_liblldb_dir()")
- bOk = True
- strErrMsg = ""
-
- strLldbLibDir = ""
- bHaveLldbLibDir = "--lldbLibDir" in vDictArgs
- if bHaveLldbLibDir:
- strLldbLibDir = vDictArgs["--lldbLibDir"]
- if (bHaveLldbLibDir == False) or (strLldbLibDir.__len__() == 0):
- strLldbLibDir = "lib"
-
- return (bOk, strLldbLibDir, strErrMsg)
-
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
@@ -431,29 +221,6 @@ def main(vDictArgs):
bOk, strFrameworkPythonDir, strMsg = get_framework_python_dir(vDictArgs)
- if bOk:
- bOk, strCfgBldDir, strMsg = get_config_build_dir(
- vDictArgs, strFrameworkPythonDir)
- if bOk and bDbg:
- print((strMsgPyFileLocatedHere % strFrameworkPythonDir))
- print((strMsgConfigBuildDir % strCfgBldDir))
-
- if bOk:
- bOk, strLldbLibDir, strMsg = get_liblldb_dir(vDictArgs)
-
- if bOk:
- bOk, strMsg = find_or_create_python_dir(
- vDictArgs, strFrameworkPythonDir)
-
- bUseSystemSix = "--useSystemSix" in vDictArgs
-
- if not bUseSystemSix and bOk:
- bOk, strMsg = copy_six(vDictArgs, strFrameworkPythonDir)
-
- if bOk:
- bOk, strMsg = copy_lldbpy_file_to_lldb_pkg_dir(vDictArgs,
- strFrameworkPythonDir,
- strCfgBldDir)
strRoot = os.path.normpath(vDictArgs["--srcRoot"])
if bOk:
# lldb
@@ -549,10 +316,6 @@ def main(vDictArgs):
vDictArgs, strFrameworkPythonDir, "/diagnose", listPkgFiles)
if bOk:
- bOk, strMsg = macosx_copy_file_for_heap(
- vDictArgs, strFrameworkPythonDir)
-
- if bOk:
return (0, strMsg)
else:
strErrMsgProgFail += strMsg
More information about the lldb-commits
mailing list