blob: aa4b7bd9fe7cfd105ea11b7865b6c75f09c54de5 [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 = []
mark a. foltz5528ecf2022-08-24 10:26:08 -070010 visibility = [ "*" ]
11 public = [
12 "base/error.h",
13 "base/interface_info.h",
14 "base/ip_address.h",
15 "base/location.h",
16 "base/tls_connect_options.h",
17 "base/tls_credentials.h",
18 "base/tls_listen_options.h",
19 "base/trace_logging_activation.h",
20 "base/trace_logging_types.h",
21 "base/trivial_clock_traits.h",
22 "base/udp_packet.h",
23 ]
Ryan Keane1d9c0c42019-07-29 15:22:19 -070024
Yuri Wiitalab2d13232019-02-04 18:07:28 -080025 sources = [
Jordan Baylesa26582d2019-07-10 14:44:58 -070026 "base/error.cc",
Yuri Wiitala22f643c2019-11-25 14:54:17 -080027 "base/interface_info.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -070028 "base/ip_address.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -070029 "base/location.cc",
Jordan Bayles1c785bd2019-08-15 10:32:33 -070030 "base/tls_credentials.cc",
Yuri Wiitala8e6db3b2019-11-20 11:20:54 -080031 "base/trace_logging_activation.cc",
Yuri Wiitalaf162a612019-11-22 22:46:04 -080032 "base/trivial_clock_traits.cc",
Yuri Wiitala977b6ef2019-11-07 17:08:25 -080033 "base/udp_packet.cc",
Yuri Wiitalab2d13232019-02-04 18:07:28 -080034 ]
Jordan Bayles9eb09742019-01-15 14:04:52 -080035
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080036 public_configs = [ "../build:openscreen_include_dirs" ]
37}
38
Ryan Keane37e21e82021-04-30 14:48:07 -070039# Public API source files. May depend on nothing except :base.
40source_set("logging") {
41 defines = []
mark a. foltz5528ecf2022-08-24 10:26:08 -070042 visibility = [
43 ":*",
44 "../util/*",
45 ]
Ryan Keane37e21e82021-04-30 14:48:07 -070046
mark a. foltz5528ecf2022-08-24 10:26:08 -070047 public = [ "api/logging.h" ]
Ryan Keane37e21e82021-04-30 14:48:07 -070048
49 public_deps = [ ":base" ]
50}
51
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080052# Public API source files. These may depend on nothing except :base.
53source_set("api") {
54 defines = []
mark a. foltz5528ecf2022-08-24 10:26:08 -070055 visibility = [ "*" ]
56 public = [
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080057 "api/export.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080058 "api/network_interface.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080059 "api/scoped_wake_lock.h",
Ryan Keanec2417882020-05-08 09:41:21 -070060 "api/serial_delete_ptr.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080061 "api/task_runner.h",
62 "api/time.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080063 "api/tls_connection.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080064 "api/tls_connection_factory.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080065 "api/trace_logging_platform.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080066 "api/udp_socket.h",
67 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -070068 sources = [
69 "api/scoped_wake_lock.cc",
70 "api/tls_connection.cc",
71 "api/tls_connection_factory.cc",
72 "api/trace_logging_platform.cc",
73 "api/udp_socket.cc",
74 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080075
Ryan Keane37e21e82021-04-30 14:48:07 -070076 public_deps = [
77 ":base",
78 ":logging",
79 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080080}
81
82# The following target is only activated in standalone builds (see :platform).
Jordan Bayles150295b2019-12-18 14:54:58 -080083if (!build_with_chromium) {
84 source_set("standalone_impl") {
85 defines = []
mark a. foltz5528ecf2022-08-24 10:26:08 -070086 visibility = [ "../*" ]
87 public = [
Jordan Bayles150295b2019-12-18 14:54:58 -080088 "impl/logging.h",
Ryan Keaneb4d61bb2020-01-29 13:07:39 -080089 "impl/network_interface.h",
mark a. foltz5528ecf2022-08-24 10:26:08 -070090 "impl/task_runner.h",
91 "impl/text_trace_logging_platform.h",
92 ]
93 sources = [
94 "impl/network_interface.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -080095 "impl/socket_handle.h",
96 "impl/socket_handle_waiter.cc",
97 "impl/socket_handle_waiter.h",
Jordan Bayles8f0e0432021-02-01 12:07:16 -080098 "impl/socket_state.h",
Jordan Bayles150295b2019-12-18 14:54:58 -080099 "impl/stream_socket.h",
100 "impl/task_runner.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800101 "impl/text_trace_logging_platform.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800102 "impl/time.cc",
103 "impl/tls_write_buffer.cc",
104 "impl/tls_write_buffer.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800105 ]
106
Jordan Bayles56af85f2020-04-27 15:08:55 -0700107 public_configs = [ "//util:trace_logging_config" ]
108
Jordan Bayles150295b2019-12-18 14:54:58 -0800109 if (is_linux) {
Jordan Baylesc35af7d2020-03-24 08:15:00 -0700110 sources += [
111 "impl/network_interface_linux.cc",
112 "impl/scoped_wake_lock_linux.cc",
113 "impl/scoped_wake_lock_linux.h",
114 ]
Jordan Bayles150295b2019-12-18 14:54:58 -0800115 } else if (is_mac) {
116 defines += [
117 # Required, to use the new IPv6 Sockets options introduced by RFC 3542.
118 "__APPLE_USE_RFC_3542",
119 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800120
Jordan Bayles842767b2020-11-23 14:50:17 -0800121 frameworks = [
Jordan Bayles150295b2019-12-18 14:54:58 -0800122 "CoreFoundation.framework",
123 "IOKit.framework",
124 ]
125
126 sources += [
127 "impl/network_interface_mac.cc",
128 "impl/scoped_wake_lock_mac.cc",
129 "impl/scoped_wake_lock_mac.h",
130 ]
131 }
132
133 if (is_posix) {
mark a. foltz5528ecf2022-08-24 10:26:08 -0700134 public += [ "impl/platform_client_posix.h" ]
Jordan Bayles150295b2019-12-18 14:54:58 -0800135 sources += [
136 "impl/logging_posix.cc",
mark a. foltzd6a5a222020-07-28 17:28:06 -0700137 "impl/logging_test.h",
Jordan Bayles150295b2019-12-18 14:54:58 -0800138 "impl/platform_client_posix.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800139 "impl/scoped_pipe.h",
140 "impl/socket_address_posix.cc",
141 "impl/socket_address_posix.h",
142 "impl/socket_handle_posix.cc",
143 "impl/socket_handle_posix.h",
144 "impl/socket_handle_waiter_posix.cc",
145 "impl/socket_handle_waiter_posix.h",
146 "impl/stream_socket_posix.cc",
147 "impl/stream_socket_posix.h",
148 "impl/timeval_posix.cc",
149 "impl/timeval_posix.h",
150 "impl/tls_connection_factory_posix.cc",
151 "impl/tls_connection_factory_posix.h",
152 "impl/tls_connection_posix.cc",
153 "impl/tls_connection_posix.h",
154 "impl/tls_data_router_posix.cc",
155 "impl/tls_data_router_posix.h",
156 "impl/udp_socket_posix.cc",
157 "impl/udp_socket_posix.h",
158 "impl/udp_socket_reader_posix.cc",
159 "impl/udp_socket_reader_posix.h",
160 ]
161 }
162
163 deps = [
164 ":api",
165 "../third_party/abseil",
166 "../third_party/boringssl",
167 "../util",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800168 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700169 friend = [ ":unittests" ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800170 }
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800171}
Jordan Bayles9ade4152019-05-08 17:03:24 -0700172
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800173# The main target, which either assumes an embedder will link-in the platform
174# API implementation elsewhere, or links-in the :standalone_impl in the build.
175source_set("platform") {
mark a. foltz5528ecf2022-08-24 10:26:08 -0700176 visibility = [ "*" ]
Ryan Keanec2417882020-05-08 09:41:21 -0700177 public_deps = [ ":api" ]
Jordan Baylesa80724b2019-05-02 17:17:26 -0700178 if (!build_with_chromium) {
Ryan Keanec2417882020-05-08 09:41:21 -0700179 deps = [ ":standalone_impl" ]
Yuri Wiitalab2d13232019-02-04 18:07:28 -0800180 }
btolsch9d6900c2018-05-30 18:22:53 -0700181}
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700182
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800183# Test helpers, referenced in other Open Screen BUILD.gn test targets.
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700184source_set("test") {
185 testonly = true
mark a. foltz5528ecf2022-08-24 10:26:08 -0700186 visibility = [ "../*" ]
187 public = [
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700188 "test/fake_clock.h",
Yuri Wiitalaec353612019-06-18 17:32:39 -0700189 "test/fake_task_runner.h",
Ryan Keane7d4b5fc2019-08-30 12:38:39 -0700190 "test/fake_udp_socket.h",
btolsch07bf81f2019-11-26 13:52:05 -0800191 "test/mock_tls_connection.h",
Ryan Keane1c693972020-03-11 15:26:28 -0700192 "test/mock_udp_socket.h",
btolsch31665eb2020-04-03 01:49:40 -0700193 "test/paths.h",
Ryan Keane38e7d512019-08-02 15:37:49 -0700194 "test/trace_logging_helpers.h",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700195 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700196 sources = [
197 "test/fake_clock.cc",
198 "test/fake_task_runner.cc",
199 "test/fake_udp_socket.cc",
200 "test/paths_internal.h",
201 ]
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700202
btolsch31665eb2020-04-03 01:49:40 -0700203 if (is_posix) {
204 sources += [ "test/paths_posix.cc" ]
205 }
206 if (is_linux) {
207 sources += [ "test/paths_internal_linux.cc" ]
btolschb586d7a2020-04-30 15:53:15 -0700208 } else if (is_mac) {
btolsch31665eb2020-04-03 01:49:40 -0700209 sources += [ "test/paths_internal_mac.cc" ]
btolschb586d7a2020-04-30 15:53:15 -0700210 } else if (build_with_chromium) {
211 # NOTE: This is used to resolve a linking issue when compiling in Chromium
212 # for other platforms, but nothing in here is called.
213 sources += [ "test/paths_internal_other.cc" ]
btolsch31665eb2020-04-03 01:49:40 -0700214 }
215
btolsch9d9da7b2021-02-09 10:39:30 -0800216 public_deps = [
217 ":api",
218 ":base",
219 ]
220
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700221 deps = [
222 ":platform",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800223 "../third_party/abseil",
Ryan Keanedeb48b32019-06-28 16:24:40 -0700224 "../third_party/googletest:gmock",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800225 "../util",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700226 ]
227}
228
mark a. foltz3fe46172019-09-18 05:50:30 -0700229source_set("unittests") {
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700230 testonly = true
mark a. foltz5528ecf2022-08-24 10:26:08 -0700231 visibility = [ "..:openscreen_unittests_all" ]
232 public = []
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700233 sources = [
Ryan Keanec2417882020-05-08 09:41:21 -0700234 "api/serial_delete_ptr_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700235 "api/time_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700236 "base/error_unittest.cc",
237 "base/ip_address_unittest.cc",
238 "base/location_unittest.cc",
Ryan Keane3e5d23e2020-06-10 09:56:11 -0700239 "base/udp_packet_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700240 ]
241
Jordan Baylesf3b911c2021-06-22 11:28:50 -0700242 deps = [
243 ":platform",
244 ":test",
245 "../third_party/abseil",
246 "../third_party/boringssl",
247 "../third_party/googletest:gmock",
248 "../third_party/googletest:gtest",
249 "../util",
250 ]
251
Jordan Baylesc1804992022-08-30 17:10:11 +0000252 # The socket integration tests assume that you can Bind with UDP sockets,
253 # which is simply not true when we are built inside of Chromium.
Jordan Bayles9ef84122020-04-27 12:08:38 -0700254 if (!build_with_chromium) {
Jordan Baylesc1804992022-08-30 17:10:11 +0000255 sources += [ "api/socket_integration_unittest.cc" ]
256
Jordan Baylesf3b911c2021-06-22 11:28:50 -0700257 deps += [ ":standalone_impl" ]
Jordan Bayles9ef84122020-04-27 12:08:38 -0700258 }
259
Jordan Baylescc471802019-07-09 14:25:02 -0700260 # The unit tests in impl/ assume the standalone implementation is being used.
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700261 # Exclude them if an embedder is providing the implementation.
262 if (!build_with_chromium) {
btolschc92ba2f2019-04-10 11:46:01 -0700263 sources += [
Jordan Baylesa26582d2019-07-10 14:44:58 -0700264 "impl/task_runner_unittest.cc",
Jordan Baylescc471802019-07-09 14:25:02 -0700265 "impl/time_unittest.cc",
btolschc92ba2f2019-04-10 11:46:01 -0700266 ]
Jordan Bayles063c3b52019-08-13 18:14:55 -0700267
Ryan Keane32c88d02019-07-02 18:46:14 -0700268 if (is_posix) {
Jordan Baylesa26582d2019-07-10 14:44:58 -0700269 sources += [
mark a. foltzd6a5a222020-07-28 17:28:06 -0700270 "impl/logging_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700271 "impl/scoped_pipe_unittest.cc",
Jordan Bayles62b7c6a2019-08-15 10:32:33 -0700272 "impl/socket_address_posix_unittest.cc",
Ryan Keane2fdf9662019-09-25 13:29:32 -0700273 "impl/socket_handle_waiter_posix_unittest.cc",
mark a. foltzcbdea4b2019-11-18 16:49:14 -0800274 "impl/timeval_posix_unittest.cc",
Ryan Keaned838a252019-09-25 12:48:15 -0700275 "impl/tls_data_router_posix_unittest.cc",
Ryan Keanef2776122019-10-11 09:07:33 -0700276 "impl/tls_write_buffer_unittest.cc",
Ryan Keanee93f8c72019-09-25 12:35:00 -0700277 "impl/udp_socket_reader_posix_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700278 ]
Ryan Keane32c88d02019-07-02 18:46:14 -0700279 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700280 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700281}