diff options
author | Haibo Huang <hhb@google.com> | 2019-10-07 23:49:01 +0000 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2019-10-07 23:49:01 +0000 |
commit | 61f471a705a5df3d581ba4905337f433bac3ba1f (patch) | |
tree | e9b2f65b0e30300541d8fcefa733d2f6009b6729 /lldb/scripts/Python/finishSwigPythonLLDB.py | |
parent | f4c7345b88f8ca56ee350a4a0dbfee7e2db79839 (diff) | |
download | bcm5719-llvm-61f471a705a5df3d581ba4905337f433bac3ba1f.tar.gz bcm5719-llvm-61f471a705a5df3d581ba4905337f433bac3ba1f.zip |
[lldb] Unifying lldb python path
Based on mgorny@'s D67890
There are 3 places where python site-package path is calculated
independently:
1. finishSwigPythonLLDB.py where files are written to site-packages.
2. lldb/scripts/CMakeLists.txt where site-packages are installed.
3. ScriptInterpreterPython.cpp where site-packages are added to
PYTHONPATH.
This change creates the path once and use it everywhere. So that they
will not go out of sync.
Also it provides a chance for cross compiling users to specify the right
path for site-packages.
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D68442
llvm-svn: 373991
Diffstat (limited to 'lldb/scripts/Python/finishSwigPythonLLDB.py')
-rw-r--r-- | lldb/scripts/Python/finishSwigPythonLLDB.py | 93 |
1 files changed, 1 insertions, 92 deletions
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) #++--------------------------------------------------------------------------- |