summaryrefslogtreecommitdiff
path: root/chromium/components/cronet/BUILD.gn
blob: 8665bc24d7a938d06cab71734c773d1c7bf13612 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Copyright 2017 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/util/process_version.gni")
import("//build/util/version.gni")
import("//testing/test.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)",
  ]
}

# Cronet common implementation.
source_set("cronet_common") {
  sources = [
    "cronet_global_state.h",
    "cronet_prefs_manager.cc",
    "cronet_prefs_manager.h",
    "cronet_url_request.cc",
    "cronet_url_request.h",
    "cronet_url_request_context.cc",
    "cronet_url_request_context.h",
    "histogram_manager.cc",
    "histogram_manager.h",
    "host_cache_persistence_manager.cc",
    "host_cache_persistence_manager.h",
    "stale_host_resolver.cc",
    "stale_host_resolver.h",
    "url_request_context_config.cc",
    "url_request_context_config.h",
  ]
  deps = [
    ":cronet_version_header",
    "//base",
    "//components/metrics:metrics",
    "//components/prefs:prefs",
    "//net",
    "//third_party/metrics_proto",
  ]
}

# Unit tests for Cronet common implementation.
source_set("cronet_common_unittests") {
  testonly = true

  deps = [
    ":cronet_common",
    "//components/prefs:test_support",
    "//net:test_support",
  ]

  sources = [
    "histogram_manager_unittest.cc",
    "host_cache_persistence_manager_unittest.cc",
    "run_all_unittests.cc",
    "stale_host_resolver_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.
# Android and iOS have their own platform-specific rules to build Cronet.
if (!is_ios && !is_android) {
  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 = [
        "-rpath",
        "@executable_path/",
      ]
    }
  }

  shared_library("cronet") {
    deps = [
      "//base",

      # Explicitly add the exe_and_shlib_deps, otherwise the library will fail
      # to link in component builds, due to missing libc++ symbols.
      "//build/config:exe_and_shlib_deps",
      "//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",
        "@rpath/lib${target_name}.dylib",
      ]
      public_configs = [ ":shared_library_public_config" ]
    }
  }

  test("cronet_tests") {
    deps = [
      ":cronet",
      "//base",
      "//base/test:test_support",
      "//components/cronet/native/test:cronet_native_tests",
    ]

    sources = [
      "run_all_unittests.cc",
    ]

    if (is_linux && !is_component_build) {
      public_configs = [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
    }
  }

  test("cronet_unittests") {
    deps = [
      ":cronet_common",
      ":cronet_common_unittests",
      "//base",
      "//components/cronet/native:cronet_native_unittests",
      "//net",
    ]

    sources = [
      "cronet_global_state_stubs.cc",
    ]
  }
}