浏览代码

Reland "[depot_tools] Support both gn paths in gn.py"

This is a reland of commit df8c52a5490967bc4ad1fd63fed3f08e4b757a1a

Whats changed:
- Only edit the paths created after GetBuildtoolsPlatformBinaryPath()
- Fixed paths (the new paths needed an extra 'gn')
- Check if path isfile(), since the old buildtools/<platform>/gn will
still exist but becomes a directory

Verified locally with buildtools/linux64/gn/gn and
buildtools/linux64/gn

Original change's description:
> [depot_tools] Support both gn paths in gn.py
>
> Build in support for both buildtools/<platform>/gn and
> buildtools/<platform>/gn/gn preemptively.
> This will allow the libfuzzer builders in https://chromium-review.googlesource.com/c/chromium/src/+/5474162 to succeed.
>
> Bug: b/328065301
> Change-Id: I97b401cb1b3339cfa7962f60b891be05baac75d5
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5479888
> Reviewed-by: Joanna Wang <jojwang@chromium.org>
> Commit-Queue: Stephanie Kim <kimstephanie@google.com>

Bug: b/328065301
Change-Id: I54a9ae12cb51882e80823ab0c89efa0841025a9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5482565
Commit-Queue: Stephanie Kim <kimstephanie@google.com>
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Stephanie Kim 1 年之前
父节点
当前提交
13f6ecbbbb
共有 1 个文件被更改,包括 12 次插入6 次删除
  1. 12 6
      gn.py

+ 12 - 6
gn.py

@@ -80,12 +80,18 @@ def main(args):
             'path.\nThis must be run inside a checkout.',
             'path.\nThis must be run inside a checkout.',
             file=sys.stderr)
             file=sys.stderr)
         return 1
         return 1
-    gn_path = os.path.join(bin_path, 'gn' + gclient_paths.GetExeSuffix())
-    if not os.path.exists(gn_path):
-        print('gn.py: Could not find gn executable at: %s' % gn_path,
-              file=sys.stderr)
-        return 2
-    return subprocess.call([gn_path] + args[1:])
+    # TODO(b/328065301): Once chromium/src CL has landed to migrate
+    # buildtools/<platform>/gn to buildtools/<platform>/gn/gn, only return
+    # gn/gn path.
+    old_gn_path = os.path.join(bin_path, 'gn' + gclient_paths.GetExeSuffix())
+    new_gn_path = os.path.join(bin_path, 'gn',
+                               'gn' + gclient_paths.GetExeSuffix())
+    paths = [new_gn_path, old_gn_path]
+    for path in paths:
+        if os.path.isfile(path):
+            return subprocess.call([path] + args[1:])
+    print('gn.py: Could not find gn executable at: %s' % paths, file=sys.stderr)
+    return 2
 
 
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':