Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: native_client_sdk/src/tools/oshelpers.py

Issue 12220085: [NaCl SDK] Print nice error if host build can't find gcc or cl.exe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/tools/oshelpers.py
diff --git a/native_client_sdk/src/tools/oshelpers.py b/native_client_sdk/src/tools/oshelpers.py
index e9655a2d9faecda91b2a8a14a20acbef156f092a..0cfebc072b9531ea7b805d5b124b9df7ac9a7142 100755
--- a/native_client_sdk/src/tools/oshelpers.py
+++ b/native_client_sdk/src/tools/oshelpers.py
@@ -469,12 +469,50 @@ def Zip(args):
return 0
+def Which(args):
+ """A Unix style which.
+
+ Looks for all arguments in the PATH environment variable, and prints their
+ path if they are executable files.
+
+ Note: If you pass an argument with a path to which, it will just test if it
+ is executable, not if it is in the path.
+ """
+ parser = optparse.OptionParser(usage='usage: which args...')
+ _, files = parser.parse_args(args)
+ if files == 0:
+ return
+
+ env_path = os.environ.get('PATH', '')
+ paths = env_path.split(os.pathsep)
+
+ def IsExecutableFile(path):
+ return os.path.isfile(path) and os.access(path, os.X_OK)
+
+ retval = 0
+ for filename in files:
+ if os.path.sep in filename:
+ if IsExecutableFile(filename):
+ print filename
+ continue
+
+ for path in paths:
+ filepath = os.path.join(path, filename)
+ if IsExecutableFile(filepath):
+ print os.path.abspath(os.path.join(path, filename))
+ break
+ else:
+ retval = 1
+ return retval
+
+
FuncMap = {
'cp': Copy,
'mkdir': Mkdir,
'mv': Move,
'rm': Remove,
'zip': Zip,
+ 'which': Which,
}

Powered by Google App Engine
This is Rietveld 408576698