| # 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") |
| |
| declare_args() { |
| # If set to true, this will remove histogram manager to reduce binary size. |
| disable_histogram_support = is_mac || is_win |
| } |
| |
| # Disable histogram support is not allowed on Android. |
| assert(!disable_histogram_support || !is_android) |
| |
| buildflag_header("cronet_buildflags") { |
| header = "cronet_buildflags.h" |
| flags = [ "DISABLE_HISTOGRAM_SUPPORT=$disable_histogram_support" ] |
| } |
| |
| 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)", |
| ] |
| } |
| |
| # 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_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_buildflags", |
| ":cronet_version_header", |
| "//base", |
| "//components/prefs:prefs", |
| "//net", |
| ] |
| |
| if (!disable_histogram_support) { |
| 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 { |
| config("shared_library_public_config") { |
| if (is_mac && !is_component_build) { |
| # Executable targets that depend on the shared libraries below need to have |
| # the rpath setup in non-component build configurations. |
| ldflags = [ "-Wl,-rpath,@executable_path/" ] |
| } |
| } |
| |
| _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" ] |
| |
| if (is_mac && !is_component_build) { |
| ldflags = [ |
| "-install_name", |
| "@executable_path/$_cronet_shared_lib_file_name", |
| ] |
| public_configs = [ ":shared_library_public_config" ] |
| } |
| } |
| |
| 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" ] |
| } |
| } |
| |
| 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", |
| ] |
| } |
| |
| _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_native_perf_test") { |
| testonly = true |
| sources = [ |
| "native/perftest/main.cc", |
| "native/perftest/perf_test.cc", |
| ] |
| deps = [ |
| "//base", |
| "//components/cronet", |
| "//components/cronet/native:cronet_native_headers", |
| "//components/cronet/native/test:cronet_native_tests", |
| "//components/cronet/native/test:cronet_native_testutil", |
| "//net:test_support", |
| ] |
| } |
| |
| 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:gtest", |
| ] |
| } |
| } |