def copy_lldbpy_file_to_lldb_pkg_dir(vDictArgs, vstrFrameworkPythonDir, vstrCfgBldDir): dbg = utilsDebug.CDebugFnVerbose( "Python script copy_lldbpy_file_to_lldb_pkg_dir()") bOk = True bDbg = vDictArgs.has_key("-d") strMsg = "" strSrc = os.path.join(vstrCfgBldDir, "lldb.py") strSrc = os.path.normcase(strSrc) strDst = os.path.join(vstrFrameworkPythonDir, "__init__.py") strDst = os.path.normcase(strDst) if not os.path.exists(strSrc): strMsg = strErrMsgLLDBPyFileNotNotFound % strSrc return (bOk, strMsg) try: if bDbg: print(strMsgCopyLLDBPy % (strSrc, strDst)) shutil.copyfile(strSrc, strDst) except IOError as e: bOk = False strMsg = "I/O error( %d ): %s %s" % (e.errno, e.strerror, strErrMsgCpLldbpy) if e.errno == 2: strMsg += " Src:'%s' Dst:'%s'" % (strSrc, strDst) except: bOk = False strMsg = strErrMsgUnexpected % sys.exec_info()[0] return (bOk, strMsg)
def main(vArgv): dbg = utilsDebug.CDebugFnVerbose("main()") bOk = False dictArgs = {} nResult = 0 strMsg = "" # The validate arguments fn will exit the program if tests fail nResult, dictArgs = validate_arguments(vArgv) eOSType = utilsOsType.determine_os_type() if eOSType == utilsOsType.EnumOsType.Unknown: program_exit(-4, strMsgErrorOsTypeUnknown) global gbDbgFlag gbDbgFlag = "-d" in dictArgs if gbDbgFlag: print_out_input_parameters(dictArgs) # Check to see if we were called from the Makefile system. If we were, check # if the caller wants SWIG to generate a dependency file. # Not used in this program, but passed through to the language script file # called by this program global gbMakeFileFlag gbMakeFileFlag = "-m" in dictArgs nResult, strMsg = run_post_process_for_each_script_supported(dictArgs) program_exit(nResult, strMsg)
def create_symlinks(vDictArgs, vstrFrameworkPythonDir): dbg = utilsDebug.CDebugFnVerbose("Python script create_symlinks()") bOk = True strErrMsg = "" eOSType = utilsOsType.determine_os_type() # Make symlink for _lldb strLibLldbFileName = "_lldb" if bOk: bOk, strErrMsg = make_symlink_liblldb(vDictArgs, vstrFrameworkPythonDir, strLibLldbFileName) # Make symlink for darwin-debug on Darwin strDarwinDebugFileName = "darwin-debug" if bOk and eOSType == utilsOsType.EnumOsType.Darwin: bOk, strErrMsg = make_symlink_darwin_debug(vDictArgs, vstrFrameworkPythonDir, strDarwinDebugFileName) # Make symlink for argdumper strArgdumperFileName = "argdumper" if bOk: bOk, strErrMsg = make_symlink_argdumper(vDictArgs, vstrFrameworkPythonDir, strArgdumperFileName) return (bOk, strErrMsg)
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 += "/LLDB.framework"; if os.path.exists( strWkDir ): if bDbg: print(strMsgFoundLldbFrameWkDir % strWkDir); strWkDir += "/Resources/Python/lldb"; strWkDir = os.path.normcase( strWkDir ); else: bOk = False; strErrMsg = strErrMsgFrameWkPyDirNotExist % strWkDir; return (bOk, strWkDir, strErrMsg);
def get_framework_python_dir_other_platforms(vDictArgs): dbg = utilsDebug.CDebugFnVerbose( "Python script get_framework_python_dir_other_platform()") bOk = True strWkDir = "" strErrMsg = "" bDbg = vDictArgs.has_key("-d") bMakeFileCalled = vDictArgs.has_key("-m") 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)
def copy_six(vDictArgs, vstrFrameworkPythonDir): dbg = utilsDebug.CDebugFnVerbose("Python script copy_six()") bDbg = "-d" in vDictArgs bOk = True strMsg = "" site_packages_dir = os.path.dirname(vstrFrameworkPythonDir) six_module_filename = "six.py" src_file = os.path.join( vDictArgs['--srcRoot'], "third_party", "Python", "module", "six", six_module_filename) src_file = os.path.normpath(src_file) target = os.path.join(site_packages_dir, six_module_filename) if bDbg: print((strMsgCopySixPy % (src_file, target))) try: shutil.copyfile(src_file, target) except: bOk = False strMsg = strErrMsgCopySixPyFailed % (src_file, target) return (bOk, strMsg)
def validate_arguments( vArgv ): dbg = utilsDebug.CDebugFnVerbose( "validate_arguments()" ); strMsg = ""; dictArgs = {}; nResult = 0; strListArgs = "hdmM"; # Format "hiox:" = -h -i -o -x <arg> listLongArgs = ["srcRoot=", "targetDir=", "cfgBldDir=", "prefix=", "swigExecutable=", "argsFile"]; dictArgReq = { "-h": "o", # o = optional, m = mandatory "-d": "o", "-m": "o", "-M": "o", "--srcRoot": "m", "--targetDir": "m", "--swigExecutable" : "o", "--cfgBldDir": "o", "--prefix": "o", "--argsFile": "o" }; strHelpInfo = get_help_information(); # Check for mandatory parameters nResult, dictArgs, strMsg = utilsArgsParse.parse( vArgv, strListArgs, listLongArgs, dictArgReq, strHelpInfo ); if nResult < 0: program_exit_on_failure( nResult, strMsg ); # User input -h for help if nResult == 1: program_exit_success( 0, strMsg ); return (nResult, dictArgs);
def make_symlink(vDictArgs, vstrFrameworkPythonDir, vstrSrcFile, vstrTargetFile): dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink()") bOk = True strErrMsg = "" bDbg = "-d" in vDictArgs strTarget = os.path.join(vstrFrameworkPythonDir, vstrTargetFile) strTarget = os.path.normcase(strTarget) strSrc = "" os.chdir(vstrFrameworkPythonDir) bMakeFileCalled = "-m" in vDictArgs eOSType = utilsOsType.determine_os_type() if not bMakeFileCalled: strBuildDir = os.path.join("..", "..", "..") else: # Resolve vstrSrcFile path relatively the build directory if eOSType == utilsOsType.EnumOsType.Windows: # On a Windows platform the vstrFrameworkPythonDir looks like: # llvm\\build\\Lib\\site-packages\\lldb strBuildDir = os.path.join("..", "..", "..") else: # On a UNIX style platform the vstrFrameworkPythonDir looks like: # llvm/build/lib/python2.7/site-packages/lldb strBuildDir = os.path.join("..", "..", "..", "..") strSrc = os.path.normcase(os.path.join(strBuildDir, vstrSrcFile)) return make_symlink_native(vDictArgs, strSrc, strTarget)
def run_post_process_for_each_script_supported(vDictArgs): dbg = utilsDebug.CDebugFnVerbose( "run_post_process_for_each_script_supported()") nResult = 0 strStatusMsg = "" strScriptDir = os.path.normpath( os.path.join(vDictArgs["--srcRoot"], "scripts")) strFinishFileName = "finishSwig%sLLDB.py" # Check for the existence of the scripts folder strScriptsDir = os.path.normcase(strScriptDir) bOk = os.path.exists(strScriptsDir) if not bOk: return (-8, strScriptDirNotFound) # Look for any script language directories to build for listDirs = ["Python"] # Iterate script directory find any script language directories for scriptLang in listDirs: # __pycache__ is a magic directory in Python 3 that holds .pyc files if scriptLang != "__pycache__" and scriptLang != "swig_bot_lib": dbg.dump_text("Executing language script for \'%s\'" % scriptLang) nResult, strStatusMsg = run_post_process(scriptLang, strFinishFileName, vDictArgs) if nResult < 0: break if nResult < 0: strTmp = strPostProcessError % scriptLang strTmp += strStatusMsg strStatusMsg = strTmp return (nResult, strStatusMsg)
def validate_arguments(vArgv): dbg = utilsDebug.CDebugFnVerbose("validate_arguments()") strMsg = "" dictArgs = {} nResult = 0 strListArgs = "hdm" # Format "hiox:" = -h -i -o -x <arg> listLongArgs = ["srcRoot=", "targetDir=", "cfgBldDir=", "prefix=", "cmakeBuildConfiguration=", "lldbLibDir=", "argsFile"] dictArgReq = { "-h": "o", # o = optional, m = mandatory "-d": "o", "-m": "o", "--srcRoot": "m", "--targetDir": "m", "--cfgBldDir": "o", "--prefix": "o", "--cmakeBuildConfiguration": "o", "--lldbLibDir": "o", "--argsFile": "o" } # Check for mandatory parameters nResult, dictArgs, strMsg = utilsArgsParse.parse(vArgv, strListArgs, listLongArgs, dictArgReq, strHelpInfo) if nResult < 0: program_exit_on_failure(nResult, strMsg) # User input -h for help if nResult == 1: program_exit_success(0, strMsg) return (nResult, dictArgs)
def make_symlink_liblldb(vDictArgs, vstrFrameworkPythonDir, vstrLiblldbFileName, vstrLldbLibDir): dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_liblldb()") bOk = True strErrMsg = "" strTarget = vstrLiblldbFileName strSrc = "" eOSType = utilsOsType.determine_os_type() if eOSType == utilsOsType.EnumOsType.Windows: # When importing an extension module using a debug version of python, you # write, for example, "import foo", but the interpreter searches for # "foo_d.pyd" if is_debug_interpreter(): strTarget += "_d" strTarget += ".pyd" else: strTarget += ".so" bMakeFileCalled = "-m" in vDictArgs if not bMakeFileCalled: strSrc = os.path.join(vstrLldbLibDir, "LLDB") else: strLibFileExtn = "" if eOSType == utilsOsType.EnumOsType.Windows: strSrc = os.path.join("bin", "liblldb.dll") else: if eOSType == utilsOsType.EnumOsType.Darwin: strLibFileExtn = ".dylib" else: strLibFileExtn = ".so" strSrc = os.path.join(vstrLldbLibDir, "liblldb" + strLibFileExtn) bOk, strErrMsg = make_symlink(vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget) return (bOk, strErrMsg)
def get_framework_python_dir(vDictArgs): dbg = utilsDebug.CDebugFnVerbose( "Python script get_framework_python_dir()") bOk = True strErrMsg = "" strWkDir = os.path.normpath(vDictArgs["--lldbPythonPath"]) return (bOk, strWkDir, strErrMsg)
def macosx_copy_file_for_heap(vDictArgs, vstrFrameworkPythonDir): dbg = utilsDebug.CDebugFnVerbose( "Python script macosx_copy_file_for_heap()") bOk = True strMsg = "" eOSType = utilsOsType.determine_os_type() if eOSType != utilsOsType.EnumOsType.Darwin: return (bOk, strMsg) strHeapDir = os.path.join(vstrFrameworkPythonDir, "macosx", "heap") strHeapDir = os.path.normcase(strHeapDir) if (os.path.exists(strHeapDir) and os.path.isdir(strHeapDir)): return (bOk, strMsg) os.makedirs(strHeapDir) strRoot = os.path.normpath(vDictArgs["--srcRoot"]) strSrc = os.path.join(strRoot, "examples", "darwin", "heap_find", "heap", "heap_find.cpp") shutil.copy(strSrc, strHeapDir) strSrc = os.path.join(strRoot, "examples", "darwin", "heap_find", "heap", "Makefile") shutil.copy(strSrc, strHeapDir) return (bOk, strMsg)
def run_post_process(vStrScriptLang, vstrFinishFileName, vDictArgs): dbg = utilsDebug.CDebugFnVerbose("run_post_process()") nResult = 0 strStatusMsg = "" strScriptFile = vstrFinishFileName % vStrScriptLang strScriptFileDir = os.path.normpath( os.path.join(vDictArgs["--srcRoot"], "scripts", vStrScriptLang)) strScriptFilePath = os.path.join(strScriptFileDir, strScriptFile) # Check for the existence of the script file strPath = os.path.normcase(strScriptFilePath) bOk = os.path.exists(strPath) if not bOk: strDir = os.path.normcase(strScriptFileDir) strStatusMsg = strScriptNotFound % (strScriptFile, strDir) return (-9, strStatusMsg) if gbDbgFlag: print((strScriptLangFound % vStrScriptLang)) print((strExecuteMsg % vStrScriptLang)) # Change where Python looks for our modules strDir = os.path.normcase(strScriptFileDir) sys.path.append(strDir) # Execute the specific language script dictArgs = vDictArgs # Remove any args not required before passing on strModuleName = strScriptFile[:strScriptFile.__len__() - 3] module = __import__(strModuleName) nResult, strStatusMsg = module.main(dictArgs) # Revert sys path sys.path.remove(strDir) return (nResult, strStatusMsg)
def run_swig( vStrScriptLang, vSwigBuildFileName, vDictArgs ): dbg = utilsDebug.CDebugFnVerbose( "run_swig()" ); nResult = 0; strStatusMsg = ""; strScriptFile = vSwigBuildFileName % vStrScriptLang; strScriptFileDir = "%s%s/%s" % (vDictArgs[ "--srcRoot" ], "/scripts", vStrScriptLang); strScriptFilePath = "%s/%s" % (strScriptFileDir, strScriptFile); # Check for the existence of the script file strPath = os.path.normcase( strScriptFilePath ); bOk = os.path.exists( strPath ); if bOk == False: strDir = os.path.normcase( strScriptFileDir ); strStatusMsg = strSwigScriptNotFound % (strScriptFile, strDir); return (-9, strStatusMsg); if gbDbgFlag: print strSwigScriptLangFound % vStrScriptLang; print strSwigExecuteMsg % vStrScriptLang; # Change where Python looks for our modules strDir = os.path.normcase( strScriptFileDir ); sys.path.append( strDir ); # Execute the specific language script dictArgs = vDictArgs; # Remove any args not required before passing on strModuleName = strScriptFile[ : strScriptFile.__len__() - 3 ]; module = __import__( strModuleName ); nResult, strStatusMsg = module.main( dictArgs ); # Revert sys path sys.path.remove( strDir ); return (nResult, strStatusMsg);
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 = vDictArgs.has_key("--prefix") if bHaveArgPrefix: strPythonInstallDir = os.path.normpath(vDictArgs["--prefix"]) bHaveArgCmakeBuildConfiguration = vDictArgs.has_key( "--cmakeBuildConfiguration") 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)
def make_symlink_argdumper(vDictArgs, vstrFrameworkPythonDir, vstrArgdumperFileName): dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_argdumper()") bOk = True strErrMsg = "" strTarget = vstrArgdumperFileName strSrc = "" eOSType = utilsOsType.determine_os_type() if eOSType == utilsOsType.EnumOsType.Windows: strTarget += ".exe" bMakeFileCalled = vDictArgs.has_key("-m") if not bMakeFileCalled: return (bOk, strErrMsg) else: strExeFileExtn = "" if eOSType == utilsOsType.EnumOsType.Windows: strExeFileExtn = ".exe" strSrc = os.path.join("bin", "argdumper" + strExeFileExtn) bOk, strErrMsg = make_symlink(vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget) return (bOk, strErrMsg)
def create_py_pkg(vDictArgs, vstrFrameworkPythonDir, vstrPkgDir, vListPkgFiles): dbg = utilsDebug.CDebugFnVerbose("Python script create_py_pkg()") dbg.dump_object("Package file(s):", vListPkgFiles) bDbg = vDictArgs.has_key("-d") bOk = True strMsg = "" if vstrPkgDir.__len__() != 0 and vstrPkgDir[0] != "/": bOk = False strMsg = strErrMsgCreatePyPkgMissingSlash return (bOk, strMsg) strPkgName = vstrPkgDir strPkgName = "lldb" + strPkgName.replace("/", ".") strPkgDir = vstrFrameworkPythonDir strPkgDir += vstrPkgDir strPkgDir = os.path.normcase(strPkgDir) if not (os.path.exists(strPkgDir) and os.path.isdir(strPkgDir)): if bDbg: print(strMsgCreatePyPkgMkDir % strPkgDir) os.makedirs(strPkgDir) for strPkgFile in vListPkgFiles: if os.path.exists(strPkgFile) and os.path.isfile(strPkgFile): if bDbg: print(strMsgCreatePyPkgCopyPkgFile % (strPkgFile, strPkgDir)) shutil.copy(strPkgFile, strPkgDir) # Create a packet init files if there wasn't one strPkgIniFile = strPkgDir + "/__init__.py" strPkgIniFile = os.path.normcase(strPkgIniFile) if os.path.exists(strPkgIniFile) and os.path.isfile(strPkgIniFile): return (bOk, strMsg) strPyScript = "__all__ = [" strDelimiter = "" for strPkgFile in vListPkgFiles: if os.path.exists(strPkgFile) and os.path.isfile(strPkgFile): strBaseName = os.path.basename(strPkgFile) nPos = strBaseName.find(".") if nPos != -1: strBaseName = strBaseName[0:nPos] strPyScript += "%s\"%s\"" % (strDelimiter, strBaseName) strDelimiter = "," strPyScript += "]\n" strPyScript += "for x in __all__:\n" strPyScript += "\t__import__('%s.' + x)" % strPkgName if bDbg: print(strMsgCreatePyPkgInitFile % strPkgIniFile) file = open(strPkgIniFile, "w") file.write(strPyScript) file.close() return (bOk, strMsg)
def check_lldb_swig_executable_file_exists_FreeBSD( vDictArgs ): dbg = utilsDebug.CDebugFnVerbose( "check_lldb_swig_executable_file_exists_FreeBSD()" ); bExeFileFound = False; # ToDo: Find the SWIG executable and add the path to the args dictionary #vDictArgs.[ "--swigExePath" ] = "/usr/bin/swig"; strStatusMsg = "Sorry function 'check_lldb_swig_executable_file_exists_FreeBSD()' is not implemented"; return (bExeFileFound, strStatusMsg);
def make_symlink_six(vDictArgs, vstrFrameworkPythonDir): dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_six()") site_packages_dir = os.path.dirname(vstrFrameworkPythonDir) six_module_filename = "six.py" src_file = os.path.join(vDictArgs['--srcRoot'], "third_party", "Python", "module", "six", six_module_filename) src_file = os.path.normpath(src_file) target = os.path.join(site_packages_dir, six_module_filename) return make_symlink_native(vDictArgs, src_file, target)
def check_lldb_swig_executable_file_exists_Windows( vDictArgs ): dbg = utilsDebug.CDebugFnVerbose( "check_lldb_swig_executable_file_exists_Windows()" ); # Will always be true as it assumed the path to SWIG executable will be # in the OS system environmental variable %PATH%. Easier this way as the # user may have renamed the directory and or custom path installation. bExeFileFound = True; vDictArgs[ "--swigExePath" ] = ""; vDictArgs[ "--swigExeName" ] = "swig.exe"; return (bExeFileFound, None);
def get_interface_files(vDictArgs): dbg = utilsDebug.CDebugFnVerbose("Python script get_interface_files()") listIFaceFiles = [ "/scripts/interface/SBAddress.i", "/scripts/interface/SBAttachInfo.i", "/scripts/interface/SBBlock.i", "/scripts/interface/SBBreakpoint.i", "/scripts/interface/SBBreakpointLocation.i", "/scripts/interface/SBBroadcaster.i", "/scripts/interface/SBCommandInterpreter.i", "/scripts/interface/SBCommandReturnObject.i", "/scripts/interface/SBCommunication.i", "/scripts/interface/SBCompileUnit.i", "/scripts/interface/SBData.i", "/scripts/interface/SBDebugger.i", "/scripts/interface/SBDeclaration.i", "/scripts/interface/SBError.i", "/scripts/interface/SBEvent.i", "/scripts/interface/SBExpressionOptions.i", "/scripts/interface/SBFileSpec.i", "/scripts/interface/SBFrame.i", "/scripts/interface/SBFunction.i", "/scripts/interface/SBHostOS.i", "/scripts/interface/SBInputReader.i", "/scripts/interface/SBInstruction.i", "/scripts/interface/SBInstructionList.i", "/scripts/interface/SBLanguageRuntime.i", "/scripts/interface/SBLaunchInfo.i", "/scripts/interface/SBLineEntry.i", "/scripts/interface/SBListener.i", "/scripts/interface/SBModule.i", "/scripts/interface/SBModuleSpec.i", "/scripts/interface/SBProcess.i", "/scripts/interface/SBSourceManager.i", "/scripts/interface/SBStream.i", "/scripts/interface/SBStringList.i", "/scripts/interface/SBSymbol.i", "/scripts/interface/SBSymbolContext.i", "/scripts/interface/SBTarget.i", "/scripts/interface/SBThread.i", "/scripts/interface/SBThreadCollection.i", "/scripts/interface/SBType.i", "/scripts/interface/SBTypeCategory.i", "/scripts/interface/SBTypeFilter.i", "/scripts/interface/SBTypeFormat.i", "/scripts/interface/SBTypeNameSpecifier.i", "/scripts/interface/SBTypeSummary.i", "/scripts/interface/SBTypeSynthetic.i", "/scripts/interface/SBValue.i", "/scripts/interface/SBValueList.i", "/scripts/interface/SBWatchpoint.i" ] bDebug = vDictArgs.has_key("-d") strRt = vDictArgs["--srcRoot"] strRt = os.path.normcase(strRt) strInterfaceFiles = "" for strIFace in listIFaceFiles[0:len(listIFaceFiles)]: strIFace = os.path.normcase(strIFace) strInterfaceFiles += " %s%s" % (strRt, strIFace) if bDebug: print strMsgIFaceFiles print strInterfaceFiles vDictArgs["--ifaceFiles"] = strInterfaceFiles return True
def get_pylib_for_platform(vstrPythonInstallDir): dbg = utilsDebug.CDebugFnVerbose("Python script get_pylib_for_platform()") from distutils.sysconfig import get_python_lib if platform.system() == 'Linux': if platform.linux_distribution()[0] == 'Fedora': dbg.dump_text("Platform is Fedora Linux") # On Fedora the installation gets split into lib and lib64, # which prevents building lldb from completing successfully. return get_python_lib(False, False, vstrPythonInstallDir) return get_python_lib(True, False, vstrPythonInstallDir)
def run_post_process_for_each_script_supported(vDictArgs): dbg = utilsDebug.CDebugFnVerbose( "run_post_process_for_each_script_supported()") nResult = 0 strStatusMsg = "" strScriptDir = os.path.normpath( os.path.join(vDictArgs["--srcRoot"], "scripts")) strFinishFileName = "finishSwig%sLLDB.py" # Check for the existence of the scripts folder strScriptsDir = os.path.normcase(strScriptDir) bOk = os.path.exists(strScriptsDir) if bOk == False: return (-8, strScriptDirNotFound) # Look for any script language directories to build for listDirs = [] nDepth = 1 for strPath, listDirs, listFiles in os.walk(strScriptDir): nDepth = nDepth - 1 if nDepth == 0: break # Skip the directory that contains the interface files. listDirs.remove('interface') # and the svn directory. if '.svn' in listDirs: listDirs.remove('.svn') if gbDbgFlag: sys.stdout.write(strScriptLangsFound) for dir in listDirs: sys.stdout.write(dir) print("\n") # Iterate script directory find any script language directories for scriptLang in listDirs: # __pycache__ is a magic directory in Python 3 that holds .pyc files if scriptLang != "__pycache__" and scriptLang != "swig_bot_lib": dbg.dump_text("Executing language script for \'%s\'" % scriptLang) nResult, strStatusMsg = run_post_process(scriptLang, strFinishFileName, vDictArgs) if nResult < 0: break if nResult < 0: strTmp = strPostProcessError % scriptLang strTmp += strStatusMsg strStatusMsg = strTmp return (nResult, strStatusMsg)
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)
def get_config_build_dir(vDictArgs, vstrFrameworkPythonDir): dbg = utilsDebug.CDebugFnVerbose("Python script get_config_build_dir()") bOk = True strErrMsg = "" strConfigBldDir = "" bHaveConfigBldDir = vDictArgs.has_key("--cfgBldDir") if bHaveConfigBldDir: strConfigBldDir = vDictArgs["--cfgBldDir"] if (bHaveConfigBldDir == False) or (strConfigBldDir.__len__() == 0): strConfigBldDir = vstrFrameworkPythonDir return (bOk, strConfigBldDir, strErrMsg)
def get_config_build_dir( vDictArgs, vstrFrameworkPythonDir ): dbg = utilsDebug.CDebugFnVerbose( "Python script get_config_build_dir()" ); bOk = True; strErrMsg = ""; strConfigBldDir = ""; bHaveConfigBldDir = "--cfgBldDir" in vDictArgs; if bHaveConfigBldDir: strConfigBldDir = vDictArgs[ "--cfgBldDir" ]; if (bHaveConfigBldDir == False) or (strConfigBldDir.__len__() == 0): strConfigBldDir = vstrFrameworkPythonDir; return (bOk, strConfigBldDir, strErrMsg);
def make_symlink(vDictArgs, vstrFrameworkPythonDir, vstrSrcFile, vstrTargetFile): dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink()") bOk = True strErrMsg = "" bDbg = vDictArgs.has_key("-d") strTarget = os.path.join(vstrFrameworkPythonDir, vstrTargetFile) strTarget = os.path.normcase(strTarget) strSrc = "" os.chdir(vstrFrameworkPythonDir) bMakeFileCalled = vDictArgs.has_key("-m") eOSType = utilsOsType.determine_os_type() if not bMakeFileCalled: return (bOk, strErrMsg) else: # Resolve vstrSrcFile path relatively the build directory if eOSType == utilsOsType.EnumOsType.Windows: # On a Windows platform the vstrFrameworkPythonDir looks like: # llvm\\build\\Lib\\site-packages\\lldb strBuildDir = os.path.join("..", "..", "..") else: # On a UNIX style platform the vstrFrameworkPythonDir looks like: # llvm/build/lib/python2.7/site-packages/lldb strBuildDir = os.path.join("..", "..", "..", "..") strSrc = os.path.normcase(os.path.join(strBuildDir, vstrSrcFile)) strTargetDir = os.path.dirname(strTarget) strSrc = os.path.relpath(os.path.abspath(strSrc), strTargetDir) if eOSType == utilsOsType.EnumOsType.Unknown: bOk = False strErrMsg = strErrMsgOsTypeUnknown elif eOSType == utilsOsType.EnumOsType.Windows: if os.path.isfile(strTarget): if bDbg: print strMsgSymlinkExists % vstrTargetFile return (bOk, strErrMsg) if bDbg: print strMsgSymlinkMk % (vstrTargetFile, strSrc, strTarget) bOk, strErrMsg = make_symlink_windows(strSrc, strTarget) else: if os.path.islink(strTarget): if bDbg: print strMsgSymlinkExists % vstrTargetFile return (bOk, strErrMsg) if bDbg: print strMsgSymlinkMk % (vstrTargetFile, strSrc, strTarget) bOk, strErrMsg = make_symlink_other_platforms(strSrc, strTarget) return (bOk, strErrMsg)
def make_symlink( vDictArgs, vstrFrameworkPythonDir, vstrSrcFile, vstrTargetFile): dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink()") strTarget = os.path.join(vstrFrameworkPythonDir, vstrTargetFile) strTarget = os.path.normcase(strTarget) strPrefix = vDictArgs['--prefix'] os.chdir(vstrFrameworkPythonDir) strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile)) strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget)) return make_symlink_native(vDictArgs, strRelSrc, strTarget)
def check_lldb_swig_file_exists( vstrSrcRoot, veOSType ): dbg = utilsDebug.CDebugFnVerbose( "check_lldb_swig_file_exists()" ); bOk = True; strStatusMsg = ""; strSwigFilePathName = "/scripts/lldb.swig"; strFullPath = os.path.normcase( vstrSrcRoot + strSwigFilePathName ); bOk = os.path.isfile( strFullPath ); if bOk: if gbDbgFlag: print strSwigFileFound; else: strStatusMsg = strSwigFileFoundNotFound % strFullPath; return (bOk, strStatusMsg);