From 87b8965080693f084e5784efde234b127711d8c1 Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Mon, 26 Jul 2021 16:19:37 -0700 Subject: 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 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 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 --- configure.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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. -- cgit v1.2.1 From b5fa2d589cd12b34019b8fbc27280ae75635cf2c Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Wed, 9 Mar 2022 13:33:26 -1000 Subject: Fix function and parameter names, and comment --- configure.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.py b/configure.py index fcc987c..510a702 100755 --- a/configure.py +++ b/configure.py @@ -305,15 +305,15 @@ 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.""" +def search_system_path(file_name): + """Find a file in the system path.""" for dir in os.environ['path'].split(';'): - path = os.path.join(dir, exe_name) + path = os.path.join(dir, file_name) if os.path.exists(path): return path if platform.is_msvc(): - if not SearchPath('cl.exe'): + if not search_system_path('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. -- cgit v1.2.1