Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -31,7 +31,7 @@ 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") Index: scripts/Python/finishSwigPythonLLDB.py =================================================================== --- scripts/Python/finishSwigPythonLLDB.py +++ scripts/Python/finishSwigPythonLLDB.py @@ -358,11 +358,12 @@ # 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 @@ 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 @@ 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 @@ # 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 @@ 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 @@ 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 @@ 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 @@ 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) Index: scripts/finishSwigWrapperClasses.py =================================================================== --- scripts/finishSwigWrapperClasses.py +++ scripts/finishSwigWrapperClasses.py @@ -72,6 +72,8 @@ 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 @@ \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 @@ 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 @@ "--cfgBldDir": "o", "--prefix": "o", "--cmakeBuildConfiguration": "o", + "--lldbLibDir": "o", "--argsFile": "o" } # Check for mandatory parameters @@ -337,11 +340,13 @@ --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.