blob: 4015aa5a0a5917523a4bb94ef0c9ff51beca9c92 [file] [log] [blame]
btolsch9d6900c2018-05-30 18:22:53 -07001# Copyright 2018 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Yuri Wiitalab2d13232019-02-04 18:07:28 -08005import("//build_overrides/build.gni")
btolsch5292c942018-07-26 00:06:22 -07006
Yuri Wiitalaca24ee52019-12-05 16:51:42 -08007# Source files that depend on nothing (all your base/ are belong to us).
8source_set("base") {
Ryan Keane1d9c0c42019-07-29 15:22:19 -07009 defines = []
10
Yuri Wiitalab2d13232019-02-04 18:07:28 -080011 sources = [
Jordan Baylesa26582d2019-07-10 14:44:58 -070012 "base/error.cc",
13 "base/error.h",
Yuri Wiitala22f643c2019-11-25 14:54:17 -080014 "base/interface_info.cc",
15 "base/interface_info.h",
Jordan Baylesa26582d2019-07-10 14:44:58 -070016 "base/ip_address.cc",
17 "base/ip_address.h",
18 "base/location.cc",
19 "base/location.h",
Jordan Bayles1c785bd2019-08-15 10:32:33 -070020 "base/socket_state.h",
21 "base/tls_connect_options.h",
22 "base/tls_credentials.cc",
23 "base/tls_credentials.h",
24 "base/tls_listen_options.h",
Yuri Wiitala8e6db3b2019-11-20 11:20:54 -080025 "base/trace_logging_activation.cc",
26 "base/trace_logging_activation.h",
27 "base/trace_logging_types.h",
Yuri Wiitalaf162a612019-11-22 22:46:04 -080028 "base/trivial_clock_traits.cc",
29 "base/trivial_clock_traits.h",
Yuri Wiitala977b6ef2019-11-07 17:08:25 -080030 "base/udp_packet.cc",
31 "base/udp_packet.h",
Yuri Wiitalab2d13232019-02-04 18:07:28 -080032 ]
Jordan Bayles9eb09742019-01-15 14:04:52 -080033
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080034 public_configs = [ "../build:openscreen_include_dirs" ]
35}
36
37# Public API source files. These may depend on nothing except :base.
38source_set("api") {
39 defines = []
40
41 sources = [
42 "api/export.h",
43 "api/logging.h",
44 "api/network_interface.h",
45 "api/scoped_wake_lock.cc",
46 "api/scoped_wake_lock.h",
47 "api/task_runner.h",
48 "api/time.h",
49 "api/tls_connection.cc",
50 "api/tls_connection.h",
51 "api/tls_connection_factory.cc",
52 "api/tls_connection_factory.h",
53 "api/trace_logging_platform.cc",
54 "api/trace_logging_platform.h",
55 "api/udp_socket.cc",
56 "api/udp_socket.h",
57 ]
58
Jordan Bayles9eb09742019-01-15 14:04:52 -080059 public_deps = [
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080060 ":base",
61 ]
62}
63
64# The following target is only activated in standalone builds (see :platform).
Jordan Bayles150295b2019-12-18 14:54:58 -080065if (!build_with_chromium) {
66 source_set("standalone_impl") {
67 defines = []
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080068
Jordan Bayles150295b2019-12-18 14:54:58 -080069 sources = [
70 "impl/logging.h",
Ryan Keaneb4d61bb2020-01-29 13:07:39 -080071 "impl/network_interface.cc",
72 "impl/network_interface.h",
Jordan Bayles150295b2019-12-18 14:54:58 -080073 "impl/socket_handle.h",
74 "impl/socket_handle_waiter.cc",
75 "impl/socket_handle_waiter.h",
76 "impl/stream_socket.h",
77 "impl/task_runner.cc",
78 "impl/task_runner.h",
79 "impl/text_trace_logging_platform.cc",
80 "impl/text_trace_logging_platform.h",
81 "impl/time.cc",
82 "impl/tls_write_buffer.cc",
83 "impl/tls_write_buffer.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080084 ]
85
Jordan Bayles56af85f2020-04-27 15:08:55 -070086 public_configs = [ "//util:trace_logging_config" ]
87
Jordan Bayles150295b2019-12-18 14:54:58 -080088 if (is_linux) {
Jordan Baylesc35af7d2020-03-24 08:15:00 -070089 sources += [
90 "impl/network_interface_linux.cc",
91 "impl/scoped_wake_lock_linux.cc",
92 "impl/scoped_wake_lock_linux.h",
93 ]
Jordan Bayles150295b2019-12-18 14:54:58 -080094 } else if (is_mac) {
95 defines += [
96 # Required, to use the new IPv6 Sockets options introduced by RFC 3542.
97 "__APPLE_USE_RFC_3542",
98 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080099
Jordan Bayles150295b2019-12-18 14:54:58 -0800100 libs = [
101 "CoreFoundation.framework",
102 "IOKit.framework",
103 ]
104
105 sources += [
106 "impl/network_interface_mac.cc",
107 "impl/scoped_wake_lock_mac.cc",
108 "impl/scoped_wake_lock_mac.h",
109 ]
110 }
111
112 if (is_posix) {
113 sources += [
114 "impl/logging_posix.cc",
115 "impl/platform_client_posix.cc",
116 "impl/platform_client_posix.h",
117 "impl/scoped_pipe.h",
118 "impl/socket_address_posix.cc",
119 "impl/socket_address_posix.h",
120 "impl/socket_handle_posix.cc",
121 "impl/socket_handle_posix.h",
122 "impl/socket_handle_waiter_posix.cc",
123 "impl/socket_handle_waiter_posix.h",
124 "impl/stream_socket_posix.cc",
125 "impl/stream_socket_posix.h",
126 "impl/timeval_posix.cc",
127 "impl/timeval_posix.h",
128 "impl/tls_connection_factory_posix.cc",
129 "impl/tls_connection_factory_posix.h",
130 "impl/tls_connection_posix.cc",
131 "impl/tls_connection_posix.h",
132 "impl/tls_data_router_posix.cc",
133 "impl/tls_data_router_posix.h",
134 "impl/udp_socket_posix.cc",
135 "impl/udp_socket_posix.h",
136 "impl/udp_socket_reader_posix.cc",
137 "impl/udp_socket_reader_posix.h",
138 ]
139 }
140
141 deps = [
142 ":api",
143 "../third_party/abseil",
144 "../third_party/boringssl",
145 "../util",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800146 ]
147 }
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800148}
Jordan Bayles9ade4152019-05-08 17:03:24 -0700149
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800150# The main target, which either assumes an embedder will link-in the platform
151# API implementation elsewhere, or links-in the :standalone_impl in the build.
152source_set("platform") {
153 public_deps = [
154 ":api",
155 ]
Jordan Baylesa80724b2019-05-02 17:17:26 -0700156 if (!build_with_chromium) {
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800157 deps = [
158 ":standalone_impl",
btolschc92ba2f2019-04-10 11:46:01 -0700159 ]
Yuri Wiitalab2d13232019-02-04 18:07:28 -0800160 }
btolsch9d6900c2018-05-30 18:22:53 -0700161}
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700162
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800163# Test helpers, referenced in other Open Screen BUILD.gn test targets.
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700164source_set("test") {
165 testonly = true
166 sources = [
167 "test/fake_clock.cc",
168 "test/fake_clock.h",
Yuri Wiitalaec353612019-06-18 17:32:39 -0700169 "test/fake_task_runner.cc",
170 "test/fake_task_runner.h",
Ryan Keane7d4b5fc2019-08-30 12:38:39 -0700171 "test/fake_udp_socket.cc",
172 "test/fake_udp_socket.h",
btolsch07bf81f2019-11-26 13:52:05 -0800173 "test/mock_tls_connection.h",
Ryan Keane1c693972020-03-11 15:26:28 -0700174 "test/mock_udp_socket.h",
btolsch31665eb2020-04-03 01:49:40 -0700175 "test/paths.h",
176 "test/paths_internal.h",
Ryan Keane38e7d512019-08-02 15:37:49 -0700177 "test/trace_logging_helpers.h",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700178 ]
179
btolsch31665eb2020-04-03 01:49:40 -0700180 if (is_posix) {
181 sources += [ "test/paths_posix.cc" ]
182 }
183 if (is_linux) {
184 sources += [ "test/paths_internal_linux.cc" ]
185 }
186 if (is_mac) {
187 sources += [ "test/paths_internal_mac.cc" ]
188 }
189
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700190 deps = [
191 ":platform",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800192 "../third_party/abseil",
Ryan Keanedeb48b32019-06-28 16:24:40 -0700193 "../third_party/googletest:gmock",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800194 "../util",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700195 ]
196}
197
mark a. foltz3fe46172019-09-18 05:50:30 -0700198source_set("unittests") {
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700199 testonly = true
200
201 sources = [
202 "api/time_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700203 "base/error_unittest.cc",
204 "base/ip_address_unittest.cc",
205 "base/location_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700206 ]
207
Jordan Bayles9ef84122020-04-27 12:08:38 -0700208 # The socket integration tests assume that you can Bind with UDP sockets,
209 # which is simply not true when we are built inside of Chromium.
210 if (!build_with_chromium) {
211 sources += [ "api/socket_integration_unittest.cc" ]
212 }
213
Jordan Baylescc471802019-07-09 14:25:02 -0700214 # The unit tests in impl/ assume the standalone implementation is being used.
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700215 # Exclude them if an embedder is providing the implementation.
216 if (!build_with_chromium) {
btolschc92ba2f2019-04-10 11:46:01 -0700217 sources += [
Jordan Baylesa26582d2019-07-10 14:44:58 -0700218 "impl/task_runner_unittest.cc",
Jordan Baylescc471802019-07-09 14:25:02 -0700219 "impl/time_unittest.cc",
btolschc92ba2f2019-04-10 11:46:01 -0700220 ]
Jordan Bayles063c3b52019-08-13 18:14:55 -0700221
Ryan Keane32c88d02019-07-02 18:46:14 -0700222 if (is_posix) {
Jordan Baylesa26582d2019-07-10 14:44:58 -0700223 sources += [
Jordan Baylesa26582d2019-07-10 14:44:58 -0700224 "impl/scoped_pipe_unittest.cc",
Jordan Bayles62b7c6a2019-08-15 10:32:33 -0700225 "impl/socket_address_posix_unittest.cc",
Ryan Keane2fdf9662019-09-25 13:29:32 -0700226 "impl/socket_handle_waiter_posix_unittest.cc",
mark a. foltzcbdea4b2019-11-18 16:49:14 -0800227 "impl/timeval_posix_unittest.cc",
Ryan Keaned838a252019-09-25 12:48:15 -0700228 "impl/tls_data_router_posix_unittest.cc",
Ryan Keanef2776122019-10-11 09:07:33 -0700229 "impl/tls_write_buffer_unittest.cc",
Ryan Keanee93f8c72019-09-25 12:35:00 -0700230 "impl/udp_socket_reader_posix_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700231 ]
Ryan Keane32c88d02019-07-02 18:46:14 -0700232 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700233 }
234
235 deps = [
236 ":platform",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800237 ":test",
238 "../third_party/abseil",
239 "../third_party/boringssl",
Ryan Keanedeb48b32019-06-28 16:24:40 -0700240 "../third_party/googletest:gmock",
btolsch4666ed22019-04-25 15:58:07 -0700241 "../third_party/googletest:gtest",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800242 "../util",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700243 ]
244}