[Lldb-commits] [lldb] r267462 - Create _lldb python symlink correctly when LLVM_LIBDIR_SUFFIX is used

Francis Ricci via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 25 13:34:34 PDT 2016


Author: fjricci
Date: Mon Apr 25 15:34:34 2016
New Revision: 267462

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

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

Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=267462&r1=267461&r2=267462&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Mon Apr 25 15:34:34 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/trunk/scripts/Python/finishSwigPythonLLDB.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/finishSwigPythonLLDB.py?rev=267462&r1=267461&r2=267462&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/finishSwigPythonLLDB.py (original)
+++ lldb/trunk/scripts/Python/finishSwigPythonLLDB.py Mon Apr 25 15:34:34 2016
@@ -358,11 +358,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 = ""
@@ -382,7 +383,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:
@@ -392,7 +393,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)
 
@@ -462,11 +463,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 = ""
@@ -477,7 +479,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"
@@ -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)

Modified: lldb/trunk/scripts/finishSwigWrapperClasses.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/finishSwigWrapperClasses.py?rev=267462&r1=267461&r2=267462&view=diff
==============================================================================
--- lldb/trunk/scripts/finishSwigWrapperClasses.py (original)
+++ lldb/trunk/scripts/finishSwigWrapperClasses.py Mon Apr 25 15:34:34 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 lldb-commits mailing list