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

This reverts commit df8c52a549.

Reason for revert: Found bugs

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: I2480e587ce314f7856edc7011fed945e01924371
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5482563
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Stephanie Kim <kimstephanie@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
changes/63/5482563/2
Stephanie Kim 10 months ago committed by LUCI CQ
parent df8c52a549
commit b0e9b98aef

51
gn.py

@ -33,33 +33,22 @@ def PruneVirtualEnv():
])
# TODO(b/328065301): Once chromium/src CL has landed to migrate
# buildtools/<platform>/gn to buildtools/<platform>/gn/gn, only return
# gn/gn path.
def findGnOptionsInPath():
def findGnInPath():
env_path = os.getenv('PATH')
if not env_path:
return
exe = 'gn'
if sys.platform in ('win32', 'cygwin'):
exe += '.exe'
path_options = []
for bin_dir in env_path.split(os.pathsep):
if bin_dir.rstrip(os.sep).endswith('depot_tools'):
# skip depot_tools to avoid calling gn.py infinitely.
continue
for path in [
os.path.join(bin_dir, 'gn', exe),
os.path.join(bin_dir, exe),
]:
if os.path.isfile(path):
path_options.append(path)
return path_options
gn_path = os.path.join(bin_dir, exe)
if os.path.isfile(gn_path):
return gn_path
# TODO(b/328065301): Once chromium/src CL has landed to migrate
# buildtools/<platform>/gn to buildtools/<platform>/gn/gn, only return
# gn/gn path.
def main(args):
# Prune all evidence of VPython/VirtualEnv out of the environment. This
# means that we 'unwrap' vpython VirtualEnv path/env manipulation.
@ -74,35 +63,29 @@ def main(args):
# downloaded by cipd in the projects DEPS.
primary_solution_path = gclient_paths.GetPrimarySolutionPath()
if primary_solution_path:
old_gn_path = os.path.join(primary_solution_path, 'third_party',
'gn' + gclient_paths.GetExeSuffix())
new_gn_path = os.path.join(primary_solution_path, 'third_party', 'gn',
'gn' + gclient_paths.GetExeSuffix())
for path in [new_gn_path, old_gn_path]:
if os.path.exists(path):
return subprocess.call([path] + args[1:])
gn_path = os.path.join(primary_solution_path, 'third_party', 'gn',
'gn' + gclient_paths.GetExeSuffix())
if os.path.exists(gn_path):
return subprocess.call([gn_path] + args[1:])
# Otherwise try the old .sha1 and download_from_google_storage locations
# inside of buildtools.
bin_path = gclient_paths.GetBuildtoolsPlatformBinaryPath()
if not bin_path:
gn_path_options = findGnOptionsInPath()
for path in gn_path_options:
if os.path.exists(path):
return subprocess.call([path] + args[1:])
gn_path = findGnInPath()
if gn_path:
return subprocess.call([gn_path] + args[1:])
print(
'gn.py: Could not find checkout in any parent of the current '
'path.\nThis must be run inside a checkout.',
file=sys.stderr)
return 1
old_gn_path = os.path.join(bin_path, gclient_paths.GetExeSuffix())
new_gn_path = os.path.join(bin_path, 'gn', gclient_paths.GetExeSuffix())
paths = [new_gn_path, old_gn_path]
for path in paths:
if os.path.exists(path):
return subprocess.call([path] + args[1:])
print('gn.py: Could not find gn executable at: %s' % paths, file=sys.stderr)
return 2
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:])
if __name__ == '__main__':

Loading…
Cancel
Save