mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Update "cit" tool to use vpython instead of run.py.
Note that this can't be submitted until the infra "cit" branch has been bumped to at least https://crrev.com/c/3041136. See https://crbug.com/1236862 for details. Bug: 1229907 Change-Id: I331cdd5d0ce35fb23e4634e125c462a7ed19e837 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3071511 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Owen Rodley <orodley@chromium.org>
This commit is contained in:
28
cit.py
28
cit.py
@@ -91,11 +91,11 @@ def get_available_tools():
|
|||||||
"""Returns a tuple of (list of infra tools, list of cipd tools)"""
|
"""Returns a tuple of (list of infra tools, list of cipd tools)"""
|
||||||
infra_tools = []
|
infra_tools = []
|
||||||
cipd_tools = []
|
cipd_tools = []
|
||||||
starting = os.path.join(TARGET_DIR, 'infra', 'infra', 'tools')
|
starting = os.path.join(INFRA_DIR, 'infra', 'tools')
|
||||||
for root, _, files in os.walk(starting):
|
for root, _, files in os.walk(starting):
|
||||||
if '__main__.py' in files:
|
if '__main__.py' in files:
|
||||||
infra_tools.append(root[len(starting)+1:].replace(os.path.sep, '.'))
|
infra_tools.append(root[len(starting)+1:].replace(os.path.sep, '.'))
|
||||||
cipd = os.path.join(TARGET_DIR, 'infra', 'cipd')
|
cipd = os.path.join(INFRA_DIR, 'cipd')
|
||||||
for fn in os.listdir(cipd):
|
for fn in os.listdir(cipd):
|
||||||
if is_exe(os.path.join(cipd, fn)):
|
if is_exe(os.path.join(cipd, fn)):
|
||||||
cipd_tools.append(fn)
|
cipd_tools.append(fn)
|
||||||
@@ -107,7 +107,7 @@ def usage():
|
|||||||
print("""usage: cit.py <name of tool> [args for tool]
|
print("""usage: cit.py <name of tool> [args for tool]
|
||||||
|
|
||||||
Wrapper for maintaining and calling tools in:
|
Wrapper for maintaining and calling tools in:
|
||||||
"infra.git/run.py infra.tools.*"
|
"infra.git, infra.tools.*"
|
||||||
"infra.git/cipd/*"
|
"infra.git/cipd/*"
|
||||||
|
|
||||||
Available infra tools are:""")
|
Available infra tools are:""")
|
||||||
@@ -124,18 +124,24 @@ def run(args):
|
|||||||
if not args:
|
if not args:
|
||||||
return usage()
|
return usage()
|
||||||
|
|
||||||
|
env = os.environ
|
||||||
tool_name = args[0]
|
tool_name = args[0]
|
||||||
# Check to see if it is a infra tool first.
|
# Check to see if it is a infra tool first.
|
||||||
infra_dir = os.path.join(
|
tool_dir = os.path.join(
|
||||||
TARGET_DIR, 'infra', 'infra', 'tools', *tool_name.split('.'))
|
INFRA_DIR, 'infra', 'tools', *tool_name.split('.'))
|
||||||
cipd_file = os.path.join(TARGET_DIR, 'infra', 'cipd', tool_name)
|
cipd_file = os.path.join(INFRA_DIR, 'cipd', tool_name)
|
||||||
if sys.platform.startswith('win'):
|
if sys.platform.startswith('win'):
|
||||||
cipd_file += '.exe'
|
cipd_file += '.exe'
|
||||||
if (os.path.isdir(infra_dir)
|
if (os.path.isdir(tool_dir)
|
||||||
and os.path.isfile(os.path.join(infra_dir, '__main__.py'))):
|
and os.path.isfile(os.path.join(tool_dir, '__main__.py'))):
|
||||||
cmd = [
|
cmd = [
|
||||||
sys.executable, os.path.join(TARGET_DIR, 'infra', 'run.py'),
|
'vpython', '-vpython-spec', os.path.join(INFRA_DIR, '.vpython'),
|
||||||
'infra.tools.%s' % tool_name]
|
'-m', 'infra.tools.%s' % tool_name]
|
||||||
|
|
||||||
|
# Augment PYTHONPATH so that infra.tools.<tool_name> can be found without
|
||||||
|
# running from that directory, which would mess up any relative paths passed
|
||||||
|
# to the tool.
|
||||||
|
env['PYTHONPATH'] = INFRA_DIR + os.pathsep + env['PYTHONPATH']
|
||||||
elif os.path.isfile(cipd_file) and is_exe(cipd_file):
|
elif os.path.isfile(cipd_file) and is_exe(cipd_file):
|
||||||
cmd = [cipd_file]
|
cmd = [cipd_file]
|
||||||
else:
|
else:
|
||||||
@@ -144,7 +150,7 @@ def run(args):
|
|||||||
|
|
||||||
# Add the remaining arguments.
|
# Add the remaining arguments.
|
||||||
cmd.extend(args[1:])
|
cmd.extend(args[1:])
|
||||||
return subprocess.call(cmd)
|
return subprocess.call(cmd, env=env)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user