summaryrefslogtreecommitdiff
path: root/chromium/build/config
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/build/config')
-rw-r--r--chromium/build/config/BUILDCONFIG.gn11
-rw-r--r--chromium/build/config/OWNERS1
-rw-r--r--chromium/build/config/android/OWNERS2
-rw-r--r--chromium/build/config/android/config.gni19
-rw-r--r--chromium/build/config/android/copy_ex.gni1
-rw-r--r--chromium/build/config/android/internal_rules.gni1541
-rw-r--r--chromium/build/config/android/rules.gni392
-rw-r--r--chromium/build/config/c++/BUILD.gn11
-rw-r--r--chromium/build/config/c++/c++.gni2
-rw-r--r--chromium/build/config/chromecast_build.gni3
-rw-r--r--chromium/build/config/chromeos/rules.gni110
-rw-r--r--chromium/build/config/compiler/BUILD.gn77
-rw-r--r--chromium/build/config/compiler/compiler.gni14
-rw-r--r--chromium/build/config/compiler/pgo/BUILD.gn25
-rw-r--r--chromium/build/config/compiler/pgo/pgo.gni3
-rw-r--r--chromium/build/config/fuchsia/BUILD.gn7
-rw-r--r--chromium/build/config/fuchsia/generate_runner_scripts.gni34
-rw-r--r--chromium/build/config/fuchsia/gfx_tests.cmx5
-rw-r--r--chromium/build/config/fuchsia/package.gni25
-rw-r--r--chromium/build/config/ios/ios_sdk.gni43
-rw-r--r--chromium/build/config/ios/rules.gni68
-rw-r--r--chromium/build/config/linux/BUILD.gn8
-rw-r--r--chromium/build/config/mac/BUILD.gn7
-rw-r--r--chromium/build/config/mac/OWNERS2
-rw-r--r--chromium/build/config/mac/mac_sdk.gni9
-rw-r--r--chromium/build/config/mac/prepare_framework_version.py2
-rw-r--r--chromium/build/config/mac/sdk_info.py4
-rw-r--r--chromium/build/config/win/BUILD.gn7
-rw-r--r--chromium/build/config/win/manifest.gni6
29 files changed, 1273 insertions, 1166 deletions
diff --git a/chromium/build/config/BUILDCONFIG.gn b/chromium/build/config/BUILDCONFIG.gn
index 6f5d5f123f8..4cc6bfc45e6 100644
--- a/chromium/build/config/BUILDCONFIG.gn
+++ b/chromium/build/config/BUILDCONFIG.gn
@@ -237,7 +237,7 @@ if (target_os == "android") {
_default_toolchain = "//build/toolchain/mac:ios_clang_$target_cpu"
} else if (target_os == "mac") {
assert(host_os == "mac", "Mac cross-compiles are unsupported.")
- _default_toolchain = host_toolchain
+ _default_toolchain = "//build/toolchain/mac:clang_$target_cpu"
} else if (target_os == "win") {
# On Windows, we use the same toolchain for host and target by default.
# Beware, win cross builds have some caveats, see docs/win_cross.md
@@ -585,10 +585,9 @@ foreach(_target_type,
# On Android, write shared library output file to metadata. We will use
# this information to, for instance, collect all shared libraries that
# should be packaged into an APK.
- if (!defined(invoker.metadata) && is_android && (_target_type ==
- "shared_library" ||
- _target_type ==
- "loadable_module")) {
+ if (!defined(invoker.metadata) && is_android &&
+ (_target_type == "shared_library" ||
+ _target_type == "loadable_module")) {
_output_name = _target_name
if (defined(invoker.output_name)) {
_output_name = invoker.output_name
@@ -641,7 +640,7 @@ template("component") {
assert(invoker.static_component_type == "static_library" ||
invoker.static_component_type == "source_set")
_component_mode = invoker.static_component_type
- } else if (!defined(invoker.sources)) {
+ } else if (!defined(invoker.sources) || invoker.sources == []) {
# When there are no sources defined, use a source set to avoid creating
# an empty static library (which generally don't work).
_component_mode = "source_set"
diff --git a/chromium/build/config/OWNERS b/chromium/build/config/OWNERS
index 9eccd5b9f14..13d88a2dfc9 100644
--- a/chromium/build/config/OWNERS
+++ b/chromium/build/config/OWNERS
@@ -1,4 +1,5 @@
dpranke@chromium.org
+dpranke@google.com
scottmg@chromium.org
per-file *jumbo*=bratell.d@gmail.com
diff --git a/chromium/build/config/android/OWNERS b/chromium/build/config/android/OWNERS
index 0dad8ce2b30..9184df6a8ac 100644
--- a/chromium/build/config/android/OWNERS
+++ b/chromium/build/config/android/OWNERS
@@ -2,5 +2,3 @@ agrieve@chromium.org
digit@chromium.org
tiborg@chromium.org
wnwen@chromium.org
-
-# COMPONENT: Build
diff --git a/chromium/build/config/android/config.gni b/chromium/build/config/android/config.gni
index a560d2698a8..8838f279509 100644
--- a/chromium/build/config/android/config.gni
+++ b/chromium/build/config/android/config.gni
@@ -45,6 +45,10 @@ if (is_android || is_chromeos) {
# repositories to support both public only and internal builds.
enable_chrome_android_internal = has_chrome_android_internal
+ # The default to use for android:minSdkVersion for targets that do
+ # not explicitly set it.
+ default_min_sdk_version = 21
+
# Android API level for 32 bits platforms
android32_ndk_api_level = 16
@@ -68,9 +72,6 @@ if (is_android || is_chromeos) {
}
}
- # Our build rules support only KitKat+.
- default_min_sdk_version = 19
-
if (!defined(default_android_ndk_root)) {
default_android_ndk_root = "//third_party/android_ndk"
default_android_ndk_version = "r20"
@@ -88,6 +89,11 @@ if (is_android || is_chromeos) {
public_android_sdk = true
}
+ # For use downstream when we are building with preview Android SDK
+ if (!defined(final_android_sdk)) {
+ final_android_sdk = public_android_sdk
+ }
+
if (!defined(default_lint_android_sdk_root)) {
# Purposefully repeated so that downstream can change
# default_android_sdk_root without changing lint version.
@@ -209,6 +215,11 @@ if (is_android || is_chromeos) {
# configured to use it.
enable_proguard_obfuscation = true
+ # Controls whether |short_resource_paths| and |strip_resource_names| are
+ # respected. Useful when trying to analyze APKs using tools that do not
+ # support mapping these names.
+ enable_arsc_obfuscation = true
+
# The target to use as the system WebView implementation.
system_webview_apk_target = "//android_webview:system_webview_apk"
}
@@ -236,7 +247,7 @@ if (is_android || is_chromeos) {
enable_bazel_desugar = true
# Enables Java library desugaring.
- # This will cause an extra 1MB classes.dex file to appear in every apk.
+ # This will cause an extra classes.dex file to appear in every apk.
enable_jdk_library_desugaring = false
}
diff --git a/chromium/build/config/android/copy_ex.gni b/chromium/build/config/android/copy_ex.gni
index 14fbedb3b37..0ea9e706683 100644
--- a/chromium/build/config/android/copy_ex.gni
+++ b/chromium/build/config/android/copy_ex.gni
@@ -28,6 +28,7 @@ template("copy_ex") {
[
"data",
"deps",
+ "public_deps",
"testonly",
"visibility",
])
diff --git a/chromium/build/config/android/internal_rules.gni b/chromium/build/config/android/internal_rules.gni
index 1494124a991..b6b7627dda3 100644
--- a/chromium/build/config/android/internal_rules.gni
+++ b/chromium/build/config/android/internal_rules.gni
@@ -16,47 +16,69 @@ import("//build/util/generate_wrapper.gni")
import("//build_overrides/build.gni")
assert(is_android)
-# These filters identify most targets that eventually use the java_library_impl
-# template.
-_java_lib_patterns = [
+# The following _java_*_types variables capture all the existing target types.
+# If a new type is introduced, please add it to one of these categories,
+# preferring the more specific resource/library types.
+_java_resource_types = [
+ "android_assets",
+ "android_resources",
+]
+
+_java_library_types = [
+ "java_library",
+ "system_java_library",
+ "android_app_bundle_module",
+]
+
+# These are leaf java target types. They cannot be passed as deps to other
+# targets. Thus their naming schemes are not enforced.
+_java_leaf_types = [
+ "android_apk",
+ "android_app_bundle",
+ "dist_aar",
+ "dist_jar",
+ "java_annotation_processor",
+ "java_binary",
+ "junit_binary",
+]
+
+# All _java_resource_types targets must conform to these patterns.
+_java_resource_patterns = [
+ "*:*_assets",
+ "*android*:assets",
+ "*:*_apk_*resources",
+ "*android*:resources",
+ "*:*_resources",
+ "*:*_grd",
+ "*:*locale_paks",
+ "*:*_java_strings",
+ "*:*strings_java",
+]
+
+# All _java_library_types targets must conform to these patterns. This includes
+# all non-leaf targets that use java_library_impl.
+_java_library_patterns = [
"*:*_java",
"*:*_javalib",
- "*:*_java_*", # e.g. java_test_support
+ "*:*_java_*", # e.g. chrome_java_test_support
"*:java",
"*:junit",
"*:junit_*",
"*:*_junit_*",
"*:*javatests",
+ "*:*_bundle_module",
# TODO(agrieve): Rename targets below to match above patterns.
- "*android_webview/glue*:glue",
+ "//android_webview/glue:glue",
]
-# These identify targets that have .build_config files (except for android_apk,
-# java_binary, android_app_bundle since we never need to depend on these).
-_java_target_patterns = _java_lib_patterns + [
- "*:*_assets",
- "*android*:assets",
- "*:*_apk_*resources",
- "*android*:resources",
- "*:*_resources",
- "*:*_grd",
- "*:*locale_paks",
- "*_bundle_module",
- ]
-
-# Targets that match _java_target_patterns but are not actually java targets.
-_java_target_exceptions = [ "*:*_unpack_aar" ]
-
-# These targets match _java_lib_patterns but do not use java_library_impl.
-_java_lib_exceptions =
- _java_target_patterns - _java_lib_patterns + _java_target_exceptions + [
- "*:*__res", # TODO(wnwen): Rename these to the standard ones.
- ]
+# These identify all non-leaf targets that have .build_config files.
+_java_target_patterns = _java_library_patterns + _java_resource_patterns
_r8_path = "//third_party/r8/lib/r8.jar"
_desugar_jdk_libs_json = "//third_party/r8/desugar_jdk_libs.json"
_desugar_jdk_libs_jar = "//third_party/android_deps/libs/com_android_tools_desugar_jdk_libs/desugar_jdk_libs-1.0.5.jar"
+_desugar_runtime_jar = "$root_build_dir/obj/third_party/bazel/desugar/Desugar_runtime.processed.jar"
_dexdump_path = "$android_sdk_build_tools/dexdump"
_dexlayout_path = "//third_party/android_build_tools/art/dexlayout"
@@ -120,19 +142,32 @@ build_config_target_suffix = "__build_config_crbug_908819"
# build/android/gyp/util/build_utils.py:ExpandFileArgs
template("write_build_config") {
_type = invoker.type
-
- # Don't need to enforce naming scheme for these targets since we never
- # consider them in dependency chains.
- if (_type != "android_apk" && _type != "java_binary" && _type != "dist_jar" &&
- _type != "java_annotation_processor" && _type != "dist_aar" &&
- _type != "android_app_bundle") {
- _parent_invoker = invoker.invoker
- _target_label =
- get_label_info(":${_parent_invoker.target_name}", "label_no_toolchain")
- if (filter_exclude([ _target_label ], _java_target_patterns) != [] &&
- filter_exclude([ _target_label ], _java_target_exceptions) != []) {
+ _parent_invoker = invoker.invoker
+ _target_label =
+ get_label_info(":${_parent_invoker.target_name}", "label_no_toolchain")
+
+ # Ensure targets match naming patterns so that __assetres, __header, __impl
+ # targets work properly. Those generated targets allow for effective deps
+ # filtering.
+ if (filter_exclude([ _type ], _java_resource_types) == []) {
+ if (filter_exclude([ _target_label ], _java_resource_patterns) != []) {
+ assert(false, "Invalid java resource target name: $_target_label")
+ }
+ } else if (filter_exclude([ _type ], _java_library_types) == []) {
+ if (filter_exclude([ _target_label ], _java_library_patterns) != [] ||
+ filter_exclude([ _target_label ], _java_resource_patterns) == []) {
+ assert(false, "Invalid java library target name: $_target_label")
+ }
+ } else if (_type == "group") {
+ if (filter_exclude([ _target_label ], _java_target_patterns) != []) {
assert(false, "Invalid java target name: $_target_label")
}
+ } else if (filter_exclude([ _type ], _java_leaf_types) != []) {
+ assert(false, "This java type needs a category: $_type")
+ }
+
+ if (defined(invoker.public_target_label)) {
+ _target_label = invoker.public_target_label
}
action_with_pydeps(target_name) {
@@ -156,12 +191,11 @@ template("write_build_config") {
_deps_configs = []
if (defined(invoker.possible_config_deps)) {
foreach(_possible_dep, invoker.possible_config_deps) {
- _target_label = get_label_info(_possible_dep, "label_no_toolchain")
- if (filter_exclude([ _target_label ], _java_target_patterns) == [] &&
- filter_exclude([ _target_label ], _java_target_exceptions) != []) {
+ _dep_label = get_label_info(_possible_dep, "label_no_toolchain")
+ if (filter_exclude([ _dep_label ], _java_target_patterns) == []) {
# Put the bug number in the target name so that false-positives
# have a hint in the error message about non-existent dependencies.
- deps += [ "$_target_label$build_config_target_suffix" ]
+ deps += [ "$_dep_label$build_config_target_suffix" ]
_dep_gen_dir = get_label_info(_possible_dep, "target_gen_dir")
_dep_name = get_label_info(_possible_dep, "name")
_deps_configs += [ "$_dep_gen_dir/$_dep_name.build_config" ]
@@ -177,6 +211,8 @@ template("write_build_config") {
"--deps-configs=$_rebased_deps_configs",
"--build-config",
rebase_path(invoker.build_config, root_build_dir),
+ "--gn-target",
+ _target_label,
]
if (defined(invoker.chromium_code) && !invoker.chromium_code) {
@@ -184,10 +220,16 @@ template("write_build_config") {
args += [ "--non-chromium-code" ]
}
- if (defined(invoker.jar_path)) {
+ if (defined(invoker.device_jar_path)) {
args += [
- "--jar-path",
- rebase_path(invoker.jar_path, root_build_dir),
+ "--device-jar-path",
+ rebase_path(invoker.device_jar_path, root_build_dir),
+ ]
+ }
+ if (defined(invoker.host_jar_path)) {
+ args += [
+ "--host-jar-path",
+ rebase_path(invoker.host_jar_path, root_build_dir),
]
}
if (defined(invoker.unprocessed_jar_path)) {
@@ -208,22 +250,20 @@ template("write_build_config") {
rebase_path(invoker.java_resources_jar, root_build_dir),
]
}
- if (defined(invoker.skip_jetify) && invoker.skip_jetify) {
- args += [ "--skip-jetify" ]
- }
if (defined(invoker.jetified_jar_path)) {
args += [
"--jetified-jar-path",
rebase_path(invoker.jetified_jar_path, root_build_dir),
]
}
- if (defined(invoker.annotation_processor_deps)) {
+ if (defined(invoker.annotation_processor_deps) &&
+ invoker.annotation_processor_deps != []) {
_processor_configs = []
foreach(_processor_dep, invoker.annotation_processor_deps) {
- _target_label = get_label_info(_processor_dep, "label_no_toolchain")
+ _dep_label = get_label_info(_processor_dep, "label_no_toolchain")
_dep_gen_dir = get_label_info(_processor_dep, "target_gen_dir")
_dep_name = get_label_info(_processor_dep, "name")
- deps += [ "$_target_label$build_config_target_suffix" ]
+ deps += [ "$_dep_label$build_config_target_suffix" ]
_processor_configs += [ "$_dep_gen_dir/$_dep_name.build_config" ]
}
_rebased_processor_configs =
@@ -471,12 +511,12 @@ template("write_build_config") {
}
if (defined(invoker.static_library_dependent_targets)) {
_dependent_configs = []
- foreach(_target, invoker.static_library_dependent_targets) {
- _target_name = _target.name
- _target_label = get_label_info(_target_name, "label_no_toolchain")
- deps += [ "$_target_label$build_config_target_suffix" ]
- _dep_gen_dir = get_label_info(_target_name, "target_gen_dir")
- _dep_name = get_label_info(_target_name, "name")
+ foreach(_dep, invoker.static_library_dependent_targets) {
+ _dep_name = _dep.name
+ _dep_label = get_label_info(_dep_name, "label_no_toolchain")
+ deps += [ "$_dep_label$build_config_target_suffix" ]
+ _dep_gen_dir = get_label_info(_dep_name, "target_gen_dir")
+ _dep_name = get_label_info(_dep_name, "name")
_config =
rebase_path("$_dep_gen_dir/$_dep_name.build_config", root_build_dir)
_dependent_configs += [ _config ]
@@ -494,11 +534,11 @@ template("write_build_config") {
]
}
if (defined(invoker.base_module_target)) {
- _target_label =
+ _base_label =
get_label_info(invoker.base_module_target, "label_no_toolchain")
- _dep_gen_dir = get_label_info(_target_label, "target_gen_dir")
- _dep_name = get_label_info(_target_label, "name")
- deps += [ "$_target_label$build_config_target_suffix" ]
+ _dep_gen_dir = get_label_info(_base_label, "target_gen_dir")
+ _dep_name = get_label_info(_base_label, "name")
+ deps += [ "$_base_label$build_config_target_suffix" ]
args += [
"--base-module-build-config",
rebase_path("$_dep_gen_dir/$_dep_name.build_config", root_build_dir),
@@ -523,7 +563,8 @@ template("write_build_config") {
# }
_msg = [
"Tried to build an Android target in a non-default toolchain.",
- "target: " + get_label_info(":$target_name", "label_with_toolchain"),
+ "target: $_target_label",
+ "current_toolchain: $current_toolchain",
"default_toolchain: $default_toolchain",
]
args += [ "--fail=$_msg" ]
@@ -859,70 +900,89 @@ template("test_runner_script") {
}
if (enable_java_templates) {
- android_sdk_jar = "$android_sdk/android.jar"
-
template("android_lint") {
action_with_pydeps(target_name) {
forward_variables_from(invoker,
[
- "deps",
"data_deps",
"public_deps",
"testonly",
])
+ if (!defined(deps)) {
+ deps = []
+ }
+
+ # https://crbug.com/1098752 Fix for bot OOM (https://crbug.com/1098333).
+ pool = "//build/toolchain:link_pool($default_toolchain)"
+
+ # Lint only requires generated sources and generated resources from the
+ # build. Since turbine __header targets already depend on and generate all
+ # the generated sources, and the __assetres targets include all generated
+ # resources, lint only needs to depend on the header and assetres targets
+ # rather than the top level java targets.
+ if (defined(invoker.deps)) {
+ foreach(_dep, invoker.deps) {
+ _target_label = get_label_info(_dep, "label_no_toolchain")
+ if (filter_exclude([ _target_label ], _java_library_patterns) == [] &&
+ filter_exclude([ _target_label ], _java_resource_patterns) !=
+ []) {
+ deps += [
+ # Strictly speaking the __header target is sufficient, since they
+ # already depend on resources (due to srcjar deps), but prefer to
+ # be more explicit here since if/when __header targets stop
+ # depending on resources (e.g. if R.java generation moves to java
+ # targets), lint will not be affected.
+ "${_target_label}__assetres",
+ "${_target_label}__header",
+ ]
+ } else {
+ deps += [ _dep ]
+ }
+ }
+ }
+
if (defined(invoker.lint_suppressions_file)) {
- lint_suppressions_file = invoker.lint_suppressions_file
- } else if (!defined(lint_suppressions_file)) {
- # WebRTC defines its own lint_suppressions_file:
- # //tools_webrtc/android/suppressions.xml
- lint_suppressions_file = "//build/android/lint/suppressions.xml"
+ _suppressions_file = invoker.lint_suppressions_file
+
+ # The custom suppressions file might be a generated file needing a dep.
+ # e.g. generating it by appending to the default suppressions.xml file.
+ if (defined(invoker.lint_suppressions_dep)) {
+ deps += [ invoker.lint_suppressions_dep ]
+ }
+ } else {
+ _suppressions_file = "//build/android/lint/suppressions.xml"
}
_min_sdk_version = default_min_sdk_version
if (defined(invoker.min_sdk_version)) {
_min_sdk_version = invoker.min_sdk_version
}
- _lint_path = "$lint_android_sdk_root/cmdline-tools/latest/bin/lint"
+
+ _lint_binary_path = "$lint_android_sdk_root/cmdline-tools/latest/bin/lint"
_cache_dir = "$root_build_dir/android_lint_cache"
- _result_path = "$target_out_dir/$target_name/result.xml"
- _config_path = "$target_out_dir/$target_name/config.xml"
- _stamp_path = "$target_out_dir/$target_name/build.lint.stamp"
- _suppressions_file = lint_suppressions_file
- _platform_xml_path =
- "$lint_android_sdk_root/platform-tools/api/api-versions.xml"
+
+ # Save these generated xml files in a consistent location for debugging.
+ _lint_gen_dir = "$target_gen_dir/$target_name"
script = "//build/android/gyp/lint.py"
depfile = "$target_gen_dir/$target_name.d"
inputs = [
- _lint_path,
- _platform_xml_path,
+ _lint_binary_path,
_suppressions_file,
]
- # _result_path is also an output, but do not list it in order to avoid it
- # being uploaded to swarming as part of isolates. This happens as a
- # side-effect of lint targets being listed as "data_deps" in order to
- # have them run concurrently with other targets.
- outputs = [ _stamp_path ]
-
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
- "--lint-path",
- rebase_path(_lint_path, root_build_dir),
+ "--lint-binary-path",
+ rebase_path(_lint_binary_path, root_build_dir),
"--cache-dir",
rebase_path(_cache_dir, root_build_dir),
- "--platform-xml-path",
- rebase_path(_platform_xml_path, root_build_dir),
- "--android-sdk-version=${lint_android_sdk_version}",
"--config-path",
rebase_path(_suppressions_file, root_build_dir),
- "--product-dir=.",
- "--result-path",
- rebase_path(_result_path, root_build_dir),
- "--stamp",
- rebase_path(_stamp_path, root_build_dir),
- "--include-unexpected-failures",
+ "--lint-gen-dir",
+ rebase_path(_lint_gen_dir, root_build_dir),
+ "--android-sdk-version=${lint_android_sdk_version}",
"--min-sdk-version=$_min_sdk_version",
"--android-sdk-root",
rebase_path(lint_android_sdk_root, root_build_dir),
@@ -933,11 +993,27 @@ if (enable_java_templates) {
args += [ "--testonly" ]
}
+ if (defined(invoker.manifest_package)) {
+ args += [ "--manifest-package=${invoker.manifest_package}" ]
+ }
+
+ if (java_warnings_as_errors) {
+ args += [ "--can-fail-build" ]
+ }
+
+ _stamp_path = "$target_out_dir/$target_name/build.lint.stamp"
if (defined(invoker.create_cache) && invoker.create_cache) {
args += [ "--silent" ]
+
+ # Putting the stamp file in the cache dir allows us to depend on ninja
+ # to create the cache dir for us.
+ _stamp_path = "$_cache_dir/build.lint.stamp"
} else {
+ deps += [
+ "//build/android:prepare_android_lint_cache",
+ invoker.build_config_dep,
+ ]
inputs += [ invoker.build_config ]
- deps += [ "//build/android:prepare_android_lint_cache" ]
_rebased_build_config =
rebase_path(invoker.build_config, root_build_dir)
args += [
@@ -947,14 +1023,13 @@ if (enable_java_templates) {
"--resource-sources=@FileArg($_rebased_build_config:deps_info:lint_resource_sources)",
"--resource-zips=@FileArg($_rebased_build_config:deps_info:lint_resource_zips)",
]
- if (java_warnings_as_errors) {
- args += [ "--can-fail-build" ]
- }
}
- if (defined(invoker.manifest_package)) {
- args += [ "--manifest-package=${invoker.manifest_package}" ]
- }
+ outputs = [ _stamp_path ]
+ args += [
+ "--stamp",
+ rebase_path(_stamp_path, root_build_dir),
+ ]
}
}
@@ -973,7 +1048,10 @@ if (enable_java_templates) {
# http://crbug.com/725224. Fix for bots running out of memory.
_pool = "//build/toolchain:link_pool($default_toolchain)"
- _inputs = [ invoker.build_config ]
+ _inputs = [
+ invoker.build_config,
+ _r8_path,
+ ]
if (defined(invoker.inputs)) {
_inputs += invoker.inputs
}
@@ -986,6 +1064,11 @@ if (enable_java_templates) {
_mapping_path = invoker.proguard_mapping_path
}
+ _enable_jdk_library_desugaring = enable_jdk_library_desugaring
+ if (defined(invoker.supports_jdk_library_desugaring) &&
+ !invoker.supports_jdk_library_desugaring) {
+ _enable_jdk_library_desugaring = false
+ }
_proguard_sourcefile_suffix = ""
if (defined(invoker.proguard_sourcefile_suffix)) {
_proguard_sourcefile_suffix = "-${invoker.proguard_sourcefile_suffix}"
@@ -999,6 +1082,8 @@ if (enable_java_templates) {
"@FileArg($_rebased_build_config:deps_info:proguard_classpath_jars)",
"--classpath",
"@FileArg($_rebased_build_config:android:sdk_jars)",
+ "--r8-path",
+ rebase_path(_r8_path, root_build_dir),
]
if (enable_proguard_obfuscation) {
@@ -1020,7 +1105,7 @@ if (enable_java_templates) {
_args += [
"--feature-name=${_feature_module.name}",
"--dex-dest=@FileArg($_rebased_module_build_config:final_dex:path)",
- "--feature-jars=@FileArg($_rebased_module_build_config:deps_info:java_runtime_classpath)",
+ "--feature-jars=@FileArg($_rebased_module_build_config:deps_info:device_classpath)",
]
_deps += [ _feature_module.build_config_target ]
}
@@ -1066,26 +1151,25 @@ if (enable_java_templates) {
]
}
- if (!defined(invoker.proguard_jar_path)) {
+ if (_enable_jdk_library_desugaring) {
_args += [
- "--r8-path",
- rebase_path(_r8_path, root_build_dir),
+ "--desugar-jdk-libs-json",
+ rebase_path(_desugar_jdk_libs_json, root_build_dir),
]
- _inputs += [ _r8_path ]
- if (enable_jdk_library_desugaring) {
- _args += [
- "--desugar-jdk-libs-json",
- rebase_path(_desugar_jdk_libs_json, root_build_dir),
- ]
- _inputs += [ _desugar_jdk_libs_json ]
- }
- } else {
- _proguard_jar_path = invoker.proguard_jar_path
+ _inputs += [ _desugar_jdk_libs_json ]
+
+ _args += [
+ "--desugar-jdk-libs-jar",
+ rebase_path(_desugar_jdk_libs_jar, root_build_dir),
+ ]
+ _inputs += [ _desugar_jdk_libs_jar ]
+
+ _desugared_library_keep_rule_output_path =
+ "$target_gen_dir/$target_name.desugared_library_keep_rules.flags"
_args += [
- "--proguard-path",
- rebase_path(_proguard_jar_path, root_build_dir),
+ "--desugared-library-keep-rule-output",
+ rebase_path(_desugared_library_keep_rule_output_path, root_build_dir),
]
- _inputs += [ _proguard_jar_path ]
}
_enable_assert = is_java_debug || dcheck_always_on
@@ -1099,45 +1183,39 @@ if (enable_java_templates) {
_args += invoker.args
}
- if (defined(invoker.verify_proguard_flags_target_name)) {
- _expectations_target = "${invoker.verify_proguard_flags_target_name}" +
- "_proguard_expectations"
+ if (defined(invoker.expected_proguard_config)) {
+ _expectations_target =
+ "${invoker.top_target_name}_validate_proguard_config"
action_with_pydeps(_expectations_target) {
- _expected_configs_file =
- get_label_info(":${invoker.verify_proguard_flags_target_name}",
- "dir") +
- "/java/${invoker.verify_proguard_flags_target_name}" +
- ".proguard_flags.expected"
- _failed_proguard_expectation_file =
- "$android_configuration_failure_dir/" +
- string_replace(_expected_configs_file, "/", "_")
- _expectation_stamp = "${target_gen_dir}/${_expectations_target}.stamp"
- if (fail_on_android_expectations) {
- args += [ "--fail-on-expectations" ]
- }
script = _script
# Need to depend on all deps so that proguard.txt within .aar files get
# extracted.
deps = _deps
- pool = _pool
depfile = "${target_gen_dir}/${target_name}.d"
inputs = [
invoker.build_config,
- _expected_configs_file,
+ invoker.expected_proguard_config,
]
+ _failure_file =
+ "$android_configuration_failure_dir/" +
+ string_replace(invoker.expected_proguard_config, "/", "_")
+ _expectation_stamp = "$target_gen_dir/$target_name.stamp"
outputs = [ _expectation_stamp ]
args = _args + [
"--depfile",
rebase_path(depfile, root_build_dir),
"--proguard-expectations-failure-file",
- rebase_path(_failed_proguard_expectation_file, root_build_dir),
+ rebase_path(_failure_file, root_build_dir),
"--expected-configs-file",
- rebase_path(_expected_configs_file, root_build_dir),
+ rebase_path(invoker.expected_proguard_config, root_build_dir),
"--stamp",
rebase_path(_expectation_stamp, root_build_dir),
"--only-verify-expectations",
]
+ if (fail_on_android_expectations) {
+ args += [ "--fail-on-expectations" ]
+ }
}
_deps += [ ":$_expectations_target" ]
}
@@ -1186,7 +1264,9 @@ if (enable_java_templates) {
"--main-class",
_main_class,
]
- args += [ "--classpath=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)" ]
+ args += [
+ "--classpath=@FileArg($_rebased_build_config:deps_info:host_classpath)",
+ ]
if (use_jacoco_coverage) {
args += [
@@ -1214,8 +1294,6 @@ if (enable_java_templates) {
_proguard_enabled =
defined(invoker.proguard_enabled) && invoker.proguard_enabled
_is_dex_merging = defined(invoker.input_dex_filearg)
- _proguarding_with_r8 =
- _proguard_enabled && !defined(invoker.proguard_jar_path)
_enable_multidex =
!defined(invoker.enable_multidex) || invoker.enable_multidex
_enable_main_dex_list = _enable_multidex && _min_sdk_version < 21
@@ -1228,6 +1306,9 @@ if (enable_java_templates) {
}
}
+ # It's not safe to dex merge with libraries dex'ed at higher api versions.
+ assert(!_is_dex_merging || _min_sdk_version >= default_min_sdk_version)
+
# For D8's backported method desugaring to work properly, the dex merge step
# must not be set to a higher minSdkVersion than it was for the libraries.
if (_enable_desugar && _is_dex_merging) {
@@ -1235,7 +1316,7 @@ if (enable_java_templates) {
}
assert(defined(invoker.output) ||
- (_proguarding_with_r8 && defined(invoker.modules)))
+ (_proguard_enabled && defined(invoker.modules)))
assert(!_proguard_enabled || !(defined(invoker.input_dex_filearg) ||
defined(invoker.input_classes_filearg) ||
defined(invoker.input_class_jars)),
@@ -1257,30 +1338,29 @@ if (enable_java_templates) {
}
if (_proguard_enabled) {
- if (_proguarding_with_r8) {
- if (defined(invoker.output)) {
- _proguard_output_path = invoker.output
- }
- _proguard_target_name = target_name
- } else {
- _proguard_output_path = invoker.output + ".proguard.jar"
- _proguard_target_name = "${target_name}__proguard"
+ if (defined(invoker.output)) {
+ _proguard_output_path = invoker.output
}
+ _proguard_target_name = target_name
proguard(_proguard_target_name) {
forward_variables_from(invoker,
[
"build_config",
+ "data",
+ "data_deps",
+ "deps",
"disable_checkdiscard",
"disable_r8_outlining",
- "deps",
+ "expected_proguard_config",
+ "is_static_library",
"modules",
- "verify_proguard_flags_target_name",
- "proguard_jar_path",
"proguard_mapping_path",
"proguard_sourcefile_suffix",
- "is_static_library",
+ "supports_jdk_library_desugaring",
"testonly",
+ "top_target_name",
+ "visibiity",
])
inputs = []
if (defined(invoker.inputs)) {
@@ -1292,13 +1372,20 @@ if (enable_java_templates) {
args = [
"--proguard-configs=@FileArg($_rebased_build_config:deps_info:proguard_all_configs)",
- "--input-paths=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)",
"--min-api=$_min_sdk_version",
]
+ if (defined(invoker.has_apk_under_test) && invoker.has_apk_under_test) {
+ args += [ "--input-paths=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath_extended)" ]
+ } else {
+ args += [ "--input-paths=@FileArg($_rebased_build_config:deps_info:device_classpath)" ]
+ }
if (enable_bazel_desugar) {
deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ]
- inputs += [ "$root_build_dir/lib.java/third_party/bazel/desugar/Desugar_runtime.jar" ]
- args += [ "--input-paths=lib.java/third_party/bazel/desugar/Desugar_runtime.jar" ]
+ inputs += [ _desugar_runtime_jar ]
+ args += [
+ "--input-paths",
+ rebase_path(_desugar_runtime_jar, root_build_dir),
+ ]
}
if (defined(invoker.proguard_args)) {
args += invoker.proguard_args
@@ -1317,7 +1404,7 @@ if (enable_java_templates) {
args += [ "--apply-mapping=$_rebased_apply_mapping_path" ]
}
- if (_proguarding_with_r8 && _enable_main_dex_list) {
+ if (_enable_main_dex_list) {
if (defined(invoker.extra_main_dex_proguard_config)) {
args += [
"--main-dex-rules-path",
@@ -1335,36 +1422,25 @@ if (enable_java_templates) {
if (defined(_proguard_output_path)) {
output_path = _proguard_output_path
- if (_proguarding_with_r8) {
- config_output_path = "$_proguard_output_path.proguard_flags"
- }
+ config_output_path = "$_proguard_output_path.proguard_flags"
} else {
mapping_path = "$target_out_dir/$target_name.mapping"
- if (_proguarding_with_r8) {
- config_output_path = "$target_out_dir/$target_name.proguard_flags"
- }
+ config_output_path = "$target_out_dir/$target_name.proguard_flags"
}
}
- }
-
- if (!_proguarding_with_r8) {
+ } else { # !_proguard_enabled
+ _is_library = defined(invoker.is_library) && invoker.is_library
_input_class_jars = []
if (defined(invoker.input_class_jars)) {
_input_class_jars = invoker.input_class_jars
}
- if (_proguard_enabled) {
- _input_class_jars += [ _proguard_output_path ]
- }
_deps = invoker.deps
- if (_proguard_enabled) {
- _deps += [ ":${_proguard_target_name}" ]
- }
- if (_is_dex_merging && enable_bazel_desugar) {
+ if (!_is_library && enable_bazel_desugar) {
# It would be more efficient to use the pre-dex'ed copy of the runtime,
# but it's easier to add it in this way.
_deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ]
- _input_class_jars += [ "$root_build_dir/lib.java/third_party/bazel/desugar/Desugar_runtime.jar" ]
+ _input_class_jars += [ _desugar_runtime_jar ]
}
if (_input_class_jars != []) {
_rebased_input_class_jars =
@@ -1442,7 +1518,13 @@ if (enable_java_templates) {
}
action_with_pydeps(target_name) {
- forward_variables_from(invoker, [ "testonly" ])
+ forward_variables_from(invoker,
+ [
+ "data",
+ "data_deps",
+ "testonly",
+ "visibility",
+ ])
script = "//build/android/gyp/dex.py"
deps = _deps
depfile = "$target_gen_dir/$target_name.d"
@@ -1459,9 +1541,8 @@ if (enable_java_templates) {
rebase_path(_r8_path, root_build_dir),
]
- if (!_proguard_enabled && enable_incremental_d8 &&
- !(defined(invoker.disable_incremental) &&
- invoker.disable_incremental)) {
+ if (enable_incremental_d8 && !(defined(invoker.disable_incremental) &&
+ invoker.disable_incremental)) {
# Don't use incremental dexing for ProGuarded inputs as a precaution.
args += [
"--incremental-dir",
@@ -1479,11 +1560,10 @@ if (enable_java_templates) {
deps += [ ":${_main_dex_list_target_name}" ]
inputs += [ _main_dex_list_path ]
}
- } else if (defined(invoker.enable_library_multidex) &&
- invoker.enable_library_multidex) {
- args += [ "--multi-dex" ]
}
-
+ if (_is_library) {
+ args += [ "--library" ]
+ }
if (defined(invoker.input_dex_filearg)) {
inputs += [ invoker.build_config ]
args += [ "--dex-inputs-filearg=${invoker.input_dex_filearg}" ]
@@ -1515,20 +1595,13 @@ if (enable_java_templates) {
invoker.dexlayout_profile,
]
inputs += _default_art_libs
- if (_proguard_enabled) {
- args += [
- "--proguard-mapping-path",
- rebase_path(invoker.proguard_mapping_path, root_build_dir),
- ]
- inputs += [ invoker.proguard_mapping_path ]
- }
}
# Never compile intemediates with --release in order to:
# 1) not require recompiles when toggling is_java_debug,
# 2) allow incremental_install=1 to still have local variable
# information even when is_java_debug=false.
- if (!is_java_debug && _is_dex_merging) {
+ if (!is_java_debug && !_is_library) {
args += [ "--release" ]
}
@@ -1605,7 +1678,9 @@ if (enable_java_templates) {
"testonly",
])
- _sources_json_file = "$target_out_dir/${target_name}_sources.json"
+ # The name needs to match the SOURCES_JSON_FILES_SUFFIX in
+ # generate_coverage_metadata_for_java.py.
+ _sources_json_file = "$target_out_dir/${target_name}__jacoco_sources.json"
_jacococli_jar = "//third_party/jacoco/lib/jacococli.jar"
script = "//build/android/gyp/jacoco_instr.py"
@@ -1638,115 +1713,78 @@ if (enable_java_templates) {
}
}
- # TODO(digit): Document this!
- #
- # Variables:
- # testonly:
- # build_config:
- # input_jar_path:
- # output_jar_path:
- # supports_android:
- # jacoco_instrument: Use Jacoco-instrumented classes to generate Java
- # coverage data.
- # jar_excluded_patterns: Optional list of .class file patterns to exclude
- # from the final .jar file.
- # jar_included_patterns: Optional list of .class file patterns to include
- # in the final .jar file. jar_excluded_patterns take precedence over this.
- # skip_jetify: A boolean on whether to skip jetifying or not.
- # strip_resource_classes:
- # deps:
- # java_files:
- # java_sources_file:
- # inputs:
- # data_deps:
- # visibility:
- #
- template("process_java_prebuilt") {
- set_sources_assignment_filter([])
- forward_variables_from(invoker, [ "testonly" ])
-
- assert(invoker.build_config != "")
- _build_config = invoker.build_config
- _rebased_build_config = rebase_path(_build_config, root_build_dir)
- assert(_rebased_build_config != "" || true) # Mark used.
-
- _input_jar_path = invoker.input_jar_path
- _output_jar_path = invoker.output_jar_path
-
- # Turned off because of existing code which fails the assertion
- _enable_thread_annotations = false
-
- _jacoco_instrument = invoker.jacoco_instrument
- _skip_jetify = defined(invoker.skip_jetify) && invoker.skip_jetify
+ template("filter_jar") {
+ action_with_pydeps(target_name) {
+ script = "//build/android/gyp/filter_zip.py"
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "testonly",
+ ])
+ inputs = [ invoker.input_jar ]
+ if (defined(invoker.inputs)) {
+ inputs += invoker.inputs
+ }
+ outputs = [ invoker.output_jar ]
- _enable_bytecode_rewriter = _enable_thread_annotations
- _is_prebuilt = defined(invoker.is_prebuilt) && invoker.is_prebuilt
- _enable_bytecode_checks = !defined(invoker.enable_bytecode_checks) ||
- invoker.enable_bytecode_checks
- _missing_classes_allowlist = []
- if (defined(invoker.missing_classes_allowlist)) {
- _missing_classes_allowlist = invoker.missing_classes_allowlist
+ _jar_excluded_patterns = []
+ if (defined(invoker.jar_excluded_patterns)) {
+ _jar_excluded_patterns = invoker.jar_excluded_patterns
+ }
+ _jar_included_patterns = []
+ if (defined(invoker.jar_included_patterns)) {
+ _jar_included_patterns = invoker.jar_included_patterns
+ }
+ _strip_resource_classes = defined(invoker.strip_resource_classes) &&
+ invoker.strip_resource_classes
+ args = [
+ "--input",
+ rebase_path(invoker.input_jar, root_build_dir),
+ "--output",
+ rebase_path(invoker.output_jar, root_build_dir),
+ "--exclude-globs=${_jar_excluded_patterns}",
+ "--include-globs=${_jar_included_patterns}",
+ ]
+ if (_strip_resource_classes) {
+ inputs += [ invoker.build_config ]
+ _rebased_build_config =
+ rebase_path(invoker.build_config, root_build_dir)
+ args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
+ }
}
+ }
- # Release builds don't have asserts enabled, so they often will not run the
- # bytecode rewriter. We are okay with having release builds not run the
- # bytecode checks at all, since the dependency errors can be caught in debug
- # mode.
- not_needed([
- "_is_prebuilt",
- "_enable_bytecode_checks",
- "_missing_classes_allowlist",
- ])
- if (defined(invoker.enable_bytecode_rewriter)) {
- not_needed([
- "_enable_custom_resources",
- "_enable_thread_annotations",
- ])
- _enable_bytecode_rewriter = invoker.enable_bytecode_rewriter
- }
+ template("process_java_prebuilt") {
+ forward_variables_from(invoker, [ "testonly" ])
- _jar_excluded_patterns = []
- if (defined(invoker.jar_excluded_patterns)) {
- _jar_excluded_patterns = invoker.jar_excluded_patterns
- }
- _jar_included_patterns = []
- if (defined(invoker.jar_included_patterns)) {
- _jar_included_patterns = invoker.jar_included_patterns
- }
- _strip_resource_classes = defined(invoker.strip_resource_classes) &&
- invoker.strip_resource_classes
- _filter_jar = _jar_excluded_patterns != [] ||
- _jar_included_patterns != [] || _strip_resource_classes
+ _rebased_build_config = rebase_path(invoker.build_config, root_build_dir)
+ not_needed([ "_rebased_build_config" ])
+ not_needed(invoker, [ "build_config_dep" ])
- _deps = []
- _previous_output_jar = _input_jar_path
+ _deps = invoker.jar_deps
+ _previous_output_jar = invoker.input_jar_path
- if (!_skip_jetify) {
+ if (defined(invoker.jetified_jar_path)) {
_jetify_target = "${target_name}__jetify"
- _jetify_input_jar = _previous_output_jar
- _jetify_output_jar = "$target_out_dir/$target_name.jetified.jar"
action_with_pydeps(_jetify_target) {
script = "//build/android/gyp/jetify_jar.py"
deps = _deps
- if (defined(invoker.deps)) {
- deps += invoker.deps
- }
_jetify_jar_path =
"//third_party/jetifier_standalone/bin/jetifier-standalone"
_jetify_config_path =
"//third_party/jetifier_standalone/config/ignore_R.config"
inputs = [
- _jetify_input_jar,
+ _previous_output_jar,
_jetify_jar_path,
]
- outputs = [ _jetify_output_jar ]
+ outputs = [ invoker.jetified_jar_path ]
args = [
"--input-path",
rebase_path(invoker.input_jar_path, root_build_dir),
"--output-path",
- rebase_path(_jetify_output_jar, root_build_dir),
+ rebase_path(invoker.jetified_jar_path, root_build_dir),
"--jetify-path",
rebase_path(_jetify_jar_path, root_build_dir),
"--jetify-config-path",
@@ -1756,192 +1794,159 @@ if (enable_java_templates) {
_deps = []
_deps = [ ":$_jetify_target" ]
- _previous_output_jar = _jetify_output_jar
- }
-
- if (_enable_bytecode_rewriter) {
- _java_bytecode_rewriter_target = "${target_name}__bytecode_rewrite"
- _java_bytecode_rewriter_input_jar = _previous_output_jar
- _java_bytecode_rewriter_output_jar =
- "$target_out_dir/$target_name.bytecode-rewritten.jar"
-
- action_with_pydeps(_java_bytecode_rewriter_target) {
- script = "//build/android/gyp/bytecode_processor.py"
- _bytecode_rewriter_script =
- "$root_build_dir/bin/helper/java_bytecode_rewriter"
- deps = _deps + [ "//build/android/bytecode:java_bytecode_rewriter($default_toolchain)" ]
- if (defined(invoker.deps)) {
- deps += invoker.deps
- }
- inputs = [
- _bytecode_rewriter_script,
- _java_bytecode_rewriter_input_jar,
- _build_config,
- ]
- outputs = [ _java_bytecode_rewriter_output_jar ]
- args = [
- "--script",
- rebase_path(_bytecode_rewriter_script, root_build_dir),
- "--input-jar",
- rebase_path(_java_bytecode_rewriter_input_jar, root_build_dir),
- "--output-jar",
- rebase_path(_java_bytecode_rewriter_output_jar, root_build_dir),
- ]
- if (_is_prebuilt) {
- args += [ "--is-prebuilt" ]
- }
- if (defined(_enable_custom_resources) && _enable_custom_resources) {
- args += [ "--enable-custom-resources" ]
- }
- if (_enable_thread_annotations) {
- args += [ "--enable-thread-annotations" ]
+ _previous_output_jar = invoker.jetified_jar_path
+ }
+
+ # Create the .jar in lib.java for use by java_binary.
+ if (defined(invoker.host_jar_path)) {
+ filter_jar("${target_name}_host") {
+ forward_variables_from(invoker,
+ [
+ "jar_excluded_patterns",
+ "jar_included_patterns",
+ "strip_resource_classes",
+ ])
+ deps = _deps
+ input_jar = _previous_output_jar
+ output_jar = invoker.host_jar_path
+ inputs = []
+ if (defined(strip_resource_classes) && strip_resource_classes) {
+ inputs += [ invoker.build_config ]
+ deps += [ invoker.build_config_dep ]
+ args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
}
- if (_enable_bytecode_checks) {
- args += [ "--enable-check-class-path" ]
+ if (defined(invoker.inputs)) {
+ inputs += invoker.inputs
+ deps += invoker.input_deps
}
- args += [
- "--missing-classes-allowlist",
- "${_missing_classes_allowlist}",
- "--direct-classpath-jars",
- "@FileArg($_rebased_build_config:javac:classpath)",
- "--sdk-classpath-jars",
- "@FileArg($_rebased_build_config:android:sdk_jars)",
- "--extra-classpath-jars",
- "@FileArg($_rebased_build_config:deps_info:javac_full_classpath)",
- ]
}
-
- _deps = []
- _deps = [ ":$_java_bytecode_rewriter_target" ]
- _previous_output_jar = _java_bytecode_rewriter_output_jar
}
- if (invoker.enable_desugar) {
- _desugar_target = "${target_name}__desugar"
- _desugar_input_jar = _previous_output_jar
- _desugar_output_jar = "$target_out_dir/$target_name.desugar.jar"
+ if (defined(invoker.device_jar_path)) {
+ if (invoker.enable_desugar) {
+ _desugar_target = "${target_name}_device__desugar"
+ _desugar_output_jar = "$target_out_dir/$target_name.desugar.jar"
- action_with_pydeps(_desugar_target) {
- script = "//build/android/gyp/desugar.py"
- deps = _deps
- depfile = "$target_gen_dir/$target_name.d"
- if (defined(invoker.deps)) {
- deps += invoker.deps
+ action_with_pydeps(_desugar_target) {
+ script = "//build/android/gyp/desugar.py"
+ deps = _deps + invoker.classpath_deps
+ depfile = "$target_gen_dir/$target_name.d"
+ _desugar_jar = "//third_party/bazel/desugar/Desugar.jar"
+
+ inputs = [
+ invoker.build_config,
+ _previous_output_jar,
+ _desugar_jar,
+ ]
+ outputs = [ _desugar_output_jar ]
+ args = [
+ "--desugar-jar",
+ rebase_path(_desugar_jar, root_build_dir),
+ "--input-jar",
+ rebase_path(_previous_output_jar, root_build_dir),
+ "--output-jar",
+ rebase_path(_desugar_output_jar, root_build_dir),
+
+ # Temporarily using java_full_interface_classpath until classpath validation of targets
+ # is implemented, see http://crbug.com/885273
+ "--classpath=@FileArg($_rebased_build_config:deps_info:jetified_full_jar_classpath)",
+ "--bootclasspath=@FileArg($_rebased_build_config:android:sdk_interface_jars)",
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ ]
}
- _desugar_jar = "//third_party/bazel/desugar/Desugar.jar"
- inputs = [
- _build_config,
- _desugar_input_jar,
- _desugar_jar,
- ]
- outputs = [ _desugar_output_jar ]
- args = [
- "--desugar-jar",
- rebase_path(_desugar_jar, root_build_dir),
- "--input-jar",
- rebase_path(_desugar_input_jar, root_build_dir),
- "--output-jar",
- rebase_path(_desugar_output_jar, root_build_dir),
-
- # Temporarily using java_full_interface_classpath until classpath validation of targets
- # is implemented, see http://crbug.com/885273
- "--classpath=@FileArg($_rebased_build_config:deps_info:jetified_full_jar_classpath)",
- "--bootclasspath=@FileArg($_rebased_build_config:android:sdk_interface_jars)",
- "--depfile",
- rebase_path(depfile, root_build_dir),
- ]
+ _deps = []
+ _deps = [ ":$_desugar_target" ]
+ _previous_output_jar = _desugar_output_jar
}
- _deps = []
- _deps = [ ":$_desugar_target" ]
- _previous_output_jar = _desugar_output_jar
- }
-
- if (_filter_jar) {
- _filter_target = "${target_name}__filter"
- _filter_input_jar = _previous_output_jar
- _filter_output_jar = "$target_out_dir/$target_name.filtered.jar"
-
- action_with_pydeps(_filter_target) {
- script = "//build/android/gyp/filter_zip.py"
+ if (invoker.jacoco_instrument) {
+ _filter_jar_target_name = "${target_name}_device__filter_jar"
+ _filter_jar_output_jar = "$target_out_dir/$target_name.filter.jar"
+ } else {
+ _filter_jar_target_name = "${target_name}_device"
+ _filter_jar_output_jar = invoker.device_jar_path
+ }
+ filter_jar(_filter_jar_target_name) {
+ forward_variables_from(invoker,
+ [
+ "jar_excluded_patterns",
+ "jar_included_patterns",
+ "strip_resource_classes",
+ ])
deps = _deps
- if (defined(invoker.deps)) {
- deps += invoker.deps
- }
- inputs = [
- _build_config,
- _filter_input_jar,
- ]
- outputs = [ _filter_output_jar ]
- args = [
- "--input",
- rebase_path(_filter_input_jar, root_build_dir),
- "--output",
- rebase_path(_filter_output_jar, root_build_dir),
- "--exclude-globs=$_jar_excluded_patterns",
- "--include-globs=$_jar_included_patterns",
- ]
- if (_strip_resource_classes) {
+ input_jar = _previous_output_jar
+ output_jar = _filter_jar_output_jar
+ inputs = []
+ if (defined(strip_resource_classes) && strip_resource_classes) {
+ inputs += [ invoker.build_config ]
+ deps += [ invoker.build_config_dep ]
args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
}
+ if (!defined(invoker.host_jar_path) && defined(invoker.inputs)) {
+ inputs += invoker.inputs
+ deps += invoker.input_deps
+ }
}
- _deps = []
- _deps = [ ":$_filter_target" ]
- _previous_output_jar = _filter_output_jar
- }
-
- if (_jacoco_instrument) {
- # Jacoco must run after desugar (or else desugar sometimes fails).
- _jacoco_target = "${target_name}__jacoco"
- _jacoco_input_jar = _previous_output_jar
- _jacoco_output_jar = "$target_out_dir/$target_name.instrumented.jar"
+ if (invoker.jacoco_instrument) {
+ # Jacoco must run after desugar (or else desugar sometimes fails).
+ # It must run after filtering to avoid the same (filtered) class mapping
+ # to multiple .jar files.
+ jacoco_instr("${target_name}_device") {
+ deps = [ ":$_filter_jar_target_name" ] + invoker.jar_deps
+ forward_variables_from(invoker,
+ [
+ "java_files",
+ "java_sources_file",
+ ])
- jacoco_instr(_jacoco_target) {
- deps = _deps
- if (defined(invoker.deps)) {
- deps += invoker.deps
+ input_jar_path = _filter_jar_output_jar
+ output_jar_path = invoker.device_jar_path
}
-
- forward_variables_from(invoker,
- [
- "java_files",
- "java_sources_file",
- ])
-
- input_jar_path = _jacoco_input_jar
- output_jar_path = _jacoco_output_jar
}
-
- _deps = []
- _deps = [ ":$_jacoco_target" ]
- _previous_output_jar = _jacoco_output_jar
}
+ }
- _output_jar_target = "${target_name}__copy"
-
- # This is copy_ex rather than copy to ensure that JARs (rather than
- # possibly broken symlinks to them) get copied into the output
- # directory.
- copy_ex(_output_jar_target) {
- forward_variables_from(invoker, [ "inputs" ])
- deps = _deps
- if (defined(invoker.deps)) {
- deps += invoker.deps
+ template("bytecode_processor") {
+ action_with_pydeps(target_name) {
+ forward_variables_from(invoker, [ "testonly" ])
+ _bytecode_checker_script = "$root_build_dir/bin/helper/bytecode_processor"
+ script = "//build/android/gyp/bytecode_processor.py"
+ inputs = [
+ invoker.build_config,
+ invoker.input_jar,
+ _bytecode_checker_script,
+ ]
+ outputs = [ "$target_out_dir/$target_name.bytecode.stamp" ]
+ deps =
+ invoker.deps +
+ [ "//build/android/bytecode:bytecode_processor($default_toolchain)" ]
+ _rebased_build_config = rebase_path(invoker.build_config, root_build_dir)
+ args = [
+ "--script",
+ rebase_path(_bytecode_checker_script, root_build_dir),
+ "--gn-target=${invoker.target_label}",
+ "--input-jar",
+ rebase_path(invoker.input_jar, root_build_dir),
+ "--stamp",
+ rebase_path(outputs[0], root_build_dir),
+ "--direct-classpath-jars=@FileArg($_rebased_build_config:javac:classpath)",
+ "--full-classpath-jars=@FileArg($_rebased_build_config:deps_info:javac_full_classpath)",
+ "--full-classpath-gn-targets=@FileArg($_rebased_build_config:deps_info:javac_full_classpath_targets)",
+ ]
+ if (invoker.is_prebuilt) {
+ args += [ "--is-prebuilt" ]
+ }
+ if (invoker.requires_android) {
+ args += [ "--sdk-classpath-jars=@FileArg($_rebased_build_config:android:sdk_jars)" ]
+ }
+ if (defined(invoker.missing_classes_allowlist)) {
+ args += [
+ "--missing-classes-allowlist=${invoker.missing_classes_allowlist}",
+ ]
}
- dest = _output_jar_path
- sources = [ _previous_output_jar ]
- outputs = [ _output_jar_path ]
- }
-
- group(target_name) {
- forward_variables_from(invoker,
- [
- "data_deps",
- "visibility",
- ])
- public_deps = [ ":$_output_jar_target" ]
}
}
@@ -2125,10 +2130,14 @@ if (enable_java_templates) {
# final R.java sources for all resource packages the binary depends on.
#
# Input variables:
+ # android_sdk_dep: The sdk dep that these resources should compile against.
+ #
# deps: Specifies the input dependencies for this target.
#
# build_config: Path to the .build_config file corresponding to the target.
#
+ # build_config_dep: Dep target to generate the .build_config file.
+ #
# android_manifest: Path to root manifest for the binary.
#
# version_code: (optional)
@@ -2238,7 +2247,23 @@ if (enable_java_templates) {
"visibility",
])
- _deps = invoker.deps
+ _deps = [
+ invoker.android_sdk_dep,
+ invoker.build_config_dep,
+ ]
+ if (defined(invoker.android_manifest_dep)) {
+ _deps += [ invoker.android_manifest_dep ]
+ }
+ foreach(_dep, invoker.deps) {
+ _target_label = get_label_info(_dep, "label_no_toolchain")
+ if (filter_exclude([ _target_label ], _java_library_patterns) == [] &&
+ filter_exclude([ _target_label ], _java_resource_patterns) != []) {
+ # Depend on the java libraries' transitive __assetres target instead.
+ _deps += [ "${_target_label}__assetres" ]
+ } else {
+ _deps += [ _dep ]
+ }
+ }
if (defined(invoker.arsc_output)) {
_arsc_output = invoker.arsc_output
@@ -2506,43 +2531,26 @@ if (enable_java_templates) {
_args += [ "--is-bundle-module" ]
}
- if (defined(invoker.verify_manifest_target_name)) {
+ if (defined(invoker.expected_android_manifest)) {
_expectations_target =
- "${invoker.verify_manifest_target_name}_manifest_expectations"
+ "${invoker.top_target_name}_validate_android_manifest"
action_with_pydeps(_expectations_target) {
- _target_src_dir = get_label_info(":$target_name", "dir")
_normalized_output = "${invoker.android_manifest}.normalized"
- _manifest_expectations_failure_filepath =
+ _failure_file =
"$android_configuration_failure_dir/" +
- "${invoker.verify_manifest_target_name}.AndroidManifest.failed"
+ string_replace(invoker.expected_android_manifest, "/", "_")
inputs = [
invoker.android_manifest,
invoker.build_config,
+ invoker.expected_android_manifest,
]
- if (defined(invoker.expected_manifest_base_expectation)) {
+ if (defined(invoker.expected_android_manifest_base)) {
_args += [
"--expected-manifest-base-expectation",
- rebase_path(invoker.expected_manifest_base_expectation,
- root_build_dir),
+ rebase_path(invoker.expected_android_manifest_base, root_build_dir),
]
- inputs += [ invoker.expected_manifest_base_expectation ]
-
- # When invoker.expected_manifest_base_expectation is defined, we use
- # a different file extension to indicate that the expected file is a
- # diff file.
- # In addition, we set expected_manifest_base_expectation only for
- # internal targets, therefore, the expected file is in a different
- # directory.
- _expected_file =
- "$_target_src_dir/" +
- "${invoker.verify_manifest_target_name}.AndroidManifest" +
- ".diff.expected"
- } else {
- _expected_file =
- "$_target_src_dir/java/" +
- "${invoker.verify_manifest_target_name}.AndroidManifest.expected"
+ inputs += [ invoker.expected_android_manifest_base ]
}
- inputs += [ _expected_file ]
if (fail_on_android_expectations) {
_args += [ "--fail-on-expectations" ]
}
@@ -2555,12 +2563,11 @@ if (enable_java_templates) {
script = _script
args = _args + [
"--expected-file",
- rebase_path(_expected_file, root_build_dir),
+ rebase_path(invoker.expected_android_manifest, root_build_dir),
"--android-manifest-normalized",
rebase_path(_normalized_output, root_build_dir),
"--android-manifest-expectations-failure-file",
- rebase_path(_manifest_expectations_failure_filepath,
- root_build_dir),
+ rebase_path(_failure_file, root_build_dir),
"--only-verify-expectations",
]
}
@@ -2636,7 +2643,7 @@ if (enable_java_templates) {
_rebased_build_config =
rebase_path(invoker.build_config, root_build_dir)
args += [
- "--jar-files=@FileArg($_rebased_build_config:deps_info:jar_path)",
+ "--jar-files=@FileArg($_rebased_build_config:deps_info:unprocessed_jar_path)",
"--jar-files=@FileArg($_rebased_build_config:deps_info:javac_full_classpath)",
"--in-res-info-path",
rebase_path(invoker.res_size_info_path, root_build_dir),
@@ -2675,9 +2682,8 @@ if (enable_java_templates) {
# keystore_password: Keystore password.
# uncompress_shared_libraries: (optional, default false) Whether to store
# native libraries inside the APK uncompressed and page-aligned.
- # verify_native_libs_and_assets_target_name: (optional): If set, will verify
- # the list of included native libraries and assets is consistent with an
- # expectation file.
+ # expected_libs_and_assets: (optional): Verify the list of included native
+ # libraries and assets is consistent with the given expectation file.
template("package_apk") {
forward_variables_from(invoker,
[
@@ -2803,43 +2809,33 @@ if (enable_java_templates) {
_args += [ "--secondary-native-lib-placeholders=$_secondary_native_lib_placeholders" ]
}
- if (defined(invoker.verify_native_libs_and_assets_target_name)) {
+ if (defined(invoker.expected_libs_and_assets)) {
_expectations_target =
- "${invoker.verify_native_libs_and_assets_target_name}" +
- "_libs_and_assets_expectations"
+ "${invoker.top_target_name}_validate_libs_and_assets"
action_with_pydeps(_expectations_target) {
_stamp = "$target_gen_dir/$target_name.stamp"
- _target_src_dir = get_label_info(":$target_name", "dir")
- _expected_native_libs_and_assets =
- "$_target_src_dir/java/" +
- "${invoker.verify_native_libs_and_assets_target_name}." +
- "${target_cpu}.native_libs_and_assets.expected"
- _native_libs_and_assets_expectation_failure_filepath =
+ _failure_file =
"$android_configuration_failure_dir/" +
- "${invoker.verify_native_libs_and_assets_target_name}." +
- "${target_cpu}.native_libs_and_assets.failed"
- if (fail_on_android_expectations) {
- _args += [ "--fail-on-expectations" ]
- }
-
+ string_replace(invoker.expected_libs_and_assets, "/", "_")
inputs = [
invoker.build_config,
- _expected_native_libs_and_assets,
+ invoker.expected_libs_and_assets,
]
deps = [ invoker.build_config_dep ]
outputs = [ _stamp ]
script = _script
- args =
- _args + [
- "--expected-native-libs-and-assets",
- rebase_path(_expected_native_libs_and_assets, root_build_dir),
- "--native-libs-and-assets-expectation-failure-file",
- rebase_path(_native_libs_and_assets_expectation_failure_filepath,
- root_build_dir),
- "--stamp",
- rebase_path(_stamp, root_build_dir),
- "--only-verify-expectations",
- ]
+ args = _args + [
+ "--expected-native-libs-and-assets",
+ rebase_path(invoker.expected_libs_and_assets, root_build_dir),
+ "--native-libs-and-assets-expectation-failure-file",
+ rebase_path(_failure_file, root_build_dir),
+ "--stamp",
+ rebase_path(_stamp, root_build_dir),
+ "--only-verify-expectations",
+ ]
+ if (fail_on_android_expectations) {
+ args += [ "--fail-on-expectations" ]
+ }
}
_deps += [ ":$_expectations_target" ]
}
@@ -2889,7 +2885,6 @@ if (enable_java_templates) {
# javac:processor_classes
# javac_jar_path: Path to the final output .jar file.
# javac_args: Optional list of extra arguments to pass to javac.
- # never_goma: When true, ignore the value of use_java_goma.
# chromium_code: Whether this corresponds to Chromium-specific sources.
# requires_android: True if these sources can only run on Android.
# additional_jar_files: Optional list of files to copy into the resulting
@@ -3016,8 +3011,7 @@ if (enable_java_templates) {
if (invoker.supports_android || invoker.use_turbine) {
args += [ "--java-version=1.8" ]
}
- if ((!defined(invoker.never_goma) || !invoker.never_goma) &&
- use_java_goma) {
+ if (use_java_goma) {
args += [ "--gomacc-path=$goma_dir/gomacc" ]
# Override the default action_pool when goma is enabled.
@@ -3047,16 +3041,14 @@ if (enable_java_templates) {
if (invoker.enable_errorprone) {
# Our custom plugin pulls in the main errorprone dep transitively.
- _errorprone_dep =
- "//tools/android/errorprone_plugin:errorprone_plugin_java"
+ _errorprone_dep = "//tools/android/errorprone_plugin:errorprone_plugin"
deps += [ _errorprone_dep ]
_dep_gen_dir = get_label_info(_errorprone_dep, "target_gen_dir")
_dep_name = get_label_info(_errorprone_dep, "name")
_rebased_errorprone_buildconfig =
rebase_path("$_dep_gen_dir/$_dep_name.build_config", root_build_dir)
args += [
- "--processorpath=@FileArg($_rebased_errorprone_buildconfig:deps_info:jar_path)",
- "--processorpath=@FileArg($_rebased_errorprone_buildconfig:deps_info:javac_full_classpath)",
+ "--processorpath=@FileArg($_rebased_errorprone_buildconfig:deps_info:host_classpath)",
"--enable-errorprone",
]
}
@@ -3083,37 +3075,22 @@ if (enable_java_templates) {
}
}
- template("java_header_group") {
+ template("java_lib_group") {
forward_variables_from(invoker, [ "testonly" ])
+ _group_name = invoker.group_name
+ not_needed([ "_group_name" ])
group(target_name) {
if (defined(invoker.deps)) {
deps = []
foreach(_dep, invoker.deps) {
_target_label = get_label_info(_dep, "label_no_toolchain")
- if (filter_exclude([ _target_label ], _java_lib_patterns) == [] &&
- filter_exclude([ _target_label ], _java_lib_exceptions) != []) {
- # This is a java dep, so replace it.
- deps += [ "${_target_label}__header" ]
- } else {
- deps += [ _dep ]
- }
- }
- }
- }
- }
-
- template("java_impl_group") {
- forward_variables_from(invoker, [ "testonly" ])
- group(target_name) {
- if (defined(invoker.deps)) {
- deps = []
- foreach(_dep, invoker.deps) {
- _target_label = get_label_info(_dep, "label_no_toolchain")
- if (filter_exclude([ _target_label ], _java_lib_patterns) == [] &&
- filter_exclude([ _target_label ], _java_lib_exceptions) != []) {
- # This is a java dep, so replace it.
- deps += [ "${_target_label}__impl" ]
+ if (filter_exclude([ _target_label ], _java_library_patterns) == [] &&
+ filter_exclude([ _target_label ], _java_resource_patterns) !=
+ []) {
+ # This is a java library dep, so replace it.
+ deps += [ "${_target_label}__${_group_name}" ]
} else {
+ # Transitive java group targets should also include direct deps.
deps += [ _dep ]
}
}
@@ -3184,7 +3161,6 @@ if (enable_java_templates) {
# requires_android: Optional. True if target can only run on Android.
# java_files: Optional list of Java source file paths for this target.
# javac_args: Optional list of extra arguments to pass to javac.
- # never_goma: When true, ignore the value of use_java_goma.
# errorprone_args: Optional list of extra arguments to pass to .
# srcjar_deps: Optional list of .srcjar targets (not file paths). The Java
# source files they contain will also be compiled for this target.
@@ -3194,23 +3170,14 @@ if (enable_java_templates) {
# java_files is empty. If not
# jar_path: Optional path to a prebuilt .jar file for this target.
# Mutually exclusive with java_files and srcjar_deps.
- # final_jar_path: Optional path to the final output .jar file (after
- # processing). If not provided, the output will go under
- # $root_build_dir/lib.java/
- # output_name: Optional output name for the final jar path. Ignored if
- # final_jar_path is provided. Otherwise, used to determine the name
- # of the final jar. If not provided, the default is to use the same
+ # output_name: Optional output name for the final jar path. Used to
+ # determine the name of the final jar. Default is to use the same
# name as jar_path, if provided, or main_target_name.
- # dex_path: Optional. Path to the output dex.jar file for this target.
- # Ignored if !supports_android.
# main_class: Main Java class name for 'java_binary', 'junit_binary' and
# 'java_annotation_processor' target types. Should not be set for other
# ones.
# deps: Dependencies for this target.
# testonly: True iff target should only be used for tests.
- # enable_turbine: If exists then will be used to determine whether to run
- # turbine or not. Useful for disabling turbine headers for problematic
- # targets.
# chromium_code: Optional. Whether this is Chromium-specific code. If not
# provided, this is determined automatically, based on the location of
# the source files (i.e. anything under third_party/ is not
@@ -3244,8 +3211,6 @@ if (enable_java_templates) {
# from the final .jar file.
# jar_included_patterns: Optional list of .class file patterns to include
# in the final .jar file. jar_excluded_patterns take precedence over this.
- # min_sdk_version: Optional. The minimum Android SDK version this target
- # supports.
#
# For 'android_apk' and 'android_app_bundle_module' targets only:
#
@@ -3293,15 +3258,12 @@ if (enable_java_templates) {
# TODO(crbug.com/1042017): Remove.
not_needed(invoker, [ "no_build_hooks" ])
- # TODO(bjoyce): Remove when able to use.
- not_needed(invoker, [ "enable_jetify" ])
set_sources_assignment_filter([])
forward_variables_from(invoker, [ "testonly" ])
_is_prebuilt = defined(invoker.jar_path)
_is_annotation_processor = invoker.type == "java_annotation_processor"
_is_java_binary =
invoker.type == "java_binary" || invoker.type == "junit_binary"
- _is_system_library = invoker.type == "system_java_library"
_supports_android =
defined(invoker.supports_android) && invoker.supports_android
_requires_android =
@@ -3341,8 +3303,6 @@ if (enable_java_templates) {
"main_class cannot be used for target of type ${invoker.type}")
}
- # Don't enable coverage or lint unless the target has some non-generated
- # files.
if (defined(invoker.chromium_code)) {
_chromium_code = invoker.chromium_code
} else {
@@ -3357,7 +3317,15 @@ if (enable_java_templates) {
}
}
+ # Define build_config_deps which will be a list of targets required to
+ # build the _build_config.
+ _build_config = "$target_gen_dir/$_main_target_name.build_config"
+ _build_config_target_name =
+ "${_main_target_name}$build_config_target_suffix"
+
# The only target that might have no prebuilt and no sources is a java_binary.
+ _build_host_jar = false
+ _build_device_jar = false
if (_is_prebuilt || _has_sources) {
if (defined(invoker.output_name)) {
_output_name = invoker.output_name
@@ -3367,20 +3335,25 @@ if (enable_java_templates) {
_output_name = _main_target_name
}
- # Jar files can be needed at runtime (by Robolectric tests or java binaries),
- # so do not put them under gen/.
- _target_dir_name = get_label_info(":$_main_target_name", "dir")
- _final_jar_path =
- "$root_out_dir/lib.java$_target_dir_name/$_output_name.jar"
- if (defined(invoker.final_jar_path)) {
- _final_jar_path = invoker.final_jar_path
+ _build_host_jar = _is_java_binary || _is_annotation_processor ||
+ invoker.type == "java_library"
+ _build_device_jar =
+ invoker.type != "system_java_library" && _supports_android
+ if (_build_host_jar) {
+ # Jar files can be needed at runtime (by Robolectric tests or java binaries),
+ # so do not put them under obj/.
+ # TODO(agrieve): I suspect it would be better to use dist_jar for java_binary
+ # rather than archiving unnecessary .jar files within lib.java.
+ _target_dir_name = get_label_info(":$_main_target_name", "dir")
+ _host_processed_jar_path =
+ "$root_out_dir/lib.java$_target_dir_name/$_output_name.jar"
}
-
- # TODO(wnwen): Enable turbine for non-chromium code when r8 optimizes out
- # bridge methods.
- _enable_turbine = _has_sources && _chromium_code
- if (defined(invoker.enable_turbine)) {
- _enable_turbine = invoker.enable_turbine
+ if (_build_device_jar) {
+ _device_processed_jar_path =
+ "$target_out_dir/$_output_name.processed.jar"
+ _dex_path = "$target_out_dir/$_main_target_name.dex.jar"
+ _enable_desugar =
+ !defined(invoker.enable_desugar) || !invoker.enable_desugar
}
# For static libraries, the javac jar output is created at the intermediate
@@ -3388,13 +3361,10 @@ if (enable_java_templates) {
# spot that the .build_config knows about. Technically this should be done
# for the ijar as well, but this is only used for APK targets where
# the ijar path isn't actually used.
- _build_config_jar_path = _final_jar_path
- _final_ijar_path = get_path_info(_final_jar_path, "dir") + "/" +
- get_path_info(_final_jar_path, "name")
- if (_enable_turbine) {
- _final_ijar_path += ".turbine.jar"
+ if (_has_sources) {
+ _final_ijar_path = "$target_out_dir/$_output_name.turbine.jar"
} else {
- _final_ijar_path += ".ijar.jar"
+ _final_ijar_path = "$target_out_dir/$_output_name.ijar.jar"
}
if (_has_sources) {
@@ -3408,58 +3378,77 @@ if (enable_java_templates) {
} else {
_unprocessed_jar_path = _javac_jar_path
}
-
- if (_supports_android) {
- _dex_path = "$target_out_dir/$_main_target_name.dex.jar"
- if (defined(invoker.dex_path)) {
- _dex_path = invoker.dex_path
- }
+ }
+ if (_build_host_jar || _build_device_jar) {
+ if (defined(invoker.enable_jetify) && invoker.enable_jetify) {
+ _jetified_jar_path = "$target_out_dir/${_main_target_name}.jetified.jar"
}
}
- _public_deps = []
- _accumulated_deps = []
- _java_header_deps = []
- _java_impl_deps = []
- _java_full_deps = []
- if (defined(invoker.deps)) {
- foreach(_dep, invoker.deps) {
- _target_label = get_label_info(_dep, "label_no_toolchain")
- if (filter_exclude([ _target_label ], _java_lib_patterns) == [] &&
- filter_exclude([ _target_label ], _java_lib_exceptions) != []) {
- # This is a java dep, so replace it with its header.
- _java_header_deps += [ "${_target_label}__header" ]
- _java_impl_deps += [ "${_target_label}__impl" ]
- _java_full_deps += [ _dep ]
- } else {
- # Not a java header dep, so no need to replace it with its header.
- _accumulated_deps += [ _dep ]
+ if (_is_prebuilt || _has_sources) {
+ _java_header_deps = []
+ _java_impl_deps = []
+ _non_java_deps = []
+ if (defined(invoker.deps)) {
+ foreach(_dep, invoker.deps) {
+ _target_label = get_label_info(_dep, "label_no_toolchain")
+ if (filter_exclude([ _target_label ], _java_library_patterns) == [] &&
+ filter_exclude([ _target_label ], _java_resource_patterns) !=
+ []) {
+ # This is a java dep, so replace it with its header.
+ _java_header_deps += [ "${_target_label}__header" ]
+ _java_impl_deps += [ "${_target_label}__impl" ]
+ } else {
+ _non_java_deps += [ _dep ]
+ }
}
}
- }
- # TODO(crbug.com/1078484): Don't use desugared .jar files for java binaries.
- if (_is_java_binary && enable_bazel_desugar) {
- _accumulated_deps +=
- [ "//third_party/bazel/desugar:desugar_runtime_java" ]
- }
+ # Don't need to depend on the apk-under-test to be packaged.
+ if (defined(invoker.apk_under_test)) {
+ _java_header_deps += [ "${invoker.apk_under_test}__java__header" ]
+ _java_impl_deps += [ "${invoker.apk_under_test}__java__impl" ]
+ }
- if (defined(_final_jar_path)) {
+ _extra_java_deps = []
_jacoco_instrument =
use_jacoco_coverage && _chromium_code && _java_files != [] &&
- !_is_java_binary && !_is_annotation_processor &&
- (!defined(invoker.testonly) || !invoker.testonly)
+ _build_device_jar && (!defined(invoker.testonly) || !invoker.testonly)
if (defined(invoker.jacoco_never_instrument)) {
_jacoco_instrument =
!invoker.jacoco_never_instrument && _jacoco_instrument
}
if (_jacoco_instrument) {
- _java_full_deps += [ "//third_party/jacoco:jacocoagent_java" ]
- _java_header_deps += [ "//third_party/jacoco:jacocoagent_java__header" ]
- _java_impl_deps += [ "//third_party/jacoco:jacocoagent_java__impl" ]
+ _extra_java_deps += [ "//third_party/jacoco:jacocoagent_java" ]
+ }
+
+ _include_android_sdk = _build_device_jar
+ if (defined(invoker.include_android_sdk)) {
+ _include_android_sdk = invoker.include_android_sdk
+ }
+ if (_include_android_sdk) {
+ _sdk_java_dep = "//third_party/android_sdk:android_sdk_java"
+ if (defined(invoker.alternative_android_sdk_dep)) {
+ _sdk_java_dep = invoker.alternative_android_sdk_dep
+ }
+
+ # This is an android_system_java_prebuilt target, so no headers.
+ _extra_java_deps += [ _sdk_java_dep ]
}
+
+ _classpath_deps = _java_header_deps + _non_java_deps + _extra_java_deps +
+ [ ":$_build_config_target_name" ]
+ _full_classpath_deps =
+ _java_impl_deps + _non_java_deps + _extra_java_deps +
+ [ ":$_build_config_target_name" ]
}
+ # Often needed, but too hard to figure out when ahead of time.
+ not_needed([
+ "_classpath_deps",
+ "_full_classpath_deps",
+ ])
+
if (_java_files != []) {
_java_sources_file = "$target_gen_dir/$_main_target_name.sources"
if (defined(invoker.java_sources_file)) {
@@ -3468,28 +3457,6 @@ if (enable_java_templates) {
write_file(_java_sources_file, rebase_path(_java_files, root_build_dir))
}
- _include_android_sdk = !_is_system_library && _supports_android
- if (defined(invoker.include_android_sdk)) {
- _include_android_sdk = invoker.include_android_sdk
- }
- if (_include_android_sdk) {
- _sdk_java_dep = "//third_party/android_sdk:android_sdk_java"
- if (defined(invoker.alternative_android_sdk_dep)) {
- _sdk_java_dep = invoker.alternative_android_sdk_dep
- }
-
- # This is an android_system_java_prebuilt target, so no headers.
- _accumulated_deps += [ _sdk_java_dep ]
- }
- _jetified_jar_path =
- "$target_out_dir/${target_name}__process_prebuilt.jetified.jar"
-
- # Define build_config_deps which will be a list of targets required to
- # build the _build_config.
- _build_config = "$target_gen_dir/$_main_target_name.build_config"
- _build_config_target_name =
- "${_main_target_name}$build_config_target_suffix"
-
write_build_config(_build_config_target_name) {
forward_variables_from(invoker,
[
@@ -3498,6 +3465,7 @@ if (enable_java_templates) {
"gradle_treat_as_prebuilt",
"input_jars_paths",
"main_class",
+ "public_target_label",
"proguard_configs",
"proguard_enabled",
"proguard_mapping_path",
@@ -3545,9 +3513,17 @@ if (enable_java_templates) {
chromium_code = _chromium_code
build_config = _build_config
is_prebuilt = _is_prebuilt
- jetified_jar_path = _jetified_jar_path
- possible_config_deps = _java_full_deps + _accumulated_deps
- skip_jetify = defined(invoker.skip_jetify) && invoker.skip_jetify
+ if (defined(invoker.enable_jetify) && invoker.enable_jetify) {
+ jetified_jar_path = _jetified_jar_path
+ }
+
+ possible_config_deps = []
+ if (defined(_extra_java_deps)) {
+ possible_config_deps = _extra_java_deps
+ }
+ if (defined(invoker.deps)) {
+ possible_config_deps += invoker.deps
+ }
if (defined(apk_under_test)) {
possible_config_deps += [ apk_under_test ]
}
@@ -3556,12 +3532,15 @@ if (enable_java_templates) {
bypass_platform_checks = defined(invoker.bypass_platform_checks) &&
invoker.bypass_platform_checks
- if (defined(_final_jar_path)) {
- jar_path = _build_config_jar_path
+ if (_is_prebuilt || _has_sources) {
ijar_path = _final_ijar_path
unprocessed_jar_path = _unprocessed_jar_path
}
- if (defined(_dex_path)) {
+ if (_build_host_jar) {
+ host_jar_path = _host_processed_jar_path
+ }
+ if (_build_device_jar) {
+ device_jar_path = _device_processed_jar_path
dex_path = _dex_path
}
if (_java_files != []) {
@@ -3576,35 +3555,22 @@ if (enable_java_templates) {
}
if (defined(invoker.include_java_resources) &&
invoker.include_java_resources) {
+ java_resources_jar = _unprocessed_jar_path
if (defined(invoker.jar_path)) {
# Use original jar_path because _jar_path points to a library without
# resources.
- java_resources_jar = invoker.jar_path
} else {
- java_resources_jar = _final_jar_path
+ java_resources_jar = _device_processed_jar_path
}
}
}
- # Don't need to depend on the apk-under-test to be packaged.
- if (defined(invoker.apk_under_test)) {
- # No need to add to _java_full_deps since that is only used for
- # write_build_config.
- _java_header_deps += [ "${invoker.apk_under_test}__java__header" ]
- _java_impl_deps += [ "${invoker.apk_under_test}__java__impl" ]
- }
- if (defined(invoker.android_manifest_dep)) {
- _accumulated_deps += [ invoker.android_manifest_dep ]
- }
- if (defined(invoker.annotation_processor_deps)) {
- # We need the full annotation processors rather than just the headers.
- _accumulated_deps += invoker.annotation_processor_deps
- }
-
- if (_has_sources || _is_prebuilt) {
+ if (_is_prebuilt || _has_sources) {
_header_target_name = "${target_name}__header"
}
+ _public_deps = []
+ _analysis_public_deps = []
if (_has_sources) {
if (defined(invoker.enable_errorprone)) {
_enable_errorprone = invoker.enable_errorprone
@@ -3635,8 +3601,7 @@ if (enable_java_templates) {
if (!defined(deps)) {
deps = []
}
- deps += _java_header_deps + _accumulated_deps +
- [ ":$_build_config_target_name" ]
+ deps += _classpath_deps
# android_apk and junit_binary pass R.java srcjars via srcjar_deps.
if (_type == "java_library" && _requires_android) {
@@ -3652,27 +3617,27 @@ if (enable_java_templates) {
"provider_configurations",
"javac_args",
"jar_excluded_patterns",
- "never_goma",
]
+ _annotation_processor_deps = []
+ if (defined(invoker.annotation_processor_deps)) {
+ _annotation_processor_deps = invoker.annotation_processor_deps
+ }
- if (_enable_turbine) {
- compile_java_helper(_header_target_name) {
- forward_variables_from(invoker, _compile_java_forward_variables)
- use_turbine = true
- output_jar_path = _final_ijar_path
- generated_jar_path = _generated_jar_path
- }
+ compile_java_helper(_header_target_name) {
+ forward_variables_from(invoker, _compile_java_forward_variables)
+ use_turbine = true
+ output_jar_path = _final_ijar_path
+ generated_jar_path = _generated_jar_path
+ deps = _annotation_processor_deps
}
+ _public_deps += [ ":$_header_target_name" ]
- _analysis_public_deps = []
_compile_java_target = "${_main_target_name}__compile_java"
compile_java_helper(_compile_java_target) {
forward_variables_from(invoker, _compile_java_forward_variables)
output_jar_path = _javac_jar_path
- if (_enable_turbine) {
- deps = [ ":$_header_target_name" ]
- generated_jar_path = _generated_jar_path
- }
+ deps = [ ":$_header_target_name" ]
+ generated_jar_path = _generated_jar_path
}
if (_enable_errorprone) {
_compile_java_errorprone_target = "${_main_target_name}__errorprone"
@@ -3685,121 +3650,129 @@ if (enable_java_templates) {
}
javac_args += invoker.errorprone_args
}
- if (_enable_turbine) {
- deps = [ ":$_header_target_name" ]
- generated_jar_path = _generated_jar_path
- }
+ deps = [ ":$_header_target_name" ]
+ generated_jar_path = _generated_jar_path
output_jar_path = "$target_out_dir/$target_name.errorprone.stamp"
}
_analysis_public_deps += [ ":$_compile_java_errorprone_target" ]
}
} # _has_sources
- if (_has_sources || _is_prebuilt) {
- if (!_enable_turbine) {
- generate_interface_jar(_header_target_name) {
- # Always used the unfiltered .jar to create the interface jar so that
- # other targets will resolve filtered classes when depending on
- # BuildConfig, NativeLibraries, etc.
- input_jar = _unprocessed_jar_path
- output_jar = _final_ijar_path
-
- # Some prebuilts have java deps (e.g. //third_party/proguard:retrace_java).
- deps = _java_header_deps + _accumulated_deps
- if (_has_sources) {
- deps += [ ":$_compile_java_target" ]
- }
+ if (_is_prebuilt) {
+ generate_interface_jar(_header_target_name) {
+ # Always used the unfiltered .jar to create the interface jar so that
+ # other targets will resolve filtered classes when depending on
+ # BuildConfig, NativeLibraries, etc.
+ input_jar = _unprocessed_jar_path
+ output_jar = _final_ijar_path
+
+ # ijar does not require classpath, but must declare these as deps so
+ # that they are transitive deps for targets that depend on this
+ # target. If we can change compile & desugar steps to use direct
+ # interface classpath rather than full interface classpath, then this
+ # could just be _non_java_deps.
+ deps = _classpath_deps
+ if (_has_sources) {
+ deps += [ ":$_compile_java_target" ]
}
}
_public_deps += [ ":$_header_target_name" ]
}
- if (defined(_final_jar_path)) {
- if (_is_system_library) {
- # These deps are only needed for the process_java_prebuilt template.
- not_needed([ "_java_impl_deps" ])
-
- _copy_system_library_target_name = "${target_name}__copy_system_library"
-
- # Use copy_ex rather than copy to ensure that we copy symlink targets
- # rather than the symlink itself.
- copy_ex(_copy_system_library_target_name) {
- sources = [ _unprocessed_jar_path ]
- dest = _final_jar_path
- outputs = [ _final_jar_path ]
+ if (_build_host_jar || _build_device_jar) {
+ _process_prebuilt_target_name = "${target_name}_process"
+ process_java_prebuilt(_process_prebuilt_target_name) {
+ forward_variables_from(invoker,
+ [
+ "jar_excluded_patterns",
+ "jar_included_patterns",
+ ])
+ build_config = _build_config
+ build_config_dep = ":$_build_config_target_name"
+ input_jar_path = _unprocessed_jar_path
+ jar_deps = _non_java_deps
+ if (_has_sources) {
+ jar_deps += [ ":$_compile_java_target" ]
}
- _public_deps += [ ":$_copy_system_library_target_name" ]
- } else {
- _enable_desugar = (!defined(invoker.enable_desugar) ||
- !invoker.enable_desugar) && _supports_android
- _process_prebuilt_target_name = "${target_name}__process_prebuilt"
- process_java_prebuilt(_process_prebuilt_target_name) {
- forward_variables_from(invoker,
- [
- "enable_bytecode_checks",
- "enable_bytecode_rewriter",
- "missing_classes_allowlist",
- "jar_excluded_patterns",
- "jar_included_patterns",
- "skip_jetify",
- ])
- enable_desugar = _enable_desugar && enable_bazel_desugar
- is_prebuilt = _is_prebuilt
- build_config = _build_config
- input_jar_path = _unprocessed_jar_path
+ if (_build_host_jar) {
+ host_jar_path = _host_processed_jar_path
+ }
+ if (_build_device_jar) {
+ device_jar_path = _device_processed_jar_path
jacoco_instrument = _jacoco_instrument
if (_jacoco_instrument) {
java_files = _java_files
java_sources_file = _java_sources_file
}
- output_jar_path = _final_jar_path
- deps = _java_impl_deps + _accumulated_deps +
- [ ":$_build_config_target_name" ]
- if (_has_sources) {
- deps += [ ":$_compile_java_target" ]
- }
-
- # proguard_configs listed on java_library targets need to be marked
- # as inputs to at least one action so that "gn analyze" will know
- # about them. Although ijar doesn't use them, it's a convenient spot
- # to list them.
- # https://crbug.com/827197
- if (defined(invoker.proguard_configs)) {
- inputs = invoker.proguard_configs
- if (!defined(deps)) {
- deps = []
- }
- deps += _srcjar_deps # For the aapt-generated proguard rules.
+ enable_desugar = _enable_desugar && enable_bazel_desugar
+ if (enable_desugar) {
+ classpath_deps = _full_classpath_deps
}
}
- _public_deps += [ ":$_process_prebuilt_target_name" ]
+ if (defined(invoker.enable_jetify) && invoker.enable_jetify) {
+ jetified_jar_path = _jetified_jar_path
+ }
- if (defined(_dex_path)) {
- dex("${target_name}__dex") {
- input_class_jars = [ _final_jar_path ]
+ # proguard_configs listed on java_library targets need to be marked
+ # as inputs to at least one action so that "gn analyze" will know
+ # about them. Although ijar doesn't use them, it's a convenient spot
+ # to list them.
+ # https://crbug.com/827197
+ if (defined(invoker.proguard_configs)) {
+ inputs = invoker.proguard_configs
+ input_deps = _non_java_deps + _srcjar_deps # For the aapt-generated
+ # proguard rules.
+ }
+ }
+ if (_build_host_jar) {
+ _public_deps += [ ":${_process_prebuilt_target_name}_host" ]
+ }
+ if (_build_device_jar) {
+ _public_deps += [ ":${_process_prebuilt_target_name}_device" ]
+ }
- enable_desugar = _enable_desugar
+ if (!defined(invoker.enable_bytecode_checks) ||
+ invoker.enable_bytecode_checks) {
+ _bytecode_checks_target = "${target_name}__validate_classpath"
+ bytecode_processor(_bytecode_checks_target) {
+ forward_variables_from(invoker, [ "missing_classes_allowlist" ])
+ deps = _full_classpath_deps
+ if (_has_sources) {
+ deps += [ ":$_compile_java_target" ]
+ }
+ requires_android = _requires_android
+ target_label =
+ get_label_info(":${invoker.target_name}", "label_no_toolchain")
+ input_jar = _unprocessed_jar_path
+ build_config = _build_config
+ is_prebuilt = _is_prebuilt
+ }
+ _analysis_public_deps += [ ":$_bytecode_checks_target" ]
+ }
+ }
- # There's no value in per-class dexing prebuilts since they never
- # change just one class at a time.
- disable_incremental = _is_prebuilt
- output = _dex_path
- deps = [ ":$_process_prebuilt_target_name" ]
+ if (_build_device_jar) {
+ dex("${target_name}__dex") {
+ input_class_jars = [ _device_processed_jar_path ]
+ enable_desugar = _enable_desugar
- if (enable_desugar && !enable_bazel_desugar) {
- build_config = _build_config
- final_ijar_path = _final_ijar_path
- deps += _java_header_deps + [ ":$_header_target_name" ]
- }
+ # There's no value in per-class dexing prebuilts since they never
+ # change just one class at a time.
+ disable_incremental = _is_prebuilt
+ output = _dex_path
+ deps = [ ":${_process_prebuilt_target_name}_device" ]
- # For library targets, we do not need a proper main dex list, but do
- # need to allow multiple dex files.
- enable_multidex = false
- enable_library_multidex = true
- }
- _public_deps += [ ":${target_name}__dex" ]
+ if (enable_desugar && !enable_bazel_desugar) {
+ # Desugaring with D8 requires full classpath.
+ build_config = _build_config
+ final_ijar_path = _final_ijar_path
+ deps += _classpath_deps + [ ":$_header_target_name" ]
}
+
+ enable_multidex = false
+ is_library = true
}
+ _public_deps += [ ":${target_name}__dex" ]
}
if (_is_java_binary) {
@@ -3829,6 +3802,11 @@ if (enable_java_templates) {
public_deps = _public_deps
}
+ java_lib_group("${target_name}__assetres") {
+ forward_variables_from(invoker, [ "deps" ])
+ group_name = "assetres"
+ }
+
group(target_name) {
forward_variables_from(invoker,
[
@@ -3873,13 +3851,17 @@ if (enable_java_templates) {
# packaged into each module.
# is_multi_abi: If true will add a library placeholder for the missing ABI if
# either the primary or the secondary ABI has no native libraries set.
-# verify_native_libs_and_assets_target_name: (optional): If set, will verify
-# the list of included native libraries and assets is consistent with an
-# expectation file.
+# expected_libs_and_assets: (optional): Verify the list of included native
+# libraries and assets is consistent with the given expectation file.
+# proguard_enabled: Optional. True if proguarding is enabled for this
+# bundle. Default is to enable this only for release builds. Note that
+# this will always perform synchronized proguarding.
template("create_android_app_bundle_module") {
_rebased_build_config = rebase_path(invoker.build_config, root_build_dir)
_rebased_native_libraries_config =
rebase_path(invoker.native_libraries_config, root_build_dir)
+ _proguard_enabled =
+ defined(invoker.proguard_enabled) && invoker.proguard_enabled
forward_variables_from(invoker,
[
@@ -3950,8 +3932,9 @@ template("create_android_app_bundle_module") {
_args += [ "--dex-file=@FileArg($_rebased_build_config:final_dex:path)" ]
}
- # TODO(https://crbug.com/1056751): Add support for proguarding jdk libs.
- if (enable_jdk_library_desugaring && invoker.module_name == "base") {
+ # The library is imported via proguard when proguard is enabled.
+ if (!_proguard_enabled && enable_jdk_library_desugaring &&
+ invoker.module_name == "base") {
_all_jdk_libs = "//build/android:all_jdk_libs"
_deps += [ _all_jdk_libs ]
_jdk_libs_dex =
@@ -3963,26 +3946,14 @@ template("create_android_app_bundle_module") {
]
}
- if (defined(invoker.verify_native_libs_and_assets_target_name)) {
- _expectations_target =
- "${invoker.verify_native_libs_and_assets_target_name}" +
- "_libs_and_assets_expectations"
+ if (defined(invoker.expected_libs_and_assets)) {
+ _expectations_target = "${invoker.top_target_name}_validate_libs_and_assets"
action_with_pydeps(_expectations_target) {
_stamp = "$target_gen_dir/$target_name.stamp"
- _target_src_dir = get_label_info(":$target_name", "dir")
- _expected_native_libs_and_assets =
- "$_target_src_dir/java/" +
- "${invoker.verify_native_libs_and_assets_target_name}." +
- "${target_cpu}.native_libs_and_assets.expected"
- _native_libs_and_assets_expectation_failure_filepath =
- "$android_configuration_failure_dir/" +
- "${invoker.verify_native_libs_and_assets_target_name}." +
- "${target_cpu}.native_libs_and_assets.failed"
- if (fail_on_android_expectations) {
- _args += [ "--fail-on-expectations" ]
- }
+ _failure_file = "$android_configuration_failure_dir/" +
+ string_replace(invoker.expected_libs_and_assets, "/", "_")
inputs = [
- _expected_native_libs_and_assets,
+ invoker.expected_libs_and_assets,
invoker.build_config,
invoker.native_libraries_config,
]
@@ -3998,14 +3969,16 @@ template("create_android_app_bundle_module") {
script = _script
args = _args + [
"--expected-native-libs-and-assets",
- rebase_path(_expected_native_libs_and_assets, root_build_dir),
+ rebase_path(invoker.expected_libs_and_assets, root_build_dir),
"--native-libs-and-assets-expectation-failure-file",
- rebase_path(_native_libs_and_assets_expectation_failure_filepath,
- root_build_dir),
+ rebase_path(_failure_file, root_build_dir),
"--stamp",
rebase_path(_stamp, root_build_dir),
"--only-verify-expectations",
]
+ if (fail_on_android_expectations) {
+ args += [ "--fail-on-expectations" ]
+ }
}
_deps += [ ":$_expectations_target" ]
}
@@ -4066,7 +4039,7 @@ template("dexsplitter") {
"--dex-dest=@FileArg($_rebased_module_build_config:final_dex:path)",
]
if (!defined(invoker.feature_jars_args)) {
- args += [ "--feature-jars=@FileArg($_rebased_module_build_config:deps_info:java_runtime_classpath)" ]
+ args += [ "--feature-jars=@FileArg($_rebased_module_build_config:deps_info:device_classpath)" ]
}
deps += [ _feature_module.build_config_target ]
}
diff --git a/chromium/build/config/android/rules.gni b/chromium/build/config/android/rules.gni
index cd0258af22c..412041fe56e 100644
--- a/chromium/build/config/android/rules.gni
+++ b/chromium/build/config/android/rules.gni
@@ -524,17 +524,12 @@ if (enable_java_templates) {
# The sources aren't compiled so don't check their dependencies.
check_includes = false
script = "//build/android/gyp/java_cpp_enum.py"
- depfile = "$target_gen_dir/$target_name.d"
_srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
_rebased_srcjar_path = rebase_path(_srcjar_path, root_build_dir)
_rebased_sources = rebase_path(invoker.sources, root_build_dir)
- args = [
- "--depfile",
- rebase_path(depfile, root_build_dir),
- "--srcjar=$_rebased_srcjar_path",
- ] + _rebased_sources
+ args = [ "--srcjar=$_rebased_srcjar_path" ] + _rebased_sources
outputs = [ _srcjar_path ]
}
}
@@ -708,12 +703,16 @@ if (enable_java_templates) {
_cpu_family,
]
if (invoker.use_final_fields) {
+ # Write native_libraries_list_file via depfile rather than specifyin it
+ # as a dep in order allow R8 to run in parallel with native compilation.
+ depfile = "$target_gen_dir/$target_name.d"
args += [
"--final",
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
"--native-libraries-list",
rebase_path(invoker.native_libraries_list_file, root_build_dir),
]
- inputs = [ invoker.native_libraries_list_file ]
if (defined(invoker.version_number)) {
args += [
"--version-number",
@@ -1123,12 +1122,9 @@ if (enable_java_templates) {
# }
# }
template("java_group") {
- forward_variables_from(invoker,
- [
- "testonly",
- "input_jars_paths",
- ])
+ forward_variables_from(invoker, [ "testonly" ])
write_build_config("$target_name$build_config_target_suffix") {
+ forward_variables_from(invoker, [ "input_jars_paths" ])
type = "group"
build_config = "$target_gen_dir/${invoker.target_name}.build_config"
supports_android = true
@@ -1136,11 +1132,16 @@ if (enable_java_templates) {
possible_config_deps = invoker.deps
}
}
- java_header_group("${target_name}__header") {
- forward_variables_from(invoker, [ "deps" ])
- }
- java_impl_group("${target_name}__impl") {
- forward_variables_from(invoker, [ "deps" ])
+ foreach(_group_name,
+ [
+ "header",
+ "impl",
+ "assetres",
+ ]) {
+ java_lib_group("${target_name}__${_group_name}") {
+ forward_variables_from(invoker, [ "deps" ])
+ group_name = _group_name
+ }
}
group(target_name) {
forward_variables_from(invoker, "*")
@@ -1335,13 +1336,18 @@ if (enable_java_templates) {
_build_config_target_name = "$target_name$build_config_target_suffix"
_deps = [
"//testing/android/junit:junit_test_support",
+ "//third_party/android_deps:robolectric_all_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
- "//third_party/robolectric:robolectric_all_java",
]
if (defined(invoker.deps)) {
_deps += invoker.deps
}
+ if (defined(invoker.alternative_android_sdk_dep)) {
+ _android_sdk_dep = invoker.alternative_android_sdk_dep
+ } else {
+ _android_sdk_dep = "//third_party/android_sdk:android_sdk_java"
+ }
# a package name or a manifest is required to have resources. This is
# added so that junit tests that do not care about the package name can
@@ -1356,7 +1362,9 @@ if (enable_java_templates) {
_compile_resources_target = "${target_name}__compile_resources"
compile_resources(_compile_resources_target) {
forward_variables_from(invoker, [ "android_manifest" ])
- deps = _deps + [ ":$_build_config_target_name" ]
+ deps = _deps
+ android_sdk_dep = _android_sdk_dep
+ build_config_dep = ":$_build_config_target_name"
build_config = _build_config
if (defined(_package_name)) {
rename_manifest_package = _package_name
@@ -1469,7 +1477,6 @@ if (enable_java_templates) {
# [ [ path_to_file, path_to_put_in_jar ] ]
#
# javac_args: Additional arguments to pass to javac.
- # never_goma: When true, ignore the value of use_java_goma.
# errorprone_args: Additional arguments to pass to errorprone.
#
# data_deps, testonly
@@ -1535,11 +1542,6 @@ if (enable_java_templates) {
# deps = [ ":my_java_lib" ]
# output = "$root_build_dir/MyLibrary.jar"
# }
- # dist_jar("sideloaded_dex") {
- # deps = [ ":my_java_lib" ]
- # output = "$root_build_dir/MyLibrary.jar"
- # dex_path = "$root_build_dir/MyLibrary.dex"
- # }
template("dist_jar") {
# TODO(crbug.com/1042017): Remove.
not_needed(invoker, [ "no_build_hooks" ])
@@ -1620,12 +1622,20 @@ if (enable_java_templates) {
} else if (_use_unprocessed_jars) {
args += [ "--input-zips=@FileArg($_rebased_build_config:deps_info:javac_full_classpath)" ]
} else {
- args += [ "--input-zips=@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)" ]
+ args += [ "--input-zips=@FileArg($_rebased_build_config:deps_info:device_classpath)" ]
}
}
+ _excludes = []
if (defined(invoker.jar_excluded_patterns)) {
- args +=
- [ "--input-zips-excluded-globs=${invoker.jar_excluded_patterns}" ]
+ _excludes += invoker.jar_excluded_patterns
+ }
+ if (_use_interface_jars) {
+ # Turbine adds files like: META-INF/TRANSITIVE/.../Foo.class
+ # These confuse proguard: https://crbug.com/1081443
+ _excludes += [ "META-INF/*" ]
+ }
+ if (_excludes != []) {
+ args += [ "--input-zips-excluded-globs=$_excludes" ]
}
}
}
@@ -1634,21 +1644,15 @@ if (enable_java_templates) {
#
# Variables:
# output: Path to the output dex.
+ # proguard_enabled: Whether to enable R8.
# proguard_configs: List of proguard configs.
- # proguard_jar_path: The path to proguard.jar you wish to use. If undefined,
- # the proguard used will be the checked in one in //third_party/proguard.
#
# Example
# dist_dex("lib_fatjar") {
# deps = [ ":my_java_lib" ]
# output = "$root_build_dir/MyLibrary.jar"
# }
- # dist_jar("sideloaded_dex") {
- # deps = [ ":my_java_lib" ]
- # output = "$root_build_dir/MyLibrary.jar"
- # dex_path = "$root_build_dir/MyLibrary.dex"
- # }
- template("proguarded_dist_dex") {
+ template("dist_dex") {
_deps = [ "//third_party/android_sdk:android_sdk_java" ]
if (defined(invoker.deps)) {
_deps += invoker.deps
@@ -1659,10 +1663,13 @@ if (enable_java_templates) {
write_build_config(_build_config_target_name) {
type = "dist_jar"
- forward_variables_from(invoker, [ "proguard_configs" ])
+ forward_variables_from(invoker,
+ [
+ "proguard_configs",
+ "proguard_enabled",
+ ])
supports_android = true
requires_android = true
- proguard_enabled = true
possible_config_deps = _deps
build_config = _build_config
}
@@ -1670,15 +1677,28 @@ if (enable_java_templates) {
_deps += [ ":$_build_config_target_name" ]
dex(target_name) {
- deps = _deps
- build_config = _build_config
- proguard_enabled = true
forward_variables_from(invoker,
[
+ "data",
+ "data_deps",
+ "visibility",
+ "testonly",
"proguard_configs",
+ "proguard_enabled",
"min_sdk_version",
])
+ deps = _deps
+ build_config = _build_config
+ enable_multidex = false
output = invoker.output
+ if (defined(proguard_enabled) && proguard_enabled) {
+ # When trying to build a stand-alone .dex, don't add in jdk_libs_dex.
+ supports_jdk_library_desugaring = false
+ } else {
+ _rebased_build_config = rebase_path(_build_config, root_build_dir)
+ input_dex_filearg =
+ "@FileArg(${_rebased_build_config}:final_dex:all_dex_files)"
+ }
}
}
@@ -1807,8 +1827,6 @@ if (enable_java_templates) {
# Supports all variables of java_library(), plus:
# deps: In addition to defining java deps, this can also include
# android_assets() and android_resources() targets.
- # dex_path: If set, the resulting .dex.jar file will be placed under this
- # path.
# alternative_android_sdk_ijar: if set, the given android_sdk_ijar file
# replaces the default android_sdk_ijar.
# alternative_android_sdk_ijar_dep: the target that generates
@@ -2073,8 +2091,8 @@ if (enable_java_templates) {
# apk or module.
# resources_config_path: Path to the aapt2 optimize config file that tags
# resources with acceptable/non-acceptable optimizations.
- # verify_manifest: Enables verification of expected merged manifest based
- # on a golden file.
+ # expected_android_manifest: Enables verification of expected merged
+ # manifest based on a golden file.
# resource_ids_provider_dep: If passed, this target will use the resource
# IDs generated by {resource_ids_provider_dep}__compile_res during
# resource compilation.
@@ -2113,14 +2131,13 @@ if (enable_java_templates) {
# main_component_library: Specifies the name of the base component's library
# in a component build. If given, the system will find dependent native
# libraries at runtime by inspecting this library (optional).
- # verify_native_libs_and_assets: (optional): If true, will verify the list
- # of included native libraries and assets is consistent with an
+ # expected_libs_and_assets: (optional): Verify the list
+ # of included native libraries and assets is consistent with the given
# expectation file.
template("android_apk_or_module") {
forward_variables_from(invoker, [ "testonly" ])
assert(defined(invoker.android_manifest))
- _out_dir = "$target_out_dir/$target_name"
- _base_path = "$_out_dir/$target_name"
+ _base_path = "$target_out_dir/$target_name/$target_name"
_build_config = "$target_gen_dir/$target_name.build_config"
_build_config_target = "$target_name$build_config_target_suffix"
@@ -2133,9 +2150,6 @@ if (enable_java_templates) {
_target_sdk_version = invoker.target_sdk_version
}
- # JUnit tests use resource zip files. These must not be put in gen/
- # directory or they will not be available to tester bots.
- _jar_path = "$_base_path.jar"
_template_name = target_name
_is_bundle_module =
@@ -2154,9 +2168,11 @@ if (enable_java_templates) {
}
_short_resource_paths =
- defined(invoker.short_resource_paths) && invoker.short_resource_paths
+ defined(invoker.short_resource_paths) && invoker.short_resource_paths &&
+ enable_arsc_obfuscation
_strip_resource_names =
- defined(invoker.strip_resource_names) && invoker.strip_resource_names
+ defined(invoker.strip_resource_names) && invoker.strip_resource_names &&
+ enable_arsc_obfuscation
_optimize_resources = _strip_resource_names || _short_resource_paths
if (!_is_bundle_module && _short_resource_paths) {
@@ -2330,8 +2346,7 @@ if (enable_java_templates) {
_is_static_library_provider =
defined(invoker.static_library_dependent_targets) && _proguard_enabled
if (_is_static_library_provider) {
- _static_library_sync_dex_path =
- "$_out_dir/static_library_synchronized_proguard.r8dex.jar"
+ _static_library_sync_dex_path = "$_base_path.synchronized.r8dex.jar"
_resource_ids_provider_deps = []
foreach(_target, invoker.static_library_dependent_targets) {
if (_target.is_resource_ids_provider) {
@@ -2405,9 +2420,7 @@ if (enable_java_templates) {
_final_deps = []
- _enable_main_dex_list =
- _enable_multidex &&
- (!defined(invoker.min_sdk_version) || invoker.min_sdk_version < 21)
+ _enable_main_dex_list = _enable_multidex && _min_sdk_version < 21
if (_enable_main_dex_list) {
_generated_proguard_main_dex_config =
"$_base_path.resources.main-dex-proguard.txt"
@@ -2453,6 +2466,8 @@ if (enable_java_templates) {
[
"aapt_locale_allowlist",
"app_as_shared_lib",
+ "expected_android_manifest",
+ "expected_android_manifest_base",
"manifest_package",
"max_sdk_version",
"no_xml_namespaces",
@@ -2466,22 +2481,19 @@ if (enable_java_templates) {
"resources_config_path",
"shared_resources",
"shared_resources_allowlist_locales",
- "short_resource_paths",
- "strip_resource_names",
"support_zh_hk",
])
+ short_resource_paths = _short_resource_paths
+ strip_resource_names = _strip_resource_names
android_manifest = _android_manifest
+ android_manifest_dep = ":$_merge_manifest_target"
version_code = _version_code
version_name = _version_name
min_sdk_version = _min_sdk_version
target_sdk_version = _target_sdk_version
- if (defined(invoker.verify_manifest) && invoker.verify_manifest &&
- !is_java_debug) {
- verify_manifest_target_name = _template_name
- build_config_dep = ":$_build_config_target"
- android_manifest_dep = ":$_merge_manifest_target"
- forward_variables_from(invoker,
- [ "expected_manifest_base_expectation" ])
+
+ if (defined(expected_android_manifest)) {
+ top_target_name = _template_name
}
if (defined(_resource_ids_provider_dep)) {
@@ -2503,11 +2515,9 @@ if (enable_java_templates) {
}
build_config = _build_config
- deps = _deps + [
- ":$_merge_manifest_target",
- ":$_build_config_target",
- _android_sdk_dep,
- ]
+ build_config_dep = ":$_build_config_target"
+ android_sdk_dep = _android_sdk_dep
+ deps = _deps
# The static library uses the R.txt files generated by the
# static_library_dependent_targets when generating the final R.java file.
@@ -2622,16 +2632,17 @@ if (enable_java_templates) {
if (_generate_native_libraries_java) {
write_native_libraries_java("${_template_name}__native_libraries") {
forward_variables_from(invoker, [ "main_component_library" ])
- deps = [
- ":${_template_name}__secondary_abi_shared_library_list",
- ":${_template_name}__shared_library_list",
- ]
+ deps = []
if (defined(invoker.native_lib_version_rule)) {
deps += [ invoker.native_lib_version_rule ]
}
if (defined(invoker.native_lib_version_arg)) {
version_number = invoker.native_lib_version_arg
}
+
+ # Do not add a dep on the generated_file target in order to avoid having
+ # to build the native libraries before this target. The dependency is
+ # instead captured via a depfile.
if (_native_libs_deps != []) {
native_libraries_list_file = _shared_library_list_file
} else {
@@ -2750,7 +2761,6 @@ if (enable_java_templates) {
"javac_args",
"native_lib_placeholders",
"processor_args_javac",
- "skip_jetify",
"secondary_abi_loadable_modules",
"secondary_native_lib_placeholders",
"sources",
@@ -2784,7 +2794,6 @@ if (enable_java_templates) {
supports_android = true
requires_android = true
srcjar_deps = _srcjar_deps
- final_jar_path = _jar_path
if (defined(_final_dex_path)) {
final_dex_path = _final_dex_path
}
@@ -2824,10 +2833,9 @@ if (enable_java_templates) {
}
}
- # Don't depend on the runtime_deps target in order to avoid having to
- # build the native libraries just to create the .build_config file.
- # The dep is unnecessary since the runtime_deps file is created by gn gen
- # and the runtime_deps file is added to write_build_config.py's depfile.
+ # Do not add a dep on the generated_file target in order to avoid having
+ # to build the native libraries before this target. The dependency is
+ # instead captured via a depfile.
if (_native_libs_deps != []) {
shared_libraries_runtime_deps_file = _shared_library_list_file
}
@@ -2866,13 +2874,6 @@ if (enable_java_templates) {
if (_uses_static_library_synchronized_proguard) {
_final_dex_target_dep = "${invoker.static_library_provider}__dexsplitter"
} else if (_is_bundle_module && _proguard_enabled) {
- # A small sanity check to help developers with a subtle point!
- assert(
- !defined(invoker.proguard_jar_path),
- "proguard_jar_path should not be used for app bundle modules " +
- "when proguard is enabled. Pass it to the android_app_bundle() " +
- "target instead!")
-
_final_deps += [ ":$_java_target" ]
} else if (_incremental_apk) {
if (defined(invoker.negative_main_dex_globs)) {
@@ -2910,16 +2911,21 @@ if (enable_java_templates) {
":$_java_target",
]
if (_proguard_enabled) {
- forward_variables_from(invoker, [ "proguard_jar_path" ])
deps += _deps + [ ":$_compile_resources_target" ]
proguard_mapping_path = _proguard_mapping_path
proguard_sourcefile_suffix = "$android_channel-$_version_code"
- } else {
+ has_apk_under_test = defined(invoker.apk_under_test)
+ } else if (_min_sdk_version >= default_min_sdk_version) {
+ # Enable dex merging only when min_sdk_version is >= what the library
+ # .dex files were created with.
input_dex_filearg =
"@FileArg(${_rebased_build_config}:final_dex:all_dex_files)"
if (_enable_main_dex_list) {
- main_dex_list_input_classes_filearg = "@FileArg(${_rebased_build_config}:deps_info:java_runtime_classpath)"
+ main_dex_list_input_classes_filearg = "@FileArg(${_rebased_build_config}:deps_info:java_runtime_classpath_extended)"
}
+ } else {
+ input_classes_filearg =
+ "@FileArg($_rebased_build_config:deps_info:device_classpath)"
}
if (_is_static_library_provider) {
@@ -3137,6 +3143,7 @@ if (enable_java_templates) {
package_apk("$_create_apk_target") {
forward_variables_from(invoker,
[
+ "expected_libs_and_assets",
"native_lib_placeholders",
"secondary_abi_loadable_modules",
"secondary_native_lib_placeholders",
@@ -3146,10 +3153,9 @@ if (enable_java_templates) {
"library_renames",
])
- if (defined(invoker.verify_native_libs_and_assets) &&
- invoker.verify_native_libs_and_assets) {
- verify_native_libs_and_assets_target_name = _template_name
+ if (defined(expected_libs_and_assets)) {
build_config_dep = ":$_build_config_target"
+ top_target_name = _template_name
}
build_config = _build_config
@@ -3161,8 +3167,7 @@ if (enable_java_templates) {
deps = _deps + [ ":$_build_config_target" ]
- # TODO(https://crbug.com/1056751): Add support for proguarding jdk libs.
- if (enable_jdk_library_desugaring) {
+ if (!_proguard_enabled && enable_jdk_library_desugaring) {
_all_jdk_libs = "//build/android:all_jdk_libs"
deps += [ _all_jdk_libs ]
jdk_libs_dex = get_label_info(_all_jdk_libs, "target_out_dir") +
@@ -3170,16 +3175,14 @@ if (enable_java_templates) {
}
if (_incremental_apk) {
- _dex_target =
- "//build/android/incremental_install:bootstrap_java__dex"
+ _dex_target = "//build/android/incremental_install:apk_dex"
deps += [
":${_incremental_compile_resources_target_name}",
_dex_target,
]
- dex_path =
- get_label_info(_dex_target, "target_out_dir") + "/bootstrap.dex"
+ dex_path = get_label_info(_dex_target, "target_out_dir") + "/apk.dex"
# All native libraries are side-loaded, so use a placeholder to force
# the proper bitness for the app.
@@ -3353,17 +3356,22 @@ if (enable_java_templates) {
android_lint(_android_lint_target) {
forward_variables_from(invoker,
[
+ "lint_suppressions_dep",
+ "lint_suppressions_file",
"manifest_package",
"min_sdk_version",
])
build_config = _build_config
- deps = [
- ":$_build_config_target",
- ":$_java_target",
- ]
+ build_config_dep = ":$_build_config_target"
+ deps = [ ":$_java_target" ]
}
} else {
- not_needed(invoker, [ "manifest_package" ])
+ not_needed(invoker,
+ [
+ "manifest_package",
+ "lint_suppressions_dep",
+ "lint_suppressions_file",
+ ])
}
group(target_name) {
@@ -3382,14 +3390,16 @@ if (enable_java_templates) {
data_deps = []
}
+ # Include unstripped native libraries so tests can symbolize stacks.
+ data_deps += _all_native_libs_deps
+
if (_enable_lint) {
data_deps += [ ":$_android_lint_target" ]
}
if (_incremental_apk) {
# device/commands is used by the installer script to push files via .zip.
- data_deps +=
- [ "//build/android/pylib/device/commands" ] + _native_libs_deps
+ data_deps += [ "//build/android/pylib/device/commands" ]
}
if (_uses_static_library) {
data_deps += [ invoker.static_library_provider ]
@@ -3465,6 +3475,8 @@ if (enable_java_templates) {
"keystore_name",
"keystore_password",
"keystore_path",
+ "lint_suppressions_dep",
+ "lint_suppressions_file",
"load_library_from_apk",
"loadable_modules",
"manifest_package",
@@ -3484,7 +3496,6 @@ if (enable_java_templates) {
"product_version_resources_dep",
"proguard_configs",
"proguard_enabled",
- "proguard_jar_path",
"r_java_root_package_name",
"resource_exclusion_exceptions",
"resource_exclusion_regex",
@@ -3495,7 +3506,6 @@ if (enable_java_templates) {
"secondary_abi_loadable_modules",
"secondary_abi_shared_libraries",
"secondary_native_lib_placeholders",
- "skip_jetify",
"shared_libraries",
"shared_resources",
"shared_resources_allowlist_locales",
@@ -3515,9 +3525,9 @@ if (enable_java_templates) {
"library_always_compress",
"library_renames",
"use_chromium_linker",
- "verify_manifest",
- "expected_manifest_base_expectation",
- "verify_native_libs_and_assets",
+ "expected_android_manifest",
+ "expected_android_manifest_base",
+ "expected_libs_and_assets",
"version_code",
"version_name",
])
@@ -3615,7 +3625,6 @@ if (enable_java_templates) {
"product_version_resources_dep",
"proguard_configs",
"proguard_enabled",
- "proguard_jar_path",
"resource_exclusion_exceptions",
"resource_exclusion_regex",
"resource_ids_provider_dep",
@@ -3641,8 +3650,8 @@ if (enable_java_templates) {
"library_renames",
"use_chromium_linker",
"use_modern_linker",
- "verify_manifest",
- "expected_manifest_base_expectation",
+ "expected_android_manifest",
+ "expected_android_manifest_base",
"version_code",
"version_name",
])
@@ -4045,12 +4054,13 @@ if (enable_java_templates) {
# Use the regular proto library to generate lite protos.
_protoc_bin = "//third_party/android_protoc/protoc"
_proto_runtime = "//third_party/android_deps:com_google_protobuf_protobuf_javalite_java"
- _protoc_javalite_plugin_dir = "//third_party/protoc_javalite/"
}
_proto_path = invoker.proto_path
_template_name = target_name
action_with_pydeps("${_template_name}__protoc_java") {
+ # The suffix "__protoc_java.srcjar" is used by SuperSize to identify
+ # protobuf symbols.
_srcjar_path = "$target_gen_dir/$target_name.srcjar"
script = "//build/protoc_java.py"
@@ -4087,11 +4097,6 @@ if (enable_java_templates) {
if (_generate_nano) {
args += [ "--nano" ]
- } else {
- args += [
- "--protoc-javalite-plugin-dir",
- rebase_path(_protoc_javalite_plugin_dir, root_build_dir),
- ]
}
}
@@ -4148,7 +4153,13 @@ if (enable_java_templates) {
_info_path = invoker.info_path
}
_output_path = "${target_out_dir}/${target_name}"
- _unpack_target_name = "${target_name}__unpack_aar"
+ _target_name_without_java_or_junit =
+ string_replace(string_replace(target_name, "_java", ""), "_junit", "")
+
+ # This unpack target is a python action, not a valid java target. Since the
+ # java targets below depend on it, its name must not match the java patterns
+ # in internal_rules.gni.
+ _unpack_target_name = "${_target_name_without_java_or_junit}__unpack_aar"
_ignore_aidl = defined(invoker.ignore_aidl) && invoker.ignore_aidl
_ignore_assets = defined(invoker.ignore_assets) && invoker.ignore_assets
_ignore_manifest =
@@ -4237,8 +4248,14 @@ if (enable_java_templates) {
outputs +=
get_path_info(rebase_path(_scanned_files.subjars, "", _output_path),
"abspath")
- if (!_ignore_proguard_configs && _scanned_files.has_proguard_flags) {
- outputs += [ "${_output_path}/proguard.txt" ]
+ if (!_ignore_proguard_configs) {
+ if (_scanned_files.has_proguard_flags) {
+ outputs += [ "${_output_path}/proguard.txt" ]
+ }
+ if (defined(_scanned_files.has_proguard_check_flags) &&
+ _scanned_files.has_proguard_check_flags) {
+ outputs += [ "${_output_path}/proguard-checks.txt" ]
+ }
}
if (_extract_native_libraries && _scanned_files.has_native_libraries) {
@@ -4255,7 +4272,7 @@ if (enable_java_templates) {
# Create the android_resources target for resources.
if (_has_unignored_resources ||
(!_scanned_files.is_manifest_empty && !_ignore_manifest)) {
- _res_target_name = "${target_name}__res"
+ _res_target_name = "${target_name}__resources"
android_resources(_res_target_name) {
forward_variables_from(invoker,
[
@@ -4285,38 +4302,37 @@ if (enable_java_templates) {
not_needed(invoker, [ "strip_drawables" ])
}
- _java_library_vars = [
- "enable_bytecode_checks",
- "enable_bytecode_rewriter",
- "missing_classes_allowlist",
- "enable_jetify",
- "jar_excluded_patterns",
- "jar_included_patterns",
- "requires_android",
- "skip_jetify",
- "testonly",
- ]
+ # Create android_java_prebuilt target for classes.jar.
+ if (_scanned_files.has_classes_jar) {
+ _java_library_vars = [
+ "enable_bytecode_checks",
+ "enable_jetify",
+ "jar_excluded_patterns",
+ "jar_included_patterns",
+ "missing_classes_allowlist",
+ "requires_android",
+ "testonly",
+ ]
- # Create android_java_prebuilt target for extra jars within jars/.
- _subjar_targets = []
- foreach(_tuple, _scanned_files.subjar_tuples) {
- _current_target = "${target_name}__subjar_${_tuple[0]}"
- _subjar_targets += [ ":$_current_target" ]
- java_prebuilt(_current_target) {
- forward_variables_from(invoker, _java_library_vars)
- deps = [ ":$_unpack_target_name" ]
- if (!defined(requires_android)) {
- requires_android = true
+ # Create android_java_prebuilt target for extra jars within jars/.
+ _subjar_targets = []
+ foreach(_tuple, _scanned_files.subjar_tuples) {
+ _current_target = "${target_name}__subjar_${_tuple[0]}"
+ _subjar_targets += [ ":$_current_target" ]
+ java_prebuilt(_current_target) {
+ forward_variables_from(invoker, _java_library_vars)
+ deps = [ ":$_unpack_target_name" ]
+ if (!defined(requires_android)) {
+ requires_android = true
+ }
+ supports_android = true
+ jar_path = "$_output_path/${_tuple[1]}"
+ _base_output_name = get_path_info(jar_path, "name")
+ output_name = "${invoker.target_name}-$_base_output_name"
+ public_target_label = invoker.target_name
}
- supports_android = true
- jar_path = "$_output_path/${_tuple[1]}"
- _base_output_name = get_path_info(jar_path, "name")
- output_name = "${invoker.target_name}-$_base_output_name"
}
- }
- # Create android_java_prebuilt target for classes.jar.
- if (_scanned_files.has_classes_jar) {
_jar_target_name = "${target_name}__classes"
java_prebuilt(_jar_target_name) {
forward_variables_from(invoker, _java_library_vars)
@@ -4340,12 +4356,19 @@ if (enable_java_templates) {
jar_path = "$_output_path/classes.jar"
output_name = invoker.target_name
- if (!_ignore_proguard_configs && _scanned_files.has_proguard_flags) {
+ if (!_ignore_proguard_configs) {
if (!defined(proguard_configs)) {
proguard_configs = []
}
- proguard_configs += [ "$_output_path/proguard.txt" ]
+ if (_scanned_files.has_proguard_flags) {
+ proguard_configs += [ "$_output_path/proguard.txt" ]
+ }
+ if (defined(_scanned_files.has_proguard_check_flags) &&
+ _scanned_files.has_proguard_check_flags) {
+ proguard_configs += [ "$_output_path/proguard-checks.txt" ]
+ }
}
+ public_target_label = invoker.target_name
}
}
@@ -4416,9 +4439,6 @@ if (enable_java_templates) {
# bundle. Default is to enable this only for release builds. Note that
# this will always perform synchronized proguarding.
#
- # proguard_jar_path: Optional. Path to custom proguard jar used for
- # proguarding.
- #
# enable_multidex: Optional. Enable multidexing of optimized modules jars
# when using synchronized proguarding. Only applies to base module.
#
@@ -4439,16 +4459,16 @@ if (enable_java_templates) {
# avoid library duplication. Effectively, the static library will be
# treated as the parent of the base module.
#
- # verify_proguard_flags: Enables verification of expected merged proguard
- # flags based on a golden file.
+ # expected_proguard_config: Checks that the merged set of proguard flags
+ # matches the given config.
#
# version_code: Optional. Version code of the target.
#
# is_multi_abi: If true will add a library placeholder for the missing ABI
# if either the primary or the secondary ABI has no native libraries set.
#
- # verify_native_libs_and_assets: (optional): If true, will verify the list
- # of included native libraries and assets is consistent with an
+ # expected_libs_and_assets: (optional): Verify the list
+ # of included native libraries and assets is consistent with the given
# expectation file.
#
# default_modules_for_testing: (optional): A list of DFM that the wrapper
@@ -4669,28 +4689,22 @@ if (enable_java_templates) {
if (defined(invoker.min_sdk_version)) {
not_needed(invoker, [ "min_sdk_version" ])
}
- if (defined(proguard_jar_path)) {
- not_needed(invoker, [ "proguard_jar_path" ])
- }
} else {
- _verify_proguard_flags = defined(invoker.verify_proguard_flags) &&
- invoker.verify_proguard_flags
dex(_dex_target) {
forward_variables_from(invoker,
[
- "proguard_jar_path",
+ "expected_proguard_config",
"min_sdk_version",
])
+ if (defined(expected_proguard_config)) {
+ top_target_name = _target_name
+ }
enable_multidex = _enable_multidex
proguard_enabled = true
proguard_mapping_path = _proguard_mapping_path
proguard_sourcefile_suffix = "$android_channel-$_version_code"
build_config = _build_config
- if (_verify_proguard_flags) {
- verify_proguard_flags_target_name = _target_name
- }
-
deps = _module_java_targets + [ ":$_build_config_target" ]
modules = _modules
}
@@ -4725,6 +4739,7 @@ if (enable_java_templates) {
"is_multi_abi",
"min_sdk_version",
"uncompress_dex",
+ "proguard_enabled",
])
module_name = _module.name
build_config = _module_build_config
@@ -4732,9 +4747,9 @@ if (enable_java_templates) {
native_libraries_config = _native_libraries_config
if (module_name == "base" &&
- defined(invoker.verify_native_libs_and_assets) &&
- invoker.verify_native_libs_and_assets) {
- verify_native_libs_and_assets_target_name = "${_target_name}__base"
+ defined(invoker.expected_libs_and_assets)) {
+ top_target_name = _target_name
+ expected_libs_and_assets = invoker.expected_libs_and_assets
build_config_target = _module_build_config_target
native_libraries_config_target = ":$_native_libraries_config_target"
if (defined(android_app_secondary_abi)) {
@@ -4968,15 +4983,22 @@ if (enable_java_templates) {
android_lint(_android_lint_target) {
forward_variables_from(invoker,
[
+ "lint_suppressions_dep",
+ "lint_suppressions_file",
"manifest_package",
"min_sdk_version",
- "lint_suppressions_file",
])
build_config = _build_config
- deps = _module_java_targets + [ ":$_build_config_target" ]
+ build_config_dep = ":$_build_config_target"
+ deps = _module_java_targets
}
} else {
- not_needed(invoker, [ "manifest_package" ])
+ not_needed(invoker,
+ [
+ "manifest_package",
+ "lint_suppressions_dep",
+ "lint_suppressions_file",
+ ])
}
group(_target_name) {
@@ -5085,17 +5107,11 @@ template("generate_ui_locale_resources") {
_output_zip = "${root_out_dir}/resource_zips/${_rebased_output_zip_path}/" +
"${target_name}.zip"
- _locales = invoker.ui_locales
- _depfile = "$target_gen_dir/$target_name.d"
-
- action(_generating_target_name) {
+ action_with_pydeps(_generating_target_name) {
script = "//build/android/gyp/create_ui_locale_resources.py"
- depfile = _depfile
outputs = [ _output_zip ]
args = [
- "--locale-list=$_locales",
- "--depfile",
- rebase_path(_depfile, root_build_dir),
+ "--locale-list=${invoker.ui_locales}",
"--output-zip",
rebase_path(_output_zip, root_build_dir),
]
diff --git a/chromium/build/config/c++/BUILD.gn b/chromium/build/config/c++/BUILD.gn
index 9787a0b982d..9cd944dce32 100644
--- a/chromium/build/config/c++/BUILD.gn
+++ b/chromium/build/config/c++/BUILD.gn
@@ -39,11 +39,12 @@ config("runtime_library") {
defines += [ "_LIBCPP_ABI_UNSTABLE" ]
}
- if (is_component_build) {
- # In component builds, symbols from libc++.so are exported for all DSOs to
- # use. If the system libc++ gets loaded (indirectly through a system
- # library), then it will conflict with our libc++.so. Add a custom ABI
- # version if we're building with _LIBCPP_ABI_UNSTABLE to avoid conflicts.
+ if (libcxx_is_shared) {
+ # When libcxx_is_shared is true, symbols from libc++.so are exported for
+ # all DSOs to use. If the system libc++ gets loaded (indirectly through
+ # a system library), then it will conflict with our libc++.so. Add a
+ # custom ABI version if we're building with _LIBCPP_ABI_UNSTABLE to avoid
+ # conflicts.
#
# Windows doesn't need to set _LIBCPP_ABI_VERSION since there's no system
# C++ library we could conflict with.
diff --git a/chromium/build/config/c++/c++.gni b/chromium/build/config/c++/c++.gni
index 5ced4596fac..f4abd1d8ae2 100644
--- a/chromium/build/config/c++/c++.gni
+++ b/chromium/build/config/c++/c++.gni
@@ -58,7 +58,7 @@ declare_args() {
# libc++abi needs to be exported from executables to be picked up by shared
# libraries on certain instrumented builds.
export_libcxxabi_from_executables =
- use_custom_libcxx && !is_win && !is_component_build &&
+ use_custom_libcxx && !is_ios && !is_win && !is_component_build &&
(is_asan || is_ubsan_vptr)
# On Android, many shared libraries get loaded from the context of a JRE. In
diff --git a/chromium/build/config/chromecast_build.gni b/chromium/build/config/chromecast_build.gni
index 97304c3a4d2..a7552b939e9 100644
--- a/chromium/build/config/chromecast_build.gni
+++ b/chromium/build/config/chromecast_build.gni
@@ -25,6 +25,9 @@ declare_args() {
# If non empty, rpath of executables is set to this.
# If empty, default value is used.
target_rpath = ""
+
+ # Set true to enable modular_updater.
+ enable_modular_updater = false
}
# Note(slan): This arg depends on the value of is_chromecast, and thus must be
diff --git a/chromium/build/config/chromeos/rules.gni b/chromium/build/config/chromeos/rules.gni
index d0a2f19d47c..3b029a5d32d 100644
--- a/chromium/build/config/chromeos/rules.gni
+++ b/chromium/build/config/chromeos/rules.gni
@@ -7,11 +7,59 @@ import("//build/config/chromeos/args.gni")
assert(is_chromeos)
-declare_args() {
- # Determines if we're running tests on VMs or on devices.
- # TODO(crbug.com/866062): Is there a better way to do this?
- cros_is_vm = cros_board == "amd64-generic" || cros_board == "betty" ||
- cros_board == "betty-pi-arc"
+# Determine the real paths for various items in the SDK, which may be used
+# in the 'generate_runner_script' template below. We do so outside the template
+# to confine exec_script to a single invocation.
+cros_is_vm = false
+if (is_chromeos_device && cros_sdk_version != "") {
+ _cache_path_prefix =
+ "//build/cros_cache/chrome-sdk/symlinks/${cros_board}+${cros_sdk_version}"
+
+ # It's difficult to determine if any given board supports QEMU images. So
+ # check if there's one present in the expected location.
+ _qemu_image_path = "${_cache_path_prefix}+chromiumos_qemu_image.tar.xz"
+
+ # TODO(crbug.com/937821): Check for the board in a gclient list var to
+ # determine if we expect a VM image.
+ cros_is_vm = exec_script("//build/dir_exists.py",
+ [ rebase_path(_qemu_image_path) ],
+ "string") == "True"
+
+ _symlinks = [
+ # Tast harness & test data.
+ rebase_path("${_cache_path_prefix}+chromeos-base/tast-cmd"),
+ rebase_path("${_cache_path_prefix}+chromeos-base/tast-remote-tests-cros"),
+
+ # Binutils (and other toolchain tools) used to deploy Chrome to the device.
+ rebase_path(
+ "${_cache_path_prefix}+environment_chromeos-base_chromeos-chrome.tar.xz"),
+ rebase_path("${_cache_path_prefix}+target_toolchain"),
+ ]
+ if (cros_is_vm) {
+ # VM-related tools.
+ _symlinks += [
+ rebase_path("${_cache_path_prefix}+sys-firmware/seabios"),
+ rebase_path(_qemu_image_path),
+ rebase_path("${_cache_path_prefix}+app-emulation/qemu"),
+ ]
+ }
+ _symlink_targets =
+ exec_script("//build/get_symlink_targets.py", _symlinks, "list lines")
+ tast_sdk_items = [
+ _symlink_targets[0],
+ _symlink_targets[1],
+ ]
+ toolchain_sdk_items = [
+ _symlink_targets[2],
+ _symlink_targets[3],
+ ]
+ if (cros_is_vm) {
+ vm_sdk_items = [
+ _symlink_targets[4],
+ _symlink_targets[5],
+ _symlink_targets[6],
+ ]
+ }
}
# Creates a script at $generated_script that can be used to launch a cros VM
@@ -44,12 +92,6 @@ template("generate_runner_script") {
deploy_chrome = false
}
- # These are the only 2 conditions when ${_cache_path_prefix} is used, so
- # initialize it in a conditional.
- if (deploy_chrome || cros_is_vm) {
- _cache_path_prefix = "//build/cros_cache/chrome-sdk/tarballs/"
- }
-
assert(defined(generated_script),
"Must specify where to place generated test launcher script via " +
"'generated_script'")
@@ -90,24 +132,6 @@ template("generate_runner_script") {
"//third_party/chromite/",
]
- # Add the VM/QEMU-launching bits if needed.
- if (cros_is_vm) {
- assert(defined(_cache_path_prefix))
- _vm_image_path = "${_cache_path_prefix}/chromiumos_qemu_image.tar.xz/"
- _qemu_dir = "${_cache_path_prefix}/app-emulation/"
- _firmware_dir = "${_cache_path_prefix}/sys-firmware/"
- data += [
- _firmware_dir,
- _vm_image_path,
- _qemu_dir,
- ]
- }
- if (is_tast) {
- data += [
- "${_cache_path_prefix}/chromeos-base/tast-cmd/",
- "${_cache_path_prefix}/chromeos-base/tast-remote-tests-cros/",
- ]
- }
if (defined(invoker.data)) {
deps += invoker.data
}
@@ -134,15 +158,24 @@ template("generate_runner_script") {
if (deploy_chrome) {
args += [ "--deploy-chrome" ]
+ }
- # To deploy chrome to the VM, it needs to be stripped down to fit into
- # the VM. This is done by using binutils in the toolchain. So add the
- # toolchain to the data.
- assert(defined(_cache_path_prefix))
- data += [
- "${_cache_path_prefix}/environment_chromeos-base_chromeos-chrome.tar.xz",
- "${_cache_path_prefix}/target_toolchain/",
- ]
+ # If we're in the cros chrome-sdk (and not the raw ebuild), the test will
+ # need some additional runtime data located in the SDK cache.
+ if (cros_sdk_version != "") {
+ # Add the VM/QEMU-launching bits if needed.
+ if (cros_is_vm) {
+ data += vm_sdk_items
+ }
+ if (is_tast) {
+ data += tast_sdk_items
+ }
+ if (deploy_chrome) {
+ # To deploy chrome to the VM, it needs to be stripped down to fit into
+ # the VM. This is done by using binutils in the toolchain. So add the
+ # toolchain to the data.
+ data += toolchain_sdk_items
+ }
}
# When --test-exe is specified, test_runner.py will push the exe to the VM
@@ -191,8 +224,7 @@ template("tast_test") {
# The following expression filters out all non-critical tests. See the link
# below for more details:
# https://chromium.googlesource.com/chromiumos/platform/tast/+/master/docs/test_attributes.md
- tast_attr_expr =
- "!disabled && (\"group:mainline\" || !\"group:*\") && \"dep:chrome\""
+ tast_attr_expr = "\"group:mainline\" && \"dep:chrome\""
if (defined(enable_tast_informational_tests) &&
enable_tast_informational_tests) {
diff --git a/chromium/build/config/compiler/BUILD.gn b/chromium/build/config/compiler/BUILD.gn
index 01d97a3605f..6e219b3994e 100644
--- a/chromium/build/config/compiler/BUILD.gn
+++ b/chromium/build/config/compiler/BUILD.gn
@@ -121,9 +121,6 @@ declare_args() {
thin_lto_enable_optimizations =
(is_chromeos || is_android || is_win) && is_official_build
- # By default only the binaries in official builds get build IDs.
- force_local_build_id = false
-
# Initialize all local variables with a pattern. This flag will fill
# uninitialized floating-point types (and 32-bit pointers) with 0xFF and the
# rest with 0xAA. This makes behavior of uninitialized memory bugs consistent,
@@ -143,6 +140,15 @@ declare_args() {
# reduce TLB misses which gives performance improvement on cpu usage.
# The gold linker by default has text section splitting enabled.
use_text_section_splitting = false
+
+ # Token limits may not be accurate for build configs not covered by the CQ,
+ # so only enable them by default for mainstream build configs.
+ enable_wmax_tokens =
+ !is_official_build &&
+ (is_mac || (is_linux && !is_chromeos && target_cpu == "x64") ||
+ (is_win && target_cpu == "x86") || (is_win && target_cpu == "x64") ||
+ (is_android && target_cpu == "arm") ||
+ (is_android && target_cpu == "arm64"))
}
declare_args() {
@@ -323,14 +329,16 @@ config("compiler") {
}
}
- if (is_official_build || force_local_build_id) {
- # Explicitly pass --build-id to ld. Compilers used to always pass this
- # implicitly but don't any more (in particular clang when built without
- # ENABLE_LINKER_BUILD_ID=ON). The crash infrastructure does need a build
- # id, so explicitly enable it in official builds. It's not needed in
- # unofficial builds and computing it does slow down the link, so go with
- # faster links in unofficial builds.
+ # Explicitly pass --build-id to ld. Compilers used to always pass this
+ # implicitly but don't any more (in particular clang when built without
+ # ENABLE_LINKER_BUILD_ID=ON).
+ if (is_official_build) {
+ # The sha1 build id has lower risk of collision but is more expensive to
+ # compute, so only use it in the official build to avoid slowing down
+ # links.
ldflags += [ "-Wl,--build-id=sha1" ]
+ } else if (current_os != "aix") {
+ ldflags += [ "-Wl,--build-id" ]
}
if (!is_android) {
@@ -543,6 +551,23 @@ config("compiler") {
}
}
+ # C++17 removes trigraph support, so preemptively disable trigraphs. This is
+ # especially useful given the collision with ecmascript's logical assignment
+ # operators: https://github.com/tc39/proposal-logical-assignment
+ if (is_clang) {
+ # clang-cl disables trigraphs by default
+ if (!is_win) {
+ # The gnu variants of C++11 and C++14 already disable trigraph support,
+ # but when building with clang, we use -std=c++11 / -std=c++14, which
+ # enables trigraph support: override that here.
+ cflags_cc += [ "-fno-trigraphs" ]
+ }
+
+ # Don't warn that trigraphs are ignored, since trigraphs are disabled
+ # anyway.
+ cflags_cc += [ "-Wno-trigraphs" ]
+ }
+
if (is_mac) {
# The system libc++ on Mac doesn't have aligned allocation in C++17.
defines += [ "_LIBCPP_HAS_NO_ALIGNED_ALLOCATION" ]
@@ -1468,14 +1493,6 @@ config("default_warnings") {
cflags += [ "-Wno-nonportable-include-path" ]
}
- if (target_os == "chromeos") {
- # Disable clang warnings of "-Wmax-tokens" because CQ doesn't cover all CrOS use
- # cases, so it's too late to fix when the error goes to CrOS side.
- # Also nacl toolchain doesn't recognize the flag, so avoid passing to nacl clang
- # See crbug.com/1079053 for more details.
- cflags += [ "-Wno-max-tokens" ]
- }
-
if (current_toolchain == host_toolchain || !use_xcode_clang) {
# Flags NaCl (Clang 3.7) and Xcode 9.2 (Clang clang-900.0.39.2) do not
# recognize.
@@ -1504,6 +1521,13 @@ config("default_warnings") {
# TODO(https://crbug.com/995993): Clean up and enable.
"-Wno-implicit-fallthrough",
]
+
+ if (enable_wmax_tokens) {
+ cflags += [ "-Wmax-tokens" ]
+ } else {
+ # TODO(https://crbug.com/1049569): Remove after Clang 87b235db.
+ cflags += [ "-Wno-max-tokens" ]
+ }
}
}
}
@@ -1970,6 +1994,14 @@ config("optimize") {
} else {
cflags = [ "-Os" ] + common_optimize_on_cflags
}
+ } else if (is_chromeos) {
+ # TODO(gbiv): This is partially favoring size over speed. CrOS exclusively
+ # uses clang, and -Os in clang is more of a size-conscious -O2 than "size at
+ # any cost" (AKA -Oz). It'd be nice to:
+ # - Make `optimize_for_size` apply to all platforms where we're optimizing
+ # for size by default (so, also Windows)
+ # - Investigate -Oz here, maybe just for ARM?
+ cflags = [ "-Os" ] + common_optimize_on_cflags
} else {
cflags = [ "-O2" ] + common_optimize_on_cflags
}
@@ -1998,6 +2030,12 @@ config("no_optimize") {
} else {
cflags = [ "-Os" ] + common_optimize_on_cflags
}
+
+ if (!is_component_build) {
+ # Required for library partitions. Without this all symbols just end up
+ # in the base partition.
+ ldflags = [ "-Wl,--gc-sections" ]
+ }
} else if (is_fuchsia) {
# On Fuchsia, we optimize for size here to reduce the size of debug build
# packages so they can be run in a KVM. See crbug.com/910243 for details.
@@ -2249,7 +2287,8 @@ config("symbols") {
cflags += [ "-g2" ]
}
- if (is_clang && !is_nacl && !use_xcode_clang) {
+ # TODO(https://crbug.com/1050118): Investigate missing debug info on mac.
+ if (is_clang && !is_nacl && !use_xcode_clang && !is_mac && !is_ios) {
cflags += [
"-Xclang",
"-debug-info-kind=constructor",
diff --git a/chromium/build/config/compiler/compiler.gni b/chromium/build/config/compiler/compiler.gni
index bd21ffe5dc3..ef8cc5fdfd5 100644
--- a/chromium/build/config/compiler/compiler.gni
+++ b/chromium/build/config/compiler/compiler.gni
@@ -110,7 +110,13 @@ declare_args() {
# Determine whether to enable or disable frame pointers, based on the platform
# and build arguments.
-if (is_mac || is_ios || is_linux) {
+if (is_chromeos) {
+ # ChromeOS generally prefers frame pointers, to support CWP.
+ # However, Clang does not currently generate usable frame pointers in ARM
+ # 32-bit builds (https://bugs.llvm.org/show_bug.cgi?id=18505) so disable them
+ # there to avoid the unnecessary overhead.
+ enable_frame_pointers = current_cpu != "arm"
+} else if (is_mac || is_ios || is_linux) {
enable_frame_pointers = true
} else if (is_win) {
# 64-bit Windows ABI doesn't support frame pointers.
@@ -119,12 +125,6 @@ if (is_mac || is_ios || is_linux) {
} else {
enable_frame_pointers = true
}
-} else if (is_chromeos) {
- # ChromeOS generally prefers frame pointers, to support CWP.
- # However, Clang does not currently generate usable frame pointers in ARM
- # 32-bit builds (https://bugs.llvm.org/show_bug.cgi?id=18505) so disable them
- # there to avoid the unnecessary overhead.
- enable_frame_pointers = current_cpu != "arm"
} else if (is_android) {
enable_frame_pointers =
enable_profiling ||
diff --git a/chromium/build/config/compiler/pgo/BUILD.gn b/chromium/build/config/compiler/pgo/BUILD.gn
index 84c941faaf6..20f01f3cafa 100644
--- a/chromium/build/config/compiler/pgo/BUILD.gn
+++ b/chromium/build/config/compiler/pgo/BUILD.gn
@@ -14,16 +14,12 @@ config("pgo_instrumentation_flags") {
# Only add flags when chrome_pgo_phase == 1, so that variables we would use
# are not required to be defined when we're not actually using PGO.
if (chrome_pgo_phase == 1 && is_clang && !is_nacl && is_a_target_toolchain) {
- # TODO(sebmarchand): Add a GN flag that allows setting the PGO profile
- # name or find a way to remove use {target_name} in the filename?
- # This uses the "%m" specifier to allow concurrent runs of the
- # instrumented image.
- cflags = [ "-fprofile-instr-generate=%m.profraw" ]
+ cflags = [ "-fprofile-generate" ]
if (!is_win) {
# Windows directly calls link.exe instead of the compiler driver when
# linking, and embeds the path to the profile runtime library as
# dependent library into each object file.
- ldflags = [ "-fprofile-instr-generate" ]
+ ldflags = [ "-fprofile-generate" ]
}
}
}
@@ -37,14 +33,22 @@ config("pgo_optimization_flags") {
if (chrome_pgo_phase == 2 && is_clang && !is_nacl && is_a_target_toolchain) {
_pgo_target = ""
+ # There are txt files used by //tools/update_pgo_profiles.py to decide which
+ # profiles to use, adding them as inputs so that analyzer recognizes the
+ # dependencies.
+ inputs = []
+
if (is_win) {
if (target_cpu == "x64") {
_pgo_target = "win64"
+ inputs = [ "//chrome/build/win64.pgo.txt" ]
} else {
_pgo_target = "win32"
+ inputs = [ "//chrome/build/win32.pgo.txt" ]
}
} else if (is_mac) {
_pgo_target = "mac"
+ inputs = [ "//chrome/build/mac.pgo.txt" ]
}
if (pgo_data_path == "" && _pgo_target != "") {
@@ -66,7 +70,14 @@ config("pgo_optimization_flags") {
# and at least some profile data always ends up being considered
# out of date, so make sure we don't error for those cases.
"-Wno-profile-instr-unprofiled",
- "-Wno-error=profile-instr-out-of-date",
+ "-Wno-profile-instr-out-of-date",
+
+ # Some hashing conflict results in a lot of warning like this when doing
+ # a PGO build:
+ # warning: foo.cc: Function control flow change detected (hash mismatch)
+ # [-Wbackend-plugin]
+ # See https://crbug.com/978401
+ "-Wno-backend-plugin",
]
}
}
diff --git a/chromium/build/config/compiler/pgo/pgo.gni b/chromium/build/config/compiler/pgo/pgo.gni
index a0cbb6acc05..f616b88a052 100644
--- a/chromium/build/config/compiler/pgo/pgo.gni
+++ b/chromium/build/config/compiler/pgo/pgo.gni
@@ -9,6 +9,9 @@ declare_args() {
# 1 : Used during the PGI (instrumentation) phase.
# 2 : Used during the PGO (optimization) phase.
chrome_pgo_phase = 0
+ if (is_official_build && (is_win || is_mac)) {
+ chrome_pgo_phase = 2
+ }
# When using chrome_pgo_phase = 2, read profile data from this path.
pgo_data_path = ""
diff --git a/chromium/build/config/fuchsia/BUILD.gn b/chromium/build/config/fuchsia/BUILD.gn
index 7ee1923d946..427f364a6b4 100644
--- a/chromium/build/config/fuchsia/BUILD.gn
+++ b/chromium/build/config/fuchsia/BUILD.gn
@@ -13,6 +13,13 @@ config("compiler") {
# but on other platforms it's much higher, so a variety of code assumes more
# will be available. Raise to 8M which matches e.g. macOS.
ldflags = [ "-Wl,-z,stack-size=0x800000" ]
+
+ if (target_cpu != "arm64") {
+ # TODO(https://crbug.com/1086134): RELR packing of dynamic relocations is
+ # enabled by default in the Fuchsia toolchain, but is not fully supported
+ # in Chromium builds except on ARM64.
+ ldflags += [ "-Wl,--pack-dyn-relocs=none" ]
+ }
}
# Settings for executables.
diff --git a/chromium/build/config/fuchsia/generate_runner_scripts.gni b/chromium/build/config/fuchsia/generate_runner_scripts.gni
index 2f57fc0c607..a0bae5eee6b 100644
--- a/chromium/build/config/fuchsia/generate_runner_scripts.gni
+++ b/chromium/build/config/fuchsia/generate_runner_scripts.gni
@@ -26,12 +26,9 @@ declare_args() {
# package_name_override: Specifies the name of the generated package, if its
# name is different than the |package| target name. This value must match
# package_name_override in the |package| target.
-# archive_name_override: Specifies the filename of the archive file (FAR)
-# which contains the package's data.
-# If left unset, defaults to |package_name_override|.
-# Defaults to the package's name.
-# package_deps: An array of [package, archive_basename] pairs that specify
-# additional dependency packages to be installed prior to execution.
+# package_deps: An array of [package, package_name_override] array pairs
+# which specify additional dependency packages to be installed
+# prior to execution.
# runner_script: The runner script implementation to use, relative to
# "build/fuchsia". Defaults to "test_runner.py".
# install_only: If true, executing the script will only install the package
@@ -39,29 +36,19 @@ declare_args() {
template("fuchsia_package_runner") {
forward_variables_from(invoker, [ "runner_script" ])
- # Compute the package name.
if (defined(invoker.package_name_override)) {
- _package_name = invoker.package_name_override
+ _pkg_shortname = invoker.package_name_override
} else {
- _package_name = get_label_info(invoker.package, "name")
- }
-
- # Compute the archive (FAR) filename.
- if (defined(invoker.archive_name_override)) {
- _archive_shortname = invoker.archive_name_override
- } else {
- _archive_shortname = _package_name
+ _pkg_shortname = get_label_info(invoker.package, "name")
}
_pkg_dir = "$root_out_dir/gen/" + get_label_info(invoker.package, "dir") +
- "/" + _archive_shortname
- _manifest_path = "$_pkg_dir/${_archive_shortname}.archive_manifest"
- _package_path = "$_pkg_dir/${_archive_shortname}.far"
+ "/" + _pkg_shortname
+ _package_path = "$_pkg_dir/${_pkg_shortname}.far"
- generated_run_pkg_script_path =
- "$root_build_dir/bin/run_${_archive_shortname}"
+ generated_run_pkg_script_path = "$root_build_dir/bin/run_${_pkg_shortname}"
generated_install_pkg_script_path =
- "$root_build_dir/bin/install_${_archive_shortname}"
+ "$root_build_dir/bin/install_$_pkg_shortname"
_generate_runner_target = "${target_name}__generate_runner"
_generate_installer_target = "${target_name}__generate_installer"
@@ -100,7 +87,6 @@ template("fuchsia_package_runner") {
# Declares the files that are needed for test execution on the
# swarming test client.
data = [
- _manifest_path,
"//build/fuchsia/",
"//build/util/lib/",
"//third_party/fuchsia-sdk/sdk/.build-id/",
@@ -167,7 +153,7 @@ template("fuchsia_package_runner") {
"--target-cpu",
target_cpu,
"--package-name",
- _package_name,
+ _pkg_shortname,
]
if (defined(invoker.use_test_server) && invoker.use_test_server) {
diff --git a/chromium/build/config/fuchsia/gfx_tests.cmx b/chromium/build/config/fuchsia/gfx_tests.cmx
index 5e51f421120..081fc0f5482 100644
--- a/chromium/build/config/fuchsia/gfx_tests.cmx
+++ b/chromium/build/config/fuchsia/gfx_tests.cmx
@@ -11,15 +11,20 @@
"zero"
],
"services": [
+ "fuchsia.accessibility.semantics.SemanticsManager",
+ "fuchsia.device.NameProvider",
"fuchsia.fonts.Provider",
"fuchsia.intl.PropertyProvider",
"fuchsia.logger.Log",
"fuchsia.logger.LogSink",
+ "fuchsia.memorypressure.Provider",
"fuchsia.process.Launcher",
"fuchsia.sys.Environment",
"fuchsia.sys.Loader",
"fuchsia.sysmem.Allocator",
"fuchsia.tracing.provider.Registry",
+ "fuchsia.ui.input.ImeService",
+ "fuchsia.ui.input.ImeVisibilityService",
"fuchsia.ui.policy.Presenter",
"fuchsia.ui.scenic.Scenic",
"fuchsia.vulkan.loader.Loader"
diff --git a/chromium/build/config/fuchsia/package.gni b/chromium/build/config/fuchsia/package.gni
index e7bca251c5f..51ebad637b1 100644
--- a/chromium/build/config/fuchsia/package.gni
+++ b/chromium/build/config/fuchsia/package.gni
@@ -13,9 +13,6 @@ import("//third_party/fuchsia-sdk/sdk/build/package.gni")
# Parameters are:
# package_name_override: Specifies the name of the package to generate,
# if different than |target_name|.
-# archive_filename_override: Specifies the filename of the generated FAR.
-# If left unset, defaults to |package_name_override|.
-# Defaults to the target name.
# binary: The executable target which should be launched.
# manifest: A path to the manifest that will be used.
# "testonly" targets default to using
@@ -107,27 +104,7 @@ template("cr_fuchsia_package") {
}
}
- # Generate a Fuchsia ARchive (FAR) of the requested name.
- if (defined(invoker.archive_name_override)) {
- _archive_name = invoker.archive_name_override
- } else {
- _archive_name = _package_name
- }
-
- if (_archive_name != _package_name) {
- _archive_target = target_name + "__cr-archive"
-
- copy(target_name) {
- deps = [ ":${_archive_target}" ]
- _pkg_out_dir = "${target_gen_dir}/${_package_name}"
- sources = [ "${_pkg_out_dir}/${_package_name}.far" ]
- outputs = [ "${_pkg_out_dir}/${_archive_name}.far" ]
- }
- } else {
- _archive_target = target_name
- }
-
- fuchsia_package(_archive_target) {
+ fuchsia_package(target_name) {
forward_variables_from(invoker, [ "testonly" ])
package_name = _package_name
if (defined(invoker.excluded_files)) {
diff --git a/chromium/build/config/ios/ios_sdk.gni b/chromium/build/config/ios/ios_sdk.gni
index f3aaf810644..917a6902ae1 100644
--- a/chromium/build/config/ios/ios_sdk.gni
+++ b/chromium/build/config/ios/ios_sdk.gni
@@ -27,12 +27,18 @@ declare_args() {
# not work (see build/BUILDCONFIG.gn for pattern that would cause issue).
ios_sdk_developer_dir = ""
- # The iOS Code signing identity to use
- # TODO(GYP), TODO(sdfresne): Consider having a separate
- # ios_enable_code_signing_flag=<bool> flag to make the invocation clearer.
+ # Control whether codesiging is enabled (ignored for simulator builds).
ios_enable_code_signing = true
+
+ # Explicitly select the identity to use for codesigning. If defined, must
+ # be set to a non-empty string that will be passed to codesigning. Can be
+ # left unspecified if ios_code_signing_identity_description is used instead.
ios_code_signing_identity = ""
- ios_code_signing_identity_description = "iPhone Developer"
+
+ # Pattern used to select the identity to use for codesigning. If defined,
+ # must be a substring of the description of exactly one of the identities by
+ # `security find-identity -v -p codesigning`.
+ ios_code_signing_identity_description = "Apple Development"
# Prefix for CFBundleIdentifier property of iOS bundles (correspond to the
# "Organization Identifier" in Xcode). Code signing will fail if no mobile
@@ -68,6 +74,18 @@ assert(custom_toolchain == "" || additional_target_cpus == [],
use_ios_simulator = current_cpu == "x86" || current_cpu == "x64"
+# If codesigning is enabled, use must configure either a codesigning identity
+# or a filter to automatically select the codesigning identity.
+if (!use_ios_simulator && ios_enable_code_signing) {
+ assert(ios_code_signing_identity == "" ||
+ ios_code_signing_identity_description == "",
+ "You should either specify the precise identity to use with " +
+ "ios_code_signing_identity or let the code select an identity " +
+ "automatically (via find_signing_identity.py which use the " +
+ "variable ios_code_signing_identity_description to set the " +
+ "pattern to match the identity to use).")
+}
+
# Initialize additional_toolchains from additional_target_cpus. Assert here
# that the list does not contains $target_cpu nor duplicates as this would
# cause weird errors during the build.
@@ -135,12 +153,15 @@ if (!use_ios_simulator && ios_enable_code_signing) {
# Automatically select a codesigning identity if no identity is configured.
# This only applies to device build as simulator builds are not signed.
if (ios_code_signing_identity == "") {
- ios_code_signing_identity =
- exec_script("find_signing_identity.py",
- [
- "--matching-pattern",
- ios_code_signing_identity_description,
- ],
- "string")
+ find_signing_identity_args = []
+ if (ios_code_signing_identity_description != "") {
+ find_signing_identity_args = [
+ "--matching-pattern",
+ ios_code_signing_identity_description,
+ ]
+ }
+ ios_code_signing_identity = exec_script("find_signing_identity.py",
+ find_signing_identity_args,
+ "trim string")
}
}
diff --git a/chromium/build/config/ios/rules.gni b/chromium/build/config/ios/rules.gni
index 6c9733346e7..0e882464c74 100644
--- a/chromium/build/config/ios/rules.gni
+++ b/chromium/build/config/ios/rules.gni
@@ -514,13 +514,10 @@ template("ios_info_plist") {
# entitlements (must generate a single file as output); cannot be
# defined if entitlements_path is set.
#
-# bundle_extension:
-# (optional) bundle extension including the dot, default to ".app".
-#
# product_type
# (optional) string, product type for the generated Xcode project,
-# default to "com.apple.product-type.application". Should generally
-# not be overridden.
+# default to "com.apple.product-type.application". Should only be
+# overriden when building application extension.
#
# enable_code_signing
# (optional) boolean, control whether code signing is enabled or not,
@@ -546,6 +543,10 @@ template("ios_app_bundle") {
_output_name = invoker.output_name
}
+ assert(
+ !defined(invoker.bundle_extension),
+ "bundle_extension must not be set for ios_app_bundle template for $target_name")
+
_xcode_product_bundle_id = "$ios_app_bundle_id_prefix.$_output_name"
if (defined(invoker.xcode_product_bundle_id)) {
_xcode_product_bundle_id = invoker.xcode_product_bundle_id
@@ -599,10 +600,6 @@ template("ios_app_bundle") {
_default_variant = _variants[0]
- if (current_toolchain != default_toolchain) {
- not_needed("*")
- }
-
source_set(_arch_executable_source) {
forward_variables_from(invoker,
"*",
@@ -632,6 +629,21 @@ template("ios_app_bundle") {
"target_out_dir") + "/$_output_name.xcent"
}
+ _product_type = _ios_xcode_app_bundle_id
+ if (defined(invoker.product_type)) {
+ _product_type = invoker.product_type
+ }
+
+ if (_product_type == _ios_xcode_app_bundle_id) {
+ _bundle_extension = ".app"
+ } else if (_product_type == _ios_xcode_appex_bundle_id) {
+ _bundle_extension = ".appex"
+ } else {
+ assert(false, "unknown product_type \"$product_type\" for $_target_name")
+ }
+
+ _is_app_bundle = _product_type == _ios_xcode_app_bundle_id
+
executable(_arch_executable_target) {
forward_variables_from(invoker,
"*",
@@ -681,6 +693,18 @@ template("ios_app_bundle") {
"2",
]
+ # Application extension may share private frameworks with the application
+ # itself, so they need to look in both their own bundle and the surrounding
+ # app bundle for the frameworks.
+ if (!_is_app_bundle) {
+ ldflags += [
+ "-Xlinker",
+ "-rpath",
+ "-Xlinker",
+ "@executable_path/../../Frameworks",
+ ]
+ }
+
if (use_ios_simulator) {
deps += [ ":$_generate_entitlements_target($default_toolchain)" ]
@@ -791,23 +815,8 @@ template("ios_app_bundle") {
}
}
- _product_type = _ios_xcode_app_bundle_id
- if (defined(invoker.product_type)) {
- _product_type = invoker.product_type
- }
-
- _app_bundle_extension = ".app"
- _bundle_extension = _app_bundle_extension
- if (defined(invoker.bundle_extension)) {
- _bundle_extension = invoker.bundle_extension
- }
-
- # Only write PkgInfo for real application, not application extension (they
- # have the same product type but a different extension).
- _write_pkg_info = _product_type == _ios_xcode_app_bundle_id &&
- _bundle_extension == _app_bundle_extension
-
- if (_write_pkg_info) {
+ # Only write PkgInfo for real application, not application extension.
+ if (_is_app_bundle) {
_create_pkg_info = target_name + "_pkg_info"
action(_create_pkg_info) {
forward_variables_from(invoker, [ "testonly" ])
@@ -873,7 +882,7 @@ template("ios_app_bundle") {
if (!defined(bundle_deps)) {
bundle_deps = []
}
- if (_write_pkg_info) {
+ if (_is_app_bundle) {
bundle_deps += [ ":$_bundle_data_pkg_info" ]
}
bundle_deps += _variant.bundle_deps
@@ -906,6 +915,10 @@ template("ios_app_bundle") {
}
}
}
+
+ if (current_toolchain != default_toolchain) {
+ not_needed("*")
+ }
}
set_defaults("ios_app_bundle") {
@@ -948,7 +961,6 @@ template("ios_appex_bundle") {
"bundle_extension",
"product_type",
])
- bundle_extension = ".appex"
product_type = _ios_xcode_appex_bundle_id
# Add linker flags required for an application extension (determined by
diff --git a/chromium/build/config/linux/BUILD.gn b/chromium/build/config/linux/BUILD.gn
index 6b8ef4fd075..fda14196f3e 100644
--- a/chromium/build/config/linux/BUILD.gn
+++ b/chromium/build/config/linux/BUILD.gn
@@ -60,14 +60,6 @@ config("xext") {
libs = [ "Xext" ]
}
-config("xrandr") {
- libs = [ "Xrandr" ]
-}
-
-config("xscrnsaver") {
- libs = [ "Xss" ]
-}
-
config("xfixes") {
libs = [ "Xfixes" ]
}
diff --git a/chromium/build/config/mac/BUILD.gn b/chromium/build/config/mac/BUILD.gn
index de8233bba4a..5369f767267 100644
--- a/chromium/build/config/mac/BUILD.gn
+++ b/chromium/build/config/mac/BUILD.gn
@@ -24,6 +24,13 @@ config("compiler") {
"-arch",
"i386",
]
+ } else if (current_cpu == "arm64") {
+ common_mac_flags += [
+ "-arch",
+ current_cpu,
+ ]
+ } else {
+ assert(false, "unknown current_cpu $current_cpu")
}
# This is here so that all files get recompiled after an Xcode update.
diff --git a/chromium/build/config/mac/OWNERS b/chromium/build/config/mac/OWNERS
index 14747a00255..0ed2e154d83 100644
--- a/chromium/build/config/mac/OWNERS
+++ b/chromium/build/config/mac/OWNERS
@@ -1,4 +1,2 @@
rsesek@chromium.org
sdefresne@chromium.org
-
-# COMPONENT: Build
diff --git a/chromium/build/config/mac/mac_sdk.gni b/chromium/build/config/mac/mac_sdk.gni
index c43c00ddaf0..eda9dfd77d8 100644
--- a/chromium/build/config/mac/mac_sdk.gni
+++ b/chromium/build/config/mac/mac_sdk.gni
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//build/config/chrome_build.gni")
+import("//build/config/gclient_args.gni")
import("//build/config/mac/mac_sdk_overrides.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/toolchain.gni")
@@ -112,7 +113,13 @@ if (use_system_xcode) {
mac_bin_path = find_sdk_lines[1]
}
} else {
- mac_sdk_version = mac_sdk_official_version
+ if (mac_xcode_version == "default") {
+ mac_sdk_version = mac_sdk_official_version
+ } else if (mac_xcode_version == "xcode_12_beta") {
+ mac_sdk_version = "11.0"
+ } else {
+ assert(false, "unknown mac_xcode_version $mac_xcode_version")
+ }
_dev = _hermetic_xcode_path + "/Contents/Developer"
_sdk = "MacOSX${mac_sdk_version}.sdk"
mac_sdk_path = _dev + "/Platforms/MacOSX.platform/Developer/SDKs/$_sdk"
diff --git a/chromium/build/config/mac/prepare_framework_version.py b/chromium/build/config/mac/prepare_framework_version.py
index 5e8a53f20ab..db921506987 100644
--- a/chromium/build/config/mac/prepare_framework_version.py
+++ b/chromium/build/config/mac/prepare_framework_version.py
@@ -31,7 +31,7 @@ def PrepareFrameworkVersion(version_file, framework_root_dir, version):
# directory exists.
dirname = os.path.dirname(version_file)
if not os.path.isdir(dirname):
- os.makedirs(dirname, 0700)
+ os.makedirs(dirname, 0o700)
with open(version_file, 'w+') as f:
f.write(version)
diff --git a/chromium/build/config/mac/sdk_info.py b/chromium/build/config/mac/sdk_info.py
index 805097a2339..1ad11d3b195 100644
--- a/chromium/build/config/mac/sdk_info.py
+++ b/chromium/build/config/mac/sdk_info.py
@@ -69,8 +69,8 @@ def FillXcodeVersion(settings, developer_dir):
def FillMachineOSBuild(settings):
"""Fills OS build number into |settings|."""
- machine_os_build = subprocess.check_output(['sw_vers',
- '-buildVersion']).strip()
+ machine_os_build = subprocess.check_output(['sw_vers', '-buildVersion'],
+ universal_newlines=True).strip()
settings['machine_os_build'] = machine_os_build
# The reported build number is made up from the kernel major version number,
diff --git a/chromium/build/config/win/BUILD.gn b/chromium/build/config/win/BUILD.gn
index 7b44f0e4372..c0758b654af 100644
--- a/chromium/build/config/win/BUILD.gn
+++ b/chromium/build/config/win/BUILD.gn
@@ -82,6 +82,10 @@ config("compiler") {
# Don't look for includes in %INCLUDE%.
cflags += [ "/X" ]
+ # Required to make the 19041 SDK compatible with clang-cl.
+ # See https://crbug.com/1089996 issue #2 for details.
+ cflags += [ "/D__WRL_ENABLE_FUNCTION_STATICS__" ]
+
# Tell clang which version of MSVC to emulate.
cflags += [ "-fmsc-version=1916" ]
@@ -121,9 +125,6 @@ config("compiler") {
if (use_clang_diagnostics_format) {
cflags += [ "/clang:-fdiagnostics-format=clang" ]
}
-
- # Clang runtime libraries, such as the sanitizer runtimes, live here.
- lib_dirs = [ "$clang_base_path/lib/clang/$clang_version/lib/windows" ]
}
if (use_lld && !use_thin_lto && (is_clang || !use_goma)) {
diff --git a/chromium/build/config/win/manifest.gni b/chromium/build/config/win/manifest.gni
index b18a4a14129..e2115083fe5 100644
--- a/chromium/build/config/win/manifest.gni
+++ b/chromium/build/config/win/manifest.gni
@@ -41,6 +41,12 @@ as_invoker_manifest = "//build/win/as_invoker.manifest"
# elevate.
require_administrator_manifest = "//build/win/require_administrator.manifest"
+# Request the segment heap. See https://crbug.com/1014701 for details.
+declare_args() {
+ enable_segment_heap = false
+}
+segment_heap_manifest = "//build/win/segment_heap.manifest"
+
# Construct a target to combine the given manifest files into a .rc file.
#
# Variables for the windows_manifest template: