From: NAKAMURA Takumi Date: Wed, 9 Feb 2011 04:19:06 +0000 (+0000) Subject: lit/Util.py: Add two functions, checkToolsPath(dir,tools) and whichTools(tools,paths). X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=df944f1f83420b44e3a41d379c361b797c827b42;p=oota-llvm.git lit/Util.py: Add two functions, checkToolsPath(dir,tools) and whichTools(tools,paths). 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 --- diff --git a/utils/lit/lit/Util.py b/utils/lit/lit/Util.py index 414b714c82c..ad4adf2f347 100644 --- a/utils/lit/lit/Util.py +++ b/utils/lit/lit/Util.py @@ -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