blob: 70f9accb3e10617523ab54952768174a7f20764b [file] [log] [blame]
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/android/resource_sizes.gni")
import("//build/buildflag_header.gni")
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
import("//build/config/zip.gni")
import("//build/util/lastchange.gni")
import("//build/util/process_version.gni")
import("//build/util/version.gni")
import("//components/cronet/native/include/headers.gni")
import("//components/grpc_support/include/headers.gni")
import("//testing/test.gni")
import("//third_party/netty4/netty4.gni")
import("//third_party/protobuf/proto_library.gni")
import("//tools/binary_size/sizes.gni")
import("//url/features.gni")
_jni_registration_header = "$target_gen_dir/cronet_jni_registration.h"
_templates_dir = "$target_gen_dir/templates"
declare_args() {
# In integrated mode, CronetEngine will use the shared network task runner by
# other Chromium-based clients like webview without self-initialization.
# Besides, the native library would be compiled and loaded together with the
# native library of host. This mode is only for Android.
integrated_mode = false
}
buildflag_header("buildflags") {
header = "buildflags.h"
flags = [ "INTEGRATED_MODE=$integrated_mode" ]
}
generate_jni("cronet_jni_headers") {
sources = [
"java/src/org/chromium/net/impl/CronetBidirectionalStream.java",
"java/src/org/chromium/net/impl/CronetLibraryLoader.java",
"java/src/org/chromium/net/impl/CronetUploadDataStream.java",
"java/src/org/chromium/net/impl/CronetUrlRequest.java",
"java/src/org/chromium/net/impl/CronetUrlRequestContext.java",
]
}
generate_jni_registration("cronet_jni_registration") {
targets = [ ":cronet_impl_native_base_java" ]
header_output = _jni_registration_header
sources_exclusions = [
"//base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java",
"//base/android/java/src/org/chromium/base/library_loader/LibraryPrefetcher.java",
"//base/android/java/src/org/chromium/base/process_launcher/ChildProcessService.java",
"//base/android/java/src/org/chromium/base/SysUtils.java",
]
}
android_library("cronet_jni_registration_java") {
srcjar_deps = [ ":cronet_jni_registration" ]
}
java_cpp_enum("rtt_throughput_values_java") {
sources = [ "//net/nqe/network_quality.h" ]
}
java_cpp_enum("net_request_priority_java") {
sources = [ "//net/base/request_priority.h" ]
}
java_cpp_enum("net_idempotency_java") {
sources = [ "//net/base/idempotency.h" ]
}
java_cpp_enum("network_quality_observation_source_java") {
sources = [ "//net/nqe/network_quality_observation_source.h" ]
}
java_cpp_enum("url_request_error_java") {
sources = [ "url_request_error.h" ]
}
java_cpp_enum("http_cache_type_java") {
sources = [ "//components/cronet/url_request_context_config.h" ]
}
java_cpp_template("load_states_list") {
sources = [ "java/src/org/chromium/net/impl/LoadState.template" ]
inputs = [ "//net/base/load_states_list.h" ]
}
java_cpp_template("integrated_mode_state") {
sources = [ "java/src/org/chromium/net/impl/IntegratedModeState.template" ]
if (integrated_mode) {
defines = [ "INTEGRATED_MODE" ]
}
}
_generated_interface_api_version_java =
"$_templates_dir/org/chromium/net/ApiVersion.java"
_interface_api_level = read_file("interface_api_version.txt", "value")
process_version("interface_api_version") {
process_only = true
template_file = "api/src/org/chromium/net/ApiVersion.template"
sources = [
"//chrome/VERSION",
lastchange_file,
]
extra_args = [
"-e",
"API_LEVEL=$_interface_api_level",
]
output = _generated_interface_api_version_java
}
_generated_implementation_api_version_java =
"$_templates_dir/org/chromium/net/impl/ImplVersion.java"
_implementation_api_level = read_file("implementation_api_version.txt", "value")
process_version("implementation_api_version") {
process_only = true
template_file = "java/src/org/chromium/net/impl/ImplVersion.template"
sources = [
"//chrome/VERSION",
lastchange_file,
]
extra_args = [
"-e",
"API_LEVEL=$_implementation_api_level",
]
output = _generated_implementation_api_version_java
}
_cronet_version_header_include_dir = "$target_gen_dir/cronet_version_header"
source_set("cronet_static") {
deps = [
":buildflags",
":cronet_jni_headers",
":cronet_jni_registration",
"//base",
"//base/third_party/dynamic_annotations",
"//components/cronet:cronet_common",
"//components/cronet:cronet_version_header",
"//components/cronet:metrics_util",
"//components/cronet/native:cronet_native_impl",
"//components/metrics",
"//components/prefs",
"//net",
"//third_party/zlib:zlib",
"//url",
"//url:buildflags",
]
sources = [
"//components/cronet/android/cronet_bidirectional_stream_adapter.cc",
"//components/cronet/android/cronet_bidirectional_stream_adapter.h",
"//components/cronet/android/cronet_context_adapter.cc",
"//components/cronet/android/cronet_context_adapter.h",
"//components/cronet/android/cronet_library_loader.cc",
"//components/cronet/android/cronet_upload_data_stream_adapter.cc",
"//components/cronet/android/cronet_upload_data_stream_adapter.h",
"//components/cronet/android/cronet_url_request_adapter.cc",
"//components/cronet/android/cronet_url_request_adapter.h",
"//components/cronet/android/io_buffer_with_byte_buffer.cc",
"//components/cronet/android/io_buffer_with_byte_buffer.h",
"//components/cronet/android/url_request_error.cc",
"//components/cronet/android/url_request_error.h",
_jni_registration_header,
]
if (integrated_mode) {
sources += [
"//components/cronet/android/cronet_integrated_mode_state.cc",
"//components/cronet/android/cronet_integrated_mode_state.h",
]
} else {
sources += [ "//components/cronet/android/cronet_library_loader.h" ]
}
include_dirs = [ _cronet_version_header_include_dir ]
cflags = [
"-DLOGGING=1",
"-Wno-sign-promo",
]
libs = [
"android",
"log",
]
if (!use_platform_icu_alternatives) {
deps += [ "//base:i18n" ]
}
}
config("hide_all_but_jni_onload_and_cronet") {
ldflags = [ "-Wl,--version-script=" +
rebase_path("android_only_jni_onload_and_cronet_exports.lst",
root_out_dir) ]
}
_cronet_shared_lib_name = "cronet.$chrome_version_full"
shared_library("cronet") {
output_name = _cronet_shared_lib_name
sources = [ "cronet_jni.cc" ]
deps = [
":cronet_static",
"//base",
"//net:net",
]
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
configs += [ ":hide_all_but_jni_onload_and_cronet" ]
}
sizes_test("cronet_sizes") {
data_deps = [ ":cronet" ]
data = [ "${root_out_dir}/lib${_cronet_shared_lib_name}.so" ]
executable_args = [
"--platform",
"android-cronet",
]
}
# cronet_api_java.jar defines Cronet API.
android_library("cronet_api_java") {
sources = [
"api/src/org/chromium/net/BidirectionalStream.java",
"api/src/org/chromium/net/CallbackException.java",
"api/src/org/chromium/net/CronetEngine.java",
"api/src/org/chromium/net/CronetException.java",
"api/src/org/chromium/net/CronetProvider.java",
"api/src/org/chromium/net/ExperimentalBidirectionalStream.java",
"api/src/org/chromium/net/ExperimentalCronetEngine.java",
"api/src/org/chromium/net/ExperimentalUrlRequest.java",
"api/src/org/chromium/net/ICronetEngineBuilder.java",
"api/src/org/chromium/net/InlineExecutionProhibitedException.java",
"api/src/org/chromium/net/NetworkException.java",
"api/src/org/chromium/net/NetworkQualityRttListener.java",
"api/src/org/chromium/net/NetworkQualityThroughputListener.java",
"api/src/org/chromium/net/QuicException.java",
"api/src/org/chromium/net/RequestFinishedInfo.java",
"api/src/org/chromium/net/UploadDataProvider.java",
"api/src/org/chromium/net/UploadDataProviders.java",
"api/src/org/chromium/net/UploadDataSink.java",
"api/src/org/chromium/net/UrlRequest.java",
"api/src/org/chromium/net/UrlResponseInfo.java",
_generated_interface_api_version_java,
]
deps = [
":interface_api_version",
"//third_party/androidx:androidx_annotation_annotation_java",
]
}
cronet_impl_common_java_srcjar_deps = [
":http_cache_type_java",
":integrated_mode_state",
":load_states_list",
":rtt_throughput_values_java",
"//net:effective_connection_type_java",
]
cronet_impl_common_java_deps_to_package =
[ "//net/android:net_thread_stats_uid_java" ]
# cronet_impl_common_base_java.jar - common Cronet code that is shared
# by all Cronet engine implementations.
android_library("cronet_impl_common_base_java") {
sources = [
"java/src/org/chromium/net/impl/CallbackExceptionImpl.java",
"java/src/org/chromium/net/impl/CronetEngineBase.java",
"java/src/org/chromium/net/impl/CronetEngineBuilderImpl.java",
"java/src/org/chromium/net/impl/CronetExceptionImpl.java",
"java/src/org/chromium/net/impl/CronetLogger.java",
"java/src/org/chromium/net/impl/CronetLoggerFactory.java",
"java/src/org/chromium/net/impl/NetworkExceptionImpl.java",
"java/src/org/chromium/net/impl/NoOpLogger.java",
"java/src/org/chromium/net/impl/Preconditions.java",
"java/src/org/chromium/net/impl/QuicExceptionImpl.java",
"java/src/org/chromium/net/impl/RequestFinishedInfoImpl.java",
"java/src/org/chromium/net/impl/UrlRequestBase.java",
"java/src/org/chromium/net/impl/UrlRequestBuilderImpl.java",
"java/src/org/chromium/net/impl/UrlResponseInfoImpl.java",
"java/src/org/chromium/net/impl/UserAgent.java",
"java/src/org/chromium/net/impl/VersionSafeCallbacks.java",
_generated_implementation_api_version_java,
]
# Adding deps here won't include those deps in the cronet_impl_common_java.jar.
# Please add to cronet_impl_common_java_deps_to_package instead.
deps = [
":cronet_api_java",
":implementation_api_version",
"//third_party/androidx:androidx_annotation_annotation_java",
]
deps += cronet_impl_common_java_deps_to_package
srcjar_deps = cronet_impl_common_java_srcjar_deps
}
# cronet_impl_java_util_java.jar - Classes shared between Java Cronet implementations.
android_library("cronet_impl_java_util_java") {
sources = [
"java/src/org/chromium/net/impl/JavaUploadDataSinkBase.java",
"java/src/org/chromium/net/impl/JavaUrlRequestUtils.java",
]
deps = [
":cronet_api_java",
"//third_party/androidx:androidx_annotation_annotation_java",
]
}
# cronet_impl_platform_base_java.jar - Java platform based implementation of the Cronet engine.
android_library("cronet_impl_platform_base_java") {
sources = [
"java/src/org/chromium/net/impl/InputStreamChannel.java",
"java/src/org/chromium/net/impl/JavaCronetEngine.java",
"java/src/org/chromium/net/impl/JavaCronetEngineBuilderImpl.java",
"java/src/org/chromium/net/impl/JavaCronetProvider.java",
"java/src/org/chromium/net/impl/JavaUrlRequest.java",
]
deps = [
":cronet_api_java",
":cronet_impl_common_base_java",
":cronet_impl_java_util_java",
"//net/android:net_thread_stats_uid_java",
"//third_party/android_deps:com_google_code_findbugs_jsr305_java",
"//third_party/androidx:androidx_annotation_annotation_java",
]
}
# cronet_impl_fake_base_java.jar - Fake implementation of Cronet.
android_library("cronet_impl_fake_base_java") {
sources = [
"fake/java/org/chromium/net/test/FakeCronetController.java",
"fake/java/org/chromium/net/test/FakeCronetEngine.java",
"fake/java/org/chromium/net/test/FakeCronetProvider.java",
"fake/java/org/chromium/net/test/FakeUrlRequest.java",
"fake/java/org/chromium/net/test/FakeUrlResponse.java",
"fake/java/org/chromium/net/test/ResponseMatcher.java",
"fake/java/org/chromium/net/test/UrlResponseMatcher.java",
]
deps = [
":cronet_api_java",
":cronet_impl_common_base_java",
":cronet_impl_java_util_java",
"//third_party/androidx:androidx_annotation_annotation_java",
]
}
cronet_impl_native_java_srcjar_deps = [
":net_idempotency_java",
":net_request_priority_java",
":network_quality_observation_source_java",
":url_request_error_java",
]
cronet_impl_native_java_deps_to_package = [
":cronet_urlconnection_impl_java",
"//base:base_java",
"//base:jni_java",
"//build/android:build_java",
"//net/android:net_java",
"//url:url_java",
]
android_library("cronet_urlconnection_impl_java") {
sources = [
"java/src/org/chromium/net/urlconnection/CronetBufferedOutputStream.java",
"java/src/org/chromium/net/urlconnection/CronetChunkedOutputStream.java",
"java/src/org/chromium/net/urlconnection/CronetFixedModeOutputStream.java",
"java/src/org/chromium/net/urlconnection/CronetHttpURLConnection.java",
"java/src/org/chromium/net/urlconnection/CronetHttpURLStreamHandler.java",
"java/src/org/chromium/net/urlconnection/CronetInputStream.java",
"java/src/org/chromium/net/urlconnection/CronetOutputStream.java",
"java/src/org/chromium/net/urlconnection/CronetURLStreamHandlerFactory.java",
"java/src/org/chromium/net/urlconnection/MessageLoop.java",
]
deps = [
":cronet_api_java",
"//third_party/androidx:androidx_annotation_annotation_java",
]
}
# cronet_impl_native_base_java.jar - native implementation of the Cronet engine.
android_library("cronet_impl_native_base_java") {
sources = [
"java/src/org/chromium/net/impl/BidirectionalStreamBuilderImpl.java",
"java/src/org/chromium/net/impl/BidirectionalStreamNetworkException.java",
"java/src/org/chromium/net/impl/CronetBidirectionalStream.java",
"java/src/org/chromium/net/impl/CronetLibraryLoader.java",
"java/src/org/chromium/net/impl/CronetMetrics.java",
"java/src/org/chromium/net/impl/CronetUploadDataStream.java",
"java/src/org/chromium/net/impl/CronetUrlRequest.java",
"java/src/org/chromium/net/impl/CronetUrlRequestContext.java",
"java/src/org/chromium/net/impl/NativeCronetEngineBuilderImpl.java",
"java/src/org/chromium/net/impl/NativeCronetEngineBuilderWithLibraryLoaderImpl.java",
"java/src/org/chromium/net/impl/NativeCronetProvider.java",
]
# Adding deps here won't include those deps in the cronet_impl_native_java.jar.
# Please add to cronet_impl_native_java_deps_to_package instead.
deps = [
":cronet_api_java",
":cronet_impl_common_base_java",
"//base:jni_java",
"//build/android:build_java",
"//third_party/android_deps:com_google_code_findbugs_jsr305_java",
"//third_party/androidx:androidx_annotation_annotation_java",
]
deps += cronet_impl_native_java_deps_to_package
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
srcjar_deps = cronet_impl_native_java_srcjar_deps
}
# Groups all Cronet implementations and the common code into a single Java dependency.
java_group("cronet_impl_all_java") {
deps = [
":cronet_impl_common_base_java",
":cronet_impl_native_base_java",
":cronet_impl_platform_base_java",
]
}
android_resources("cronet_sample_apk_resources") {
sources = [
"sample/res/layout/activity_main.xml",
"sample/res/layout/dialog_url.xml",
"sample/res/values/dimens.xml",
"sample/res/values/strings.xml",
]
android_manifest = "sample/AndroidManifest.xml"
deps = [
"//third_party/androidx:androidx_appcompat_appcompat_java",
"//third_party/androidx:androidx_appcompat_appcompat_resources_java",
"//third_party/androidx:androidx_drawerlayout_drawerlayout_java",
"//third_party/androidx:androidx_fragment_fragment_java",
"//third_party/androidx:androidx_interpolator_interpolator_java",
"//third_party/androidx:androidx_lifecycle_lifecycle_common_java",
"//third_party/androidx:androidx_vectordrawable_vectordrawable_animated_java",
"//third_party/androidx:androidx_vectordrawable_vectordrawable_java",
]
}
android_library("cronet_sample_apk_java") {
sources = [
"sample/src/org/chromium/cronet_sample_apk/CronetSampleActivity.java",
"sample/src/org/chromium/cronet_sample_apk/CronetSampleApplication.java",
]
resources_package = "org.chromium.cronet_sample_apk"
deps = [
":cronet_sample_apk_resources",
":package_api_java",
":package_impl_native_java",
"//third_party/androidx:androidx_annotation_annotation_java",
"//third_party/androidx:androidx_appcompat_appcompat_java",
"//third_party/androidx:androidx_lifecycle_lifecycle_viewmodel_java",
]
}
android_apk("cronet_sample_apk") {
apk_name = "CronetSample"
android_manifest = "sample/AndroidManifest.xml"
shared_libraries = [ ":cronet" ]
deps = [
":cronet_combine_proguard_flags",
":cronet_sample_apk_java",
":cronet_sample_apk_resources",
]
# Cronet jars will include this, so don't duplicate.
generate_buildconfig_java = false
enable_multidex = false
if (!is_java_debug) {
proguard_enabled = true
proguard_configs = [
"$target_gen_dir/cronet_impl_native_proguard.cfg",
"cronet_impl_common_proguard.cfg",
"//base/android/proguard/chromium_apk.flags",
]
}
}
android_resource_sizes_test("resource_sizes_cronet_sample_apk") {
apk_name = "CronetSample"
data_deps = [ ":cronet_sample_apk" ]
}
action("cronet_combine_proguard_flags") {
script = "//components/cronet/tools/generate_proguard_file.py"
sources = [
"//base/android/proguard/chromium_code.flags",
# Massage the proguard to avoid incompatibilities when building internally.
"//components/cronet/android/cronet_impl_native_proguard.cfg",
]
outputs = [ "$target_gen_dir/cronet_impl_native_proguard.cfg" ]
args = [ "--output-file" ] + rebase_path(outputs, root_build_dir) +
rebase_path(sources, root_build_dir)
}
_package_dir = "$root_out_dir/cronet"
# These package_* targets represent how Cronet is used in production code.
# Using these targets is preferred to using the underlying targets like
# :cronet_api_java or :cronet_impl_all_java, as it better tests production
# usage.
android_java_prebuilt("package_api_java") {
jar_path = "$_package_dir/cronet_api.jar"
deps = [ ":repackage_api" ]
}
android_java_prebuilt("package_impl_common_java") {
jar_path = "$_package_dir/cronet_impl_common_java.jar"
deps = [
":package_api_java",
":repackage_common",
]
}
java_prebuilt("package_impl_native_java") {
# This target is a java_prebuilt instead of a android_java_prebuilt so we
# don't filter out GEN_JNI which is part of jar_excluded_patterns in
# android_java_prebuilt.
jar_path = "$_package_dir/cronet_impl_native_java.jar"
supports_android = true
requires_android = true
deps = [
":package_api_java",
":package_impl_common_java",
":repackage_native",
"//third_party/android_deps:com_google_code_findbugs_jsr305_java",
"//third_party/androidx:androidx_drawerlayout_drawerlayout_java",
"//third_party/androidx:androidx_interpolator_interpolator_java",
]
jar_excluded_patterns = [ "androidx/*/R*" ]
}
android_java_prebuilt("package_impl_util_java") {
jar_path = "$_package_dir/cronet_impl_util_java.jar"
deps = [
":package_api_java",
":repackage_util",
]
}
android_java_prebuilt("package_impl_platform_java") {
jar_path = "$_package_dir/cronet_impl_platform_java.jar"
deps = [
":package_api_java",
":package_impl_common_java",
":repackage_platform",
]
}
android_java_prebuilt("package_impl_fake_java") {
jar_path = "$_package_dir/cronet_impl_fake_java.jar"
deps = [
":package_api_java",
":package_impl_common_java",
":repackage_fake",
]
}
template("jar_src") {
action_with_pydeps(target_name) {
_rebased_src_search_dirs =
rebase_path(invoker.src_search_dirs, root_build_dir)
script = "//components/cronet/tools/jar_src.py"
depfile = "$target_gen_dir/$target_name.d"
outputs = [ invoker.jar_path ]
args = [
"--src-search-dirs=${_rebased_src_search_dirs}",
"--jar-path",
rebase_path(invoker.jar_path, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
]
deps = []
if (defined(invoker.deps)) {
deps += invoker.deps
}
_excluded_patterns = []
if (defined(invoker.excluded_patterns)) {
_excluded_patterns = invoker.excluded_patterns
}
_src_jars = []
# Add src-jar files that are listed in "src_jars".
if (defined(invoker.src_jars)) {
_rebased_src_jars = rebase_path(invoker.src_jars, root_build_dir)
_src_jars += _rebased_src_jars
}
# Add src-jar files that are generated by dependencies in "srcjar_deps".
if (defined(invoker.srcjar_deps)) {
foreach(_srcjar_dep, invoker.srcjar_deps) {
_dep_gen_dir = get_label_info(_srcjar_dep, "target_gen_dir")
_dep_name = get_label_info(_srcjar_dep, "name")
_src_jars += rebase_path([ "$_dep_gen_dir/$_dep_name.srcjar" ])
deps += [ _srcjar_dep ]
}
}
# Create the list of all source files that are given in "src_files".
_src_files = []
if (defined(invoker.src_files)) {
_src_files += invoker.src_files
}
# Handle "source_deps".
_src_list_files = []
if (defined(invoker.source_deps)) {
foreach(_source_dep, invoker.source_deps) {
_dep_gen_dir = get_label_info(_source_dep, "target_gen_dir")
_dep_name = get_label_info(_source_dep, "name")
_src_list_files += rebase_path([ "$_dep_gen_dir/$_dep_name.sources" ])
deps += [ _source_dep ]
}
}
args += [ "--src-jar=${_src_jars}" ]
args += [ "--src-files=${_src_files}" ]
args += [ "--src-list-files=${_src_list_files}" ]
args += [ "--excluded-classes=$_excluded_patterns" ]
inputs = _src_jars
inputs += _src_files
inputs += _src_list_files
}
}
jar_src("jar_cronet_api_source") {
src_search_dirs = [
"api/src",
_templates_dir,
]
source_deps = [ ":cronet_api_java" ]
jar_path = "$_package_dir/cronet_api-src.jar"
}
jar_src("jar_cronet_impl_common_java_source") {
src_search_dirs = [
"java/src",
_templates_dir,
]
source_deps = [ ":cronet_impl_common_base_java" ]
srcjar_deps = cronet_impl_common_java_srcjar_deps
jar_path = "$_package_dir/cronet_impl_common_java-src.jar"
}
jar_src("jar_cronet_impl_platform_java_source") {
src_search_dirs = [ "java/src" ]
source_deps = [ ":cronet_impl_platform_base_java" ]
jar_path = "$_package_dir/cronet_impl_platform_java-src.jar"
}
jar_src("jar_cronet_impl_fake_java_source") {
src_search_dirs = [ "fake/java" ]
source_deps = [ ":cronet_impl_fake_base_java" ]
jar_path = "$_package_dir/cronet_impl_fake_java-src.jar"
}
jar_src("jar_cronet_impl_util_java_source") {
src_search_dirs = [ "java/src" ]
source_deps = [ ":cronet_impl_java_util_java" ]
jar_path = "$_package_dir/cronet_impl_util_java-src.jar"
}
# List of patterns of .class files to exclude from the jar.
_jar_excluded_patterns = [
# Excludes Android support libraries crbug.com/832770.
"android/*",
"androidx/*",
"*/library_loader/*.class",
"*/multidex/*.class",
"*/process_launcher/*.class",
"*/SysUtils*.class",
"org/chromium/base/Feature*.class",
"org/chromium/base/jank_tracker/*.class",
"org/chromium/base/memory/MemoryPressureMonitor*.class",
]
# Excluded from repackage_jars, but not from jar_src().
_build_jar_excluded_patterns = [ "org/chromium/build/NativeLibraries.class" ]
template("repackage_jars") {
dist_jar(target_name) {
requires_android = true
direct_deps_only = true
use_unprocessed_jars = true
no_build_hooks = true
forward_variables_from(invoker, "*")
}
}
repackage_jars("repackage_api") {
output = "$_package_dir/cronet_api.jar"
deps = [ ":cronet_api_java" ]
}
repackage_jars("repackage_platform") {
output = "$_package_dir/cronet_impl_platform_java.jar"
deps = [ ":cronet_impl_platform_base_java" ]
}
repackage_jars("repackage_fake") {
output = "$_package_dir/cronet_impl_fake_java.jar"
deps = [ ":cronet_impl_fake_base_java" ]
}
repackage_jars("repackage_util") {
output = "$_package_dir/cronet_impl_util_java.jar"
deps = [ ":cronet_impl_java_util_java" ]
}
# See crbug.com/1005836 for more info on why repackage_native requires 2 extra
# targets. These 3 targets exist to ensure the correct version of GEN_JNI
# (a generated class containing native method definitions) is included.
repackage_jars("repackage_native") {
output = "$_package_dir/cronet_impl_native_java.jar"
deps = [
":cronet_jni_registration_java",
":repackage_native_java",
]
jar_excluded_patterns = _jar_excluded_patterns + _build_jar_excluded_patterns
}
_native_intermediate_jar_path = "$target_out_dir/repackage_native_impl.jar"
# Do not depend on this target directly. Use :repackage_native.
repackage_jars("repackage_native_impl") {
output = _native_intermediate_jar_path
deps = cronet_impl_native_java_deps_to_package +
[ ":cronet_impl_native_base_java" ]
jar_excluded_patterns = _jar_excluded_patterns + _build_jar_excluded_patterns
}
# Do not depend on this target directly. Use :repackage_native.
# This target exists to provide :repackage_native with a suitable target to
# depend on (since dist_aar only pulls in deps of type "java_library").
android_java_prebuilt("repackage_native_java") {
jar_path = _native_intermediate_jar_path
# Since only the unprocessed jar is used, no need to complete the bytecode
# processing step.
enable_bytecode_checks = false
deps = [ ":repackage_native_impl" ]
}
repackage_jars("repackage_common") {
output = "$_package_dir/cronet_impl_common_java.jar"
deps = cronet_impl_common_java_deps_to_package + [
":cronet_impl_common_base_java",
":cronet_impl_java_util_java",
]
}
if (!is_component_build) {
_cronet_shared_lib_file_name = "lib" + _cronet_shared_lib_name + ".so"
# cronet_sample_test_apk_resources is identical to
# cronet_sample_apk_resources. The two have to be different targets because
# targets which are common between the "instrumentation test apk" and the
# "tested apk" are removed from the "instrumentation test apk".
android_resources("cronet_sample_test_apk_resources") {
sources = [
"sample/res/layout/activity_main.xml",
"sample/res/layout/dialog_url.xml",
"sample/res/values/dimens.xml",
"sample/res/values/strings.xml",
]
android_manifest = "sample/javatests/AndroidManifest.xml"
}
instrumentation_test_apk("cronet_sample_test_apk") {
apk_name = "CronetSampleTest"
apk_under_test = ":cronet_sample_apk"
android_manifest = "sample/javatests/AndroidManifest.xml"
sources = [ "sample/javatests/src/org/chromium/cronet_sample_apk/CronetSampleTest.java" ]
deps = [
":cronet_sample_apk_java",
"//third_party/android_deps:espresso_java",
"//third_party/android_support_test_runner:rules_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/junit",
]
if (!is_java_debug) {
proguard_enabled = true
proguard_configs = [ "sample/javatests/proguard.cfg" ]
}
}
generate_jni("cronet_tests_jni_headers") {
testonly = true
sources = [
"test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java",
"test/javatests/src/org/chromium/net/CronetUrlRequestTest.java",
"test/javatests/src/org/chromium/net/ExperimentalOptionsTest.java",
"test/src/org/chromium/net/CronetTestUtil.java",
"test/src/org/chromium/net/MockCertVerifier.java",
"test/src/org/chromium/net/MockUrlRequestJobFactory.java",
"test/src/org/chromium/net/NativeTestServer.java",
"test/src/org/chromium/net/QuicTestServer.java",
"test/src/org/chromium/net/TestUploadDataStreamHandler.java",
]
}
shared_library("cronet_tests") {
testonly = true
sources = [
# While "cronet_tests" cannot depend on "cronet_static", and hence cannot
# call any Cronet functions, it can access fields of Cronet objects, so add
# Cronet header files to facilitate accessing these fields.
"//components/cronet/android/cronet_context_adapter.h",
"//components/cronet/android/cronet_url_request_adapter.h",
"//components/cronet/cronet_url_request.h",
"//components/cronet/url_request_context_config.h",
"test/cronet_test_jni.cc",
"test/cronet_test_util.cc",
"test/cronet_test_util.h",
"test/cronet_url_request_context_config_test.cc",
"test/cronet_url_request_context_config_test.h",
"test/cronet_url_request_test.cc",
"test/experimental_options_test.cc",
"test/mock_cert_verifier.cc",
"test/mock_url_request_job_factory.cc",
"test/native_test_server.cc",
"test/quic_test_server.cc",
"test/test_upload_data_stream_handler.cc",
"test/test_upload_data_stream_handler.h",
"test/url_request_intercepting_job_factory.cc",
"test/url_request_intercepting_job_factory.h",
]
deps = [
":cronet",
":cronet_tests_jni_headers",
"//base",
"//base:i18n",
"//base/test:test_support",
"//components/cronet:cronet_common",
"//components/cronet:cronet_version_header",
"//components/cronet/testing:test_support",
"//components/prefs",
"//net",
"//net:simple_quic_tools",
"//net:test_support",
"//third_party/icu",
]
include_dirs = [ _cronet_version_header_include_dir ]
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
configs += [ "//build/config/android:hide_all_but_jni" ]
}
android_resources("cronet_test_apk_resources") {
testonly = true
sources = [
"test/res/values/strings.xml",
"test/res/xml/network_security_config.xml",
"test/smoketests/res/native/values/strings.xml",
]
}
android_library("cronet_test_apk_java") {
testonly = true
sources = [
"test/src/org/chromium/net/CronetTestApplication.java",
"test/src/org/chromium/net/CronetTestUtil.java",
"test/src/org/chromium/net/Http2TestHandler.java",
"test/src/org/chromium/net/Http2TestServer.java",
"test/src/org/chromium/net/MockCertVerifier.java",
"test/src/org/chromium/net/MockUrlRequestJobFactory.java",
"test/src/org/chromium/net/NativeTestServer.java",
"test/src/org/chromium/net/QuicTestServer.java",
"test/src/org/chromium/net/ReportingCollector.java",
"test/src/org/chromium/net/TestFilesInstaller.java",
"test/src/org/chromium/net/TestUploadDataStreamHandler.java",
]
deps = [
":cronet_api_java",
":cronet_impl_all_java",
"//base:base_java",
"//base:base_java_test_support",
"//base:jni_java",
"//build/android:build_java",
"//net/android:net_java_test_support",
"//third_party/android_sdk:android_test_base_java",
"//third_party/junit",
"//third_party/netty4:netty_all_java",
]
}
cronet_smoketests_platform_only_common_srcs = [
"test/smoketests/src/org/chromium/net/smoke/ChromiumPlatformOnlyTestSupport.java",
"test/smoketests/src/org/chromium/net/smoke/CronetSmokeTestRule.java",
"test/smoketests/src/org/chromium/net/smoke/HttpTestServer.java",
"test/smoketests/src/org/chromium/net/smoke/SmokeTestRequestCallback.java",
"test/smoketests/src/org/chromium/net/smoke/TestSupport.java",
]
cronet_smoketests_native_common_srcs = cronet_smoketests_platform_only_common_srcs + [
"test/smoketests/src/org/chromium/net/smoke/ChromiumNativeTestSupport.java",
"test/smoketests/src/org/chromium/net/smoke/NativeCronetTestRule.java",
]
# cronet_common_javatests.jar - Cronet Java test common files.
android_library("cronet_common_javatests") {
testonly = true
sources = [
"test/javatests/src/org/chromium/net/CronetLoggerTestRule.java",
"test/javatests/src/org/chromium/net/CronetTestRule.java",
"test/javatests/src/org/chromium/net/TestUploadDataProvider.java",
"test/javatests/src/org/chromium/net/TestUrlRequestCallback.java",
]
deps = [
":cronet_api_java",
":cronet_impl_all_java",
"//base:base_java",
"//base:jni_java",
"//build/android:build_java",
"//third_party/android_sdk:android_test_base_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_annotation_annotation_java",
"//third_party/junit",
]
}
# cronet_fake_javatests.jar - Java tests for the fake implementation of Cronet.
android_library("cronet_fake_javatests") {
testonly = true
sources = [
"fake/javatests/org/chromium/net/test/FakeCronetControllerTest.java",
"fake/javatests/org/chromium/net/test/FakeCronetEngineTest.java",
"fake/javatests/org/chromium/net/test/FakeCronetProviderTest.java",
"fake/javatests/org/chromium/net/test/FakeUrlRequestTest.java",
"fake/javatests/org/chromium/net/test/FakeUrlResponseTest.java",
"fake/javatests/org/chromium/net/test/UrlResponseMatcherTest.java",
]
deps = [
":cronet_api_java",
":cronet_common_javatests",
":cronet_impl_common_base_java",
":cronet_impl_fake_base_java",
":cronet_impl_platform_base_java",
"//base:base_java_test_support",
"//third_party/android_sdk:android_test_base_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
]
}
cronet_javatests_deps_to_package = [
":cronet_common_javatests",
":cronet_fake_javatests",
":cronet_test_apk_java",
"//base:base_java",
"//base:jni_java",
"//base:base_java_test_support",
"//net/android:embedded_test_server_aidl_java",
"//net/android:net_java",
"//net/android:net_java_test_support",
"//url:url_java",
]
android_library("cronet_javatests") {
testonly = true
sources = [
"test/javatests/src/org/chromium/net/BidirectionalStreamQuicTest.java",
"test/javatests/src/org/chromium/net/BidirectionalStreamTest.java",
"test/javatests/src/org/chromium/net/BrotliTest.java",
"test/javatests/src/org/chromium/net/Criteria.java",
"test/javatests/src/org/chromium/net/CronetEngineBuilderTest.java",
"test/javatests/src/org/chromium/net/CronetStressTest.java",
"test/javatests/src/org/chromium/net/CronetTestRuleTest.java",
"test/javatests/src/org/chromium/net/CronetUploadTest.java",
"test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java",
"test/javatests/src/org/chromium/net/CronetUrlRequestTest.java",
"test/javatests/src/org/chromium/net/DiskStorageTest.java",
"test/javatests/src/org/chromium/net/ExperimentalOptionsTest.java",
"test/javatests/src/org/chromium/net/GetStatusTest.java",
"test/javatests/src/org/chromium/net/MetricsTestUtil.java",
"test/javatests/src/org/chromium/net/MockCertVerifierTest.java",
"test/javatests/src/org/chromium/net/NQETest.java",
"test/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java",
"test/javatests/src/org/chromium/net/NetworkErrorLoggingTest.java",
"test/javatests/src/org/chromium/net/PkpTest.java",
"test/javatests/src/org/chromium/net/QuicTest.java",
"test/javatests/src/org/chromium/net/RequestFinishedInfoTest.java",
"test/javatests/src/org/chromium/net/TestBidirectionalStreamCallback.java",
"test/javatests/src/org/chromium/net/TestDrivenDataProvider.java",
"test/javatests/src/org/chromium/net/TestNetworkQualityRttListener.java",
"test/javatests/src/org/chromium/net/TestNetworkQualityThroughputListener.java",
"test/javatests/src/org/chromium/net/UploadDataProvidersTest.java",
"test/javatests/src/org/chromium/net/UrlResponseInfoTest.java",
"test/javatests/src/org/chromium/net/impl/CronetLoggerTest.java",
"test/javatests/src/org/chromium/net/urlconnection/CronetBufferedOutputStreamTest.java",
"test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java",
"test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java",
"test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java",
"test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLStreamHandlerTest.java",
"test/javatests/src/org/chromium/net/urlconnection/CronetInputStreamTest.java",
"test/javatests/src/org/chromium/net/urlconnection/CronetURLStreamHandlerFactoryTest.java",
"test/javatests/src/org/chromium/net/urlconnection/MessageLoopTest.java",
"test/javatests/src/org/chromium/net/urlconnection/QuicUploadTest.java",
"test/javatests/src/org/chromium/net/urlconnection/TestUtil.java",
]
# Adding deps here won't include those deps in the cronet_tests_java.jar.
# Please add to cronet_javatests_deps_to_package instead.
deps = [
":cronet_api_java",
":cronet_impl_all_java",
":cronet_urlconnection_impl_java",
"//third_party/android_sdk:android_test_base_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/google-truth:google_truth_java",
"//third_party/hamcrest:hamcrest_core_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
]
deps += cronet_javatests_deps_to_package
data = [ "//components/cronet/testing/test_server/data/" ]
}
instrumentation_test_apk("cronet_test_instrumentation_apk") {
# This is the only Cronet APK with lint enabled. This one was chosen because
# it depends on basically all source files.
enable_lint = true
lint_baseline_file = "lint-baseline.xml"
lint_suppressions_file = "lint-suppressions.xml"
# Still needs to support KitKat. See crbug.com/1042122.
lint_min_sdk_version = 19
apk_name = "CronetTestInstrumentation"
android_manifest = "test/javatests/AndroidManifest.xml"
shared_libraries = [
":cronet",
":cronet_tests",
]
loadable_modules = [ "$root_out_dir/libnetty-tcnative.so" ]
sources = cronet_smoketests_native_common_srcs + [
"test/smoketests/src/org/chromium/net/smoke/Http2Test.java",
"test/smoketests/src/org/chromium/net/smoke/QuicTest.java",
]
deps = [
":cronet_api_java",
":cronet_combine_proguard_flags",
":cronet_impl_all_java",
":cronet_javatests",
":cronet_test_apk_java",
":cronet_test_apk_resources",
"//base:base_java",
"//base:base_java_test_support",
"//base:jni_java",
"//build/android:build_java",
"//net/android:net_java",
"//net/android:net_java_test_support",
"//third_party/android_sdk:android_test_base_java",
"//third_party/android_sdk:android_test_mock_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/hamcrest:hamcrest_core_java",
"//third_party/junit",
"//third_party/netty-tcnative:netty-tcnative-so",
"//third_party/netty4:netty_all_java",
]
additional_apks = [ "//net/android:net_test_support_apk" ]
data_deps = [ "//net:test_support" ]
enable_multidex = true
if (!is_java_debug) {
proguard_enabled = true
proguard_configs = [
"$target_gen_dir/cronet_impl_native_proguard.cfg",
"cronet_impl_common_proguard.cfg",
"cronet_impl_platform_proguard.cfg",
"test/proguard.cfg",
]
}
}
android_resources("cronet_smoketests_platform_only_apk_resources") {
testonly = true
sources = [
"test/smoketests/res/platform_only/values/strings.xml",
"test/smoketests/res/platform_only/xml/network_security_config.xml",
]
}
instrumentation_test_apk(
"cronet_smoketests_platform_only_instrumentation_apk") {
apk_name = "PlatformOnlyEngineSmokeTestInstrumentation"
android_manifest = "test/javatests/AndroidManifest.xml"
sources = cronet_smoketests_platform_only_common_srcs + [
"test/smoketests/src/org/chromium/net/smoke/PlatformOnlyEngineTest.java",
"test/src/org/chromium/net/CronetTestApplication.java",
]
deps = [
":cronet_api_java",
":cronet_impl_common_base_java",
":cronet_impl_platform_base_java",
":cronet_smoketests_platform_only_apk_resources",
"//base:base_java_test_support",
"//third_party/android_sdk:android_test_base_java",
"//third_party/android_sdk:android_test_mock_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/junit",
"//third_party/netty4:netty_all_java",
]
if (!is_java_debug) {
proguard_enabled = true
proguard_configs = [
"cronet_impl_common_proguard.cfg",
"cronet_impl_platform_proguard.cfg",
"test/proguard.cfg",
]
}
}
instrumentation_test_apk(
"cronet_smoketests_missing_native_library_instrumentation_apk") {
apk_name = "MissingNativeLibrarySmokeTestInstrumentation"
android_manifest = "test/javatests/AndroidManifest.xml"
sources = cronet_smoketests_native_common_srcs + [ "test/smoketests/src/org/chromium/net/smoke/MissingNativeLibraryTest.java" ]
deps = [
":cronet_api_java",
":cronet_combine_proguard_flags",
":cronet_impl_common_base_java",
":cronet_impl_platform_base_java",
":cronet_test_apk_java",
":cronet_test_apk_resources",
"//base:base_java",
"//base:base_java_test_support",
"//base:jni_java",
"//build/android:build_java",
"//third_party/android_sdk:android_test_base_java",
"//third_party/android_sdk:android_test_mock_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/junit",
"//third_party/netty4:netty_all_java",
]
enable_multidex = true
if (!is_java_debug) {
proguard_enabled = true
proguard_configs = [
"$target_gen_dir/cronet_impl_native_proguard.cfg",
"cronet_impl_common_proguard.cfg",
"cronet_impl_platform_proguard.cfg",
"test/proguard.cfg",
]
}
}
android_apk("cronet_perf_test_apk") {
testonly = true
apk_name = "CronetPerfTest"
android_manifest = "test/javaperftests/AndroidManifest.xml"
shared_libraries = [
":cronet",
":cronet_tests",
]
sources = [
"test/javaperftests/src/org/chromium/net/CronetPerfTestActivity.java",
]
deps = [
":cronet_api_java",
":cronet_combine_proguard_flags",
":cronet_impl_all_java",
":cronet_javatests",
":cronet_test_apk_java",
"//base:base_java",
"//base:jni_java",
"//build/android:build_java",
"//third_party/android_sdk:android_test_mock_java",
"//third_party/junit",
]
enable_multidex = true
if (!is_java_debug) {
proguard_enabled = true
proguard_configs = [
"$target_gen_dir/cronet_impl_native_proguard.cfg",
"cronet_impl_common_proguard.cfg",
"test/proguard.cfg",
"//base/android/proguard/chromium_apk.flags",
"//testing/android/proguard_for_test.flags",
]
enable_proguard_checks = false
}
}
test("cronet_unittests_android") {
deps = [
":cronet_impl_native_base_java",
":cronet_static",
"//base",
"//base/test:test_support",
"//components/cronet:cronet_common_unittests",
"//components/cronet/native:cronet_native_unittests",
"//components/metrics",
"//components/prefs:test_support",
"//net",
"//net:test_support",
"//net/android:net_java",
"//testing/gtest",
]
sources = [ "../run_all_unittests.cc" ]
data = [ "//components/cronet/testing/test_server/data/" ]
if (is_android) {
shard_timeout = 180
}
}
test("cronet_tests_android") {
deps = [
":cronet_impl_native_base_java",
":cronet_static",
"//base",
"//base/test:test_support",
"//components/cronet/native/test:cronet_native_tests",
"//components/metrics",
"//components/prefs:test_support",
"//net",
"//net:test_support",
"//net/android:net_java",
"//testing/gtest",
]
allow_cleartext_traffic = true
sources = [ "../run_all_unittests.cc" ]
defines = [ "CRONET_TESTS_IMPLEMENTATION" ]
data = [ "//components/cronet/testing/test_server/data/" ]
if (is_android) {
shard_timeout = 180
}
}
_test_package_dir = "$root_out_dir/cronet/test"
repackage_jars("repackage_test_jars") {
output = "$_test_package_dir/cronet_tests_java.jar"
testonly = true
deps = cronet_javatests_deps_to_package + [
":cronet_javatests",
"//third_party/netty4:netty_all_java",
]
}
zip("jar_cronet_sample_source") {
inputs = [
"sample/AndroidManifest.xml",
"sample/javatests/AndroidManifest.xml",
"sample/javatests/proguard.cfg",
"sample/javatests/src/org/chromium/cronet_sample_apk/CronetSampleTest.java",
"sample/README",
"sample/res/layout/activity_main.xml",
"sample/res/layout/dialog_url.xml",
"sample/res/values/dimens.xml",
"sample/res/values/strings.xml",
"sample/src/org/chromium/cronet_sample_apk/CronetSampleActivity.java",
"sample/src/org/chromium/cronet_sample_apk/CronetSampleApplication.java",
]
output = "$_package_dir/cronet-sample-src.jar"
base_dir = "sample"
}
jar_src("jar_cronet_impl_native_java_source") {
src_search_dirs = [
"//base/android/java/src",
"//build/android/java/src",
"//components/cronet/android/java/src",
"//net/android/java/src",
"//url/android/java/src",
]
source_deps = [
":cronet_impl_native_base_java",
"//base:base_java",
"//base:jni_java",
"//build/android:build_java",
"//net/android:net_java",
"//url:url_java",
]
srcjar_deps = cronet_impl_native_java_srcjar_deps + [
":cronet_jni_registration",
"//base:base_android_java_enums_srcjar",
"//net/android:net_android_java_enums_srcjar",
"//net/android:net_errors_java",
]
excluded_patterns = _jar_excluded_patterns
jar_path = "$_package_dir/cronet_impl_native_java-src.jar"
}
action("generate_licenses") {
_license_path = "$_package_dir/LICENSE"
script = "//tools/licenses.py"
outputs = [ _license_path ]
args = [
"license_file",
rebase_path(_license_path, root_build_dir),
"--gn-target",
"//components/cronet/android:cronet",
"--gn-out-dir",
".",
]
}
action_with_pydeps("generate_javadoc") {
script = "//components/cronet/tools/generate_javadoc.py"
depfile = "$target_gen_dir/$target_name.d"
_zip_file = "$target_gen_dir/$target_name.zip"
outputs = [ _zip_file ]
_annotations_jar = "$root_out_dir/lib.java/third_party/androidx/androidx_annotation_annotation.jar"
_src_jar = "$_package_dir/cronet_api-src.jar"
inputs = [
_annotations_jar,
_src_jar,
android_sdk_jar,
]
args = [
"--output-dir",
rebase_path(_package_dir, root_build_dir),
"--input-dir",
rebase_path("//components/cronet", root_build_dir),
"--overview-file",
rebase_path("$_package_dir/README.md.html", root_build_dir),
"--readme-file",
rebase_path("//components/cronet/README.md", root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
"--zip-file",
rebase_path(_zip_file, root_build_dir),
"--android-sdk-jar",
rebase_path(android_sdk_jar, root_build_dir),
"--support-annotations-jar",
rebase_path(_annotations_jar, root_build_dir),
# JavaDoc is generated from Cronet's API source jar.
"--input-src-jar",
rebase_path(_src_jar, root_build_dir),
]
deps = [
":jar_cronet_api_source",
"//third_party/androidx:androidx_annotation_annotation_java",
]
}
copy("cronet_package_copy") {
sources = [
"$target_gen_dir/cronet_impl_native_proguard.cfg",
"//AUTHORS",
"//chrome/VERSION",
"cronet_impl_common_proguard.cfg",
"cronet_impl_fake_proguard.cfg",
"cronet_impl_platform_proguard.cfg",
"implementation_api_version.txt",
"interface_api_version.txt",
]
outputs = [ "$_package_dir/{{source_file_part}}" ]
deps = [
":cronet_api_java",
":cronet_combine_proguard_flags",
":cronet_impl_common_base_java",
":cronet_impl_fake_base_java",
":cronet_impl_platform_base_java",
]
}
copy("cronet_package_copy_native_headers") {
sources = cronet_native_public_headers + grpc_public_headers
outputs = [ "$_package_dir/include/{{source_file_part}}" ]
}
copy("cronet_package_copy_native_lib") {
sources = [ "$root_out_dir/" + _cronet_shared_lib_file_name ]
outputs = [ "$_package_dir/libs/${android_app_abi}/" +
_cronet_shared_lib_file_name ]
deps = [ ":cronet" ]
}
copy("cronet_package_copy_native_lib_unstripped") {
sources = [ "$root_out_dir/lib.unstripped/" + _cronet_shared_lib_file_name ]
outputs = [ "$_package_dir/symbols/${android_app_abi}/" +
_cronet_shared_lib_file_name ]
deps = [ ":cronet" ]
}
copy("cronet_package_copy_native_test_lib") {
testonly = true
sources = [
"$root_out_dir/libcronet_tests.so",
"$root_out_dir/libnetty-tcnative.so",
]
outputs =
[ "$_test_package_dir/libs/${android_app_abi}/{{source_file_part}}" ]
deps = [
":cronet_tests",
"//third_party/netty-tcnative:netty-tcnative-so",
]
}
copy("cronet_package_copy_native_test_lib_unstripped") {
testonly = true
sources = [
"$root_out_dir/lib.unstripped/libcronet_tests.so",
"$root_out_dir/lib.unstripped/libnetty-tcnative.so",
]
outputs =
[ "$_test_package_dir/symbols/${android_app_abi}/{{source_file_part}}" ]
deps = [
":cronet_tests",
"//third_party/netty-tcnative:netty-tcnative-so",
]
}
copy("cronet_package_copy_test_assets") {
testonly = true
sources = [ "//components/cronet/testing/test_server/data" ]
outputs = [ "$_test_package_dir/assets/test" ]
}
copy("cronet_package_copy_test_support_apks") {
testonly = true
sources = [
# Provides EmbeddedTestServer.
"$root_out_dir/apks/ChromiumNetTestSupport.apk",
]
outputs =
[ "$_test_package_dir/apks/${android_app_abi}/{{source_file_part}}" ]
deps = [ "//net/android:net_test_support_apk" ]
}
copy("cronet_package_copy_test_files") {
testonly = true
sources = [
"//net/data/ssl/certificates/expired_cert.pem",
"//net/data/ssl/certificates/quic-chain.pem",
"//net/data/ssl/certificates/quic-leaf-cert.key",
"//net/data/ssl/certificates/quic-leaf-cert.key.pkcs8.pem",
"//net/data/ssl/certificates/root_ca_cert.pem",
]
outputs = [ "$_test_package_dir/assets/test_files/net/data/ssl/certificates/{{source_file_part}}" ]
deps = [
# Not really dependent, but builds can fail if these two targets attempt
# to create the "assets" subdirectory simultaneously.
":cronet_package_copy_test_assets",
]
}
copy("cronet_package_copy_resources") {
sources = [ "api/res/raw/keep_cronet_api.xml" ]
outputs = [ "$_package_dir/res/raw/{{source_file_part}}" ]
}
# Enforce that ARM Neon is not used when building for ARMv7
if (target_cpu == "arm" && arm_version == 7 && !arm_use_neon) {
action("enforce_no_neon") {
script = "//components/cronet/tools/check_no_neon.py"
outputs = [ "$target_gen_dir/$target_name.stamp" ]
args = [
rebase_path("${android_tool_prefix}objdump", root_build_dir),
# libcronet.so may contain ARM Neon instructions from BoringSSL, but these
# are only used after checking whether the CPU supports NEON at runtime,
# so instead check base/ as it represents a large swath of code that only
# contains Neon instructions when Neon is enabled by default.
rebase_path("$root_out_dir/obj/base/base/*.o", root_build_dir),
"--stamp",
rebase_path(outputs[0], root_build_dir),
]
deps = [ "//base:base" ]
}
}
# Enforce restrictions for API<->impl boundary.
action("api_static_checks") {
script = "//components/cronet/tools/api_static_checks.py"
outputs = [ "$target_gen_dir/$target_name.stamp" ]
_api_jar = "$target_out_dir/cronet_api_java.processed.jar"
_common_jar = "$target_out_dir/cronet_impl_common_base_java.processed.jar"
_platform_jar =
"$target_out_dir/cronet_impl_platform_base_java.processed.jar"
_native_jar = "$target_out_dir/cronet_impl_native_base_java.processed.jar"
args = [
"--api_jar",
rebase_path(_api_jar, root_build_dir),
"--impl_jar",
rebase_path(_common_jar, root_build_dir),
"--impl_jar",
rebase_path(_platform_jar, root_build_dir),
"--impl_jar",
rebase_path(_native_jar, root_build_dir),
"--stamp",
rebase_path(outputs[0], root_build_dir),
]
deps = [
":cronet_api_java",
":cronet_impl_common_base_java",
":cronet_impl_native_base_java",
":cronet_impl_platform_base_java",
]
inputs = [
_api_jar,
_common_jar,
_platform_jar,
_native_jar,
"//components/cronet/tools/update_api.py",
]
sources = [
"//components/cronet/android/api.txt",
"//components/cronet/android/interface_api_version.txt",
]
}
group("cronet_package_android") {
# Marked as testonly as it contains test-only targets too.
testonly = true
# Enforce building with ICU alternatives, crbug.com/611621.
# Enforce that arm_use_neon==false when building for ARMv7 by
# not including any deps in cronet_package target otherwise.
if (use_platform_icu_alternatives &&
(!(target_cpu == "arm" && arm_version == 7) || !arm_use_neon)) {
deps = [
":api_static_checks",
":cronet_package_copy",
":cronet_package_copy_native_headers",
":cronet_package_copy_native_lib",
":cronet_package_copy_native_lib_unstripped",
":cronet_package_copy_resources",
":cronet_sizes",
":cronet_test_package",
":generate_javadoc",
":generate_licenses",
":jar_cronet_api_source",
":jar_cronet_impl_common_java_source",
":jar_cronet_impl_fake_java_source",
":jar_cronet_impl_native_java_source",
":jar_cronet_impl_platform_java_source",
":jar_cronet_sample_source",
":repackage_api",
":repackage_common",
":repackage_fake",
":repackage_native",
":repackage_platform",
]
if (current_cpu == "arm" && arm_version == 7) {
deps += [ ":enforce_no_neon" ]
}
}
}
group("cronet_test_package") {
testonly = true
# Don't build for MIPS where tests aren't run.
if (current_cpu != "mipsel" && current_cpu != "mips64el") {
deps = [
":cronet_package_copy_native_test_lib",
":cronet_package_copy_native_test_lib_unstripped",
":cronet_package_copy_test_assets",
":cronet_package_copy_test_files",
":cronet_package_copy_test_support_apks",
":repackage_test_jars",
]
}
}
}