summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/finishSwigPythonLLDB.py
diff options
context:
space:
mode:
authorIlia K <ki.stfu@gmail.com>2015-02-13 22:30:11 +0000
committerIlia K <ki.stfu@gmail.com>2015-02-13 22:30:11 +0000
commita7e79c1b448ff7ec90b1fee27e7e148275a2fd94 (patch)
tree22b0d2443f621cc02e73ecf1c8bab269a20b6378 /lldb/scripts/Python/finishSwigPythonLLDB.py
parent8911240c9e2d28f387310f8fc51db9ce35051dbe (diff)
downloadbcm5719-llvm-a7e79c1b448ff7ec90b1fee27e7e148275a2fd94.tar.gz
bcm5719-llvm-a7e79c1b448ff7ec90b1fee27e7e148275a2fd94.zip
Fix build: revert r229148 "Fix argdumper build in cmake (OS X) after r228636" and r229159 "Fix build: make_symlink_darwin_debug passes 2 arguments into make_symlink, but it requires 4 arguments"
llvm-svn: 229166
Diffstat (limited to 'lldb/scripts/Python/finishSwigPythonLLDB.py')
-rw-r--r--lldb/scripts/Python/finishSwigPythonLLDB.py295
1 files changed, 123 insertions, 172 deletions
diff --git a/lldb/scripts/Python/finishSwigPythonLLDB.py b/lldb/scripts/Python/finishSwigPythonLLDB.py
index 4f9b31357b9..978b0d67091 100644
--- a/lldb/scripts/Python/finishSwigPythonLLDB.py
+++ b/lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -70,8 +70,8 @@ strMsgPyFileLocatedHere = "Python file will be put in '%s'";
strMsgFrameWkPyExists = "Python output folder '%s' already exists";
strMsgFrameWkPyMkDir = "Python output folder '%s' will be created";
strErrMsgCreateFrmWkPyDirFailed = "Unable to create directory '%s' error: %s";
-strMsgSymlinkExists = "Symlink for '%s' already exists";
-strMsgSymlinkMk = "Creating symlink for %s (%s -> %s)";
+strMsglldbsoExists = "Symlink '%s' already exists";
+strMsglldbsoMk = "Creating symlink for _lldb.so (%s -> %s)";
strErrMsgCpLldbpy = "copying lldb to lldb package directory";
strErrMsgCreatePyPkgMissingSlash = "Parameter 3 fn create_py_pkg() missing slash";
strErrMsgMkLinkExecute = "Command mklink failed: %s";
@@ -218,159 +218,120 @@ def copy_lldbpy_file_to_lldb_pkg_dir( vDictArgs, vstrFrameworkPythonDir, vstrCfg
strMsg = strErrMsgUnexpected % sys.exec_info()[ 0 ];
return (bOk, strMsg);
-
-#++---------------------------------------------------------------------------
-# Details: Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-# vstrTargetFile - (R) Destination file name.
-# Returns: Bool - True = function success, False = failure.
-# Str - Error description on task failure.
-# Throws: None.
-#--
-def make_symlink_windows( vstrSrcPath, vstrTargetPath ):
- print "Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath);
- dbg = utilsDebug.CDebugFnVerbose( "Python script make_symlink_windows()" );
- bOk = True;
- strErrMsg = "";
-
- try:
- csl = ctypes.windll.kernel32.CreateHardLinkW
- csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
- csl.restype = ctypes.c_ubyte
- if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
- raise ctypes.WinError()
- except Exception as e:
- if e.errno != 17:
- bOk = False;
- strErrMsg = "WinError( %d ): %s %s" % (e.errno, e.strerror, strErrMsgMakeSymlink);
- strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath);
-
- return (bOk, strErrMsg);
-
-#++---------------------------------------------------------------------------
-# Details: Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-# vstrTargetFile - (R) Destination file name.
-# Returns: Bool - True = function success, False = failure.
-# Str - Error description on task failure.
-# Throws: None.
-#--
-def make_symlink_other_platforms( vstrSrcPath, vstrTargetPath ):
- dbg = utilsDebug.CDebugFnVerbose( "Python script make_symlink_other_platforms()" );
- bOk = True;
- strErrMsg = "";
-
- try:
- os.symlink( vstrSrcPath, vstrTargetPath );
- except OSError as e:
- bOk = False;
- strErrMsg = "OSError( %d ): %s %s" % (e.errno, e.strerror, strErrMsgMakeSymlink);
- strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath);
- except:
- bOk = False;
- strErrMsg = strErrMsgUnexpected % sys.exec_info()[ 0 ];
-
- return (bOk, strErrMsg);
#++---------------------------------------------------------------------------
-# Details: Make the symbolic link.
+# Details: Make the symbolic that the script bridge for Python will need in
+# the Python framework directory. Code for specific to Windows.
# Args: vDictArgs - (R) Program input parameters.
# vstrFrameworkPythonDir - (R) Python framework directory.
-# vstrSrcFile - (R) Source file name.
-# vstrTargetFile - (R) Destination file name.
+# vstrDllName - (R) File name for _lldb.dll.
# Returns: Bool - True = function success, False = failure.
# Str - Error description on task failure.
# Throws: None.
#--
-def make_symlink( vDictArgs, vstrFrameworkPythonDir, vstrSrcFile, vstrTargetFile ):
- dbg = utilsDebug.CDebugFnVerbose( "Python script make_symlink()" );
+def make_symlink_windows( vDictArgs, vstrFrameworkPythonDir, vstrDllName ):
+ dbg = utilsDebug.CDebugFnVerbose( "Python script make_symlink_windows()" );
bOk = True;
- strErrMsg = "";
+ strMsg = "";
+
bDbg = vDictArgs.has_key( "-d" );
- strTarget = "%s/%s" % (vstrFrameworkPythonDir, vstrTargetFile);
- strTarget = os.path.normcase( strTarget );
+ strTarget = vstrDllName;
+ # 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 vDictArgs["--buildConfig"].lower() == "debug":
+ strTarget += "_d";
+ strTarget += ".pyd";
+ strDLLPath = "%s\\%s" % (vstrFrameworkPythonDir, strTarget);
+ strTarget = os.path.normcase( strDLLPath );
strSrc = "";
os.chdir( vstrFrameworkPythonDir );
bMakeFileCalled = vDictArgs.has_key( "-m" );
- eOSType = utilsOsType.determine_os_type();
if not bMakeFileCalled:
- return (bOk, strErrMsg);
+ strSrc = os.path.normcase( "../../../LLDB" );
else:
- strSrc = os.path.normcase( "../../../%s" % vstrSrcFile );
+ strLibFileExtn = ".dll";
+ strSrc = os.path.normcase( "../../../bin/liblldb%s" % strLibFileExtn );
- if eOSType == utilsOsType.EnumOsType.Unknown:
- bOk = False;
- strErrMsg = strErrMsgOsTypeUnknown;
- elif eOSType == utilsOsType.EnumOsType.Windows:
- if os.path.isfile( strTarget ):
- if bDbg:
- print strMsgSymlinkExists % vstrTargetFile;
+ if os.path.isfile( strTarget ):
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;
- if bDbg:
- print strMsgSymlinkMk % (vstrTargetFile, strSrc, strTarget);
- return (bOk, strErrMsg);
- bOk, strErrMsg = make_symlink_other_platforms( strSrc,
- strTarget );
+ print strMsglldbsoExists % strTarget;
+ return (bOk, strMsg);
- return (bOk, strErrMsg);
+ if bDbg:
+ print strMsglldbsoMk % (os.path.abspath(strSrc), os.path.abspath(strTarget));
+
+ try:
+ csl = ctypes.windll.kernel32.CreateHardLinkW
+ csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
+ csl.restype = ctypes.c_ubyte
+ if csl(strTarget, strSrc, 0) == 0:
+ raise ctypes.WinError()
+ except Exception as e:
+ bOk = False;
+ strMsg = "WinError( %d ): %s %s" % (e.errno, e.strerror, strErrMsgMakeSymlink);
+ strMsg += " Src:'%s' Target:'%s'" % (strSrc, strTarget);
+ return (bOk, strMsg);
+
#++---------------------------------------------------------------------------
-# Details: Make the symbolic that the script bridge for Python will need in
-# the Python framework directory.
+# Details: Make the symbolic link that the script bridge for Python will need in
+# the Python framework directory. Code for all platforms apart from
+# Windows.
# Args: vDictArgs - (R) Program input parameters.
# vstrFrameworkPythonDir - (R) Python framework directory.
-# vstrLiblldbName - (R) File name for _lldb library.
+# vstrSoName - (R) File name for _lldb.so.
# Returns: Bool - True = function success, False = failure.
# Str - Error description on task failure.
# Throws: None.
#--
-def make_symlink_liblldb( vDictArgs, vstrFrameworkPythonDir, vstrLiblldbFileName ):
- dbg = utilsDebug.CDebugFnVerbose( "Python script make_symlink_liblldb()" );
+def make_symlink_other_platforms( vDictArgs, vstrFrameworkPythonDir, vstrSoPath ):
+ dbg = utilsDebug.CDebugFnVerbose( "Python script make_symlink_other_platforms()" );
bOk = True;
- strErrMsg = "";
- strTarget = vstrLiblldbFileName
+ strMsg = "";
+ bDbg = vDictArgs.has_key( "-d" );
+ strTarget = vstrSoPath + ".so";
+ strSoPath = "%s/%s" % (vstrFrameworkPythonDir, strTarget);
+ strTarget = os.path.normcase( strSoPath );
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 vDictArgs["--buildConfig"].lower() == "debug":
- strTarget += "_d";
- strTarget += ".pyd";
- else:
- strTarget += ".so";
-
+
+ os.chdir( vstrFrameworkPythonDir );
bMakeFileCalled = vDictArgs.has_key( "-m" );
if not bMakeFileCalled:
- strSrc = "lib/LLDB";
+ strSrc = os.path.normcase( "../../../LLDB" );
else:
strLibFileExtn = "";
- if eOSType == utilsOsType.EnumOsType.Windows:
- strLibFileExtn = ".dll";
- strSrc = "bin/liblldb%s" % strLibFileExtn;
- else:
- if eOSType == utilsOsType.EnumOsType.Linux:
- strLibFileExtn = ".so";
- elif eOSType == utilsOsType.EnumOsType.Darwin:
- strLibFileExtn = ".dylib";
- strSrc = "lib/liblldb%s" % strLibFileExtn;
-
- bOk, strErrMsg = make_symlink( vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget );
-
- return (bOk, strErrMsg);
+ eOSType = utilsOsType.determine_os_type();
+ if eOSType == utilsOsType.EnumOsType.Linux:
+ strLibFileExtn = ".so";
+ elif eOSType == utilsOsType.EnumOsType.Darwin:
+ strLibFileExtn = ".dylib";
+ strSrc = os.path.normcase( "../../../liblldb%s" % strLibFileExtn );
+ if os.path.islink( strTarget ):
+ if bDbg:
+ print strMsglldbsoExists % strTarget;
+ return (bOk, strMsg);
+
+ if bDbg:
+ print strMsglldbsoMk;
+
+ try:
+ os.symlink( strSrc, strTarget );
+ except OSError as e:
+ bOk = False;
+ strMsg = "OSError( %d ): %s %s" % (e.errno, e.strerror, strErrMsgMakeSymlink);
+ strMsg += " Src:'%s' Target:'%s'" % (strSrc, strTarget);
+ except:
+ bOk = False;
+ strMsg = strErrMsgUnexpected % sys.exec_info()[ 0 ];
+
+ return (bOk, strMsg);
+
#++---------------------------------------------------------------------------
-# Details: Make the symbolic link to the darwin-debug.
+# Details: Make the symbolic link to the darwin-debug. Code for all platforms
+# apart from Windows.
# Args: vDictArgs - (R) Program input parameters.
# vstrFrameworkPythonDir - (R) Python framework directory.
# vstrDarwinDebugFileName - (R) File name for darwin-debug.
@@ -379,51 +340,41 @@ def make_symlink_liblldb( vDictArgs, vstrFrameworkPythonDir, vstrLiblldbFileName
# Throws: None.
#--
def make_symlink_darwin_debug( vDictArgs, vstrFrameworkPythonDir, vstrDarwinDebugFileName ):
- dbg = utilsDebug.CDebugFnVerbose( "Python script make_symlink_darwin_debug()" );
- bOk = True;
- strErrMsg = "";
- strTarget = vstrDarwinDebugFileName;
- strSrc = "";
-
- bMakeFileCalled = vDictArgs.has_key( "-m" );
- if not bMakeFileCalled:
- return (bOk, strErrMsg);
- else:
- strSrc = "bin/lldb-launcher";
-
- bOk, strErrMsg = make_symlink( vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget );
-
- return (bOk, strErrMsg);
-
-#++---------------------------------------------------------------------------
-# Details: Make the symbolic link to the argdumper.
-# Args: vDictArgs - (R) Program input parameters.
-# vstrFrameworkPythonDir - (R) Python framework directory.
-# vstrArgdumperFileName - (R) File name for argdumper.
-# Returns: Bool - True = function success, False = failure.
-# Str - Error description on task failure.
-# Throws: None.
-#--
-def make_symlink_argdumper( vDictArgs, vstrFrameworkPythonDir, vstrArgdumperFileName ):
- dbg = utilsDebug.CDebugFnVerbose( "Python script make_symlink_argdumper()" );
+ dbg = utilsDebug.CDebugFnVerbose( "Python script make_symlink_other_platforms()" );
bOk = True;
- strErrMsg = "";
- strTarget = vstrArgdumperFileName;
+ strMsg = "";
+ bDbg = vDictArgs.has_key( "-d" );
+ strTarget = vstrDarwinDebugFileName
+ strDarwinDebugPath = "%s/%s" % (vstrFrameworkPythonDir, strTarget);
+ strTarget = os.path.normcase( strDarwinDebugPath );
strSrc = "";
+ os.chdir( vstrFrameworkPythonDir );
bMakeFileCalled = vDictArgs.has_key( "-m" );
if not bMakeFileCalled:
- return (bOk, strErrMsg);
+ return (bOk, strMsg);
else:
- eOSType = utilsOsType.determine_os_type();
- strSrc = "bin/argdumper";
- if eOSType == utilsOsType.EnumOsType.Windows:
- strSrc += ".exe"
- strTarget += ".exe";
-
- bOk, strErrMsg = make_symlink( vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget );
+ strSrc = os.path.normcase( "../../../../bin/lldb-launcher" );
- return (bOk, strErrMsg);
+ if os.path.islink( strTarget ):
+ if bDbg:
+ print strMsglldbsoExists % strTarget;
+ return (bOk, strMsg);
+
+ if bDbg:
+ print strMsglldbsoMk;
+
+ try:
+ os.symlink( strSrc, strTarget );
+ except OSError as e:
+ bOk = False;
+ strMsg = "OSError( %d ): %s %s" % (e.errno, e.strerror, strErrMsgMakeSymlink);
+ strMsg += " Src:'%s' Target:'%s'" % (strSrc, strTarget);
+ except:
+ bOk = False;
+ strMsg = strErrMsgUnexpected % sys.exec_info()[ 0 ];
+
+ return (bOk, strMsg);
#++---------------------------------------------------------------------------
# Details: Make the symlink that the script bridge for Python will need in
@@ -434,34 +385,34 @@ def make_symlink_argdumper( vDictArgs, vstrFrameworkPythonDir, vstrArgdumperFile
# strErrMsg - Error description on task failure.
# Throws: None.
#--
-def create_symlinks( vDictArgs, vstrFrameworkPythonDir ):
- dbg = utilsDebug.CDebugFnVerbose( "Python script create_symlinks()" );
+def make_symlink( vDictArgs, vstrFrameworkPythonDir ):
+ dbg = utilsDebug.CDebugFnVerbose( "Python script make_symlink()" );
bOk = True;
strWkDir = "";
strErrMsg = "";
eOSType = utilsOsType.determine_os_type();
- # Make symlink for _lldb
+ # Make symlink for _lldb
strSoFileName = "_lldb";
- if bOk:
- bOk, strErrMsg = make_symlink_liblldb( vDictArgs,
+ if eOSType == utilsOsType.EnumOsType.Unknown:
+ bOk = False;
+ strErrMsg = strErrMsgOsTypeUnknown;
+ elif eOSType == utilsOsType.EnumOsType.Windows:
+ bOk, strErrMsg = make_symlink_windows( vDictArgs,
vstrFrameworkPythonDir,
strSoFileName );
+ else:
+ bOk, strErrMsg = make_symlink_other_platforms( vDictArgs,
+ vstrFrameworkPythonDir,
+ strSoFileName );
- # Make symlink for darwin-debug on Darwin
+ # Make symlink for darwin-debug
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);
#++---------------------------------------------------------------------------
@@ -680,7 +631,7 @@ def main( vDictArgs ):
bOk, strMsg = find_or_create_python_dir( vDictArgs, strFrameworkPythonDir );
if bOk:
- bOk, strMsg = create_symlinks( vDictArgs, strFrameworkPythonDir );
+ bOk, strMsg = make_symlink( vDictArgs, strFrameworkPythonDir );
if bOk:
bOk, strMsg = copy_lldbpy_file_to_lldb_pkg_dir( vDictArgs,
OpenPOWER on IntegriCloud