lit/Util.py: Add two functions, checkToolsPath(dir,tools) and whichTools(tools,paths).
authorNAKAMURA Takumi <geek4civic@gmail.com>
Wed, 9 Feb 2011 04:19:06 +0000 (04:19 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Wed, 9 Feb 2011 04:19:06 +0000 (04:19 +0000)
checkToolsPath(dir,tools):
return True if "dir" contains all "tools".

whichTools(tools,paths):
return a directory that contains all "tools" in "paths".
Or return None when all "tools" were not met.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125174 91177308-0d34-0410-b5e6-96231b3b80d8

utils/lit/lit/Util.py

index 414b714c82c336aa01de608d138eeab9c61d6fb0..ad4adf2f347399bbe953f6938cf93f9f20f8816b 100644 (file)
@@ -75,6 +75,18 @@ def which(command, paths = None):
 
     return None
 
+def checkToolsPath(dir, tools):
+    for tool in tools:
+        if not os.path.exists(os.path.join(dir, tool)):
+            return False;
+    return True;
+
+def whichTools(tools, paths):
+    for path in paths.split(os.pathsep):
+        if checkToolsPath(path, tools):
+            return path
+    return None
+
 def printHistogram(items, title = 'Items'):
     import itertools, math