Skip to content
Permalink
Browse files

[AW] Simplify and better document //aw/BUILD.gn.

This CL adds documentation to //aw/BUILD.gn to make it clearer what
our apks and libraries are for, removes some redundant dependencies,
and moves WebView code into a few top-level targets:

All Java code is in //aw:android_webview_step1_java. This will be
renamed, see the comment in the build file.
All native code is in:
 * //aw/lib - native code for embedded usecase
 * //aw/lib:webview_entry_point - entrypoint for non-monochrome
 * //aw/nonembedded - nonembedded native code

APKs and libraries can then include what they need of just these 4
targets, rather than having to include a large list of smaller
dependencies, which is more error prone and harder to reason about.

Test: ninja -C out/aw
Test: manually verify devui and license activity on all 3 build types
Bug: 934152
Change-Id: Id6125af057116341e0a9f05ee8186842845a2964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1922688
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Reviewed-by: Nate Fischer <ntfschr@chromium.org>
Reviewed-by: Richard Coles <torne@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722184}
  • Loading branch information
robbiemc authored and Commit Bot committed Dec 5, 2019
1 parent a688a12 commit 0b2663c8cfe100b1dc10a0e257eae7999e9b5797
@@ -365,7 +365,7 @@ group("gn_all") {

if (!is_chromecast) {
deps += [
"//android_webview",
"//android_webview:empty_group",
"//android_webview/test",
"//android_webview/tools/automated_ui_tests:webview_ui_test_app",
"//android_webview/tools/system_webview_shell",
@@ -24,6 +24,7 @@ if (enable_resource_whitelist_generation) {
}

if (public_android_sdk) {
# Standalone WebView APK.
system_webview_apk_tmpl("system_webview_apk") {
android_manifest = system_webview_android_manifest
android_manifest_dep =
@@ -40,6 +41,7 @@ if (public_android_sdk) {
]
}

# Trichrome WebView APK.
system_webview_apk_tmpl("trichrome_webview_apk") {
android_manifest = trichrome_webview_android_manifest
android_manifest_dep =
@@ -61,6 +63,7 @@ if (public_android_sdk) {
}
}

# Trichrome WebView APK for a 64-bit Chrome.
if (android_64bit_target_cpu) {
system_webview_apk_tmpl("trichrome_webview_64_32_apk") {
android_manifest = trichrome_webview_64_32_android_manifest
@@ -82,21 +85,34 @@ if (public_android_sdk) {
}
}

# The shared library used by standalone WebView.
shared_library("libwebviewchromium") {
deps = [
"//android_webview/lib",
"//android_webview/lib:webview_entry_point",
"//android_webview/nonembedded",
]
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
configs += [ "//build/config/android:hide_all_but_jni" ]
}

template("webview_library") {
# This template is used to define WebView's alternate-ABI libraries, which are
# used by Monochrome and Trichrome on 64-bit devices which support both 32 and
# 64-bit ABIs. WebView's browser process must use the same ABI as the embedding
# app (renderer processes used the ABI defined in the WebView APK manifest),
# which requires us to have two copies of the library available, one for each
# ABI. The primary library is the one shared with Chrome, and the alternate is
# a WebView-specific library defined here for whichever ABI isn't used by
# Chrome.
#
# Note that this library only includes code needed for the embedded usecase,
# as all non-embedded code uses the primary library.
template("webview_alternate_library") {
chrome_common_shared_library(target_name) {
forward_variables_from(invoker, "*")
deps = [
"//android_webview/lib",
"//android_webview/lib:webview_entry_point",
"//android_webview/nonembedded",
]
is_webview = true
}
@@ -110,31 +126,47 @@ if (defined(android_secondary_abi_toolchain)) {
# This target is the 32-bit WebView library that pairs with a 64-bit
# browser. It is suffixed with _64 because its name must match the 64-bit
# browser library.
webview_library("monochrome_64") {
webview_alternate_library("monochrome_64") {
}
} else {
# Inverse of above, for the original 32-bit case.
webview_library("monochrome") {
webview_alternate_library("monochrome") {
}
}
} else {
# 32-bit WebView library used in 32-bit only builds of 64/32 targets.
webview_library("monochrome_64") {
webview_alternate_library("monochrome_64") {
}
}

group("android_webview") {
if (public_android_sdk) {
deps = [
":system_webview_apk",
# Contains all Java dependencies used by WebView.
# TODO(crbug.com/934152): Rename this to android_webview_java. It has a
# temporary name because GN doesn't allow the direction
# of existing dependencies to be reversed.
java_group("android_webview_step1_java") {
deps = [
":browser_java",

# This includes AwResource, which may be called via JNI. We're including it
# here because there's currently no good way to enforce that it gets included
# when it's depended on via JNI.
":common_java",
"//android_webview/glue",
"//android_webview/nonembedded:nonembedded_java",
"//android_webview/support_library:support_lib_glue_java",
]

if (webview_includes_weblayer) {
deps += [
"//components/viz/service:service_java",
"//weblayer/browser/java",
]
}
}

java_group("android_webview_java") {
deps = [
":browser_java",
]
# An empty group included in //BUILD.gn to make this and other WebView build
# files reachable by GN.
group("empty_group") {
}

generate_jni("common_jni_headers") {
@@ -194,13 +226,6 @@ generate_jar_jni("cancellation_signal_android_jar_jni_headers") {
classes = [ "android/os/CancellationSignal.class" ]
}

# TODO(crbug.com/934152): Delete this once Clank uses the new manifest location.
group("system_webview_manifest") {
deps = [
"//android_webview/nonembedded:system_webview_manifest",
]
}

android_library("browser_java") {
java_files = [
"java/src/org/chromium/android_webview/AndroidProtocolHandler.java",
@@ -296,10 +321,6 @@ android_library("browser_java") {
":common_aidl_java",
":common_commandline_java",
":common_crash_java",

# This includes AwResource, which may be called via JNI. We're including it
# here because there's currently no good way to enforce that it gets included
# when it's depended on via JNI.
":common_java",
":common_platform_services_java",
":common_variations_utils_java",
@@ -338,13 +359,6 @@ android_library("browser_java") {
deps += [ "//components/spellcheck/browser/android:java" ]
}

if (webview_includes_weblayer) {
deps += [
"//components/viz/service:service_java",
"//weblayer/browser/java",
]
}

srcjar_deps = [
"//android_webview/browser:browser_enums",
"//components/safe_browsing/db:sb_threat_values",
@@ -9,8 +9,8 @@ import("//build/config/android/rules.gni")

android_library("glue") {
deps = [
"//android_webview:android_webview_java",
"//android_webview:android_webview_product_config_java",
"//android_webview:browser_java",
"//android_webview:common_commandline_java",
"//android_webview:common_java",
"//android_webview/nonembedded:system_webview_manifest",
@@ -29,7 +29,7 @@ android_library("support_lib_glue_java") {
]

deps = [
"//android_webview:android_webview_java",
"//android_webview:browser_java",
"//android_webview/glue:glue",
"//android_webview/support_library/boundary_interfaces:boundary_interface_java",
"//android_webview/support_library/callback:callback_java",
@@ -13,7 +13,7 @@ android_library("callback_java") {
]

deps = [
"//android_webview:android_webview_java",
"//android_webview:browser_java",
"//android_webview/support_library/boundary_interfaces:boundary_interface_java",
"//base:base_java",
]
@@ -31,12 +31,9 @@ template("system_webview_apk_tmpl") {
])

deps += [
"//android_webview:android_webview_step1_java",
"//android_webview:locale_pak_assets",
"//android_webview:pak_file_assets",
"//android_webview/glue",
"//android_webview/nonembedded:nonembedded_java",
"//android_webview/support_library:support_lib_glue_java",
"//base:base_java",
]

target_sdk_version = android_sdk_version
@@ -60,12 +60,11 @@ android_apk("webview_instrumentation_apk") {
":webview_instrumentation_apk_assets",
":webview_instrumentation_apk_resources",
":webview_instrumentation_test_utils_java",
"//android_webview:android_webview_java",
"//android_webview:android_webview_product_config_java",
"//android_webview:android_webview_step1_java",
"//android_webview:common_java",
"//android_webview:locale_pak_assets",
"//android_webview:platform_service_bridge_upstream_implementation_java",
"//android_webview/nonembedded:nonembedded_java",
"//base:base_java",
"//base:base_java_test_support",
"//components/heap_profiling:heap_profiling_java_test_support",
@@ -151,10 +150,11 @@ shared_library("libstandalonelibwebviewchromium") {
ldflags = [ "-Wl,-shared,-Bsymbolic" ]
deps = [
":webview_instrumentation_test_native_jni_impl",
"//android_webview/lib",
"//android_webview/lib:webview_entry_point",
"//android_webview/nonembedded",
"//base",
"//components/heap_profiling:test_support",
"//components/minidump_uploader",
"//content/public/test/android:content_native_test_support",
]
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
@@ -168,7 +168,7 @@ instrumentation_test_apk("webview_instrumentation_test_apk") {
min_sdk_version = 21
deps = [
":webview_instrumentation_test_utils_java",
"//android_webview:android_webview_java",
"//android_webview:android_webview_step1_java",
"//android_webview/test/embedded_test_server:aw_net_java_test_support",
"//base:base_java",
"//base:base_java_test_support",
@@ -428,7 +428,7 @@ android_assets("android_webview_unittests_assets") {
android_library("android_webview_unittests_java") {
testonly = true
deps = [
"//android_webview:android_webview_java",
"//android_webview:android_webview_step1_java",
"//base:base_java",
"//content/public/test/android:content_java_test_support",
]
@@ -457,8 +457,7 @@ junit_binary("android_webview_junit_tests") {
]

deps = [
"//android_webview:android_webview_java",
"//android_webview/nonembedded:services_java",
"//android_webview:android_webview_step1_java",
"//base:base_java_test_support",
"//content/public/test/android:content_java_test_support",
"//third_party/android_support_test_runner:runner_java",
@@ -1435,7 +1435,7 @@ template("libmonochrome_apk_or_bundle_tmpl") {
]
deps = [
"//android_webview/lib",
"//components/about_ui:about_ui_android",
"//android_webview/nonembedded",
"//components/crash/android:crashpad_main",
]

@@ -1658,9 +1658,7 @@ chrome_public_apk_or_module_tmpl("chrome_modern_public_base_bundle_module") {

android_library("monochrome_java") {
deps = [
"//android_webview/glue",
"//android_webview/nonembedded:nonembedded_java",
"//android_webview/support_library:support_lib_glue_java",
"//android_webview:android_webview_step1_java",
"//base:base_java",
"//chrome/android:chrome_java",
"//content/public/android:content_java",

0 comments on commit 0b2663c

Please sign in to comment.
You can’t perform that action at this time.