blob: bd4068aed3581be8a82b788bb819ffb4047fcfdc [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 = [
14 "base/error.h",
15 "base/interface_info.h",
16 "base/ip_address.h",
17 "base/location.h",
18 "base/tls_connect_options.h",
19 "base/tls_credentials.h",
20 "base/tls_listen_options.h",
21 "base/trace_logging_activation.h",
22 "base/trace_logging_types.h",
23 "base/trivial_clock_traits.h",
24 "base/udp_packet.h",
25 ]
Ryan Keane1d9c0c42019-07-29 15:22:19 -070026
Yuri Wiitalab2d13232019-02-04 18:07:28 -080027 sources = [
Jordan Baylesa26582d2019-07-10 14:44:58 -070028 "base/error.cc",
Yuri Wiitala22f643c2019-11-25 14:54:17 -080029 "base/interface_info.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -070030 "base/ip_address.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -070031 "base/location.cc",
Jordan Bayles1c785bd2019-08-15 10:32:33 -070032 "base/tls_credentials.cc",
Yuri Wiitala8e6db3b2019-11-20 11:20:54 -080033 "base/trace_logging_activation.cc",
Yuri Wiitalaf162a612019-11-22 22:46:04 -080034 "base/trivial_clock_traits.cc",
Yuri Wiitala977b6ef2019-11-07 17:08:25 -080035 "base/udp_packet.cc",
Yuri Wiitalab2d13232019-02-04 18:07:28 -080036 ]
Jordan Bayles9eb09742019-01-15 14:04:52 -080037
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080038 public_configs = [ "../build:openscreen_include_dirs" ]
39}
40
Ryan Keane37e21e82021-04-30 14:48:07 -070041# Public API source files. May depend on nothing except :base.
42source_set("logging") {
43 defines = []
mark a. foltz6e60fdc2022-10-27 17:05:39 -070044 visibility += [ "../util/*" ]
Ryan Keane37e21e82021-04-30 14:48:07 -070045
mark a. foltz5528ecf2022-08-24 10:26:08 -070046 public = [ "api/logging.h" ]
Ryan Keane37e21e82021-04-30 14:48:07 -070047
48 public_deps = [ ":base" ]
49}
50
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080051# Public API source files. These may depend on nothing except :base.
52source_set("api") {
53 defines = []
mark a. foltz6e60fdc2022-10-27 17:05:39 -070054 visibility += [ "*" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -070055 public = [
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080056 "api/export.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080057 "api/network_interface.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080058 "api/scoped_wake_lock.h",
Ryan Keanec2417882020-05-08 09:41:21 -070059 "api/serial_delete_ptr.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080060 "api/task_runner.h",
61 "api/time.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080062 "api/tls_connection.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080063 "api/tls_connection_factory.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080064 "api/trace_logging_platform.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080065 "api/udp_socket.h",
66 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -070067 sources = [
68 "api/scoped_wake_lock.cc",
69 "api/tls_connection.cc",
70 "api/tls_connection_factory.cc",
71 "api/trace_logging_platform.cc",
72 "api/udp_socket.cc",
73 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080074
Ryan Keane37e21e82021-04-30 14:48:07 -070075 public_deps = [
76 ":base",
77 ":logging",
78 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080079}
80
81# The following target is only activated in standalone builds (see :platform).
Jordan Bayles150295b2019-12-18 14:54:58 -080082if (!build_with_chromium) {
83 source_set("standalone_impl") {
84 defines = []
mark a. foltz6e60fdc2022-10-27 17:05:39 -070085 visibility += [ "../*" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -070086 public = [
Jordan Bayles150295b2019-12-18 14:54:58 -080087 "impl/logging.h",
Ryan Keaneb4d61bb2020-01-29 13:07:39 -080088 "impl/network_interface.h",
mark a. foltz5528ecf2022-08-24 10:26:08 -070089 "impl/task_runner.h",
90 "impl/text_trace_logging_platform.h",
91 ]
92 sources = [
93 "impl/network_interface.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -080094 "impl/socket_handle.h",
95 "impl/socket_handle_waiter.cc",
96 "impl/socket_handle_waiter.h",
Jordan Bayles8f0e0432021-02-01 12:07:16 -080097 "impl/socket_state.h",
Jordan Bayles150295b2019-12-18 14:54:58 -080098 "impl/stream_socket.h",
99 "impl/task_runner.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800100 "impl/text_trace_logging_platform.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800101 "impl/time.cc",
102 "impl/tls_write_buffer.cc",
103 "impl/tls_write_buffer.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800104 ]
105
Jordan Bayles56af85f2020-04-27 15:08:55 -0700106 public_configs = [ "//util:trace_logging_config" ]
107
Jordan Bayles150295b2019-12-18 14:54:58 -0800108 if (is_linux) {
Jordan Baylesc35af7d2020-03-24 08:15:00 -0700109 sources += [
110 "impl/network_interface_linux.cc",
111 "impl/scoped_wake_lock_linux.cc",
112 "impl/scoped_wake_lock_linux.h",
113 ]
Jordan Bayles150295b2019-12-18 14:54:58 -0800114 } else if (is_mac) {
115 defines += [
116 # Required, to use the new IPv6 Sockets options introduced by RFC 3542.
117 "__APPLE_USE_RFC_3542",
118 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800119
Jordan Bayles842767b2020-11-23 14:50:17 -0800120 frameworks = [
Jordan Bayles150295b2019-12-18 14:54:58 -0800121 "CoreFoundation.framework",
122 "IOKit.framework",
123 ]
124
125 sources += [
126 "impl/network_interface_mac.cc",
127 "impl/scoped_wake_lock_mac.cc",
128 "impl/scoped_wake_lock_mac.h",
129 ]
130 }
131
132 if (is_posix) {
mark a. foltz5528ecf2022-08-24 10:26:08 -0700133 public += [ "impl/platform_client_posix.h" ]
Jordan Bayles150295b2019-12-18 14:54:58 -0800134 sources += [
135 "impl/logging_posix.cc",
mark a. foltzd6a5a222020-07-28 17:28:06 -0700136 "impl/logging_test.h",
Jordan Bayles150295b2019-12-18 14:54:58 -0800137 "impl/platform_client_posix.cc",
Jordan Bayles150295b2019-12-18 14:54:58 -0800138 "impl/scoped_pipe.h",
139 "impl/socket_address_posix.cc",
140 "impl/socket_address_posix.h",
141 "impl/socket_handle_posix.cc",
142 "impl/socket_handle_posix.h",
143 "impl/socket_handle_waiter_posix.cc",
144 "impl/socket_handle_waiter_posix.h",
145 "impl/stream_socket_posix.cc",
146 "impl/stream_socket_posix.h",
147 "impl/timeval_posix.cc",
148 "impl/timeval_posix.h",
149 "impl/tls_connection_factory_posix.cc",
150 "impl/tls_connection_factory_posix.h",
151 "impl/tls_connection_posix.cc",
152 "impl/tls_connection_posix.h",
153 "impl/tls_data_router_posix.cc",
154 "impl/tls_data_router_posix.h",
155 "impl/udp_socket_posix.cc",
156 "impl/udp_socket_posix.h",
157 "impl/udp_socket_reader_posix.cc",
158 "impl/udp_socket_reader_posix.h",
159 ]
160 }
161
162 deps = [
163 ":api",
164 "../third_party/abseil",
165 "../third_party/boringssl",
166 "../util",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800167 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700168 friend = [ ":unittests" ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800169 }
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800170}
Jordan Bayles9ade4152019-05-08 17:03:24 -0700171
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800172# The main target, which either assumes an embedder will link-in the platform
173# API implementation elsewhere, or links-in the :standalone_impl in the build.
174source_set("platform") {
mark a. foltz6e60fdc2022-10-27 17:05:39 -0700175 visibility += [ "*" ]
Ryan Keanec2417882020-05-08 09:41:21 -0700176 public_deps = [ ":api" ]
Jordan Baylesa80724b2019-05-02 17:17:26 -0700177 if (!build_with_chromium) {
Ryan Keanec2417882020-05-08 09:41:21 -0700178 deps = [ ":standalone_impl" ]
Yuri Wiitalab2d13232019-02-04 18:07:28 -0800179 }
btolsch9d6900c2018-05-30 18:22:53 -0700180}
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700181
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800182# Test helpers, referenced in other Open Screen BUILD.gn test targets.
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700183source_set("test") {
184 testonly = true
mark a. foltz6e60fdc2022-10-27 17:05:39 -0700185 visibility += [ "../*" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700186 public = [
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700187 "test/fake_clock.h",
Yuri Wiitalaec353612019-06-18 17:32:39 -0700188 "test/fake_task_runner.h",
Ryan Keane7d4b5fc2019-08-30 12:38:39 -0700189 "test/fake_udp_socket.h",
btolsch07bf81f2019-11-26 13:52:05 -0800190 "test/mock_tls_connection.h",
Ryan Keane1c693972020-03-11 15:26:28 -0700191 "test/mock_udp_socket.h",
btolsch31665eb2020-04-03 01:49:40 -0700192 "test/paths.h",
Ryan Keane38e7d512019-08-02 15:37:49 -0700193 "test/trace_logging_helpers.h",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700194 ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700195 sources = [
196 "test/fake_clock.cc",
197 "test/fake_task_runner.cc",
198 "test/fake_udp_socket.cc",
199 "test/paths_internal.h",
200 ]
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700201
btolsch31665eb2020-04-03 01:49:40 -0700202 if (is_posix) {
203 sources += [ "test/paths_posix.cc" ]
204 }
205 if (is_linux) {
206 sources += [ "test/paths_internal_linux.cc" ]
btolschb586d7a2020-04-30 15:53:15 -0700207 } else if (is_mac) {
btolsch31665eb2020-04-03 01:49:40 -0700208 sources += [ "test/paths_internal_mac.cc" ]
btolschb586d7a2020-04-30 15:53:15 -0700209 } else if (build_with_chromium) {
210 # NOTE: This is used to resolve a linking issue when compiling in Chromium
211 # for other platforms, but nothing in here is called.
212 sources += [ "test/paths_internal_other.cc" ]
btolsch31665eb2020-04-03 01:49:40 -0700213 }
214
btolsch9d9da7b2021-02-09 10:39:30 -0800215 public_deps = [
216 ":api",
217 ":base",
218 ]
219
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700220 deps = [
221 ":platform",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800222 "../third_party/abseil",
Ryan Keanedeb48b32019-06-28 16:24:40 -0700223 "../third_party/googletest:gmock",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800224 "../util",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700225 ]
226}
227
mark a. foltz3fe46172019-09-18 05:50:30 -0700228source_set("unittests") {
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700229 testonly = true
mark a. foltz6e60fdc2022-10-27 17:05:39 -0700230 visibility += [ "..:openscreen_unittests_all" ]
mark a. foltz5528ecf2022-08-24 10:26:08 -0700231 public = []
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700232 sources = [
Ryan Keanec2417882020-05-08 09:41:21 -0700233 "api/serial_delete_ptr_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700234 "api/time_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700235 "base/error_unittest.cc",
236 "base/ip_address_unittest.cc",
237 "base/location_unittest.cc",
Ryan Keane3e5d23e2020-06-10 09:56:11 -0700238 "base/udp_packet_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700239 ]
240
Jordan Baylesf3b911c2021-06-22 11:28:50 -0700241 deps = [
242 ":platform",
243 ":test",
244 "../third_party/abseil",
245 "../third_party/boringssl",
246 "../third_party/googletest:gmock",
247 "../third_party/googletest:gtest",
248 "../util",
249 ]
250
Jordan Baylesc1804992022-08-30 17:10:11 +0000251 # The socket integration tests assume that you can Bind with UDP sockets,
252 # which is simply not true when we are built inside of Chromium.
Jordan Bayles9ef84122020-04-27 12:08:38 -0700253 if (!build_with_chromium) {
Jordan Baylesc1804992022-08-30 17:10:11 +0000254 sources += [ "api/socket_integration_unittest.cc" ]
255
Jordan Baylesf3b911c2021-06-22 11:28:50 -0700256 deps += [ ":standalone_impl" ]
Jordan Bayles9ef84122020-04-27 12:08:38 -0700257 }
258
Jordan Baylescc471802019-07-09 14:25:02 -0700259 # The unit tests in impl/ assume the standalone implementation is being used.
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700260 # Exclude them if an embedder is providing the implementation.
261 if (!build_with_chromium) {
btolschc92ba2f2019-04-10 11:46:01 -0700262 sources += [
Jordan Baylesa26582d2019-07-10 14:44:58 -0700263 "impl/task_runner_unittest.cc",
Jordan Baylescc471802019-07-09 14:25:02 -0700264 "impl/time_unittest.cc",
btolschc92ba2f2019-04-10 11:46:01 -0700265 ]
Jordan Bayles063c3b52019-08-13 18:14:55 -0700266
Ryan Keane32c88d02019-07-02 18:46:14 -0700267 if (is_posix) {
Jordan Baylesa26582d2019-07-10 14:44:58 -0700268 sources += [
mark a. foltzd6a5a222020-07-28 17:28:06 -0700269 "impl/logging_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700270 "impl/scoped_pipe_unittest.cc",
Jordan Bayles62b7c6a2019-08-15 10:32:33 -0700271 "impl/socket_address_posix_unittest.cc",
Ryan Keane2fdf9662019-09-25 13:29:32 -0700272 "impl/socket_handle_waiter_posix_unittest.cc",
mark a. foltzcbdea4b2019-11-18 16:49:14 -0800273 "impl/timeval_posix_unittest.cc",
Ryan Keaned838a252019-09-25 12:48:15 -0700274 "impl/tls_data_router_posix_unittest.cc",
Ryan Keanef2776122019-10-11 09:07:33 -0700275 "impl/tls_write_buffer_unittest.cc",
Ryan Keanee93f8c72019-09-25 12:35:00 -0700276 "impl/udp_socket_reader_posix_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700277 ]
Ryan Keane32c88d02019-07-02 18:46:14 -0700278 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700279 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700280}