blob: 304c0853c1cafdf7707088b379f41bbd65e46cc3 [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/tls_connect_options.h",
21 "base/tls_credentials.cc",
22 "base/tls_credentials.h",
23 "base/tls_listen_options.h",
Yuri Wiitala8e6db3b2019-11-20 11:20:54 -080024 "base/trace_logging_activation.cc",
25 "base/trace_logging_activation.h",
26 "base/trace_logging_types.h",
Yuri Wiitalaf162a612019-11-22 22:46:04 -080027 "base/trivial_clock_traits.cc",
28 "base/trivial_clock_traits.h",
Yuri Wiitala977b6ef2019-11-07 17:08:25 -080029 "base/udp_packet.cc",
30 "base/udp_packet.h",
Yuri Wiitalab2d13232019-02-04 18:07:28 -080031 ]
Jordan Bayles9eb09742019-01-15 14:04:52 -080032
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080033 public_configs = [ "../build:openscreen_include_dirs" ]
34}
35
Ryan Keane37e21e82021-04-30 14:48:07 -070036# Public API source files. May depend on nothing except :base.
37source_set("logging") {
38 defines = []
39
40 sources = [ "api/logging.h" ]
41
42 public_deps = [ ":base" ]
43}
44
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080045# Public API source files. These may depend on nothing except :base.
46source_set("api") {
47 defines = []
48
49 sources = [
50 "api/export.h",
51 "api/logging.h",
52 "api/network_interface.h",
53 "api/scoped_wake_lock.cc",
54 "api/scoped_wake_lock.h",
Ryan Keanec2417882020-05-08 09:41:21 -070055 "api/serial_delete_ptr.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080056 "api/task_runner.h",
57 "api/time.h",
58 "api/tls_connection.cc",
59 "api/tls_connection.h",
60 "api/tls_connection_factory.cc",
61 "api/tls_connection_factory.h",
62 "api/trace_logging_platform.cc",
63 "api/trace_logging_platform.h",
64 "api/udp_socket.cc",
65 "api/udp_socket.h",
66 ]
67
Ryan Keane37e21e82021-04-30 14:48:07 -070068 public_deps = [
69 ":base",
70 ":logging",
71 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080072}
73
74# The following target is only activated in standalone builds (see :platform).
Jordan Bayles150295b2019-12-18 14:54:58 -080075if (!build_with_chromium) {
76 source_set("standalone_impl") {
77 defines = []
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080078
Jordan Bayles150295b2019-12-18 14:54:58 -080079 sources = [
80 "impl/logging.h",
Ryan Keaneb4d61bb2020-01-29 13:07:39 -080081 "impl/network_interface.cc",
82 "impl/network_interface.h",
Jordan Bayles150295b2019-12-18 14:54:58 -080083 "impl/socket_handle.h",
84 "impl/socket_handle_waiter.cc",
85 "impl/socket_handle_waiter.h",
Jordan Bayles8f0e0432021-02-01 12:07:16 -080086 "impl/socket_state.h",
Jordan Bayles150295b2019-12-18 14:54:58 -080087 "impl/stream_socket.h",
88 "impl/task_runner.cc",
89 "impl/task_runner.h",
90 "impl/text_trace_logging_platform.cc",
91 "impl/text_trace_logging_platform.h",
92 "impl/time.cc",
93 "impl/tls_write_buffer.cc",
94 "impl/tls_write_buffer.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080095 ]
96
Jordan Bayles56af85f2020-04-27 15:08:55 -070097 public_configs = [ "//util:trace_logging_config" ]
98
Jordan Bayles150295b2019-12-18 14:54:58 -080099 if (is_linux) {
Jordan Baylesc35af7d2020-03-24 08:15:00 -0700100 sources += [
101 "impl/network_interface_linux.cc",
102 "impl/scoped_wake_lock_linux.cc",
103 "impl/scoped_wake_lock_linux.h",
104 ]
Jordan Bayles150295b2019-12-18 14:54:58 -0800105 } else if (is_mac) {
106 defines += [
107 # Required, to use the new IPv6 Sockets options introduced by RFC 3542.
108 "__APPLE_USE_RFC_3542",
109 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800110
Jordan Bayles842767b2020-11-23 14:50:17 -0800111 frameworks = [
Jordan Bayles150295b2019-12-18 14:54:58 -0800112 "CoreFoundation.framework",
113 "IOKit.framework",
114 ]
115
116 sources += [
117 "impl/network_interface_mac.cc",
118 "impl/scoped_wake_lock_mac.cc",
119 "impl/scoped_wake_lock_mac.h",
120 ]
121 }
122
123 if (is_posix) {
124 sources += [
125 "impl/logging_posix.cc",
mark a. foltzd6a5a222020-07-28 17:28:06 -0700126 "impl/logging_test.h",
Jordan Bayles150295b2019-12-18 14:54:58 -0800127 "impl/platform_client_posix.cc",
128 "impl/platform_client_posix.h",
129 "impl/scoped_pipe.h",
130 "impl/socket_address_posix.cc",
131 "impl/socket_address_posix.h",
132 "impl/socket_handle_posix.cc",
133 "impl/socket_handle_posix.h",
134 "impl/socket_handle_waiter_posix.cc",
135 "impl/socket_handle_waiter_posix.h",
136 "impl/stream_socket_posix.cc",
137 "impl/stream_socket_posix.h",
138 "impl/timeval_posix.cc",
139 "impl/timeval_posix.h",
140 "impl/tls_connection_factory_posix.cc",
141 "impl/tls_connection_factory_posix.h",
142 "impl/tls_connection_posix.cc",
143 "impl/tls_connection_posix.h",
144 "impl/tls_data_router_posix.cc",
145 "impl/tls_data_router_posix.h",
146 "impl/udp_socket_posix.cc",
147 "impl/udp_socket_posix.h",
148 "impl/udp_socket_reader_posix.cc",
149 "impl/udp_socket_reader_posix.h",
150 ]
151 }
152
153 deps = [
154 ":api",
155 "../third_party/abseil",
156 "../third_party/boringssl",
157 "../util",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800158 ]
159 }
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800160}
Jordan Bayles9ade4152019-05-08 17:03:24 -0700161
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800162# The main target, which either assumes an embedder will link-in the platform
163# API implementation elsewhere, or links-in the :standalone_impl in the build.
164source_set("platform") {
Ryan Keanec2417882020-05-08 09:41:21 -0700165 public_deps = [ ":api" ]
Jordan Baylesa80724b2019-05-02 17:17:26 -0700166 if (!build_with_chromium) {
Ryan Keanec2417882020-05-08 09:41:21 -0700167 deps = [ ":standalone_impl" ]
Yuri Wiitalab2d13232019-02-04 18:07:28 -0800168 }
btolsch9d6900c2018-05-30 18:22:53 -0700169}
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700170
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800171# Test helpers, referenced in other Open Screen BUILD.gn test targets.
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700172source_set("test") {
173 testonly = true
174 sources = [
175 "test/fake_clock.cc",
176 "test/fake_clock.h",
Yuri Wiitalaec353612019-06-18 17:32:39 -0700177 "test/fake_task_runner.cc",
178 "test/fake_task_runner.h",
Ryan Keane7d4b5fc2019-08-30 12:38:39 -0700179 "test/fake_udp_socket.cc",
180 "test/fake_udp_socket.h",
btolsch07bf81f2019-11-26 13:52:05 -0800181 "test/mock_tls_connection.h",
Ryan Keane1c693972020-03-11 15:26:28 -0700182 "test/mock_udp_socket.h",
btolsch31665eb2020-04-03 01:49:40 -0700183 "test/paths.h",
184 "test/paths_internal.h",
Ryan Keane38e7d512019-08-02 15:37:49 -0700185 "test/trace_logging_helpers.h",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700186 ]
187
btolsch31665eb2020-04-03 01:49:40 -0700188 if (is_posix) {
189 sources += [ "test/paths_posix.cc" ]
190 }
191 if (is_linux) {
192 sources += [ "test/paths_internal_linux.cc" ]
btolschb586d7a2020-04-30 15:53:15 -0700193 } else if (is_mac) {
btolsch31665eb2020-04-03 01:49:40 -0700194 sources += [ "test/paths_internal_mac.cc" ]
btolschb586d7a2020-04-30 15:53:15 -0700195 } else if (build_with_chromium) {
196 # NOTE: This is used to resolve a linking issue when compiling in Chromium
197 # for other platforms, but nothing in here is called.
198 sources += [ "test/paths_internal_other.cc" ]
btolsch31665eb2020-04-03 01:49:40 -0700199 }
200
btolsch9d9da7b2021-02-09 10:39:30 -0800201 public_deps = [
202 ":api",
203 ":base",
204 ]
205
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700206 deps = [
207 ":platform",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800208 "../third_party/abseil",
Ryan Keanedeb48b32019-06-28 16:24:40 -0700209 "../third_party/googletest:gmock",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800210 "../util",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700211 ]
212}
213
mark a. foltz3fe46172019-09-18 05:50:30 -0700214source_set("unittests") {
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700215 testonly = true
216
217 sources = [
Ryan Keanec2417882020-05-08 09:41:21 -0700218 "api/serial_delete_ptr_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700219 "api/time_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700220 "base/error_unittest.cc",
221 "base/ip_address_unittest.cc",
222 "base/location_unittest.cc",
Ryan Keane3e5d23e2020-06-10 09:56:11 -0700223 "base/udp_packet_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700224 ]
225
Jordan Baylesf3b911c2021-06-22 11:28:50 -0700226 deps = [
227 ":platform",
228 ":test",
229 "../third_party/abseil",
230 "../third_party/boringssl",
231 "../third_party/googletest:gmock",
232 "../third_party/googletest:gtest",
233 "../util",
234 ]
235
Jordan Bayles9ef84122020-04-27 12:08:38 -0700236 # The socket integration tests assume that you can Bind with UDP sockets,
237 # which is simply not true when we are built inside of Chromium.
238 if (!build_with_chromium) {
239 sources += [ "api/socket_integration_unittest.cc" ]
Jordan Baylesf3b911c2021-06-22 11:28:50 -0700240
241 deps += [ ":standalone_impl" ]
Jordan Bayles9ef84122020-04-27 12:08:38 -0700242 }
243
Jordan Baylescc471802019-07-09 14:25:02 -0700244 # The unit tests in impl/ assume the standalone implementation is being used.
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700245 # Exclude them if an embedder is providing the implementation.
246 if (!build_with_chromium) {
btolschc92ba2f2019-04-10 11:46:01 -0700247 sources += [
Jordan Baylesa26582d2019-07-10 14:44:58 -0700248 "impl/task_runner_unittest.cc",
Jordan Baylescc471802019-07-09 14:25:02 -0700249 "impl/time_unittest.cc",
btolschc92ba2f2019-04-10 11:46:01 -0700250 ]
Jordan Bayles063c3b52019-08-13 18:14:55 -0700251
Ryan Keane32c88d02019-07-02 18:46:14 -0700252 if (is_posix) {
Jordan Baylesa26582d2019-07-10 14:44:58 -0700253 sources += [
mark a. foltzd6a5a222020-07-28 17:28:06 -0700254 "impl/logging_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700255 "impl/scoped_pipe_unittest.cc",
Jordan Bayles62b7c6a2019-08-15 10:32:33 -0700256 "impl/socket_address_posix_unittest.cc",
Ryan Keane2fdf9662019-09-25 13:29:32 -0700257 "impl/socket_handle_waiter_posix_unittest.cc",
mark a. foltzcbdea4b2019-11-18 16:49:14 -0800258 "impl/timeval_posix_unittest.cc",
Ryan Keaned838a252019-09-25 12:48:15 -0700259 "impl/tls_data_router_posix_unittest.cc",
Ryan Keanef2776122019-10-11 09:07:33 -0700260 "impl/tls_write_buffer_unittest.cc",
Ryan Keanee93f8c72019-09-25 12:35:00 -0700261 "impl/udp_socket_reader_posix_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700262 ]
Ryan Keane32c88d02019-07-02 18:46:14 -0700263 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700264 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700265}