[llvm] r219991 - Add our own copy of the find_executable function to cope with installations

Peter Collingbourne peter at pcc.me.uk
Thu Oct 16 16:43:20 PDT 2014


Author: pcc
Date: Thu Oct 16 18:43:20 2014
New Revision: 219991

URL: http://llvm.org/viewvc/llvm-project?rev=219991&view=rev
Log:
Add our own copy of the find_executable function to cope with installations
that do not have the distutils.spawn package. Should hopefully fix the
aarch64 buildbot.

Modified:
    llvm/trunk/test/Bindings/Go/lit.local.cfg

Modified: llvm/trunk/test/Bindings/Go/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Go/lit.local.cfg?rev=219991&r1=219990&r2=219991&view=diff
==============================================================================
--- llvm/trunk/test/Bindings/Go/lit.local.cfg (original)
+++ llvm/trunk/test/Bindings/Go/lit.local.cfg Thu Oct 16 18:43:20 2014
@@ -1,11 +1,29 @@
-import distutils.spawn
 import os
 import pipes
 import shlex
+import sys
 
 if not 'go' in config.root.llvm_bindings:
     config.unsupported = True
 
+def find_executable(executable, path=None):
+    if path is None:
+        path = os.environ['PATH']
+    paths = path.split(os.pathsep)
+    base, ext = os.path.splitext(executable)
+
+    if (sys.platform == 'win32' or os.name == 'os2') and (ext != '.exe'):
+        executable = executable + '.exe'
+
+    if not os.path.isfile(executable):
+        for p in paths:
+            f = os.path.join(p, executable)
+            if os.path.isfile(f):
+                return f
+        return None
+    else:
+        return executable
+
 # Resolve certain symlinks in the first word of compiler.
 #
 # This is a Go-specific hack. cgo and other Go tools check $CC and $CXX for the
@@ -13,7 +31,7 @@ if not 'go' in config.root.llvm_bindings
 # $CC is cc and cc is a symlink pointing to clang, as it is on Darwin.
 def fixup_compiler_path(compiler):
     args = shlex.split(compiler)
-    path = distutils.spawn.find_executable(args[0])
+    path = find_executable(args[0])
 
     try:
         if path.endswith('/cc') and os.readlink(path) == 'clang':





More information about the llvm-commits mailing list