Browse Source

Tweak ninja fallback logic

In Skia (for example), GetPrimarySolutionPath works, but FindGclientRoot
does not (users tend not to use gclient to sync DEPS, etc).

Without this change, we'd get to the loop. If a user had pulled ninja to
third_party/ninja/ninja, then it would work just fine. If they hadn't,
python would throw an exception on the os.path.join line, because we'd
be passing a NoneType as the first argument.

Bug: chromium:1340825
Change-Id: Iab86450c5b6f00bc9c2716b9504debc9a56d9bb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4034942
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Nico Weber <thakis@chromium.org>
Brian Osman 2 years ago
parent
commit
a0cf432171
1 changed files with 2 additions and 2 deletions
  1. 2 2
      ninja.py

+ 2 - 2
ninja.py

@@ -69,10 +69,10 @@ def fallback(ninja_args):
 def main(args):
   # Get gclient root + src.
   primary_solution_path = gclient_paths.GetPrimarySolutionPath()
-  if not primary_solution_path:
-    return fallback(args[1:])
   gclient_root_path = gclient_paths.FindGclientRoot(os.getcwd())
   for base_path in [primary_solution_path, gclient_root_path]:
+    if not base_path:
+      continue
     ninja_path = os.path.join(base_path, 'third_party', 'ninja',
                               'ninja' + gclient_paths.GetExeSuffix())
     if os.path.isfile(ninja_path):