blob: ef47f892ab302e33985270c3bb310e93d3797618 [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",
19 "base/tls_connect_options.h",
20 "base/tls_credentials.h",
21 "base/tls_listen_options.h",
22 "base/trace_logging_activation.h",
23 "base/trace_logging_types.h",
24 "base/trivial_clock_traits.h",
25 "base/udp_packet.h",
26 ]
Ryan Keane1d9c0c42019-07-29 15:22:19 -070027
Yuri Wiitalab2d13232019-02-04 18:07:28 -080028 sources = [
Jordan Baylesa26582d2019-07-10 14:44:58 -070029 "base/error.cc",
Yuri Wiitala22f643c2019-11-25 14:54:17 -080030 "base/interface_info.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -070031 "base/ip_address.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -070032 "base/location.cc",
Jordan Bayles1c785bd2019-08-15 10:32:33 -070033 "base/tls_credentials.cc",
Yuri Wiitala8e6db3b2019-11-20 11:20:54 -080034 "base/trace_logging_activation.cc",
Jordan Bayles20f3df62022-11-10 15:31:38 -080035 "base/trace_logging_types.cc",
Yuri Wiitalaf162a612019-11-22 22:46:04 -080036 "base/trivial_clock_traits.cc",
Yuri Wiitala977b6ef2019-11-07 17:08:25 -080037 "base/udp_packet.cc",
Yuri Wiitalab2d13232019-02-04 18:07:28 -080038 ]
Jordan Bayles9eb09742019-01-15 14:04:52 -080039
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080040 public_configs = [ "../build:openscreen_include_dirs" ]
41}
42
Ryan Keane37e21e82021-04-30 14:48:07 -070043# Public API source files. May depend on nothing except :base.
44source_set("logging") {
45 defines = []
mark a. foltz6e60fdc2022-10-27 17:05:39 -070046 visibility += [ "../util/*" ]
Ryan Keane37e21e82021-04-30 14:48:07 -070047
mark a. foltz5528ecf2022-08-24 10:26:08 -070048 public = [ "api/logging.h" ]
Ryan Keane37e21e82021-04-30 14:48:07 -070049
50 public_deps = [ ":base" ]
51}
52
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080053# Public API source files. These may depend on nothing except :base.
54source_set("api") {
55 defines = []
mark a. foltz6e60fdc2022-10-27 17:05:39 -070056 visibility += [ "*" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -070057 public = [
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080058 "api/export.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080059 "api/network_interface.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080060 "api/scoped_wake_lock.h",
Ryan Keanec2417882020-05-08 09:41:21 -070061 "api/serial_delete_ptr.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080062 "api/task_runner.h",
63 "api/time.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080064 "api/tls_connection.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080065 "api/tls_connection_factory.h",
Jordan Bayles20f3df62022-11-10 15:31:38 -080066 "api/trace_event.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080067 "api/trace_logging_platform.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080068 "api/udp_socket.h",
69 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -070070 sources = [
71 "api/scoped_wake_lock.cc",
72 "api/tls_connection.cc",
73 "api/tls_connection_factory.cc",
Jordan Bayles20f3df62022-11-10 15:31:38 -080074 "api/trace_event.cc",
mark a. foltz5528ecf2022-08-24 10:26:08 -070075 "api/trace_logging_platform.cc",
76 "api/udp_socket.cc",
77 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080078
Ryan Keane37e21e82021-04-30 14:48:07 -070079 public_deps = [
80 ":base",
81 ":logging",
82 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080083}
84
85# The following target is only activated in standalone builds (see :platform).
Jordan Bayles150295b2019-12-18 14:54:58 -080086if (!build_with_chromium) {
87 source_set("standalone_impl") {
88 defines = []
mark a. foltz6e60fdc2022-10-27 17:05:39 -070089 visibility += [ "../*" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -070090 public = [
Jordan Bayles150295b2019-12-18 14:54:58 -080091 "impl/logging.h",
Ryan Keaneb4d61bb2020-01-29 13:07:39 -080092 "impl/network_interface.h",
mark a. foltz5528ecf2022-08-24 10:26:08 -070093 "impl/task_runner.h",
94 "impl/text_trace_logging_platform.h",
95 ]
96 sources = [
97 "impl/network_interface.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -080098 "impl/socket_handle.h",
99 "impl/socket_handle_waiter.cc",
100 "impl/socket_handle_waiter.h",
Jordan Bayles8f0e0432021-02-01 12:07:16 -0800101 "impl/socket_state.h",
Jordan Bayles150295b2019-12-18 14:54:58 -0800102 "impl/stream_socket.h",
103 "impl/task_runner.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800104 "impl/text_trace_logging_platform.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800105 "impl/time.cc",
106 "impl/tls_write_buffer.cc",
107 "impl/tls_write_buffer.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800108 ]
109
Jordan Bayles56af85f2020-04-27 15:08:55 -0700110 public_configs = [ "//util:trace_logging_config" ]
111
Jordan Bayles150295b2019-12-18 14:54:58 -0800112 if (is_linux) {
Jordan Baylesc35af7d2020-03-24 08:15:00 -0700113 sources += [
114 "impl/network_interface_linux.cc",
115 "impl/scoped_wake_lock_linux.cc",
116 "impl/scoped_wake_lock_linux.h",
117 ]
Jordan Bayles150295b2019-12-18 14:54:58 -0800118 } else if (is_mac) {
119 defines += [
120 # Required, to use the new IPv6 Sockets options introduced by RFC 3542.
121 "__APPLE_USE_RFC_3542",
122 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800123
Jordan Bayles842767b2020-11-23 14:50:17 -0800124 frameworks = [
Jordan Bayles150295b2019-12-18 14:54:58 -0800125 "CoreFoundation.framework",
126 "IOKit.framework",
127 ]
128
129 sources += [
130 "impl/network_interface_mac.cc",
131 "impl/scoped_wake_lock_mac.cc",
132 "impl/scoped_wake_lock_mac.h",
133 ]
134 }
135
136 if (is_posix) {
mark a. foltz5528ecf2022-08-24 10:26:08 -0700137 public += [ "impl/platform_client_posix.h" ]
Jordan Bayles150295b2019-12-18 14:54:58 -0800138 sources += [
139 "impl/logging_posix.cc",
mark a. foltzd6a5a222020-07-28 17:28:06 -0700140 "impl/logging_test.h",
Jordan Bayles150295b2019-12-18 14:54:58 -0800141 "impl/platform_client_posix.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800142 "impl/scoped_pipe.h",
143 "impl/socket_address_posix.cc",
144 "impl/socket_address_posix.h",
145 "impl/socket_handle_posix.cc",
146 "impl/socket_handle_posix.h",
147 "impl/socket_handle_waiter_posix.cc",
148 "impl/socket_handle_waiter_posix.h",
149 "impl/stream_socket_posix.cc",
150 "impl/stream_socket_posix.h",
151 "impl/timeval_posix.cc",
152 "impl/timeval_posix.h",
153 "impl/tls_connection_factory_posix.cc",
154 "impl/tls_connection_factory_posix.h",
155 "impl/tls_connection_posix.cc",
156 "impl/tls_connection_posix.h",
157 "impl/tls_data_router_posix.cc",
158 "impl/tls_data_router_posix.h",
159 "impl/udp_socket_posix.cc",
160 "impl/udp_socket_posix.h",
161 "impl/udp_socket_reader_posix.cc",
162 "impl/udp_socket_reader_posix.h",
163 ]
164 }
165
166 deps = [
167 ":api",
168 "../third_party/abseil",
169 "../third_party/boringssl",
170 "../util",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800171 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700172 friend = [ ":unittests" ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800173 }
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800174}
Jordan Bayles9ade4152019-05-08 17:03:24 -0700175
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800176# The main target, which either assumes an embedder will link-in the platform
177# API implementation elsewhere, or links-in the :standalone_impl in the build.
178source_set("platform") {
mark a. foltz6e60fdc2022-10-27 17:05:39 -0700179 visibility += [ "*" ]
Ryan Keanec2417882020-05-08 09:41:21 -0700180 public_deps = [ ":api" ]
Jordan Baylesa80724b2019-05-02 17:17:26 -0700181 if (!build_with_chromium) {
Ryan Keanec2417882020-05-08 09:41:21 -0700182 deps = [ ":standalone_impl" ]
Yuri Wiitalab2d13232019-02-04 18:07:28 -0800183 }
btolsch9d6900c2018-05-30 18:22:53 -0700184}
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700185
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800186# Test helpers, referenced in other Open Screen BUILD.gn test targets.
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700187source_set("test") {
188 testonly = true
mark a. foltz6e60fdc2022-10-27 17:05:39 -0700189 visibility += [ "../*" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700190 public = [
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700191 "test/fake_clock.h",
Yuri Wiitalaec353612019-06-18 17:32:39 -0700192 "test/fake_task_runner.h",
Ryan Keane7d4b5fc2019-08-30 12:38:39 -0700193 "test/fake_udp_socket.h",
btolsch07bf81f2019-11-26 13:52:05 -0800194 "test/mock_tls_connection.h",
Ryan Keane1c693972020-03-11 15:26:28 -0700195 "test/mock_udp_socket.h",
btolsch31665eb2020-04-03 01:49:40 -0700196 "test/paths.h",
Ryan Keane38e7d512019-08-02 15:37:49 -0700197 "test/trace_logging_helpers.h",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700198 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700199 sources = [
200 "test/fake_clock.cc",
201 "test/fake_task_runner.cc",
202 "test/fake_udp_socket.cc",
203 "test/paths_internal.h",
204 ]
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700205
btolsch31665eb2020-04-03 01:49:40 -0700206 if (is_posix) {
207 sources += [ "test/paths_posix.cc" ]
208 }
209 if (is_linux) {
210 sources += [ "test/paths_internal_linux.cc" ]
btolschb586d7a2020-04-30 15:53:15 -0700211 } else if (is_mac) {
btolsch31665eb2020-04-03 01:49:40 -0700212 sources += [ "test/paths_internal_mac.cc" ]
btolschb586d7a2020-04-30 15:53:15 -0700213 } else if (build_with_chromium) {
214 # NOTE: This is used to resolve a linking issue when compiling in Chromium
215 # for other platforms, but nothing in here is called.
216 sources += [ "test/paths_internal_other.cc" ]
btolsch31665eb2020-04-03 01:49:40 -0700217 }
218
btolsch9d9da7b2021-02-09 10:39:30 -0800219 public_deps = [
220 ":api",
221 ":base",
222 ]
223
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700224 deps = [
225 ":platform",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800226 "../third_party/abseil",
Ryan Keanedeb48b32019-06-28 16:24:40 -0700227 "../third_party/googletest:gmock",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800228 "../util",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700229 ]
230}
231
mark a. foltz3fe46172019-09-18 05:50:30 -0700232source_set("unittests") {
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700233 testonly = true
mark a. foltz6e60fdc2022-10-27 17:05:39 -0700234 visibility += [ "..:openscreen_unittests_all" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700235 public = []
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700236 sources = [
Ryan Keanec2417882020-05-08 09:41:21 -0700237 "api/serial_delete_ptr_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700238 "api/time_unittest.cc",
mark a. foltzeca304d2023-01-25 13:45:44 -0800239 "base/byte_view_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700240 "base/error_unittest.cc",
241 "base/ip_address_unittest.cc",
242 "base/location_unittest.cc",
Ryan Keane3e5d23e2020-06-10 09:56:11 -0700243 "base/udp_packet_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700244 ]
245
Jordan Baylesf3b911c2021-06-22 11:28:50 -0700246 deps = [
247 ":platform",
248 ":test",
249 "../third_party/abseil",
250 "../third_party/boringssl",
251 "../third_party/googletest:gmock",
252 "../third_party/googletest:gtest",
253 "../util",
254 ]
255
Jordan Baylesc1804992022-08-30 17:10:11 +0000256 # The socket integration tests assume that you can Bind with UDP sockets,
257 # which is simply not true when we are built inside of Chromium.
Jordan Bayles9ef84122020-04-27 12:08:38 -0700258 if (!build_with_chromium) {
Jordan Baylesc1804992022-08-30 17:10:11 +0000259 sources += [ "api/socket_integration_unittest.cc" ]
260
Jordan Baylesf3b911c2021-06-22 11:28:50 -0700261 deps += [ ":standalone_impl" ]
Jordan Bayles9ef84122020-04-27 12:08:38 -0700262 }
263
Jordan Baylescc471802019-07-09 14:25:02 -0700264 # The unit tests in impl/ assume the standalone implementation is being used.
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700265 # Exclude them if an embedder is providing the implementation.
266 if (!build_with_chromium) {
btolschc92ba2f2019-04-10 11:46:01 -0700267 sources += [
Jordan Baylesa26582d2019-07-10 14:44:58 -0700268 "impl/task_runner_unittest.cc",
Jordan Baylescc471802019-07-09 14:25:02 -0700269 "impl/time_unittest.cc",
btolschc92ba2f2019-04-10 11:46:01 -0700270 ]
Jordan Bayles063c3b52019-08-13 18:14:55 -0700271
Ryan Keane32c88d02019-07-02 18:46:14 -0700272 if (is_posix) {
Jordan Baylesa26582d2019-07-10 14:44:58 -0700273 sources += [
mark a. foltzd6a5a222020-07-28 17:28:06 -0700274 "impl/logging_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700275 "impl/scoped_pipe_unittest.cc",
Jordan Bayles62b7c6a2019-08-15 10:32:33 -0700276 "impl/socket_address_posix_unittest.cc",
Ryan Keane2fdf9662019-09-25 13:29:32 -0700277 "impl/socket_handle_waiter_posix_unittest.cc",
mark a. foltzcbdea4b2019-11-18 16:49:14 -0800278 "impl/timeval_posix_unittest.cc",
Ryan Keaned838a252019-09-25 12:48:15 -0700279 "impl/tls_data_router_posix_unittest.cc",
Ryan Keanef2776122019-10-11 09:07:33 -0700280 "impl/tls_write_buffer_unittest.cc",
Ryan Keanee93f8c72019-09-25 12:35:00 -0700281 "impl/udp_socket_reader_posix_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700282 ]
Ryan Keane32c88d02019-07-02 18:46:14 -0700283 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700284 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700285}