|
|
|
@ -33,22 +33,33 @@ def PruneVirtualEnv():
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def findGnInPath():
|
|
|
|
|
# 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():
|
|
|
|
|
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
|
|
|
|
|
gn_path = os.path.join(bin_dir, exe)
|
|
|
|
|
if os.path.isfile(gn_path):
|
|
|
|
|
return gn_path
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
@ -63,29 +74,35 @@ def main(args):
|
|
|
|
|
# downloaded by cipd in the projects DEPS.
|
|
|
|
|
primary_solution_path = gclient_paths.GetPrimarySolutionPath()
|
|
|
|
|
if primary_solution_path:
|
|
|
|
|
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:])
|
|
|
|
|
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:])
|
|
|
|
|
|
|
|
|
|
# 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 = findGnInPath()
|
|
|
|
|
if gn_path:
|
|
|
|
|
return subprocess.call([gn_path] + args[1:])
|
|
|
|
|
gn_path_options = findGnOptionsInPath()
|
|
|
|
|
for path in gn_path_options:
|
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
return subprocess.call([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
|
|
|
|
|
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:])
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|