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

This is a reland of commit df8c52a549

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>
changes/65/5482565/7
Stephanie Kim 1 year ago committed by LUCI CQ
parent 85e409e69a
commit 13f6ecbbbb

18
gn.py

@ -80,12 +80,18 @@ def main(args):
'path.\nThis must be run inside a checkout.',
file=sys.stderr)
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__':

Loading…
Cancel
Save