blob: 067bd420909c5d06abbb426ce3815fc8e423367e [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/socket_state.h",
21 "base/tls_connect_options.h",
22 "base/tls_credentials.cc",
23 "base/tls_credentials.h",
24 "base/tls_listen_options.h",
Yuri Wiitala8e6db3b2019-11-20 11:20:54 -080025 "base/trace_logging_activation.cc",
26 "base/trace_logging_activation.h",
27 "base/trace_logging_types.h",
Yuri Wiitalaf162a612019-11-22 22:46:04 -080028 "base/trivial_clock_traits.cc",
29 "base/trivial_clock_traits.h",
Yuri Wiitala977b6ef2019-11-07 17:08:25 -080030 "base/udp_packet.cc",
31 "base/udp_packet.h",
Yuri Wiitalab2d13232019-02-04 18:07:28 -080032 ]
Jordan Bayles9eb09742019-01-15 14:04:52 -080033
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080034 public_configs = [ "../build:openscreen_include_dirs" ]
35}
36
37# Public API source files. These may depend on nothing except :base.
38source_set("api") {
39 defines = []
40
41 sources = [
42 "api/export.h",
43 "api/logging.h",
44 "api/network_interface.h",
45 "api/scoped_wake_lock.cc",
46 "api/scoped_wake_lock.h",
47 "api/task_runner.h",
48 "api/time.h",
49 "api/tls_connection.cc",
50 "api/tls_connection.h",
51 "api/tls_connection_factory.cc",
52 "api/tls_connection_factory.h",
53 "api/trace_logging_platform.cc",
54 "api/trace_logging_platform.h",
55 "api/udp_socket.cc",
56 "api/udp_socket.h",
57 ]
58
Jordan Bayles9eb09742019-01-15 14:04:52 -080059 public_deps = [
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080060 ":base",
61 ]
62}
63
64# The following target is only activated in standalone builds (see :platform).
Jordan Bayles150295b2019-12-18 14:54:58 -080065if (!build_with_chromium) {
66 source_set("standalone_impl") {
67 defines = []
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080068
Jordan Bayles150295b2019-12-18 14:54:58 -080069 sources = [
70 "impl/logging.h",
71 "impl/socket_handle.h",
72 "impl/socket_handle_waiter.cc",
73 "impl/socket_handle_waiter.h",
74 "impl/stream_socket.h",
75 "impl/task_runner.cc",
76 "impl/task_runner.h",
77 "impl/text_trace_logging_platform.cc",
78 "impl/text_trace_logging_platform.h",
79 "impl/time.cc",
80 "impl/tls_write_buffer.cc",
81 "impl/tls_write_buffer.h",
82 "impl/weak_ptr.h",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080083 ]
84
Jordan Bayles150295b2019-12-18 14:54:58 -080085 if (is_linux) {
86 sources += [ "impl/network_interface_linux.cc" ]
87 } else if (is_mac) {
88 defines += [
89 # Required, to use the new IPv6 Sockets options introduced by RFC 3542.
90 "__APPLE_USE_RFC_3542",
91 ]
Yuri Wiitalaca24ee52019-12-05 16:51:42 -080092
Jordan Bayles150295b2019-12-18 14:54:58 -080093 libs = [
94 "CoreFoundation.framework",
95 "IOKit.framework",
96 ]
97
98 sources += [
99 "impl/network_interface_mac.cc",
100 "impl/scoped_wake_lock_mac.cc",
101 "impl/scoped_wake_lock_mac.h",
102 ]
103 }
104
105 if (is_posix) {
106 sources += [
107 "impl/logging_posix.cc",
108 "impl/platform_client_posix.cc",
109 "impl/platform_client_posix.h",
110 "impl/scoped_pipe.h",
111 "impl/socket_address_posix.cc",
112 "impl/socket_address_posix.h",
113 "impl/socket_handle_posix.cc",
114 "impl/socket_handle_posix.h",
115 "impl/socket_handle_waiter_posix.cc",
116 "impl/socket_handle_waiter_posix.h",
117 "impl/stream_socket_posix.cc",
118 "impl/stream_socket_posix.h",
119 "impl/timeval_posix.cc",
120 "impl/timeval_posix.h",
121 "impl/tls_connection_factory_posix.cc",
122 "impl/tls_connection_factory_posix.h",
123 "impl/tls_connection_posix.cc",
124 "impl/tls_connection_posix.h",
125 "impl/tls_data_router_posix.cc",
126 "impl/tls_data_router_posix.h",
127 "impl/udp_socket_posix.cc",
128 "impl/udp_socket_posix.h",
129 "impl/udp_socket_reader_posix.cc",
130 "impl/udp_socket_reader_posix.h",
131 ]
132 }
133
134 deps = [
135 ":api",
136 "../third_party/abseil",
137 "../third_party/boringssl",
138 "../util",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800139 ]
140 }
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800141}
Jordan Bayles9ade4152019-05-08 17:03:24 -0700142
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800143# The main target, which either assumes an embedder will link-in the platform
144# API implementation elsewhere, or links-in the :standalone_impl in the build.
145source_set("platform") {
146 public_deps = [
147 ":api",
148 ]
Jordan Baylesa80724b2019-05-02 17:17:26 -0700149 if (!build_with_chromium) {
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800150 deps = [
151 ":standalone_impl",
btolschc92ba2f2019-04-10 11:46:01 -0700152 ]
Yuri Wiitalab2d13232019-02-04 18:07:28 -0800153 }
btolsch9d6900c2018-05-30 18:22:53 -0700154}
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700155
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800156# Test helpers, referenced in other Open Screen BUILD.gn test targets.
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700157source_set("test") {
158 testonly = true
159 sources = [
160 "test/fake_clock.cc",
161 "test/fake_clock.h",
Yuri Wiitalaec353612019-06-18 17:32:39 -0700162 "test/fake_task_runner.cc",
163 "test/fake_task_runner.h",
Ryan Keane7d4b5fc2019-08-30 12:38:39 -0700164 "test/fake_udp_socket.cc",
165 "test/fake_udp_socket.h",
btolsch07bf81f2019-11-26 13:52:05 -0800166 "test/mock_tls_connection.h",
Ryan Keane38e7d512019-08-02 15:37:49 -0700167 "test/trace_logging_helpers.h",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700168 ]
169
170 deps = [
171 ":platform",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800172 "../third_party/abseil",
Ryan Keanedeb48b32019-06-28 16:24:40 -0700173 "../third_party/googletest:gmock",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800174 "../util",
Jordan Baylesaa021ce2019-05-29 13:57:44 -0700175 ]
176}
177
mark a. foltz3fe46172019-09-18 05:50:30 -0700178source_set("unittests") {
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700179 testonly = true
180
181 sources = [
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800182 "api/socket_integration_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700183 "api/time_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700184 "base/error_unittest.cc",
185 "base/ip_address_unittest.cc",
186 "base/location_unittest.cc",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700187 ]
188
Jordan Baylescc471802019-07-09 14:25:02 -0700189 # The unit tests in impl/ assume the standalone implementation is being used.
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700190 # Exclude them if an embedder is providing the implementation.
191 if (!build_with_chromium) {
btolschc92ba2f2019-04-10 11:46:01 -0700192 sources += [
Jordan Baylesa26582d2019-07-10 14:44:58 -0700193 "impl/task_runner_unittest.cc",
Jordan Baylescc471802019-07-09 14:25:02 -0700194 "impl/time_unittest.cc",
Yuri Wiitalafb75b092019-11-14 14:13:18 -0800195 "impl/weak_ptr_unittest.cc",
btolschc92ba2f2019-04-10 11:46:01 -0700196 ]
Jordan Bayles063c3b52019-08-13 18:14:55 -0700197
Ryan Keane32c88d02019-07-02 18:46:14 -0700198 if (is_posix) {
Jordan Baylesa26582d2019-07-10 14:44:58 -0700199 sources += [
Jordan Baylesa26582d2019-07-10 14:44:58 -0700200 "impl/scoped_pipe_unittest.cc",
Jordan Bayles62b7c6a2019-08-15 10:32:33 -0700201 "impl/socket_address_posix_unittest.cc",
Ryan Keane2fdf9662019-09-25 13:29:32 -0700202 "impl/socket_handle_waiter_posix_unittest.cc",
mark a. foltzcbdea4b2019-11-18 16:49:14 -0800203 "impl/timeval_posix_unittest.cc",
Ryan Keaned838a252019-09-25 12:48:15 -0700204 "impl/tls_data_router_posix_unittest.cc",
Ryan Keanef2776122019-10-11 09:07:33 -0700205 "impl/tls_write_buffer_unittest.cc",
Ryan Keanee93f8c72019-09-25 12:35:00 -0700206 "impl/udp_socket_reader_posix_unittest.cc",
Jordan Baylesa26582d2019-07-10 14:44:58 -0700207 ]
Ryan Keane32c88d02019-07-02 18:46:14 -0700208 }
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700209 }
210
211 deps = [
212 ":platform",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800213 ":test",
214 "../third_party/abseil",
215 "../third_party/boringssl",
Ryan Keanedeb48b32019-06-28 16:24:40 -0700216 "../third_party/googletest:gmock",
btolsch4666ed22019-04-25 15:58:07 -0700217 "../third_party/googletest:gtest",
Yuri Wiitalaca24ee52019-12-05 16:51:42 -0800218 "../util",
Yuri Wiitalaeb8eee72019-03-26 15:52:43 -0700219 ]
220}