From 13f6ecbbbb132e471ed2dda5e7d0aba5c7061249 Mon Sep 17 00:00:00 2001 From: Stephanie Kim Date: Wed, 24 Apr 2024 16:41:26 +0000 Subject: [PATCH] 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//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//gn and > buildtools//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 > Commit-Queue: Stephanie Kim Bug: b/328065301 Change-Id: I54a9ae12cb51882e80823ab0c89efa0841025a9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5482565 Commit-Queue: Stephanie Kim Reviewed-by: Joanna Wang --- gn.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gn.py b/gn.py index a56bc97b4..8a4319389 100755 --- a/gn.py +++ b/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//gn to buildtools//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__':