brucem created this revision.
brucem added reviewers: zturner, domipheus.
brucem added a subscriber: lldb-commits.

Remove per-platform variants of this in favor of just having
Windows and Unix. The code that was previously specific to
Linux can be further simplified and used on all non-Windows
platforms that are currently supported as build hosts.

This code only runs when --swigExecutable isn't given on the
command line. cmake always passes that in, so this is never
actually used in current practice.

http://reviews.llvm.org/D14415

Files:
  scripts/buildSwigWrapperClasses.py

Index: scripts/buildSwigWrapperClasses.py
===================================================================
--- scripts/buildSwigWrapperClasses.py
+++ scripts/buildSwigWrapperClasses.py
@@ -310,108 +310,49 @@
     return (nResult, strStatusMsg)
 
 #++---------------------------------------------------------------------------
-# Details:  Dummy function - system unknown. Function should not be called.
-# Args:     vDictArgs   - (R) Program input parameters.
-# Returns:  Bool    - False = Program logic error.
-#           Str     - Error message.
-# Throws:   None.
-#--
-def check_lldb_swig_executable_file_exists_Unknown(vDictArgs):
-    dbg = utilsDebug.CDebugFnVerbose("check_lldb_swig_executable_file_exists_Unknown()")
-    # Do nothing
-    return (False, strMsgErrorOsTypeUnknown)
-
-#++---------------------------------------------------------------------------
-# Details:  Locate the SWIG executable file in a Windows system. Several hard
-#           coded predetermined possible file path locations are searched.
-#           (This is good candidate for a derived class object)
+# Details:  Locate the SWIG executable file in a Windows system. This actually
+#           just assumes that it is on the path and performs no checks.
 # Args:     vDictArgs   - (W) Program input parameters.
 # Returns:  Bool    - True = Success.
 #                   - False = Failure file not found.
 #           Str     - Error message.
 # Throws:   None.
 #--
-def check_lldb_swig_executable_file_exists_Windows(vDictArgs):
-    dbg = utilsDebug.CDebugFnVerbose("check_lldb_swig_executable_file_exists_Windows()")
+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)
+    return (True, None)
 
 #++---------------------------------------------------------------------------
-# Details:  Locate the SWIG executable file in a Linux system. Several hard
+# Details:  Locate the SWIG executable file in a Unix system. Several hard
 #           coded predetermined possible file path locations are searched.
 #           (This is good candidate for a derived class object)
 # Args:     vDictArgs   - (W) Program input parameters.
 # Returns:  Bool    - True = Success.
 #                   - False = Failure file not found.
 #           Str     - Error message.
 # Throws:   None.
 #--
-def check_lldb_swig_executable_file_exists_Linux(vDictArgs):
-    dbg = utilsDebug.CDebugFnVerbose("check_lldb_swig_executable_file_exists_Linux()")
-    bExeFileFound = False
-
-    strSwigExe = "swig"
-    strSwigExePath = "/usr/bin"
-    strExe = os.path.normcase("%s/%s" % (strSwigExePath, strSwigExe))
-    if os.path.isfile(strExe) and os.access(strExe, os.X_OK):
-        bExeFileFound = True
-        vDictArgs["--swigExePath"] = os.path.normcase(strSwigExePath)
-        vDictArgs["--swigExeName"] = strSwigExe
-        return (bExeFileFound, None)
-
-    strSwigExePath = "/usr/local/bin"
-    strExe = os.path.normcase("%s/%s" % (strSwigExePath, strSwigExe))
-    if os.path.isfile(strExe) and os.access(strExe, os.X_OK):
-        bExeFileFound = True
-        vDictArgs["--swigExePath"] = os.path.normcase(strSwigExePath)
-        vDictArgs["--swigExeName"] = strSwigExe
-        return (bExeFileFound, None)
-
-    return (bExeFileFound, strSwigExeFileNotFound)
-
-#++---------------------------------------------------------------------------
-# Details:  Locate the SWIG executable file in a OSX system. Several hard
-#           coded predetermined possible file path locations are searched.
-#           (This is good candidate for a derived class object)
-# Args:     vDictArgs   - (W) Program input parameters.
-# Returns:  Bool    - True = Success.
-#                   - False = Failure file not found.
-#           Str     - Error message.
-# Throws:   None.
-#--
-def check_lldb_swig_executable_file_exists_Darwin(vDictArgs):
-    dbg = utilsDebug.CDebugFnVerbose("check_lldb_swig_executable_file_exists_Darwin()")
-    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_Darwin()' is not implemented"
-
-    return (bExeFileFound, strStatusMsg)
-
-#++---------------------------------------------------------------------------
-# Details:  Locate the SWIG executable file in a OSX system. Several hard
-#           coded predetermined possible file path locations are searched.
-#           (This is good candidate for a derived class object)
-# Args:     vDictArgs   - (W) Program input parameters.
-# Returns:  Bool    - True = Success.
-#                   - False = Failure file not found.
-#           Str     - Error message.
-# Throws:   None.
-#--
-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 check_lldb_swig_executable_file_exists_unix(vDictArgs):
+    dbg = utilsDebug.CDebugFnVerbose("check_lldb_swig_executable_file_exists_Unix()")
+
+    likely_paths = [
+        "/usr/bin",
+        "/usr/local/bin"
+    ]
+    for path in likely_paths:
+        exe_path = os.path.normcase(os.path.join(path, "swig"))
+        if os.path.isfile(exe_path) and os.access(exe_path, os.X_OK):
+            vDictArgs["--swigExePath"] = os.path.normcase(path)
+            vDictArgs["--swigExeName"] = exe_path
+            return (True, None)
+
+    return (False, strSwigExeFileNotFound)
 
 #++---------------------------------------------------------------------------
 # Details:  Locate the SWIG executable file. Several hard coded predetermined
@@ -425,21 +366,16 @@
 #--
 def check_lldb_swig_executable_file_exists(vDictArgs, veOSType):
     dbg = utilsDebug.CDebugFnVerbose("check_lldb_swig_executable_file_exists()")
-    bExeFileFound = False
-    strStatusMsg = ""
     if "--swigExecutable" in vDictArgs:
         vDictArgs["--swigExeName"] = os.path.basename(vDictArgs["--swigExecutable"])
         vDictArgs["--swigExePath"] = os.path.dirname(vDictArgs["--swigExecutable"])
-        bExeFileFound = True
+        return (True, None)
     else:
         from utilsOsType import EnumOsType
-        switch = {EnumOsType.Unknown : check_lldb_swig_executable_file_exists_Unknown,
-                  EnumOsType.Darwin : check_lldb_swig_executable_file_exists_Darwin,
-                  EnumOsType.FreeBSD : check_lldb_swig_executable_file_exists_FreeBSD,
-                  EnumOsType.Linux : check_lldb_swig_executable_file_exists_Linux,
-                  EnumOsType.Windows : check_lldb_swig_executable_file_exists_Windows}
-        bExeFileFound, strStatusMsg = switch[veOSType](vDictArgs)
-    return (bExeFileFound, strStatusMsg)
+        if veOSType == EnumOsType.Windows:
+            return check_lldb_swig_executable_file_exists_windows(vDictArgs)
+        else:
+            return check_lldb_swig_executable_file_exists_unix(vDictArgs)
 #++---------------------------------------------------------------------------
 # Details:  Validate the arguments passed to the program. This function exits
 #           the program should error with the arguments be found.
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to