From 4692f52daa9d305b375cf2d2e9f3b5da8a352021 Mon Sep 17 00:00:00 2001 From: Francis Ricci Date: Mon, 25 Apr 2016 20:34:34 +0000 Subject: [PATCH] Create _lldb python symlink correctly when LLVM_LIBDIR_SUFFIX is used Summary: Do not assume that liblldb.so is located in $(lldb -P)/../../../lib when creating the _lldb python symlink. Instead, use the path passed to LLVM_LIBDIR_SUFFIX, defaulting to $(lldb -P)/../../../lib when this variable is not set. Reviewers: vharron, emaste, zturner Subscribers: zturner, labath, lldb-commits, sas Differential Revision: http://reviews.llvm.org/D19067 llvm-svn: 267462 --- lldb/CMakeLists.txt | 2 +- lldb/scripts/Python/finishSwigPythonLLDB.py | 42 ++++++++++++++++++++++++----- lldb/scripts/finishSwigWrapperClasses.py | 11 +++++--- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 82dd78c..069d1c0 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -31,7 +31,7 @@ add_subdirectory(lit) 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 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py "--srcRoot=${LLDB_SOURCE_DIR}" "--targetDir=${CMAKE_CURRENT_BINARY_DIR}/scripts" "--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts" "--prefix=${CMAKE_BINARY_DIR}" "--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}" -m + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py "--srcRoot=${LLDB_SOURCE_DIR}" "--targetDir=${CMAKE_CURRENT_BINARY_DIR}/scripts" "--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts" "--prefix=${CMAKE_BINARY_DIR}" "--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}" "--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}" -m DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scripts/lldb.py COMMENT "Python script sym-linking LLDB Python API") diff --git a/lldb/scripts/Python/finishSwigPythonLLDB.py b/lldb/scripts/Python/finishSwigPythonLLDB.py index cbd229b..4d733a1 100644 --- a/lldb/scripts/Python/finishSwigPythonLLDB.py +++ b/lldb/scripts/Python/finishSwigPythonLLDB.py @@ -358,11 +358,12 @@ def make_symlink(vDictArgs, vstrFrameworkPythonDir, vstrSrcFile, vstrTargetFile) # Args: vDictArgs - (R) Program input parameters. # vstrFrameworkPythonDir - (R) Python framework directory. # vstrLiblldbName - (R) File name for _lldb library. +# vstrLiblldbDir - (R) liblldb directory. # Returns: Bool - True = function success, False = failure. # Str - Error description on task failure. # Throws: None. #-- -def make_symlink_liblldb(vDictArgs, vstrFrameworkPythonDir, vstrLiblldbFileName): +def make_symlink_liblldb(vDictArgs, vstrFrameworkPythonDir, vstrLiblldbFileName, vstrLldbLibDir): dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_liblldb()") bOk = True strErrMsg = "" @@ -382,7 +383,7 @@ def make_symlink_liblldb(vDictArgs, vstrFrameworkPythonDir, vstrLiblldbFileName) bMakeFileCalled = "-m" in vDictArgs if not bMakeFileCalled: - strSrc = os.path.join("lib", "LLDB") + strSrc = os.path.join(vstrLldbLibDir, "LLDB") else: strLibFileExtn = "" if eOSType == utilsOsType.EnumOsType.Windows: @@ -392,7 +393,7 @@ def make_symlink_liblldb(vDictArgs, vstrFrameworkPythonDir, vstrLiblldbFileName) strLibFileExtn = ".dylib" else: strLibFileExtn = ".so" - strSrc = os.path.join("lib", "liblldb" + strLibFileExtn) + strSrc = os.path.join(vstrLldbLibDir, "liblldb" + strLibFileExtn) bOk, strErrMsg = make_symlink(vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget) @@ -462,11 +463,12 @@ def make_symlink_lldb_argdumper(vDictArgs, vstrFrameworkPythonDir, vstrArgdumper # the Python framework directory. # Args: vDictArgs - (R) Program input parameters. # vstrFrameworkPythonDir - (R) Python framework directory. +# vstrLldbLibDir - (R) liblldb directory. # Returns: Bool - True = function success, False = failure. # strErrMsg - Error description on task failure. # Throws: None. #-- -def create_symlinks(vDictArgs, vstrFrameworkPythonDir): +def create_symlinks(vDictArgs, vstrFrameworkPythonDir, vstrLldbLibDir): dbg = utilsDebug.CDebugFnVerbose("Python script create_symlinks()") bOk = True strErrMsg = "" @@ -477,7 +479,8 @@ def create_symlinks(vDictArgs, vstrFrameworkPythonDir): if bOk: bOk, strErrMsg = make_symlink_liblldb(vDictArgs, vstrFrameworkPythonDir, - strLibLldbFileName) + strLibLldbFileName, + vstrLldbLibDir) # Make symlink for darwin-debug on Darwin strDarwinDebugFileName = "darwin-debug" @@ -672,6 +675,28 @@ def get_framework_python_dir(vDictArgs): 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) + #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- @@ -697,6 +722,8 @@ def get_framework_python_dir(vDictArgs): be installed. Where non-Darwin systems want to put the .py and .so files so that Python can find them automatically. Python install directory. + --lldbLibDir The name of the directory containing liblldb.so. + (optional) "lib" by default. Results: 0 Success -100+ Error from this script to the caller script. -100 Error program failure with optional message. @@ -727,10 +754,13 @@ def main(vDictArgs): print((strMsgConfigBuildDir % strCfgBldDir)) if bOk: + bOk, strLldbLibDir, strMsg = get_liblldb_dir(vDictArgs) + + if bOk: bOk, strMsg = find_or_create_python_dir(vDictArgs, strFrameworkPythonDir) if bOk: - bOk, strMsg = create_symlinks(vDictArgs, strFrameworkPythonDir) + bOk, strMsg = create_symlinks(vDictArgs, strFrameworkPythonDir, strLldbLibDir) if bOk: bOk, strMsg = copy_six(vDictArgs, strFrameworkPythonDir) diff --git a/lldb/scripts/finishSwigWrapperClasses.py b/lldb/scripts/finishSwigWrapperClasses.py index 8d7d19e..cce160d 100644 --- a/lldb/scripts/finishSwigWrapperClasses.py +++ b/lldb/scripts/finishSwigWrapperClasses.py @@ -72,6 +72,8 @@ Args: -h (optional) Print help information on this program.\n\ be installed. Where non-Darwin systems want to put\n\ the .py and .so files so that Python can find them\n\ automatically. Python install directory.\n\ + --lldbLibDir (optional) The name of the directory containing liblldb.so.\n\ + \"lib\" by default.\n\ --cmakeBuildConfiguration= (optional) Is the build configuration(Debug, Release, RelWithDebugInfo)\n\ used to determine where the bin and lib directories are \n\ created for a Windows build.\n\ @@ -80,7 +82,7 @@ Args: -h (optional) Print help information on this program.\n\ \n\ Usage:\n\ finishSwigWrapperClasses.py --srcRoot=ADirPath --targetDir=ADirPath\n\ - --cfgBldDir=ADirPath --prefix=ADirPath -m -d\n\ + --cfgBldDir=ADirPath --prefix=ADirPath --lldbLibDir=ADirPath -m -d\n\ \n\ " #TAG_PROGRAM_HELP_INFO @@ -158,7 +160,7 @@ def validate_arguments(vArgv): nResult = 0 strListArgs = "hdm" # Format "hiox:" = -h -i -o -x listLongArgs = ["srcRoot=", "targetDir=", "cfgBldDir=", "prefix=", "cmakeBuildConfiguration=", - "argsFile"] + "lldbLibDir=", "argsFile"] dictArgReq = { "-h": "o", # o = optional, m = mandatory "-d": "o", "-m": "o", @@ -167,6 +169,7 @@ def validate_arguments(vArgv): "--cfgBldDir": "o", "--prefix": "o", "--cmakeBuildConfiguration": "o", + "--lldbLibDir": "o", "--argsFile": "o" } # Check for mandatory parameters @@ -337,11 +340,13 @@ def main(vArgv): --cmakeBuildConfiguration= (optional) Is the build configuration(Debug, Release, RelWithDebugInfo)\n\ used to determine where the bin and lib directories are \n\ created for a Windows build.\n\ + --lldbLibDir= The name of the directory containing liblldb.so. + (optional) "lib" by default. --argsFile= The args are read from a file instead of the command line. Other command line args are ignored. Usage: finishSwigWrapperClasses.py --srcRoot=ADirPath --targetDir=ADirPath - --cfgBldDir=ADirPath --prefix=ADirPath -m -d + --cfgBldDir=ADirPath --prefix=ADirPath --lldbLibDir=ADirPath -m -d Results: 0 Success -1 Error - invalid parameters passed. -- 2.7.4