blob: 3d722dbea6b42bb9de77055968fa4a134c13f927 [file] [log] [blame]
# Copyright 2017 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//build/toolchain/toolchain.gni")
import("//build/util/lastchange.gni")
import("//build/util/process_version.gni")
import("//chrome/version.gni")
import("//components/cronet/native/include/headers.gni")
import("//components/grpc_support/include/headers.gni")
import("//testing/test.gni")
import("//third_party/protobuf/proto_library.gni")
process_version("cronet_version_header") {
template_file = "//components/cronet/version.h.in"
sources = [ "//chrome/VERSION" ]
output = "$target_gen_dir/version.h"
extra_args = [
"-e",
"VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)",
]
}
proto_library("request_context_config_proto") {
sources = [ "proto/request_context_config.proto" ]
}
if (is_android) {
import("//build/config/android/rules.gni")
proto_java_library("request_context_config_java_proto") {
proto_path = "."
sources = [ "proto/request_context_config.proto" ]
}
}
# Cronet common implementation.
source_set("cronet_common") {
sources = [
"cronet_context.cc",
"cronet_context.h",
"cronet_global_state.h",
"cronet_prefs_manager.cc",
"cronet_prefs_manager.h",
"cronet_proxy_delegate.cc",
"cronet_proxy_delegate.h",
"cronet_upload_data_stream.cc",
"cronet_upload_data_stream.h",
"cronet_url_request.cc",
"cronet_url_request.h",
"host_cache_persistence_manager.cc",
"host_cache_persistence_manager.h",
"url_request_context_config.cc",
"url_request_context_config.h",
]
deps = [
":cronet_version_header",
":request_context_config_proto",
"//base",
"//components/prefs",
"//net",
]
public_deps = [ "//components/metrics:library_support" ]
}
source_set("metrics_util") {
sources = [
"metrics_util.cc",
"metrics_util.h",
]
deps = [ "//base" ]
}
# Unit tests for Cronet common implementation.
source_set("cronet_common_unittests") {
testonly = true
deps = [
":cronet_common",
"//components/prefs:test_support",
"//net:test_support",
]
sources = [
"cronet_stale_host_resolver_unittest.cc",
"host_cache_persistence_manager_unittest.cc",
"network_tasks_unittest.cc",
"url_request_context_config_unittest.cc",
]
}
# For platforms on which the native Cronet library is used, build the library,
# a cronet_tests binary that exercises it, and a unit-tests binary.
if (is_android) {
group("cronet_package") {
testonly = true
deps = [ "//components/cronet/android:cronet_package_android" ]
}
} else {
_cronet_shared_lib_name = "cronet.$chrome_version_full"
_cronet_shared_lib_file_name =
"$shlib_prefix$_cronet_shared_lib_name$shlib_extension"
shared_library("cronet") {
output_name = _cronet_shared_lib_name
deps = [
"//base",
"//components/cronet:cronet_common",
"//components/cronet/native:cronet_native_impl",
"//net",
]
sources = [ "cronet_global_state_stubs.cc" ]
# TODO(crbug.com/40031409): Fix code that adds exit-time destructors and
# enable the diagnostic by removing this line.
configs += [ "//build/config/compiler:no_exit_time_destructors" ]
}
test("cronet_tests") {
deps = [
":cronet_common",
"//base",
"//base/test:test_support",
"//components/cronet/native:cronet_native_impl",
"//components/cronet/native/test:cronet_native_tests",
"//net",
]
sources = [
"cronet_global_state_stubs.cc",
"run_all_unittests.cc",
]
defines = [ "CRONET_TESTS_IMPLEMENTATION" ]
if ((is_linux || is_chromeos) && !is_component_build) {
public_configs = [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}
if (is_fuchsia) {
additional_manifest_fragments =
[ "//build/config/fuchsia/test/network.shard.test-cml" ]
}
# TODO(crbug.com/40031409): Fix code that adds exit-time destructors and
# enable the diagnostic by removing this line.
configs += [ "//build/config/compiler:no_exit_time_destructors" ]
}
test("cronet_unittests") {
deps = [
":cronet_common",
":cronet_common_unittests",
"//base",
"//base/test:test_support",
"//components/cronet/native:cronet_native_unittests",
"//net",
]
sources = [
"cronet_global_state_stubs.cc",
"run_all_unittests.cc",
]
# TODO(crbug.com/40031409): Fix code that adds exit-time destructors and
# enable the diagnostic by removing this line.
configs += [ "//build/config/compiler:no_exit_time_destructors" ]
}
_package_dir = "$root_out_dir/cronet"
# Generate LICENSE file by recursively joining all dependent licenses.
action("generate_license") {
_license_path = "$_package_dir/LICENSE"
script = "//tools/licenses/licenses.py"
inputs = [ lastchange_file ]
outputs = [ _license_path ]
args = [
"license_file",
rebase_path(_license_path, root_build_dir),
"--gn-target",
"//components/cronet:cronet",
"--gn-out-dir",
".",
]
}
# Copy boiler-plate files into the package.
copy("cronet_package_copy") {
sources = [
"${root_out_dir}${shlib_subdir}/${_cronet_shared_lib_file_name}",
"//AUTHORS",
"//chrome/VERSION",
]
deps = [ ":cronet" ]
outputs = [ "$_package_dir/{{source_file_part}}" ]
}
# Copy headers.
copy("cronet_package_headers") {
sources = cronet_native_public_headers + grpc_public_headers
outputs = [ "$_package_dir/include/{{source_file_part}}" ]
}
group("cronet_package") {
deps = [
":cronet_package_copy",
":cronet_package_headers",
":generate_license",
]
}
executable("cronet_sample") {
testonly = true
sources = [
"native/sample/main.cc",
"native/sample/sample_executor.cc",
"native/sample/sample_executor.h",
"native/sample/sample_url_request_callback.cc",
"native/sample/sample_url_request_callback.h",
]
deps = [
"//components/cronet",
"//components/cronet/native:cronet_native_headers",
]
if ((is_linux || is_chromeos) && !is_component_build) {
public_configs = [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}
}
test("cronet_sample_test") {
sources = [ "native/sample/test/sample_test.cc" ]
deps = [
":cronet_sample",
"//testing/gtest",
]
# TODO(crbug.com/40031409): Fix code that adds exit-time destructors and
# enable the diagnostic by removing this line.
configs += [ "//build/config/compiler:no_exit_time_destructors" ]
}
}