summaryrefslogtreecommitdiffstats
path: root/configure.py
diff options
context:
space:
mode:
authorBruce Dawson <brucedawson@chromium.org>2021-07-26 23:19:37 (GMT)
committerBruce Dawson <brucedawson@chromium.org>2021-07-26 23:19:37 (GMT)
commit87b8965080693f084e5784efde234b127711d8c1 (patch)
tree1c03d92665a229c3e4b1c6273bf3a74812618838 /configure.py
parent3907862a6b2c0dd1c39cc26313c738fcad0769ac (diff)
downloadNinja-87b8965080693f084e5784efde234b127711d8c1.zip
Ninja-87b8965080693f084e5784efde234b127711d8c1.tar.gz
Ninja-87b8965080693f084e5784efde234b127711d8c1.tar.bz2
Improve error messages when VS cannot be found
The first experience for most developers who start working on ninja is this cryptic error message: bootstrapping ninja... Traceback (most recent call last): File "configure.py", line 329, in <module> if platform.msvc_needs_fs(): File "configure.py", line 89, in msvc_needs_fs stderr=subprocess.PIPE) File "python\bin\lib\subprocess.py", line 394, in __init__ errread, errwrite) File "python\bin\lib\subprocess.py", line 644, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified This message happens when bootstrap.py first tries to invoke cl.exe and it cannot be found. This change looks for cl.exe and warns if it is not in the user's path, leading to this friendlier message: bootstrapping ninja... Traceback (most recent call last): File "configure.py", line 317, in <module> raise Exception('cl.exe not found. Run again from the Developer Command Prompt for VS') Exception: cl.exe not found. Run again from the Developer Command Prompt for VS
Diffstat (limited to 'configure.py')
-rwxr-xr-xconfigure.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/configure.py b/configure.py
index 4ca78fb..c0d6712 100755
--- a/configure.py
+++ b/configure.py
@@ -305,7 +305,16 @@ if platform.is_msvc():
else:
n.variable('ar', configure_env.get('AR', 'ar'))
+def SearchPath(exe_name):
+ """Find an executable (.exe, .bat, whatever) in the system path."""
+ for dir in os.environ['path'].split(';'):
+ path = os.path.join(dir, exe_name)
+ if os.path.exists(path):
+ return path
+
if platform.is_msvc():
+ if not SearchPath('cl.exe'):
+ raise Exception('cl.exe not found. Run again from the Developer Command Prompt for VS')
cflags = ['/showIncludes',
'/nologo', # Don't print startup banner.
'/Zi', # Create pdb with debug info.