aboutsummaryrefslogtreecommitdiff
path: root/platform/BUILD.gn
blob: e98067f191154ec4a146728ae924fea262ee4eec (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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# Copyright 2018 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_overrides/build.gni")

# Source files that depend on nothing (all your base/ are belong to us).
source_set("base") {
  defines = []

  sources = [
    "base/error.cc",
    "base/error.h",
    "base/interface_info.cc",
    "base/interface_info.h",
    "base/ip_address.cc",
    "base/ip_address.h",
    "base/location.cc",
    "base/location.h",
    "base/tls_connect_options.h",
    "base/tls_credentials.cc",
    "base/tls_credentials.h",
    "base/tls_listen_options.h",
    "base/trace_logging_activation.cc",
    "base/trace_logging_activation.h",
    "base/trace_logging_types.h",
    "base/trivial_clock_traits.cc",
    "base/trivial_clock_traits.h",
    "base/udp_packet.cc",
    "base/udp_packet.h",
  ]

  public_configs = [ "../build:openscreen_include_dirs" ]
}

# Public API source files. These may depend on nothing except :base.
source_set("api") {
  defines = []

  sources = [
    "api/export.h",
    "api/logging.h",
    "api/network_interface.h",
    "api/scoped_wake_lock.cc",
    "api/scoped_wake_lock.h",
    "api/serial_delete_ptr.h",
    "api/task_runner.h",
    "api/time.h",
    "api/tls_connection.cc",
    "api/tls_connection.h",
    "api/tls_connection_factory.cc",
    "api/tls_connection_factory.h",
    "api/trace_logging_platform.cc",
    "api/trace_logging_platform.h",
    "api/udp_socket.cc",
    "api/udp_socket.h",
  ]

  public_deps = [ ":base" ]
}

# The following target is only activated in standalone builds (see :platform).
if (!build_with_chromium) {
  source_set("standalone_impl") {
    defines = []

    sources = [
      "impl/logging.h",
      "impl/network_interface.cc",
      "impl/network_interface.h",
      "impl/socket_handle.h",
      "impl/socket_handle_waiter.cc",
      "impl/socket_handle_waiter.h",
      "impl/socket_state.h",
      "impl/stream_socket.h",
      "impl/task_runner.cc",
      "impl/task_runner.h",
      "impl/text_trace_logging_platform.cc",
      "impl/text_trace_logging_platform.h",
      "impl/time.cc",
      "impl/tls_write_buffer.cc",
      "impl/tls_write_buffer.h",
    ]

    public_configs = [ "//util:trace_logging_config" ]

    if (is_linux) {
      sources += [
        "impl/network_interface_linux.cc",
        "impl/scoped_wake_lock_linux.cc",
        "impl/scoped_wake_lock_linux.h",
      ]
    } else if (is_mac) {
      defines += [
        # Required, to use the new IPv6 Sockets options introduced by RFC 3542.
        "__APPLE_USE_RFC_3542",
      ]

      frameworks = [
        "CoreFoundation.framework",
        "IOKit.framework",
      ]

      sources += [
        "impl/network_interface_mac.cc",
        "impl/scoped_wake_lock_mac.cc",
        "impl/scoped_wake_lock_mac.h",
      ]
    }

    if (is_posix) {
      sources += [
        "impl/logging_posix.cc",
        "impl/logging_test.h",
        "impl/platform_client_posix.cc",
        "impl/platform_client_posix.h",
        "impl/scoped_pipe.h",
        "impl/socket_address_posix.cc",
        "impl/socket_address_posix.h",
        "impl/socket_handle_posix.cc",
        "impl/socket_handle_posix.h",
        "impl/socket_handle_waiter_posix.cc",
        "impl/socket_handle_waiter_posix.h",
        "impl/stream_socket_posix.cc",
        "impl/stream_socket_posix.h",
        "impl/timeval_posix.cc",
        "impl/timeval_posix.h",
        "impl/tls_connection_factory_posix.cc",
        "impl/tls_connection_factory_posix.h",
        "impl/tls_connection_posix.cc",
        "impl/tls_connection_posix.h",
        "impl/tls_data_router_posix.cc",
        "impl/tls_data_router_posix.h",
        "impl/udp_socket_posix.cc",
        "impl/udp_socket_posix.h",
        "impl/udp_socket_reader_posix.cc",
        "impl/udp_socket_reader_posix.h",
      ]
    }

    deps = [
      ":api",
      "../third_party/abseil",
      "../third_party/boringssl",
      "../util",
    ]
  }
}

# The main target, which either assumes an embedder will link-in the platform
# API implementation elsewhere, or links-in the :standalone_impl in the build.
source_set("platform") {
  public_deps = [ ":api" ]
  if (!build_with_chromium) {
    deps = [ ":standalone_impl" ]
  }
}

# Test helpers, referenced in other Open Screen BUILD.gn test targets.
source_set("test") {
  testonly = true
  sources = [
    "test/fake_clock.cc",
    "test/fake_clock.h",
    "test/fake_task_runner.cc",
    "test/fake_task_runner.h",
    "test/fake_udp_socket.cc",
    "test/fake_udp_socket.h",
    "test/mock_tls_connection.h",
    "test/mock_udp_socket.h",
    "test/paths.h",
    "test/paths_internal.h",
    "test/trace_logging_helpers.h",
  ]

  if (is_posix) {
    sources += [ "test/paths_posix.cc" ]
  }
  if (is_linux) {
    sources += [ "test/paths_internal_linux.cc" ]
  } else if (is_mac) {
    sources += [ "test/paths_internal_mac.cc" ]
  } else if (build_with_chromium) {
    # NOTE: This is used to resolve a linking issue when compiling in Chromium
    # for other platforms, but nothing in here is called.
    sources += [ "test/paths_internal_other.cc" ]
  }

  public_deps = [
    ":api",
    ":base",
  ]

  deps = [
    ":platform",
    "../third_party/abseil",
    "../third_party/googletest:gmock",
    "../util",
  ]
}

source_set("unittests") {
  testonly = true

  sources = [
    "api/serial_delete_ptr_unittest.cc",
    "api/time_unittest.cc",
    "base/error_unittest.cc",
    "base/ip_address_unittest.cc",
    "base/location_unittest.cc",
    "base/udp_packet_unittest.cc",
  ]

  # The socket integration tests assume that you can Bind with UDP sockets,
  # which is simply not true when we are built inside of Chromium.
  if (!build_with_chromium) {
    sources += [ "api/socket_integration_unittest.cc" ]
  }

  # The unit tests in impl/ assume the standalone implementation is being used.
  # Exclude them if an embedder is providing the implementation.
  if (!build_with_chromium) {
    sources += [
      "impl/task_runner_unittest.cc",
      "impl/time_unittest.cc",
    ]

    if (is_posix) {
      sources += [
        "impl/logging_unittest.cc",
        "impl/scoped_pipe_unittest.cc",
        "impl/socket_address_posix_unittest.cc",
        "impl/socket_handle_waiter_posix_unittest.cc",
        "impl/timeval_posix_unittest.cc",
        "impl/tls_data_router_posix_unittest.cc",
        "impl/tls_write_buffer_unittest.cc",
        "impl/udp_socket_reader_posix_unittest.cc",
      ]
    }
  }

  deps = [
    ":platform",
    ":test",
    "../third_party/abseil",
    "../third_party/boringssl",
    "../third_party/googletest:gmock",
    "../third_party/googletest:gtest",
    "../util",
  ]
}