blob: c2d9f357fcad737928bb21e59865b25cf56a9da3 [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
mark a. foltz6e60fdc2022-10-27 17:05:39 -07007visibility = [ "./*" ]
8
Yuri Wiitalaca24ee52019-12-05 16:51:42 -08009# Source files that depend on nothing (all your base/ are belong to us).
10source_set("base") {
Ryan Keane1d9c0c42019-07-29 15:22:19 -070011 defines = []
mark a. foltz6e60fdc2022-10-27 17:05:39 -070012 visibility += [ "*" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -070013 public = [
mark a. foltzeca304d2023-01-25 13:45:44 -080014 "base/byte_view.h",
mark a. foltz5528ecf2022-08-24 10:26:08 -070015 "base/error.h",
16 "base/interface_info.h",
17 "base/ip_address.h",
18 "base/location.h",
mark a. foltzcf5b8ca2023-02-07 14:44:54 -080019 "base/span.h",
mark a. foltz5528ecf2022-08-24 10:26:08 -070020 "base/tls_connect_options.h",
21 "base/tls_credentials.h",
22 "base/tls_listen_options.h",
23 "base/trace_logging_activation.h",
24 "base/trace_logging_types.h",
25 "base/trivial_clock_traits.h",
26 "base/udp_packet.h",
27 ]
Ryan Keane1d9c0c42019-07-29 15:22:19 -070028
Yuri Wiitalab2d13232019-02-04 18:07:28 -080029 sources = [
Jordan Baylesa26582d2019-07-10 14:44:58 -070030 "base/error.cc",
Yuri Wiitala22f643c2019-11-25 14:54:17 -080031 "base/interface_info.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -070032 "base/ip_address.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -070033 "base/location.cc",
Jordan Bayles1c785bd2019-08-15 10:32:33 -070034 "base/tls_credentials.cc",
Yuri Wiitala8e6db3b2019-11-20 11:20:54 -080035 "base/trace_logging_activation.cc",
Jordan Bayles20f3df62022-11-10 15:31:38 -080036 "base/trace_logging_types.cc",
Yuri Wiitalaf162a612019-11-22 22:46:04 -080037 "base/trivial_clock_traits.cc",
Yuri Wiitala977b6ef2019-11-07 17:08:25 -080038 "base/udp_packet.cc",
Yuri Wiitalab2d13232019-02-04 18:07:28 -080039 ]
Jordan Bayles9eb09742019-01-15 14:04:52 -080040
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080041 public_configs = [ "../build:openscreen_include_dirs" ]
42}
43
Ryan Keane37e21e82021-04-30 14:48:07 -070044# Public API source files. May depend on nothing except :base.
45source_set("logging") {
46 defines = []
mark a. foltz6e60fdc2022-10-27 17:05:39 -070047 visibility += [ "../util/*" ]
Ryan Keane37e21e82021-04-30 14:48:07 -070048
mark a. foltz5528ecf2022-08-24 10:26:08 -070049 public = [ "api/logging.h" ]
Ryan Keane37e21e82021-04-30 14:48:07 -070050
51 public_deps = [ ":base" ]
52}
53
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080054# Public API source files. These may depend on nothing except :base.
55source_set("api") {
56 defines = []
mark a. foltz6e60fdc2022-10-27 17:05:39 -070057 visibility += [ "*" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -070058 public = [
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080059 "api/export.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080060 "api/network_interface.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080061 "api/scoped_wake_lock.h",
Ryan Keanec2417882020-05-08 09:41:21 -070062 "api/serial_delete_ptr.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080063 "api/task_runner.h",
64 "api/time.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080065 "api/tls_connection.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080066 "api/tls_connection_factory.h",
Jordan Bayles20f3df62022-11-10 15:31:38 -080067 "api/trace_event.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080068 "api/trace_logging_platform.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080069 "api/udp_socket.h",
70 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -070071 sources = [
72 "api/scoped_wake_lock.cc",
73 "api/tls_connection.cc",
74 "api/tls_connection_factory.cc",
Jordan Bayles20f3df62022-11-10 15:31:38 -080075 "api/trace_event.cc",
mark a. foltz5528ecf2022-08-24 10:26:08 -070076 "api/trace_logging_platform.cc",
77 "api/udp_socket.cc",
78 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080079
Ryan Keane37e21e82021-04-30 14:48:07 -070080 public_deps = [
81 ":base",
82 ":logging",
83 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080084}
85
86# The following target is only activated in standalone builds (see :platform).
Jordan Bayles150295b2019-12-18 14:54:58 -080087if (!build_with_chromium) {
88 source_set("standalone_impl") {
89 defines = []
mark a. foltz6e60fdc2022-10-27 17:05:39 -070090 visibility += [ "../*" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -070091 public = [
Jordan Bayles150295b2019-12-18 14:54:58 -080092 "impl/logging.h",
Ryan Keaneb4d61bb2020-01-29 13:07:39 -080093 "impl/network_interface.h",
mark a. foltz5528ecf2022-08-24 10:26:08 -070094 "impl/task_runner.h",
95 "impl/text_trace_logging_platform.h",
96 ]
97 sources = [
98 "impl/network_interface.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -080099 "impl/socket_handle.h",
100 "impl/socket_handle_waiter.cc",
101 "impl/socket_handle_waiter.h",
Jordan Bayles8f0e0432021-02-01 12:07:16 -0800102 "impl/socket_state.h",
Jordan Bayles150295b2019-12-18 14:54:58 -0800103 "impl/stream_socket.h",
104 "impl/task_runner.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800105 "impl/text_trace_logging_platform.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800106 "impl/time.cc",
107 "impl/tls_write_buffer.cc",
108 "impl/tls_write_buffer.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800109 ]
110
Jordan Bayles56af85f2020-04-27 15:08:55 -0700111 public_configs = [ "//util:trace_logging_config" ]
112
Jordan Bayles150295b2019-12-18 14:54:58 -0800113 if (is_linux) {
Jordan Baylesc35af7d2020-03-24 08:15:00 -0700114 sources += [
115 "impl/network_interface_linux.cc",
116 "impl/scoped_wake_lock_linux.cc",
117 "impl/scoped_wake_lock_linux.h",
118 ]
Jordan Bayles150295b2019-12-18 14:54:58 -0800119 } else if (is_mac) {
120 defines += [
121 # Required, to use the new IPv6 Sockets options introduced by RFC 3542.
122 "__APPLE_USE_RFC_3542",
123 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800124
Jordan Bayles842767b2020-11-23 14:50:17 -0800125 frameworks = [
Jordan Bayles150295b2019-12-18 14:54:58 -0800126 "CoreFoundation.framework",
127 "IOKit.framework",
128 ]
129
130 sources += [
131 "impl/network_interface_mac.cc",
132 "impl/scoped_wake_lock_mac.cc",
133 "impl/scoped_wake_lock_mac.h",
134 ]
135 }
136
137 if (is_posix) {
mark a. foltz5528ecf2022-08-24 10:26:08 -0700138 public += [ "impl/platform_client_posix.h" ]
Jordan Bayles150295b2019-12-18 14:54:58 -0800139 sources += [
140 "impl/logging_posix.cc",
mark a. foltzd6a5a222020-07-28 17:28:06 -0700141 "impl/logging_test.h",
Jordan Bayles150295b2019-12-18 14:54:58 -0800142 "impl/platform_client_posix.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800143 "impl/scoped_pipe.h",
144 "impl/socket_address_posix.cc",
145 "impl/socket_address_posix.h",
146 "impl/socket_handle_posix.cc",
147 "impl/socket_handle_posix.h",
148 "impl/socket_handle_waiter_posix.cc",
149 "impl/socket_handle_waiter_posix.h",
150 "impl/stream_socket_posix.cc",
151 "impl/stream_socket_posix.h",
152 "impl/timeval_posix.cc",
153 "impl/timeval_posix.h",
154 "impl/tls_connection_factory_posix.cc",
155 "impl/tls_connection_factory_posix.h",
156 "impl/tls_connection_posix.cc",
157 "impl/tls_connection_posix.h",
158 "impl/tls_data_router_posix.cc",
159 "impl/tls_data_router_posix.h",
160 "impl/udp_socket_posix.cc",
161 "impl/udp_socket_posix.h",
162 "impl/udp_socket_reader_posix.cc",
163 "impl/udp_socket_reader_posix.h",
164 ]
165 }
166
167 deps = [
168 ":api",
169 "../third_party/abseil",
170 "../third_party/boringssl",
171 "../util",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800172 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700173 friend = [ ":unittests" ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800174 }
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800175}
Jordan Bayles9ade4152019-05-08 17:03:24 -0700176
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800177# The main target, which either assumes an embedder will link-in the platform
178# API implementation elsewhere, or links-in the :standalone_impl in the build.
179source_set("platform") {
mark a. foltz6e60fdc2022-10-27 17:05:39 -0700180 visibility += [ "*" ]
Ryan Keanec2417882020-05-08 09:41:21 -0700181 public_deps = [ ":api" ]
Jordan Baylesa80724b2019-05-02 17:17:26 -0700182 if (!build_with_chromium) {
Ryan Keanec2417882020-05-08 09:41:21 -0700183 deps = [ ":standalone_impl" ]
Yuri Wiitalab2d13232019-02-04 18:07:28 -0800184 }
btolsch9d6900c2018-05-30 18:22:53 -0700185}
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700186
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800187# Test helpers, referenced in other Open Screen BUILD.gn test targets.
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700188source_set("test") {
189 testonly = true
mark a. foltz6e60fdc2022-10-27 17:05:39 -0700190 visibility += [ "../*" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700191 public = [
mark a. foltzccc269d2023-01-31 10:28:21 -0800192 "test/byte_view_test_util.h",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700193 "test/fake_clock.h",
Yuri Wiitalaec353612019-06-18 17:32:39 -0700194 "test/fake_task_runner.h",
Ryan Keane7d4b5fc2019-08-30 12:38:39 -0700195 "test/fake_udp_socket.h",
btolsch07bf81f2019-11-26 13:52:05 -0800196 "test/mock_tls_connection.h",
Ryan Keane1c693972020-03-11 15:26:28 -0700197 "test/mock_udp_socket.h",
btolsch31665eb2020-04-03 01:49:40 -0700198 "test/paths.h",
Ryan Keane38e7d512019-08-02 15:37:49 -0700199 "test/trace_logging_helpers.h",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700200 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700201 sources = [
mark a. foltzccc269d2023-01-31 10:28:21 -0800202 "test/byte_view_test_util.cc",
mark a. foltz5528ecf2022-08-24 10:26:08 -0700203 "test/fake_clock.cc",
204 "test/fake_task_runner.cc",
205 "test/fake_udp_socket.cc",
206 "test/paths_internal.h",
207 ]
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700208
btolsch31665eb2020-04-03 01:49:40 -0700209 if (is_posix) {
210 sources += [ "test/paths_posix.cc" ]
211 }
212 if (is_linux) {
213 sources += [ "test/paths_internal_linux.cc" ]
btolschb586d7a2020-04-30 15:53:15 -0700214 } else if (is_mac) {
btolsch31665eb2020-04-03 01:49:40 -0700215 sources += [ "test/paths_internal_mac.cc" ]
btolschb586d7a2020-04-30 15:53:15 -0700216 } else if (build_with_chromium) {
217 # NOTE: This is used to resolve a linking issue when compiling in Chromium
218 # for other platforms, but nothing in here is called.
219 sources += [ "test/paths_internal_other.cc" ]
btolsch31665eb2020-04-03 01:49:40 -0700220 }
221
btolsch9d9da7b2021-02-09 10:39:30 -0800222 public_deps = [
223 ":api",
224 ":base",
225 ]
226
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700227 deps = [
228 ":platform",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800229 "../third_party/abseil",
Ryan Keanedeb48b32019-06-28 16:24:40 -0700230 "../third_party/googletest:gmock",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800231 "../util",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700232 ]
233}
234
mark a. foltz3fe46172019-09-18 05:50:30 -0700235source_set("unittests") {
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700236 testonly = true
mark a. foltz6e60fdc2022-10-27 17:05:39 -0700237 visibility += [ "..:openscreen_unittests_all" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700238 public = []
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700239 sources = [
Ryan Keanec2417882020-05-08 09:41:21 -0700240 "api/serial_delete_ptr_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700241 "api/time_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700242 "base/error_unittest.cc",
243 "base/ip_address_unittest.cc",
244 "base/location_unittest.cc",
mark a. foltzcf5b8ca2023-02-07 14:44:54 -0800245 "base/span_unittest.cc",
Ryan Keane3e5d23e2020-06-10 09:56:11 -0700246 "base/udp_packet_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700247 ]
248
Jordan Baylesf3b911c2021-06-22 11:28:50 -0700249 deps = [
250 ":platform",
251 ":test",
252 "../third_party/abseil",
253 "../third_party/boringssl",
254 "../third_party/googletest:gmock",
255 "../third_party/googletest:gtest",
256 "../util",
257 ]
258
Jordan Baylesc1804992022-08-30 17:10:11 +0000259 # The socket integration tests assume that you can Bind with UDP sockets,
260 # which is simply not true when we are built inside of Chromium.
Jordan Bayles9ef84122020-04-27 12:08:38 -0700261 if (!build_with_chromium) {
Jordan Baylesc1804992022-08-30 17:10:11 +0000262 sources += [ "api/socket_integration_unittest.cc" ]
263
Jordan Baylesf3b911c2021-06-22 11:28:50 -0700264 deps += [ ":standalone_impl" ]
Jordan Bayles9ef84122020-04-27 12:08:38 -0700265 }
266
Jordan Baylescc471802019-07-09 14:25:02 -0700267 # The unit tests in impl/ assume the standalone implementation is being used.
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700268 # Exclude them if an embedder is providing the implementation.
269 if (!build_with_chromium) {
btolschc92ba2f2019-04-10 11:46:01 -0700270 sources += [
Jordan Baylesa26582d2019-07-10 14:44:58 -0700271 "impl/task_runner_unittest.cc",
Jordan Baylescc471802019-07-09 14:25:02 -0700272 "impl/time_unittest.cc",
btolschc92ba2f2019-04-10 11:46:01 -0700273 ]
Jordan Bayles063c3b52019-08-13 18:14:55 -0700274
Ryan Keane32c88d02019-07-02 18:46:14 -0700275 if (is_posix) {
Jordan Baylesa26582d2019-07-10 14:44:58 -0700276 sources += [
mark a. foltzd6a5a222020-07-28 17:28:06 -0700277 "impl/logging_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700278 "impl/scoped_pipe_unittest.cc",
Jordan Bayles62b7c6a2019-08-15 10:32:33 -0700279 "impl/socket_address_posix_unittest.cc",
Ryan Keane2fdf9662019-09-25 13:29:32 -0700280 "impl/socket_handle_waiter_posix_unittest.cc",
mark a. foltzcbdea4b2019-11-18 16:49:14 -0800281 "impl/timeval_posix_unittest.cc",
Ryan Keaned838a252019-09-25 12:48:15 -0700282 "impl/tls_data_router_posix_unittest.cc",
Ryan Keanef2776122019-10-11 09:07:33 -0700283 "impl/tls_write_buffer_unittest.cc",
Ryan Keanee93f8c72019-09-25 12:35:00 -0700284 "impl/udp_socket_reader_posix_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700285 ]
Ryan Keane32c88d02019-07-02 18:46:14 -0700286 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700287 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700288}