0

Android: Add a depfile to bytecode_processor.py and rename it

New name: check_for_missing_direct_deps.py

Bug: 40748103
Change-Id: I667d3de8c5b32cd5f34ec5a1b49ae098b5a95470
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6108094
Reviewed-by: Peter Wen <wnwen@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1399307}
This commit is contained in:
Andrew Grieve
2024-12-20 11:39:42 -08:00
committed by Chromium LUCI CQ
parent 266fb3313d
commit acac4244d3
5 changed files with 28 additions and 21 deletions

@ -2244,9 +2244,9 @@ _GENERIC_PYDEPS_FILES = [
'build/android/gyp/apkbuilder.pydeps',
'build/android/gyp/assert_static_initializers.pydeps',
'build/android/gyp/binary_baseline_profile.pydeps',
'build/android/gyp/bytecode_processor.pydeps',
'build/android/gyp/bytecode_rewriter.pydeps',
'build/android/gyp/check_flag_expectations.pydeps',
'build/android/gyp/check_for_missing_direct_deps.pydeps',
'build/android/gyp/compile_java.pydeps',
'build/android/gyp/compile_kt.pydeps',
'build/android/gyp/compile_resources.pydeps',

@ -2,8 +2,7 @@
# Copyright 2017 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Wraps bin/helper/bytecode_processor and expands @FileArgs."""
"""Checks for incomplete direct deps."""
import argparse
import collections
@ -237,7 +236,7 @@ def _PrintAndMaybeExit(
def main(argv):
build_utils.InitLogging('BYTECODE_PROCESSOR_DEBUG')
build_utils.InitLogging('MISSING_DEPS_DEBUG')
argv = build_utils.ExpandFileArgs(argv[1:])
parser = argparse.ArgumentParser()
parser.add_argument('--target-name', help='Fully qualified GN target name.')
@ -251,6 +250,7 @@ def main(argv):
parser.add_argument('--full-classpath-jars')
parser.add_argument('--full-classpath-gn-targets')
parser.add_argument('--chromium-output-dir')
parser.add_argument('--depfile')
parser.add_argument('--stamp')
parser.add_argument('--warnings-as-errors',
action='store_true',
@ -262,12 +262,6 @@ def main(argv):
'BUILD.gn file.')
args = parser.parse_args(argv)
if server_utils.MaybeRunCommand(name=args.target_name,
argv=sys.argv,
stamp_file=args.stamp,
use_build_server=args.use_build_server):
return
args.sdk_classpath_jars = action_helpers.parse_gn_list(
args.sdk_classpath_jars)
args.direct_classpath_jars = action_helpers.parse_gn_list(
@ -279,6 +273,17 @@ def main(argv):
for t in action_helpers.parse_gn_list(args.full_classpath_gn_targets)
]
# No need to rebuild if full_classpath_jars change and direct_classpath_jars
# do not.
depfile_deps = args.direct_classpath_jars + args.sdk_classpath_jars
action_helpers.write_depfile(args.depfile, args.stamp, depfile_deps)
if server_utils.MaybeRunCommand(name=args.target_name,
argv=sys.argv,
stamp_file=args.stamp,
use_build_server=args.use_build_server):
return
logging.info('Processed args for %s, starting direct classpath check.',
args.target_name)
_EnsureDirectClasspathIsComplete(
@ -293,8 +298,7 @@ def main(argv):
auto_add_deps=args.auto_add_deps)
logging.info('Check completed.')
if args.stamp:
build_utils.Touch(args.stamp)
build_utils.Touch(args.stamp)
if __name__ == '__main__':

@ -1,5 +1,5 @@
# Generated by running:
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/bytecode_processor.pydeps build/android/gyp/bytecode_processor.py
# build/print_python_deps.py --root build/android/gyp --output build/android/gyp/check_for_missing_direct_deps.pydeps build/android/gyp/check_for_missing_direct_deps.py
../../../third_party/catapult/devil/devil/__init__.py
../../../third_party/catapult/devil/devil/android/__init__.py
../../../third_party/catapult/devil/devil/android/constants/__init__.py
@ -17,7 +17,7 @@
../list_java_targets.py
../pylib/__init__.py
../pylib/constants/__init__.py
bytecode_processor.py
check_for_missing_direct_deps.py
util/__init__.py
util/build_utils.py
util/dep_utils.py

@ -2280,10 +2280,10 @@ def main(argv):
tested_apk_config['javac_full_classpath_targets']):
jar_to_target[jar] = target
# Used by bytecode_processor to give better error message when missing
# deps are found. Both javac_full_classpath_targets and javac_full_classpath
# must be in identical orders, as they get passed as separate arrays and
# then paired up based on index.
# Used by check_for_missing_direct_deps.py to give better error message
# when missing deps are found. Both javac_full_classpath_targets and
# javac_full_classpath must be in identical orders, as they get passed as
# separate arrays and then paired up based on index.
config['deps_info']['javac_full_classpath_targets'] = [
jar_to_target[x] for x in deps_info['javac_full_classpath']
]

@ -1889,21 +1889,24 @@ if (enable_java_templates) {
}
}
template("bytecode_processor") {
template("check_for_missing_direct_deps") {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
TESTONLY_AND_VISIBILITY + [
"data_deps",
"deps",
])
script = "//build/android/gyp/bytecode_processor.py"
script = "//build/android/gyp/check_for_missing_direct_deps.py"
inputs = java_paths_for_inputs + [
invoker.build_config,
invoker.input_jar,
]
depfile = "$target_gen_dir/$target_name.d"
outputs = [ "$target_out_dir/$target_name.bytecode.stamp" ]
_rebased_build_config = rebase_path(invoker.build_config, root_build_dir)
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--target-name",
get_label_info(":${target_name}", "label_no_toolchain"),
"--gn-target=${invoker.target_label}",
@ -4134,7 +4137,7 @@ if (enable_java_templates) {
android_static_analysis != "off"
if (_enable_bytecode_checks) {
_validate_target_name = "${target_name}__validate"
bytecode_processor(_validate_target_name) {
check_for_missing_direct_deps(_validate_target_name) {
forward_variables_from(invoker, [ "missing_classes_allowlist" ])
deps = _unprocessed_jar_deps + _javac_classpath_deps +
[ ":$_build_config_target_name" ]