0

[build/android] Replace references to third_party/depot_tools/{ninja, gn}

ninja and gn are installed by DEPS. Calling them directly is better than using depot_tools/{ninja, gn} wrappers.

Bug: 1338373
Change-Id: I4097c01e0ddfc63a4745a809c083086e418014f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4060328
Auto-Submit: Junji Watanabe <jwata@google.com>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1076192}
This commit is contained in:
Junji Watanabe
2022-11-28 14:29:05 +00:00
committed by Chromium LUCI CQ
parent 9f819fae56
commit fca672cdbb
3 changed files with 18 additions and 10 deletions

@@ -13,10 +13,10 @@ import sys
from util import build_utils
_CHROMIUM_SRC = os.path.normpath(os.path.join(__file__, '..', '..', '..', '..'))
_NINJA_PATH = os.path.join(_CHROMIUM_SRC, 'third_party', 'depot_tools', 'ninja')
_NINJA_PATH = os.path.join(_CHROMIUM_SRC, 'third_party', 'ninja', 'ninja')
# Relative to _CHROMIUM_SRC
_GN_SRC_REL_PATH = os.path.join('third_party', 'depot_tools', 'gn')
_GN_SRC_REL_PATH = os.path.join('buildtools', 'linux64', 'gn')
# Regex for determining whether compile failed because 'gn gen' needs to be run.
_GN_GEN_REGEX = re.compile(r'ninja: (error|fatal):')

@@ -54,17 +54,25 @@ _VALID_TYPES = (
)
def _resolve_ninja(cmd):
def _resolve_ninja():
# Prefer the version on PATH, but fallback to known version if PATH doesn't
# have one (e.g. on bots).
if shutil.which(cmd) is None:
return os.path.join(_SRC_ROOT, 'third_party', 'depot_tools', cmd)
return cmd
if shutil.which('ninja') is None:
return os.path.join(_SRC_ROOT, 'third_party', 'ninja', 'ninja')
return 'ninja'
def _resolve_autoninja():
# Prefer the version on PATH, but fallback to known version if PATH doesn't
# have one (e.g. on bots).
if shutil.which('autoninja') is None:
return os.path.join(_SRC_ROOT, 'third_party', 'depot_tools', 'autoninja')
return 'autoninja'
def _run_ninja(output_dir, args, quiet=False):
cmd = [
_resolve_ninja('autoninja'),
_resolve_autoninja(),
'-C',
output_dir,
]
@@ -80,7 +88,7 @@ def _query_for_build_config_targets(output_dir):
# Query ninja rather than GN since it's faster.
# Use ninja rather than autoninja to avoid extra output if user has set the
# NINJA_SUMMARIZE_BUILD environment variable.
cmd = [_resolve_ninja('ninja'), '-C', output_dir, '-t', 'targets']
cmd = [_resolve_ninja(), '-C', output_dir, '-t', 'targets']
logging.info('Running: %r', cmd)
ninja_output = subprocess.run(cmd,
check=True,

@@ -16,10 +16,10 @@ import subprocess
import shutil
_CHROMIUM_SRC = pathlib.Path(__file__).resolve().parents[4].resolve()
_NINJA_PATH = _CHROMIUM_SRC / 'third_party' / 'depot_tools' / 'ninja'
_NINJA_PATH = _CHROMIUM_SRC / 'third_party' / 'ninja' / 'ninja'
# Relative to _CHROMIUM_SRC
_GN_SRC_REL_PATH = 'third_party/depot_tools/gn'
_GN_SRC_REL_PATH = 'buildtools/linux64/gn'
_USING_PARTIAL_JAVAC_MSG = 'Using partial javac optimization'