summaryrefslogtreecommitdiffstats
path: root/chromium/build/android/gyp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2024-01-26 13:38:42 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2024-02-22 12:48:48 +0000
commitada9ddbf8c604585ac344b72f7bb63ac27c84726 (patch)
treeb541471f60775e79ce2a664f01f2cff4765dc6b2 /chromium/build/android/gyp
parentbccd0c89f058482e730b73829d80bb6e8defa4c9 (diff)
BASELINE: Update Chromium to 120.0.6099.272
Change-Id: Id1e3f32155016fcdca5b92e1739d85c6093bcf84 Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/534618 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/build/android/gyp')
-rwxr-xr-xchromium/build/android/gyp/bytecode_processor.py145
-rw-r--r--chromium/build/android/gyp/bytecode_processor.pydeps9
-rwxr-xr-xchromium/build/android/gyp/compile_java.py22
-rwxr-xr-xchromium/build/android/gyp/compile_resources.py15
-rwxr-xr-xchromium/build/android/gyp/dex.py30
-rwxr-xr-xchromium/build/android/gyp/java_cpp_enum.py5
-rwxr-xr-xchromium/build/android/gyp/javac_output_processor.py30
-rwxr-xr-xchromium/build/android/gyp/lint.py45
-rwxr-xr-xchromium/build/android/gyp/nocompile_test.py9
-rwxr-xr-xchromium/build/android/gyp/proguard.py17
-rwxr-xr-xchromium/build/android/gyp/trace_event_bytecode_rewriter.py18
-rwxr-xr-xchromium/build/android/gyp/turbine.py8
-rw-r--r--chromium/build/android/gyp/util/build_utils.py3
-rw-r--r--chromium/build/android/gyp/util/dep_utils.py32
-rw-r--r--chromium/build/android/gyp/util/server_utils.py6
-rwxr-xr-xchromium/build/android/gyp/write_build_config.py20
-rwxr-xr-xchromium/build/android/gyp/write_native_libraries_java.py12
17 files changed, 189 insertions, 237 deletions
diff --git a/chromium/build/android/gyp/bytecode_processor.py b/chromium/build/android/gyp/bytecode_processor.py
index 620ae5458d3..e0c84de6bcc 100755
--- a/chromium/build/android/gyp/bytecode_processor.py
+++ b/chromium/build/android/gyp/bytecode_processor.py
@@ -7,10 +7,9 @@
import argparse
import collections
-import json
import logging
-import os
import pathlib
+import shlex
import sys
from typing import Dict, List, Tuple
@@ -21,17 +20,8 @@ from util import server_utils
import action_helpers # build_utils adds //build to sys.path.
_SRC_PATH = pathlib.Path(build_utils.DIR_SOURCE_ROOT).resolve()
-sys.path.append(str(_SRC_PATH / 'tools/android/modularization/gn'))
-from dep_operations import NO_VALID_GN_STR
-
-
-# This is a temporary constant to make reverts easier (if necessary).
-# TODO(crbug.com/1099522): Remove this and make jdeps on by default.
-_USE_JDEPS = True
-
-# This is temporary in case another revert & debug session is necessary.
-# TODO(crbug.com/1099522): Remove this when jdeps is on by default.
-_DEBUG = False
+sys.path.append(str(_SRC_PATH / 'build/gn_ast'))
+from gn_editor import NO_VALID_GN_STR
def _ShouldIgnoreDep(dep_name: str):
@@ -66,20 +56,7 @@ def _ParseDepGraph(jar_path: str):
dep_from = parsed[0]
dep_to = parsed[2]
dep_graph[dep_from].add(dep_to)
- return dep_graph, output
-
-
-def _GnTargetToBuildFilePath(gn_target: str):
- """Returns the relative BUILD.gn file path for this target from src root."""
- assert gn_target.startswith('//'), f'Relative {gn_target} name not supported.'
- ninja_target_name = gn_target[2:]
-
- # Remove the colon at the end
- colon_index = ninja_target_name.find(':')
- if colon_index != -1:
- ninja_target_name = ninja_target_name[:colon_index]
-
- return os.path.join(ninja_target_name, 'BUILD.gn')
+ return dep_graph
def _EnsureDirectClasspathIsComplete(
@@ -118,7 +95,7 @@ def _EnsureDirectClasspathIsComplete(
transitive_deps = full_classpath_deps - direct_classpath_deps
missing_classes: Dict[str, str] = {}
- dep_graph, output = _ParseDepGraph(input_jar)
+ dep_graph = _ParseDepGraph(input_jar)
logging.info('Finding missing deps from %d classes', len(dep_graph))
# dep_graph.keys() is a list of all the classes in the current input_jar. Skip
# all of these to avoid checking dependencies in the same target (e.g. A
@@ -139,6 +116,17 @@ def _EnsureDirectClasspathIsComplete(
# missing_target_names = tuple(sorted(dep_to_target[dep_to]))
# missing_targets[missing_target_names][dep_to] = dep_from
if missing_classes:
+ class_lookup_index = dep_utils.ClassLookupIndex(pathlib.Path(output_dir),
+ should_build=False)
+ missing_deps = set()
+ for dep_to in missing_classes:
+ # Using dep_utils.ClassLookupIndex ensures we respect the preferred dep
+ # if any exists for the missing deps.
+ suggested_deps = class_lookup_index.match(dep_to)
+ assert suggested_deps, f'Unable to find target for {dep_to}'
+ suggested_deps = dep_utils.DisambiguateDeps(suggested_deps)
+ missing_deps.add(suggested_deps[0].target)
+ cmd = dep_utils.CreateAddDepsCommand(gn_target, sorted(missing_deps))
def print_and_maybe_exit():
missing_targets: Dict[Tuple, List[str]] = collections.defaultdict(list)
@@ -156,48 +144,16 @@ def _EnsureDirectClasspathIsComplete(
for dep_to in deps_to:
dep_from = missing_classes[dep_to]
print(f' ** {dep_to} (needed by {dep_from})')
- if _DEBUG:
- gn_target_name = gn_target.split(':', 1)[-1]
- debug_fname = f'/tmp/bytecode_processor_debug_{gn_target_name}.json'
- with open(debug_fname, 'w') as f:
- print(gn_target, file=f)
- print(input_jar, file=f)
- print(json.dumps(sorted(sdk_classpath_deps), indent=4), file=f)
- print(json.dumps(sorted(direct_classpath_deps), indent=4), file=f)
- print(json.dumps(sorted(full_classpath_deps), indent=4), file=f)
- print(json.dumps(sorted(transitive_deps), indent=4), file=f)
- print(json.dumps(missing_classes, sort_keys=True, indent=4), file=f)
- print(output, file=f)
- print(f'DEBUG FILE: {debug_fname}')
+ print('\nHint: Run the following command to add the missing deps:')
+ print(f' {shlex.join(cmd)}\n')
if warnings_as_errors:
sys.exit(1)
if not auto_add_deps:
print_and_maybe_exit()
else:
- # Normalize chrome_public_apk__java to chrome_public_apk.
- gn_target = gn_target.split('__', 1)[0]
-
- # TODO(https://crbug.com/1099522): This should be generalized into util.
- build_file_path = _GnTargetToBuildFilePath(gn_target)
- cmd = [
- 'tools/android/modularization/gn/dep_operations.py', 'add', '--quiet',
- '--file', build_file_path, '--target', gn_target, '--deps'
- ]
- class_lookup_index = dep_utils.ClassLookupIndex(pathlib.Path(output_dir),
- should_build=False)
- missing_deps = set()
- for dep_to in missing_classes:
- # Using dep_utils.ClassLookupIndex ensures we respect the preferred dep
- # if any exists for the missing deps.
- suggested_deps = class_lookup_index.match(dep_to)
- assert suggested_deps, f'Unable to find target for {dep_to}'
- suggested_deps = dep_utils.DisambiguateDeps(suggested_deps)
- missing_deps.add(suggested_deps[0].target)
- cmd += missing_deps
failed = False
-
try:
stdout = build_utils.CheckOutput(cmd,
cwd=build_utils.DIR_SOURCE_ROOT,
@@ -212,6 +168,8 @@ def _EnsureDirectClasspathIsComplete(
failed = True
else:
raise
+
+ build_file_path = dep_utils.GnTargetToBuildFilePath(gn_target)
if failed:
print(f'Unable to auto-add missing dep(s) to {build_file_path}.')
print_and_maybe_exit()
@@ -229,8 +187,6 @@ def main(argv):
parser.add_argument('--use-build-server',
action='store_true',
help='Always use the build server.')
- parser.add_argument('--script', required=True,
- help='Path to the java binary wrapper script.')
parser.add_argument('--gn-target', required=True)
parser.add_argument('--input-jar', required=True)
parser.add_argument('--direct-classpath-jars')
@@ -239,8 +195,6 @@ def main(argv):
parser.add_argument('--full-classpath-gn-targets')
parser.add_argument('--chromium-output-dir')
parser.add_argument('--stamp')
- parser.add_argument('-v', '--verbose', action='store_true')
- parser.add_argument('--missing-classes-allowlist')
parser.add_argument('--warnings-as-errors',
action='store_true',
help='Treat all warnings as errors.')
@@ -267,52 +221,21 @@ def main(argv):
dep_utils.ReplaceGmsPackageIfNeeded(t)
for t in action_helpers.parse_gn_list(args.full_classpath_gn_targets)
]
- args.missing_classes_allowlist = action_helpers.parse_gn_list(
- args.missing_classes_allowlist)
-
- verbose = '--verbose' if args.verbose else '--not-verbose'
- # TODO(https://crbug.com/1099522): Make jdeps the default.
- if _USE_JDEPS:
- logging.info('Processed args for %s, starting direct classpath check.',
- args.target_name)
- _EnsureDirectClasspathIsComplete(
- input_jar=args.input_jar,
- gn_target=args.gn_target,
- output_dir=args.chromium_output_dir,
- sdk_classpath_jars=args.sdk_classpath_jars,
- direct_classpath_jars=args.direct_classpath_jars,
- full_classpath_jars=args.full_classpath_jars,
- full_classpath_gn_targets=args.full_classpath_gn_targets,
- warnings_as_errors=args.warnings_as_errors,
- auto_add_deps=args.auto_add_deps,
- )
- logging.info('Check completed.')
- else:
- cmd = [
- args.script, args.gn_target, args.input_jar, verbose, '--not-prebuilt'
- ]
- cmd += [str(len(args.missing_classes_allowlist))]
- cmd += args.missing_classes_allowlist
- cmd += [str(len(args.sdk_classpath_jars))]
- cmd += args.sdk_classpath_jars
- cmd += [str(len(args.direct_classpath_jars))]
- cmd += args.direct_classpath_jars
- cmd += [str(len(args.full_classpath_jars))]
- cmd += args.full_classpath_jars
- cmd += [str(len(args.full_classpath_gn_targets))]
- cmd += args.full_classpath_gn_targets
- try:
- build_utils.CheckOutput(
- cmd,
- print_stdout=True,
- fail_func=None, # type: ignore
- fail_on_output=args.warnings_as_errors)
- except build_utils.CalledProcessError as e:
- # Do not output command line because it is massive and makes the actual
- # error message hard to find.
- sys.stderr.write(e.output)
- sys.exit(1)
+ logging.info('Processed args for %s, starting direct classpath check.',
+ args.target_name)
+ _EnsureDirectClasspathIsComplete(
+ input_jar=args.input_jar,
+ gn_target=args.gn_target,
+ output_dir=args.chromium_output_dir,
+ sdk_classpath_jars=args.sdk_classpath_jars,
+ direct_classpath_jars=args.direct_classpath_jars,
+ full_classpath_jars=args.full_classpath_jars,
+ full_classpath_gn_targets=args.full_classpath_gn_targets,
+ warnings_as_errors=args.warnings_as_errors,
+ auto_add_deps=args.auto_add_deps,
+ )
+ logging.info('Check completed.')
if args.stamp:
build_utils.Touch(args.stamp)
diff --git a/chromium/build/android/gyp/bytecode_processor.pydeps b/chromium/build/android/gyp/bytecode_processor.pydeps
index 78db0c4583b..a729800ece7 100644
--- a/chromium/build/android/gyp/bytecode_processor.pydeps
+++ b/chromium/build/android/gyp/bytecode_processor.pydeps
@@ -9,13 +9,10 @@
../../../third_party/catapult/devil/devil/android/sdk/version_codes.py
../../../third_party/catapult/devil/devil/constants/__init__.py
../../../third_party/catapult/devil/devil/constants/exit_codes.py
-../../../tools/android/modularization/gn/dep_operations.py
-../../../tools/android/modularization/gn/json_gn_editor.py
-../../../tools/android/modularization/gn/utils.py
-../../../tools/android/python_utils/__init__.py
-../../../tools/android/python_utils/git_metadata_utils.py
-../../../tools/android/python_utils/subprocess_utils.py
../../action_helpers.py
+../../gn_ast/gn_editor.py
+../../gn_ast/json_gn_editor.py
+../../gn_ast/utils.py
../../gn_helpers.py
../list_java_targets.py
../pylib/__init__.py
diff --git a/chromium/build/android/gyp/compile_java.py b/chromium/build/android/gyp/compile_java.py
index 56d251033f2..60dfc1c2654 100755
--- a/chromium/build/android/gyp/compile_java.py
+++ b/chromium/build/android/gyp/compile_java.py
@@ -14,7 +14,6 @@ import shutil
import sys
import time
import zipfile
-import pathlib
import javac_output_processor
from util import build_utils
@@ -217,25 +216,15 @@ ERRORPRONE_WARNINGS_TO_ENABLE = [
def ProcessJavacOutput(output, target_name):
# These warnings cannot be suppressed even for third party code. Deprecation
# warnings especially do not help since we must support older android version.
- deprecated_re = re.compile(
- r'(Note: .* uses? or overrides? a deprecated API.)$')
+ deprecated_re = re.compile(r'Note: .* uses? or overrides? a deprecated API')
unchecked_re = re.compile(
r'(Note: .* uses? unchecked or unsafe operations.)$')
recompile_re = re.compile(r'(Note: Recompile with -Xlint:.* for details.)$')
- activity_re = re.compile(r'^(?P<prefix>\s*location: )class Activity$')
-
def ApplyFilters(line):
return not (deprecated_re.match(line) or unchecked_re.match(line)
or recompile_re.match(line))
- def Elaborate(line):
- if activity_re.match(line):
- prefix = ' ' * activity_re.match(line).end('prefix')
- return '{}\n{}Expecting a FragmentActivity? See {}'.format(
- line, prefix, 'docs/ui/android/bytecode_rewriting.md')
- return line
-
output = build_utils.FilterReflectiveAccessJavaWarnings(output)
# Warning currently cannot be silenced via javac flag.
@@ -250,7 +239,6 @@ def ProcessJavacOutput(output, target_name):
output = re.sub(r'\d+ warnings\n', '', output)
lines = (l for l in output.split('\n') if ApplyFilters(l))
- lines = (Elaborate(l) for l in lines)
output_processor = javac_output_processor.JavacOutputProcessor(target_name)
lines = output_processor.Process(lines)
@@ -759,10 +747,9 @@ def main(argv):
javac_args = [
'-g',
- # We currently target JDK 11 everywhere, since Mockito is broken by JDK17.
- # See crbug.com/1409661 for more details.
+ # Jacoco does not currently support a higher value.
'--release',
- '11',
+ '17',
# Chromium only allows UTF8 source files. Being explicit avoids
# javac pulling a default encoding from the user's environment.
'-encoding',
@@ -774,6 +761,9 @@ def main(argv):
# protobuf-generated files fail this check (javadoc has @deprecated,
# but method missing @Deprecated annotation).
'-Xlint:-dep-ann',
+ # Do not warn about finalize() methods. Android still intends to support
+ # them.
+ '-Xlint:-removal',
]
if options.enable_errorprone:
diff --git a/chromium/build/android/gyp/compile_resources.py b/chromium/build/android/gyp/compile_resources.py
index e19e851c0d3..be0db0fbcb5 100755
--- a/chromium/build/android/gyp/compile_resources.py
+++ b/chromium/build/android/gyp/compile_resources.py
@@ -126,6 +126,8 @@ def _ParseArgs(args):
'--debuggable',
action='store_true',
help='Whether to add android:debuggable="true".')
+ input_opts.add_argument('--static-library-version',
+ help='Version code for static library.')
input_opts.add_argument('--version-code', help='Version code for apk.')
input_opts.add_argument('--version-name', help='Version name for apk.')
input_opts.add_argument(
@@ -196,9 +198,6 @@ def _ParseArgs(args):
output_opts.add_argument(
'--proguard-file', help='Path to proguard.txt generated file.')
output_opts.add_argument(
- '--proguard-file-main-dex',
- help='Path to proguard.txt generated file for main dex.')
- output_opts.add_argument(
'--emit-ids-out', help='Path to file produced by aapt2 --emit-ids.')
diff_utils.AddCommandLineFlags(parser)
@@ -227,6 +226,13 @@ def _ParseArgs(args):
if options.package_id and options.shared_resources:
parser.error('--package-id and --shared-resources are mutually exclusive')
+ if options.static_library_version and (options.static_library_version !=
+ options.version_code):
+ assert options.static_library_version == options.version_code, (
+ f'static_library_version={options.static_library_version} must equal '
+ f'version_code={options.version_code}. Please verify the version code '
+ 'map for this target is defined correctly.')
+
return options
@@ -753,8 +759,6 @@ def _PackageApk(options, build):
if options.proguard_file:
link_command += ['--proguard', build.proguard_path]
link_command += ['--proguard-minimal-keep-rules']
- if options.proguard_file_main_dex:
- link_command += ['--proguard-main-dex', build.proguard_main_dex_path]
if options.emit_ids_out:
link_command += ['--emit-ids', build.emit_ids_path]
@@ -894,7 +898,6 @@ def _WriteOutputs(options, build):
(options.arsc_path, build.arsc_path),
(options.proto_path, build.proto_path),
(options.proguard_file, build.proguard_path),
- (options.proguard_file_main_dex, build.proguard_main_dex_path),
(options.emit_ids_out, build.emit_ids_path),
(options.info_path, build.info_path),
]
diff --git a/chromium/build/android/gyp/dex.py b/chromium/build/android/gyp/dex.py
index 221b3fd50c7..ae87291066f 100755
--- a/chromium/build/android/gyp/dex.py
+++ b/chromium/build/android/gyp/dex.py
@@ -61,13 +61,6 @@ def _ParseArgs(args):
parser.add_argument(
'--incremental-dir',
help='Path of directory to put intermediate dex files.')
- parser.add_argument('--main-dex-rules-path',
- action='append',
- help='Path to main dex rules for multidex.')
- parser.add_argument(
- '--multi-dex',
- action='store_true',
- help='Allow multiple dex files within output.')
parser.add_argument('--library',
action='store_true',
help='Allow numerous dex files within output.')
@@ -94,12 +87,9 @@ def _ParseArgs(args):
'--classpath',
action='append',
help='GN-list of full classpath. Needed for --desugar')
- parser.add_argument(
- '--release',
- action='store_true',
- help='Run D8 in release mode. Release mode maximises main dex and '
- 'deletes non-essential line number information (vs debug which minimizes '
- 'main dex and keeps all line number information, and then some.')
+ parser.add_argument('--release',
+ action='store_true',
+ help='Run D8 in release mode.')
parser.add_argument(
'--min-api', help='Minimum Android API level compatibility.')
parser.add_argument('--force-enable-assertions',
@@ -116,9 +106,6 @@ def _ParseArgs(args):
' Stores inputs to d8inputs.zip')
options = parser.parse_args(args)
- if options.main_dex_rules_path and not options.multi_dex:
- parser.error('--main-dex-rules-path is unused if multidex is not enabled')
-
if options.force_enable_assertions and options.assertion_handler:
parser.error('Cannot use both --force-enable-assertions and '
'--assertion-handler')
@@ -220,10 +207,6 @@ def _CreateFinalDex(d8_inputs, output, tmp_dir, dex_cmd, options=None):
needs_dexing = not all(f.endswith('.dex') for f in d8_inputs)
needs_dexmerge = output.endswith('.dex') or not (options and options.library)
if needs_dexing or needs_dexmerge:
- if options and options.main_dex_rules_path:
- for main_dex_rule in options.main_dex_rules_path:
- dex_cmd = dex_cmd + ['--main-dex-rules', main_dex_rule]
-
tmp_dex_dir = os.path.join(tmp_dir, 'tmp_dex_dir')
os.mkdir(tmp_dex_dir)
@@ -282,7 +265,7 @@ def _ParseDesugarDeps(desugar_dependencies_file):
org/chromium/base/task/TaskRunnerImpl.class
<- org/chromium/base/task/TaskRunner.class
org/chromium/base/task/TaskRunnerImplJni$1.class
- <- obj/base/jni_java.turbine.jar:org/chromium/base/JniStaticTestMocker.class
+ <- obj/base/jni_java.turbine.jar:org/jni_zero/JniStaticTestMocker.class
org/chromium/base/task/TaskRunnerImplJni.class
<- org/chromium/base/task/TaskRunnerImpl$Natives.class
"""
@@ -429,8 +412,6 @@ def main(args):
build_utils.JAVA_PATH_FOR_INPUTS, options.r8_jar_path,
options.custom_d8_jar_path
] + options.class_inputs + options.dex_inputs)
- if options.main_dex_rules_path:
- input_paths.extend(options.main_dex_rules_path)
depfile_deps = options.class_inputs_filearg + options.dex_inputs_filearg
@@ -484,8 +465,7 @@ def main(args):
for path in options.classpath:
dex_cmd += ['--classpath', path]
- if options.classpath or options.main_dex_rules_path:
- # --main-dex-rules requires bootclasspath.
+ if options.classpath:
dex_cmd += ['--lib', build_utils.JAVA_HOME]
for path in options.bootclasspath:
dex_cmd += ['--lib', path]
diff --git a/chromium/build/android/gyp/java_cpp_enum.py b/chromium/build/android/gyp/java_cpp_enum.py
index 5225b89b36b..c49f0178953 100755
--- a/chromium/build/android/gyp/java_cpp_enum.py
+++ b/chromium/build/android/gyp/java_cpp_enum.py
@@ -189,8 +189,9 @@ class HeaderParser:
enum_name_re = r'(\w+)'
optional_fixed_type_re = r'(\:\s*(\w+\s*\w+?))?'
enum_start_re = re.compile(r'^\s*(?:\[cpp.*\])?\s*enum\s+' +
- optional_class_or_struct_re + '\s*' + enum_name_re + '\s*' +
- optional_fixed_type_re + '\s*{\s*')
+ optional_class_or_struct_re + r'\s*' +
+ enum_name_re + r'\s*' + optional_fixed_type_re +
+ r'\s*{\s*')
enum_single_line_re = re.compile(
r'^\s*(?:\[cpp.*\])?\s*enum.*{(?P<enum_entries>.*)}.*$')
diff --git a/chromium/build/android/gyp/javac_output_processor.py b/chromium/build/android/gyp/javac_output_processor.py
index db588458dc6..65fa6dd74cb 100755
--- a/chromium/build/android/gyp/javac_output_processor.py
+++ b/chromium/build/android/gyp/javac_output_processor.py
@@ -8,6 +8,7 @@
import os
import pathlib
import re
+import shlex
import sys
import traceback
@@ -24,7 +25,7 @@ class JavacOutputProcessor:
def __init__(self, target_name):
self._target_name = self._RemoveSuffixesIfPresent(
["__compile_java", "__errorprone", "__header"], target_name)
- self._suggested_deps = set()
+ self._suggested_targets_list = set()
# Example: ../../ui/android/java/src/org/chromium/ui/base/Clipboard.java:45:
fileline_prefix = (
@@ -71,7 +72,7 @@ class JavacOutputProcessor:
lines = self._ElaborateLinesForUnknownSymbol(iter(lines))
for line in lines:
yield self._ApplyColors(line)
- if self._suggested_deps:
+ if self._suggested_targets_list:
def yellow(text):
return colorama.Fore.YELLOW + text + colorama.Fore.RESET
@@ -80,8 +81,21 @@ class JavacOutputProcessor:
yield yellow('Hint:') + ' One or more errors due to missing GN deps.'
yield (yellow('Hint:') + ' Try adding the following to ' +
yellow(self._target_name))
- for dep in sorted(self._suggested_deps):
- yield ' "{}",'.format(dep)
+
+ for targets in sorted(self._suggested_targets_list):
+ if len(targets) > 1:
+ suggested_targets_str = 'one of: ' + ', '.join(targets)
+ else:
+ suggested_targets_str = targets[0]
+ yield ' "{}",'.format(suggested_targets_str)
+
+ yield ''
+ yield yellow('Hint:') + (' Run the following command to add the missing '
+ 'deps:')
+ missing_targets = {targets[0] for targets in self._suggested_targets_list}
+ cmd = dep_utils.CreateAddDepsCommand(self._target_name,
+ sorted(missing_targets))
+ yield f' {shlex.join(cmd)}\n ' # Extra space necessary for new line.
def _ElaborateLinesForUnknownSymbol(self, lines):
""" Elaborates passed-in javac output for unresolved symbols.
@@ -147,15 +161,11 @@ class JavacOutputProcessor:
suggested_deps = self._class_lookup_index.match(class_to_lookup)
if not suggested_deps:
+ print(f'No suggested deps for {class_to_lookup}')
return
suggested_deps = dep_utils.DisambiguateDeps(suggested_deps)
- suggested_deps_str = ', '.join(s.target for s in suggested_deps)
-
- if len(suggested_deps) > 1:
- suggested_deps_str = 'one of: ' + suggested_deps_str
-
- self._suggested_deps.add(suggested_deps_str)
+ self._suggested_targets_list.add(tuple(d.target for d in suggested_deps))
@staticmethod
def _RemoveSuffixesIfPresent(suffixes, text):
diff --git a/chromium/build/android/gyp/lint.py b/chromium/build/android/gyp/lint.py
index 95892023355..aba130a438f 100755
--- a/chromium/build/android/gyp/lint.py
+++ b/chromium/build/android/gyp/lint.py
@@ -30,6 +30,7 @@ _DISABLED_ALWAYS = [
"LintBaseline", # Don't warn about using baseline.xml files.
"MissingInflatedId", # False positives https://crbug.com/1394222
"MissingApplicationIcon", # False positive for non-production targets.
+ "NetworkSecurityConfig", # Breaks on library certificates b/269783280.
"ObsoleteLintCustomCheck", # We have no control over custom lint checks.
"SwitchIntDef", # Many C++ enums are not used at all in java.
"Typos", # Strings are committed in English first and later translated.
@@ -270,9 +271,10 @@ def _RunLint(create_cache,
extra_manifest_paths,
min_sdk_version,
android_sdk_version)
- # Include the rebased manifest_path in the lint generated path so that it is
- # clear in error messages where the original AndroidManifest.xml came from.
- lint_android_manifest_path = os.path.join(lint_gen_dir, manifest_path)
+ # Just use a hardcoded name, since we may have different target names (and
+ # thus different manifest_paths) using the same lint baseline. Eg.
+ # trichrome_chrome_bundle and trichrome_chrome_32_64_bundle.
+ lint_android_manifest_path = os.path.join(lint_gen_dir, 'AndroidManifest.xml')
_WriteXmlFile(android_manifest_tree.getroot(), lint_android_manifest_path)
resource_root_dir = os.path.join(lint_gen_dir, _RES_ZIP_DIR)
@@ -338,7 +340,7 @@ def _RunLint(create_cache,
start = time.time()
logging.debug('Lint command %s', ' '.join(cmd))
- failed = True
+ failed = False
if creating_baseline and not warnings_as_errors:
# Allow error code 6 when creating a baseline: ERRNO_CREATED_BASELINE
@@ -347,25 +349,21 @@ def _RunLint(create_cache,
fail_func = lambda returncode, _: returncode != 0
try:
- failed = bool(
- build_utils.CheckOutput(cmd,
- print_stdout=True,
- stdout_filter=stdout_filter,
- stderr_filter=stderr_filter,
- fail_on_output=warnings_as_errors,
- fail_func=fail_func))
+ build_utils.CheckOutput(cmd,
+ print_stdout=True,
+ stdout_filter=stdout_filter,
+ stderr_filter=stderr_filter,
+ fail_on_output=warnings_as_errors,
+ fail_func=fail_func)
+ except build_utils.CalledProcessError as e:
+ failed = True
+ # Do not output the python stacktrace because it is lengthy and is not
+ # relevant to the actual lint error.
+ sys.stderr.write(e.output)
finally:
# When not treating warnings as errors, display the extra footer.
is_debug = os.environ.get('LINT_DEBUG', '0') != '0'
- if failed:
- print('- For more help with lint in Chrome:', _LINT_MD_URL)
- if is_debug:
- print('- DEBUG MODE: Here is the project.xml: {}'.format(
- _SrcRelative(project_xml_path)))
- else:
- print('- Run with LINT_DEBUG=1 to enable lint configuration debugging')
-
end = time.time() - start
logging.info('Lint command took %ss', end)
if not is_debug:
@@ -374,6 +372,15 @@ def _RunLint(create_cache,
shutil.rmtree(srcjar_root_dir, ignore_errors=True)
os.unlink(project_xml_path)
+ if failed:
+ print('- For more help with lint in Chrome:', _LINT_MD_URL)
+ if is_debug:
+ print('- DEBUG MODE: Here is the project.xml: {}'.format(
+ _SrcRelative(project_xml_path)))
+ else:
+ print('- Run with LINT_DEBUG=1 to enable lint configuration debugging')
+ sys.exit(1)
+
logging.info('Lint completed')
diff --git a/chromium/build/android/gyp/nocompile_test.py b/chromium/build/android/gyp/nocompile_test.py
index c3b02d2c961..0775c1cf0a8 100755
--- a/chromium/build/android/gyp/nocompile_test.py
+++ b/chromium/build/android/gyp/nocompile_test.py
@@ -91,12 +91,6 @@ def _find_regex_in_test_failure_output(test_output, regex):
Returns:
Whether the regular expression was found in the part of the test output
after the 'FAILED' message.
-
- If the regex does not contain '\n':
- the first 5 lines after the 'FAILED' message (including the text on the
- line after the 'FAILED' message) is searched.
- Otherwise:
- the entire test output after the 'FAILED' message is searched.
"""
if test_output is None:
return False
@@ -108,8 +102,7 @@ def _find_regex_in_test_failure_output(test_output, regex):
failure_message = test_output[failed_index:]
if regex.find('\n') >= 0:
return re.search(regex, failure_message)
-
- return _search_regex_in_list(failure_message.split('\n')[:5], regex)
+ return _search_regex_in_list(failure_message.split('\n'), regex)
def _search_regex_in_list(value, regex):
diff --git a/chromium/build/android/gyp/proguard.py b/chromium/build/android/gyp/proguard.py
index 89a1b2dd3df..f89f7c5fb97 100755
--- a/chromium/build/android/gyp/proguard.py
+++ b/chromium/build/android/gyp/proguard.py
@@ -57,6 +57,8 @@ _IGNORE_WARNINGS = (
r'OnBackAnimationCallback',
# We enforce that this class is removed via -checkdiscard.
r'FastServiceLoader\.class:.*Could not inline ServiceLoader\.load',
+ # We are following up in b/290389974
+ r'AppSearchDocumentClassMap\.class:.*Could not inline ServiceLoader\.load',
)
_BLOCKLISTED_EXPECTATION_PATHS = [
@@ -332,14 +334,6 @@ def _OptimizeWithR8(options, config_paths, libraries, dynamic_config_data):
if options.disable_checks:
cmd += ['--map-diagnostics:CheckDiscardDiagnostic', 'error', 'none']
- # chromium has junit lib in third_party/junit and third_party/android_sdk
- # which causes r8 to print "info" level diagnostic for duplicates.
- # So turn it off explicitly.
- # TODO(crbug.com/1476663): Fix the duplicates and remove this setting.
- cmd += [
- '--map-diagnostics:DuplicateTypeInProgramAndLibraryDiagnostic', 'info',
- 'none'
- ]
cmd += ['--map-diagnostics', 'info', 'warning']
# An "error" level diagnostic causes r8 to return an error exit code. Doing
# this allows our filter to decide what should/shouldn't break our build.
@@ -513,13 +507,6 @@ Tip: Build with:
third_party/android_sdk/public/build-tools/*/dexdump -d \
out/Release/apks/YourApk.apk > dex.txt
""" + stderr
-
- if 'FragmentActivity' in stderr:
- stderr += """
-You may need to update build configs to run FragmentActivityReplacer for
-additional targets. See
-https://chromium.googlesource.com/chromium/src.git/+/main/docs/ui/android/bytecode_rewriting.md.
-"""
elif had_unfiltered_items:
# Left only with empty headings. All indented items filtered out.
stderr = ''
diff --git a/chromium/build/android/gyp/trace_event_bytecode_rewriter.py b/chromium/build/android/gyp/trace_event_bytecode_rewriter.py
index 3e0e696f511..a38d06a35a8 100755
--- a/chromium/build/android/gyp/trace_event_bytecode_rewriter.py
+++ b/chromium/build/android/gyp/trace_event_bytecode_rewriter.py
@@ -6,12 +6,18 @@
import argparse
import sys
+import tempfile
import os
from util import build_utils
import action_helpers # build_utils adds //build to sys.path.
+# The real limit is generally >100kb, but 10k seems like a reasonable "it's big"
+# threshold.
+_MAX_CMDLINE = 10000
+
+
def main(argv):
argv = build_utils.ExpandFileArgs(argv[1:])
parser = argparse.ArgumentParser()
@@ -34,15 +40,23 @@ def main(argv):
if not os.path.exists(jar_dir):
os.makedirs(jar_dir)
- all_input_jars = set(args.classpath + args.input_jars)
cmd = [
- args.script, '--classpath', ':'.join(sorted(all_input_jars)),
+ args.script, '--classpath', ':'.join(args.classpath),
':'.join(args.input_jars), ':'.join(args.output_jars)
]
+ if sum(len(x) for x in cmd) > _MAX_CMDLINE:
+ # Cannot put --classpath in the args file because that is consumed by the
+ # wrapper script.
+ args_file = tempfile.NamedTemporaryFile(mode='w')
+ args_file.write('\n'.join(cmd[3:]))
+ args_file.flush()
+ cmd[3:] = ['@' + args_file.name]
+
build_utils.CheckOutput(cmd, print_stdout=True)
build_utils.Touch(args.stamp)
+ all_input_jars = args.input_jars + args.classpath
action_helpers.write_depfile(args.depfile, args.stamp, inputs=all_input_jars)
diff --git a/chromium/build/android/gyp/turbine.py b/chromium/build/android/gyp/turbine.py
index 2de92f4704a..a4cf47ee0d7 100755
--- a/chromium/build/android/gyp/turbine.py
+++ b/chromium/build/android/gyp/turbine.py
@@ -82,11 +82,7 @@ def main(argv):
cmd = build_utils.JavaCmd() + [
'-classpath', options.turbine_jar_path, 'com.google.turbine.main.Main'
]
- javac_cmd = [
- # We currently target JDK 11 everywhere.
- '--release',
- '11',
- ]
+ javac_cmd = ['--release', '17']
# Turbine reads lists from command line args by consuming args until one
# starts with double dash (--). Thus command line args should be grouped
@@ -115,7 +111,7 @@ def main(argv):
# Use jar_path to ensure paths are relative (needed for goma).
files_rsp_path = options.jar_path + '.java_files_list.txt'
with open(files_rsp_path, 'w') as f:
- f.write(' '.join(java_files))
+ f.write('\n'.join(java_files))
# Pass source paths as response files to avoid extremely long command
# lines that are tedius to debug.
cmd += ['--sources']
diff --git a/chromium/build/android/gyp/util/build_utils.py b/chromium/build/android/gyp/util/build_utils.py
index 752aa21ec55..5b1473e61eb 100644
--- a/chromium/build/android/gyp/util/build_utils.py
+++ b/chromium/build/android/gyp/util/build_utils.py
@@ -224,6 +224,7 @@ def CheckOutput(args,
logging.info('CheckOutput: %s', ' '.join(args))
child = subprocess.Popen(args,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd, env=env)
+
stdout, stderr = child.communicate()
# For Python3 only:
@@ -455,7 +456,7 @@ def ExpandFileArgs(args):
"""
new_args = list(args)
file_jsons = dict()
- r = re.compile('@FileArg\((.*?)\)')
+ r = re.compile(r'@FileArg\((.*?)\)')
for i, arg in enumerate(args):
match = r.search(arg)
if not match:
diff --git a/chromium/build/android/gyp/util/dep_utils.py b/chromium/build/android/gyp/util/dep_utils.py
index 370e3587598..cbf89370a6a 100644
--- a/chromium/build/android/gyp/util/dep_utils.py
+++ b/chromium/build/android/gyp/util/dep_utils.py
@@ -107,6 +107,14 @@ class ClassLookupIndex:
if lower_search_string in full_class_name.lower():
matches.extend(self._entries_for(full_class_name))
+ # Priority 4: Match parent class when no matches and it's an inner class.
+ if not matches:
+ components = search_string.rsplit('.', 2)
+ if len(components) == 3:
+ package, outer_class, inner_class = components
+ if outer_class[0].isupper() and inner_class[0].isupper():
+ matches.extend(self.match(f'{package}.{outer_class}'))
+
return matches
def _entries_for(self, class_name) -> List[ClassEntry]:
@@ -228,6 +236,30 @@ class ClassLookupIndex:
return full_class_names
+def GnTargetToBuildFilePath(gn_target: str):
+ """Returns the relative BUILD.gn file path for this target from src root."""
+ assert gn_target.startswith('//'), f'Relative {gn_target} name not supported.'
+ ninja_target_name = gn_target[2:]
+
+ # Remove the colon at the end
+ colon_index = ninja_target_name.find(':')
+ if colon_index != -1:
+ ninja_target_name = ninja_target_name[:colon_index]
+
+ return os.path.join(ninja_target_name, 'BUILD.gn')
+
+
+def CreateAddDepsCommand(gn_target: str, missing_deps: List[str]) -> List[str]:
+ # Normalize chrome_public_apk__java to chrome_public_apk.
+ gn_target = gn_target.split('__', 1)[0]
+
+ build_file_path = GnTargetToBuildFilePath(gn_target)
+ return [
+ 'build/gn_editor', 'add', '--quiet', '--file', build_file_path,
+ '--target', gn_target, '--deps'
+ ] + missing_deps
+
+
def ReplaceGmsPackageIfNeeded(target_name: str) -> str:
if target_name.startswith(
('//third_party/android_deps:google_play_services_',
diff --git a/chromium/build/android/gyp/util/server_utils.py b/chromium/build/android/gyp/util/server_utils.py
index b634cf978ed..6d5ed79d393 100644
--- a/chromium/build/android/gyp/util/server_utils.py
+++ b/chromium/build/android/gyp/util/server_utils.py
@@ -5,6 +5,7 @@
import contextlib
import json
import os
+import pathlib
import socket
# Use a unix abstract domain socket:
@@ -44,4 +45,9 @@ def MaybeRunCommand(name, argv, stamp_file, force):
'$ build/android/fast_local_dev_server.py\n\n') from None
return False
raise e
+
+ # Siso needs the stamp file to be created in order for the build step to
+ # complete. If the task fails when the build server runs it, the build server
+ # will delete the stamp file so that it will be run again next build.
+ pathlib.Path(stamp_file).touch()
return True
diff --git a/chromium/build/android/gyp/write_build_config.py b/chromium/build/android/gyp/write_build_config.py
index 3565329d355..1d5babbca62 100755
--- a/chromium/build/android/gyp/write_build_config.py
+++ b/chromium/build/android/gyp/write_build_config.py
@@ -1497,18 +1497,22 @@ def main(argv):
# You are allowed to depend on both android |deps_require_android| and
# non-android |deps_not_support_android| targets.
if not options.bypass_platform_checks and not options.is_robolectric:
- deps_require_android = (all_resources_deps +
- [d['name'] for d in all_library_deps if d['requires_android']])
- deps_not_support_android = (
- [d['name'] for d in all_library_deps if not d['supports_android']])
+ deps_require_android = all_resources_deps + [
+ d for d in all_library_deps if d['requires_android']
+ ]
+ deps_not_support_android = [
+ d for d in all_library_deps if not d['supports_android']
+ ]
if deps_require_android and not options.requires_android:
- raise Exception('Some deps require building for the Android platform: '
- + str(deps_require_android))
+ raise Exception(
+ 'Some deps require building for the Android platform:\n' +
+ '\n'.join('* ' + d['gn_target'] for d in deps_require_android))
if deps_not_support_android and options.supports_android:
- raise Exception('Not all deps support the Android platform: '
- + str(deps_not_support_android))
+ raise Exception('Not all deps support the Android platform:\n' +
+ '\n'.join('* ' + d['gn_target']
+ for d in deps_not_support_android))
if is_apk_or_module_target or options.type == 'dist_jar':
all_dex_files = [c['dex_path'] for c in all_library_deps]
diff --git a/chromium/build/android/gyp/write_native_libraries_java.py b/chromium/build/android/gyp/write_native_libraries_java.py
index 167f8dd25ea..96f084a0320 100755
--- a/chromium/build/android/gyp/write_native_libraries_java.py
+++ b/chromium/build/android/gyp/write_native_libraries_java.py
@@ -8,6 +8,7 @@
import argparse
import os
+import re
import sys
import zipfile
@@ -48,8 +49,7 @@ public class NativeLibraries {{
def _FormatLibraryName(library_name):
filename = os.path.split(library_name)[1]
- assert filename.startswith('lib')
- assert filename.endswith('.so')
+ assert filename.startswith('lib') and filename.endswith('.so'), filename
# Remove lib prefix and .so suffix.
return '"%s"' % filename[3:-3]
@@ -103,6 +103,14 @@ def main():
sys.stderr.write('\n')
sys.exit(1)
+ # When building for robolectric in component buildS, OS=linux causes
+ # "libmirprotobuf.so.9" to be a dep. This script, as well as
+ # System.loadLibrary("name") require libraries to end with ".so", so just
+ # filter it out.
+ native_libraries = [
+ f for f in native_libraries if not re.search(r'\.so\.\d+$', f)
+ ]
+
def bool_str(value):
if value:
return ' = true'