[llvm-commits] [PATCH] lit: makes 'where' available on cygwin

NAKAMURA Takumi geek4civic at gmail.com
Mon Aug 23 21:04:01 PDT 2010


Hello,

This patch makes lit available to clang-test on cygwin.

- on cygwin, os.pathsep==':' but Cygwin does not modify the variable PATHEXT.
  it might be enough separator is ';' with PATHEXT
  because PATHEXT is, AFAIK, Win32-specific.
- When PATHEXT exists, it makes seek suffix-less file.
  on cygwin, "/path/to/a" hits to "/path/to/a.exe".
  I quoted 2 lines from http://bugs.python.org/file16459/which.py

Please take a look, thank you!

...Takumi
-------------- next part --------------
diff --git a/utils/lit/lit/Util.py b/utils/lit/lit/Util.py
index 414b714..c758871 100644
--- a/utils/lit/lit/Util.py
+++ b/utils/lit/lit/Util.py
@@ -64,7 +64,11 @@ def which(command, paths = None):
         paths = os.defpath
 
     # Get suffixes to search.
-    pathext = os.environ.get('PATHEXT', '').split(os.pathsep)
+    pathext = os.environ.get('PATHEXT', '').split(';')
+
+    # always check command without extension, even for custom pathext
+    if not '' in pathext:
+        pathext.insert(0, '')
 
     # Search the paths...
     for path in paths.split(os.pathsep):


More information about the llvm-commits mailing list