blob: bed53576ac279cc944d6e531cb8a750b714a2e9d [file] [log] [blame]
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""The `depot_tools` module provides safe functions to access paths within
the depot_tools repo."""
import contextlib
from recipe_engine import recipe_api
class DepotToolsApi(recipe_api.RecipeApi):
def download_from_google_storage_path(self):
return self.repo_resource('')
def upload_to_google_storage_path(self):
return self.repo_resource('')
def root(self):
"""Returns (Path): The "depot_tools" root directory."""
return self.repo_resource()
def cros_path(self):
return self.repo_resource('cros')
def gn_py_path(self):
return self.repo_resource('')
# TODO(dnj): Remove this once everything uses the "gsutil" recipe module
# version.
def gsutil_py_path(self):
return self.repo_resource('')
def ninja_path(self):
ninja_exe = 'ninja.exe' if self.m.platform.is_win else 'ninja'
return self.repo_resource(ninja_exe)
def autoninja_path(self):
autoninja = 'autoninja.bat' if self.m.platform.is_win else 'autoninja'
return self.repo_resource(autoninja)
def presubmit_support_py_path(self):
return self.repo_resource('')
def on_path(self):
"""Use this context manager to put depot_tools on $PATH.
with api.depot_tools.on_path():
# run some steps
# On buildbot we have to put this on the FRONT of path, to combat the
# 'automatic' depot_tools. However, on LUCI, there is no automatic
# depot_tools, so it's safer to put it at the END of path, where it won't
# accidentally override e.g. python, vpython, etc.
key = 'env_prefixes'
if self.m.runtime.is_luci:
key = 'env_suffixes'
# By default Depot Tools do not auto update on the bots.
# (crbug/1090603)
with self.m.context(**{key: {'PATH': [self.root],