[llvm-branch-commits] [lldb] r270130 - Create _lldb python symlink correctly when LLVM_LIBDIR_SUFFIX is used

Francis Ricci via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu May 19 14:02:18 PDT 2016


Author: fjricci
Date: Thu May 19 16:02:17 2016
New Revision: 270130

URL: http://llvm.org/viewvc/llvm-project?rev=270130&view=rev
Log:
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

This is a cherry-pick of r267462

Modified:
    lldb/branches/release_38/CMakeLists.txt
    lldb/branches/release_38/scripts/Python/finishSwigPythonLLDB.py
    lldb/branches/release_38/scripts/finishSwigWrapperClasses.py

Modified: lldb/branches/release_38/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/CMakeLists.txt?rev=270130&r1=270129&r2=270130&view=diff
==============================================================================
--- lldb/branches/release_38/CMakeLists.txt (original)
+++ lldb/branches/release_38/CMakeLists.txt Thu May 19 16:02:17 2016
@@ -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")

Modified: lldb/branches/release_38/scripts/Python/finishSwigPythonLLDB.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/scripts/Python/finishSwigPythonLLDB.py?rev=270130&r1=270129&r2=270130&view=diff
==============================================================================
--- lldb/branches/release_38/scripts/Python/finishSwigPythonLLDB.py (original)
+++ lldb/branches/release_38/scripts/Python/finishSwigPythonLLDB.py Thu May 19 16:02:17 2016
@@ -345,11 +345,12 @@ def make_symlink(vDictArgs, vstrFramewor
 # 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 = ""
@@ -369,7 +370,7 @@ def make_symlink_liblldb(vDictArgs, vstr
 
     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:
@@ -379,7 +380,7 @@ def make_symlink_liblldb(vDictArgs, vstr
                 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)
 
@@ -449,11 +450,12 @@ def make_symlink_lldb_argdumper(vDictArg
 #           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 = ""
@@ -464,7 +466,8 @@ def create_symlinks(vDictArgs, vstrFrame
     if bOk:
         bOk, strErrMsg = make_symlink_liblldb(vDictArgs,
                                               vstrFrameworkPythonDir,
-                                              strLibLldbFileName)
+                                              strLibLldbFileName,
+                                              vstrLldbLibDir)
 
     # Make symlink for darwin-debug on Darwin
     strDarwinDebugFileName = "darwin-debug"
@@ -659,6 +662,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)
+
 #-----------------------------------------------------------------------------
 #-----------------------------------------------------------------------------
 #-----------------------------------------------------------------------------
@@ -684,6 +709,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.
@@ -714,10 +741,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)

Modified: lldb/branches/release_38/scripts/finishSwigWrapperClasses.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/scripts/finishSwigWrapperClasses.py?rev=270130&r1=270129&r2=270130&view=diff
==============================================================================
--- lldb/branches/release_38/scripts/finishSwigWrapperClasses.py (original)
+++ lldb/branches/release_38/scripts/finishSwigWrapperClasses.py Thu May 19 16:02:17 2016
@@ -72,6 +72,8 @@ Args:   -h              (optional) Print
                     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
 \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 <arg>
     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.




More information about the llvm-branch-commits mailing list