浏览代码

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 年之前
父节点
当前提交
a0cf432171
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      ninja.py

+ 2 - 2
ninja.py

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