diff options
Diffstat (limited to 'lldb/scripts')
-rw-r--r-- | lldb/scripts/CMakeLists.txt | 25 | ||||
-rw-r--r-- | lldb/scripts/Python/finishSwigPythonLLDB.py | 93 | ||||
-rw-r--r-- | lldb/scripts/finishSwigWrapperClasses.py | 19 | ||||
-rw-r--r-- | lldb/scripts/get_relative_lib_dir.py | 44 |
4 files changed, 7 insertions, 174 deletions
diff --git a/lldb/scripts/CMakeLists.txt b/lldb/scripts/CMakeLists.txt index 40ff2b285f7..5b86956f2a9 100644 --- a/lldb/scripts/CMakeLists.txt +++ b/lldb/scripts/CMakeLists.txt @@ -55,28 +55,3 @@ add_custom_target(swig_wrapper ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lldb.py ) -if(NOT LLDB_BUILD_FRAMEWORK) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} - -c "import distutils.sysconfig, sys; print(distutils.sysconfig.get_python_lib(True, False, sys.argv[1]))" - ${CMAKE_BINARY_DIR} - OUTPUT_VARIABLE SWIG_PYTHON_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} - -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))" - OUTPUT_VARIABLE SWIG_INSTALL_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - - # Install the LLDB python module - add_custom_target(lldb-python-scripts) - add_dependencies(lldb-python-scripts finish_swig) - install(DIRECTORY ${SWIG_PYTHON_DIR}/ - DESTINATION ${SWIG_INSTALL_DIR} - COMPONENT lldb-scripts) - if (NOT LLVM_ENABLE_IDE) - add_llvm_install_targets(install-lldb-python-scripts - COMPONENT lldb-python-scripts - DEPENDS lldb-python-scripts) - endif() -endif() diff --git a/lldb/scripts/Python/finishSwigPythonLLDB.py b/lldb/scripts/Python/finishSwigPythonLLDB.py index d4d53a85248..902ad8af5dd 100644 --- a/lldb/scripts/Python/finishSwigPythonLLDB.py +++ b/lldb/scripts/Python/finishSwigPythonLLDB.py @@ -597,86 +597,6 @@ def get_config_build_dir(vDictArgs, vstrFrameworkPythonDir): return (bOk, strConfigBldDir, strErrMsg) -#++--------------------------------------------------------------------------- -# Details: Determine where to put the files. Retrieve the directory path for -# Python's dist_packages/ site_package folder on a Windows platform. -# Args: vDictArgs - (R) Program input parameters. -# Returns: Bool - True = function success, False = failure. -# Str - Python Framework directory path. -# strErrMsg - Error description on task failure. -# Throws: None. -#-- - - -def get_framework_python_dir_windows(vDictArgs): - dbg = utilsDebug.CDebugFnVerbose( - "Python script get_framework_python_dir_windows()") - bOk = True - strWkDir = "" - strErrMsg = "" - - # We are being built by LLVM, so use the PYTHON_INSTALL_DIR argument, - # and append the python version directory to the end of it. Depending - # on the system other stuff may need to be put here as well. - from distutils.sysconfig import get_python_lib - strPythonInstallDir = "" - bHaveArgPrefix = "--prefix" in vDictArgs - if bHaveArgPrefix: - strPythonInstallDir = os.path.normpath(vDictArgs["--prefix"]) - - bHaveArgCmakeBuildConfiguration = "--cmakeBuildConfiguration" in vDictArgs - if bHaveArgCmakeBuildConfiguration: - strPythonInstallDir = os.path.join( - strPythonInstallDir, - vDictArgs["--cmakeBuildConfiguration"]) - - if strPythonInstallDir.__len__() != 0: - strWkDir = get_python_lib(True, False, strPythonInstallDir) - else: - strWkDir = get_python_lib(True, False) - strWkDir = os.path.normcase(os.path.join(strWkDir, "lldb")) - - return (bOk, strWkDir, strErrMsg) - -#++--------------------------------------------------------------------------- -# Details: Retrieve the directory path for Python's dist_packages/ -# site_package folder on a UNIX style platform. -# Args: vDictArgs - (R) Program input parameters. -# Returns: Bool - True = function success, False = failure. -# Str - Python Framework directory path. -# strErrMsg - Error description on task failure. -# Throws: None. -#-- - - -def get_framework_python_dir_other_platforms(vDictArgs): - dbg = utilsDebug.CDebugFnVerbose( - "Python script get_framework_python_dir_other_platform()") - bOk = True - strWkDir = "" - strErrMsg = "" - bDbg = "-d" in vDictArgs - - bMakeFileCalled = "-m" in vDictArgs - if bMakeFileCalled: - dbg.dump_text("Built by LLVM") - return get_framework_python_dir_windows(vDictArgs) - else: - dbg.dump_text("Built by XCode") - # We are being built by XCode, so all the lldb Python files can go - # into the LLDB.framework/Resources/Python subdirectory. - strWkDir = vDictArgs["--targetDir"] - strWkDir = os.path.join(strWkDir, "LLDB.framework") - if os.path.exists(strWkDir): - if bDbg: - print((strMsgFoundLldbFrameWkDir % strWkDir)) - strWkDir = os.path.join(strWkDir, "Resources", "Python", "lldb") - strWkDir = os.path.normcase(strWkDir) - else: - bOk = False - strErrMsg = strErrMsgFrameWkPyDirNotExist % strWkDir - - return (bOk, strWkDir, strErrMsg) #++--------------------------------------------------------------------------- # Details: Retrieve the directory path for Python's dist_packages/ @@ -694,19 +614,8 @@ def get_framework_python_dir(vDictArgs): dbg = utilsDebug.CDebugFnVerbose( "Python script get_framework_python_dir()") bOk = True - strWkDir = "" strErrMsg = "" - - eOSType = utilsOsType.determine_os_type() - if eOSType == utilsOsType.EnumOsType.Unknown: - bOk = False - strErrMsg = strErrMsgOsTypeUnknown - elif eOSType == utilsOsType.EnumOsType.Windows: - bOk, strWkDir, strErrMsg = get_framework_python_dir_windows(vDictArgs) - else: - bOk, strWkDir, strErrMsg = get_framework_python_dir_other_platforms( - vDictArgs) - + strWkDir = os.path.normpath(vDictArgs["--lldbPythonPath"]) return (bOk, strWkDir, strErrMsg) #++--------------------------------------------------------------------------- diff --git a/lldb/scripts/finishSwigWrapperClasses.py b/lldb/scripts/finishSwigWrapperClasses.py index 4d08b86e9e4..7e9166bf75e 100644 --- a/lldb/scripts/finishSwigWrapperClasses.py +++ b/lldb/scripts/finishSwigWrapperClasses.py @@ -179,6 +179,7 @@ def validate_arguments(vArgv): "prefix=", "cmakeBuildConfiguration=", "lldbLibDir=", + "lldbPythonPath=", "argsFile", "useSystemSix"] dictArgReq = {"-h": "o", # o = optional, m = mandatory @@ -191,7 +192,8 @@ def validate_arguments(vArgv): "--cmakeBuildConfiguration": "o", "--lldbLibDir": "o", "--argsFile": "o", - "--useSystemSix": "o"} + "--useSystemSix": "o", + "--lldbPythonPath": "m"} # Check for mandatory parameters nResult, dictArgs, strMsg = utilsArgsParse.parse(vArgv, strListArgs, @@ -293,11 +295,9 @@ def run_post_process_for_each_script_supported(vDictArgs): # Iterate script directory find any script language directories for scriptLang in listDirs: - # __pycache__ is a magic directory in Python 3 that holds .pyc files - if scriptLang != "__pycache__" and scriptLang != "swig_bot_lib": - dbg.dump_text("Executing language script for \'%s\'" % scriptLang) - nResult, strStatusMsg = run_post_process( - scriptLang, strFinishFileName, vDictArgs) + dbg.dump_text("Executing language script for \'%s\'" % scriptLang) + nResult, strStatusMsg = run_post_process( + scriptLang, strFinishFileName, vDictArgs) if nResult < 0: break @@ -337,13 +337,6 @@ def main(vArgv): if gbDbgFlag: print_out_input_parameters(dictArgs) - # Check to see if we were called from the Makefile system. If we were, check - # if the caller wants SWIG to generate a dependency file. - # Not used in this program, but passed through to the language script file - # called by this program - global gbMakeFileFlag - gbMakeFileFlag = "-m" in dictArgs - nResult, strMsg = run_post_process_for_each_script_supported(dictArgs) program_exit(nResult, strMsg) diff --git a/lldb/scripts/get_relative_lib_dir.py b/lldb/scripts/get_relative_lib_dir.py deleted file mode 100644 index 3afeeafd7b4..00000000000 --- a/lldb/scripts/get_relative_lib_dir.py +++ /dev/null @@ -1,44 +0,0 @@ -import distutils.sysconfig -import os -import platform -import re -import sys - - -def get_python_relative_libdir(): - """Returns the appropropriate python libdir relative to the build directory. - - @param exe_path the path to the lldb executable - - @return the python path that needs to be added to sys.path (PYTHONPATH) - in order to find the lldb python module. - """ - if platform.system() != 'Linux': - return None - - # We currently have a bug in lldb -P that does not account for - # architecture variants in python paths for - # architecture-specific modules. Handle the lookup here. - # When that bug is fixed, we should just ask lldb for the - # right answer always. - arch_specific_libdir = distutils.sysconfig.get_python_lib(True, False) - split_libdir = arch_specific_libdir.split(os.sep) - lib_re = re.compile(r"^lib.*$") - - for i in range(len(split_libdir)): - match = lib_re.match(split_libdir[i]) - if match is not None: - # We'll call this the relative root of the lib dir. - # Things like RHEL will have an arch-specific python - # lib dir, which isn't 'lib' on x86_64. - return os.sep.join(split_libdir[i:]) - # Didn't resolve it. - return None - -if __name__ == '__main__': - lib_dir = get_python_relative_libdir() - if lib_dir is not None: - sys.stdout.write(lib_dir) - sys.exit(0) - else: - sys.exit(1) |