blob: 8b15e89f214534e61421293ec407ae1f17bcef5e [file] [log] [blame]
mbonadei9aa3f0a2017-01-24 06:58:22 -08001# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS. All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
mbonadei9aa3f0a2017-01-24 06:58:22 -08008import("//build/config/arm.gni")
9import("//build/config/features.gni")
10import("//build/config/mips.gni")
11import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 06:32:23 +010012import("//build/config/sysroot.gni")
ehmaldonado0d729b32017-02-10 01:38:23 -080013import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080014import("//build_overrides/build.gni")
mbonadei96606272017-03-03 19:41:59 -080015
16if (!build_with_chromium && is_component_build) {
17 print("The Gn argument `is_component_build` is currently " +
18 "ignored for WebRTC builds.")
19 print("Component builds are supported by Chromium and the argument " +
20 "`is_component_build` makes it possible to create shared libraries " +
21 "instead of static libraries.")
22 print("If an app depends on WebRTC it makes sense to just depend on the " +
23 "WebRTC static library, so there is no difference between " +
24 "`is_component_build=true` and `is_component_build=false`.")
25 print(
Fanny Linderborg0d2dc1f2021-07-14 14:02:11 +000026 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/main/docs/component_build.md")
mbonadei96606272017-03-03 19:41:59 -080027 assert(!is_component_build, "Component builds are not supported in WebRTC.")
28}
29
kthelgason4065a572017-02-14 04:58:56 -080030if (is_ios) {
31 import("//build/config/ios/rules.gni")
32}
mbonadei9aa3f0a2017-01-24 06:58:22 -080033
Anders Carlsson37bbf792018-09-05 16:29:27 +020034if (is_mac) {
35 import("//build/config/mac/rules.gni")
36}
37
Mirko Bonadei5f078452021-07-30 22:32:55 +020038# This declare_args is separated from the next one because args declared
39# in this one, can be read from the next one (args defined in the same
40# declare_args cannot be referenced in that scope).
mbonadei9aa3f0a2017-01-24 06:58:22 -080041declare_args() {
Mirko Bonadei028248c2018-10-10 12:19:02 +020042 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
43 # expand to code that will manage symbols visibility.
44 rtc_enable_symbol_export = false
Mirko Bonadei5f078452021-07-30 22:32:55 +020045}
46
47declare_args() {
48 # Setting this to true will make RTC_OBJC_EXPORT expand to code that will
49 # manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported
50 # if C++ symbols are but setting this arg to true while keeping
51 # rtc_enable_symbol_export=false will only export RTC_OBJC_EXPORT
52 # annotated symbols.
53 rtc_enable_objc_symbol_export = rtc_enable_symbol_export
Mirko Bonadei028248c2018-10-10 12:19:02 +020054
Mirko Bonadei31b0b452018-08-22 10:37:11 +020055 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020056 # will tell the pre-processor to remove the default definition of symbols
57 # needed to use field_trial. In that case a new implementation needs to be
58 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020059 if (build_with_chromium) {
60 # When WebRTC is built as part of Chromium it should exclude the default
61 # implementation of field_trial unless it is building for NACL or
62 # Chromecast.
63 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
64 } else {
65 rtc_exclude_field_trial_default = false
66 }
Mirko Bonadei70400902018-08-21 15:44:28 +020067
Mirko Bonadei906add42018-09-05 16:03:16 +020068 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
69 # will tell the pre-processor to remove the default definition of symbols
70 # needed to use metrics. In that case a new implementation needs to be
71 # provided.
72 rtc_exclude_metrics_default = build_with_chromium
73
Johannes Kronda20c732021-02-19 16:39:41 +010074 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which
75 # will tell the pre-processor to remove the default definition of the
76 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
77 # that case a new implementation needs to be provided.
Johannes Kronbb52bdf2021-02-25 10:10:08 +010078 rtc_exclude_system_time = build_with_chromium
Johannes Kronda20c732021-02-19 16:39:41 +010079
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070080 # Setting this to false will require the API user to pass in their own
81 # SSLCertificateVerifier to verify the certificates presented from a
82 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
83 rtc_builtin_ssl_root_certificates = true
84
Karl Wibergeb254b42017-11-01 15:08:12 +010085 # Include the iLBC audio codec?
Olga Sharonova5fbd7582020-07-09 09:50:42 +000086 rtc_include_ilbc = true
Karl Wibergeb254b42017-11-01 15:08:12 +010087
mbonadei9aa3f0a2017-01-24 06:58:22 -080088 # Disable this to avoid building the Opus audio codec.
89 rtc_include_opus = true
90
minyue2e03c662017-02-01 17:31:11 -080091 # Enable this if the Opus version upon which WebRTC is built supports direct
92 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020093 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080094
mbonadei9aa3f0a2017-01-24 06:58:22 -080095 # Enable this to let the Opus audio codec change complexity on the fly.
96 rtc_opus_variable_complexity = false
97
mbonadei9aa3f0a2017-01-24 06:58:22 -080098 # Used to specify an external Jsoncpp include path when not compiling the
99 # library that comes with WebRTC (i.e. rtc_build_json == 0).
100 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
101
102 # Used to specify an external OpenSSL include path when not compiling the
103 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
104 rtc_ssl_root = ""
105
mbonadei9aa3f0a2017-01-24 06:58:22 -0800106 # Enable when an external authentication mechanism is used for performing
107 # packet authentication for RTP packets instead of libsrtp.
108 rtc_enable_external_auth = build_with_chromium
109
110 # Selects whether debug dumps for the audio processing module
111 # should be generated.
112 apm_debug_dump = false
113
Per Åhgrencc73ed32020-04-26 23:56:17 +0200114 # Selects whether the audio processing module should be excluded.
115 rtc_exclude_audio_processing_module = false
116
mbonadei9aa3f0a2017-01-24 06:58:22 -0800117 # Set this to true to enable BWE test logging.
118 rtc_enable_bwe_test_logging = false
119
Joachim Bauch93e91342017-12-07 01:25:53 +0100120 # Set this to false to skip building examples.
121 rtc_build_examples = true
122
123 # Set this to false to skip building tools.
124 rtc_build_tools = true
125
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100126 # Set this to false to skip building code that requires X11.
127 rtc_use_x11 = use_x11
128
Tomas Popela318da512018-11-13 06:32:23 +0100129 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 14:37:51 +0100130 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
131 # only when using the sysroot as PipeWire is not available in older and
132 # supported Ubuntu and Debian distributions.
Xiaohan Wang9f32f3b2020-10-01 14:46:54 -0700133 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 14:37:51 +0100134
135 # Set this to link PipeWire directly instead of using the dlopen.
136 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 06:32:23 +0100137
Jan Grulichc3c81292020-12-02 09:03:34 +0100138 # Set this to use certain PipeWire version
Jan Grulich14b036d2021-02-04 09:53:20 +0100139 # Currently WebRTC supports PipeWire 0.2 and PipeWire 0.3 (default)
140 rtc_pipewire_version = "0.3"
Jan Grulichc3c81292020-12-02 09:03:34 +0100141
mbonadei9aa3f0a2017-01-24 06:58:22 -0800142 # Enable to use the Mozilla internal settings.
143 build_with_mozilla = false
144
Philipp Hanckee95ebda2020-09-17 16:13:20 +0200145 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
146 # and NDK r16 or above.
henrika883d00f2018-03-16 10:09:49 +0100147 rtc_enable_android_aaudio = false
148
mbonadei9aa3f0a2017-01-24 06:58:22 -0800149 # Set to "func", "block", "edge" for coverage generation.
150 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
151 # It is recommend to set include_examples=0.
152 # Use llvm's sancov -html-report for human readable reports.
153 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
154 rtc_sanitize_coverage = ""
155
Philipp Hanckeaeac9f82020-09-11 11:58:18 +0200156 # Selects fixed-point code where possible.
157 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800158 if (current_cpu == "arm" || current_cpu == "arm64") {
159 rtc_prefer_fixed_point = true
160 }
161
mbonadei9aa3f0a2017-01-24 06:58:22 -0800162 # Determines whether NEON code will be built.
163 rtc_build_with_neon =
164 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
165
166 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
167 # all platforms except Android and iOS. Because FFmpeg can be built
Artem Titov22a6b2d2021-07-27 16:25:56 +0200168 # with/without H.264 support, `ffmpeg_branding` has to separately be set to a
mbonadei9aa3f0a2017-01-24 06:58:22 -0800169 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Artem Titov22a6b2d2021-07-27 16:25:56 +0200170 # H.264, compilation succeeds but `H264DecoderImpl` fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800171 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
172 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100173 #
174 # Enabling H264 when building with MSVC is currently not supported, see
175 # bugs.webrtc.org/9213#c13 for more info.
176 rtc_use_h264 =
177 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800178
Markus Handell8e75bd42020-06-05 11:47:40 +0200179 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
180 rtc_use_absl_mutex = false
181
mbonadei9aa3f0a2017-01-24 06:58:22 -0800182 # By default, use normal platform audio support or dummy audio, but don't
183 # use file-based audio playout and record.
184 rtc_use_dummy_audio_file_devices = false
185
henrika7be78832017-06-13 17:34:16 +0200186 # When set to true, replace the audio output with a sinus tone at 440Hz.
187 # The ADM will ask for audio data from WebRTC but instead of reading real
188 # audio samples from NetEQ, a sinus tone will be generated and replace the
189 # real audio samples.
190 rtc_audio_device_plays_sinus_tone = false
191
Anders Carlsson358f2e02018-06-04 10:24:37 +0200192 if (is_ios) {
193 # Build broadcast extension in AppRTCMobile for iOS. This results in the
194 # binary only running on iOS 11+, which is why it is disabled by default.
195 rtc_apprtcmobile_broadcast_extension = false
196 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200197
Jordan Rose53d3fc92021-07-06 12:16:41 -0700198 # Determines whether OpenGL is available on iOS/macOS.
199 rtc_ios_macos_use_opengl_rendering =
200 !(is_ios && target_environment == "catalyst")
201
Jiawei Ou08745302019-02-12 11:36:13 -0800202 # When set to false, builtin audio encoder/decoder factories and all the
203 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
204 # (they will still be included in libjingle_peerconnection_so.so and
205 # WebRTC.framework)
206 rtc_include_builtin_audio_codecs = true
207
208 # When set to false, builtin video encoder/decoder factories and all the
209 # video codecs they depends on will not be included in libwebrtc.{a|lib}
210 # (they will still be included in libjingle_peerconnection_so.so and
211 # WebRTC.framework)
212 rtc_include_builtin_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100213
214 # When set to true and in a standalone build, it will undefine UNICODE and
215 # _UNICODE (which are always defined globally by the Chromium Windows
216 # toolchain).
217 # This is only needed for testing purposes, WebRTC wants to be sure it
218 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
219 # wide character functions.
220 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 13:47:54 -0700221
222 # When set to true, a capturer implementation that uses the
Austin Orion66241e42021-04-22 13:22:25 -0700223 # Windows.Graphics.Capture APIs will be available for use. This introduces a
224 # dependency on the Win 10 SDK v10.0.17763.0.
Austin Orion78f04d82021-04-23 12:37:26 -0700225 rtc_enable_win_wgc = is_win
Dan Minor9c686132018-01-15 10:20:00 -0500226}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800227
Dan Minor9c686132018-01-15 10:20:00 -0500228if (!build_with_mozilla) {
229 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800230}
231
232# A second declare_args block, so that declarations within it can
233# depend on the possibly overridden variables in the first
234# declare_args block.
235declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500236 # Enables the use of protocol buffers for debug recordings.
237 rtc_enable_protobuf = !build_with_mozilla
238
239 # Set this to disable building with support for SCTP data channels.
240 rtc_enable_sctp = !build_with_mozilla
241
242 # Disable these to not build components which can be externally provided.
243 rtc_build_json = !build_with_mozilla
244 rtc_build_libsrtp = !build_with_mozilla
245 rtc_build_libvpx = !build_with_mozilla
246 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500247 rtc_build_opus = !build_with_mozilla
248 rtc_build_ssl = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500249
250 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200251 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
252 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500253 rtc_enable_libevent = false
254 rtc_build_libevent = false
255 } else {
256 rtc_enable_libevent = true
257 rtc_build_libevent = !build_with_mozilla
258 }
259
mbonadei9aa3f0a2017-01-24 06:58:22 -0800260 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
261 rtc_include_pulse_audio = !build_with_chromium
262
263 # Chromium uses its own IO handling, so the internal ADM is only built for
264 # standalone WebRTC.
265 rtc_include_internal_audio_device = !build_with_chromium
266
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800267 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 12:02:32 +0200268 # TODO: Make sure that AVX2 works also for non-clang compilers.
269 if (is_clang == true) {
270 rtc_enable_avx2 = true
271 } else {
272 rtc_enable_avx2 = false
273 }
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800274
Philipp Hancke1a89bc82021-03-02 21:23:24 +0100275 # Set this to true to build the unit tests.
276 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 10:20:00 -0500277 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200278
279 # Set this to false to skip building code that also requires X11 extensions
280 # such as Xdamage, Xfixes.
281 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100282
283 # Set this to true to fully remove logging from WebRTC.
284 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100285
286 # Set this to true to disable trace events.
287 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100288
289 # Set this to true to disable detailed error message and logging for
290 # RTC_CHECKs.
291 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100292
293 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100294 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200295
296 # Set this to true to exclude the transient suppressor in the audio processing
297 # module from the build.
298 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800299}
300
Florent Castellia80c3e52021-04-15 15:02:56 +0200301declare_args() {
Florent Castellia6983c62021-05-06 10:50:07 +0200302 # Enable the dcsctp backend for DataChannels and related unittests
303 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
304
Florent Castellia80c3e52021-04-15 15:02:56 +0200305 # Enable the usrsctp backend for DataChannels and related unittests
306 rtc_build_usrsctp = !build_with_mozilla && rtc_enable_sctp
307}
308
mbonadei9aa3f0a2017-01-24 06:58:22 -0800309# Make it possible to provide custom locations for some libraries (move these
310# up into declare_args should we need to actually use them for the GN build).
311rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800312rtc_opus_dir = "//third_party/opus"
313
314# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200315rtc_desktop_capture_supported =
316 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900317 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800318
319###############################################################################
320# Templates
321#
322
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200323# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800324# chromium.
325# We need absolute paths for all configs in templates as they are shared in
326# different subdirectories.
327webrtc_root = get_path_info(".", "abspath")
328
329# Global configuration that should be applied to all WebRTC targets.
330# You normally shouldn't need to include this in your target as it's
331# automatically included when using the rtc_* templates.
332# It sets defines, include paths and compilation warnings accordingly,
333# both for WebRTC stand-alone builds and for the scenario when WebRTC
334# native code is built as part of Chromium.
Mirko Bonadei5f078452021-07-30 22:32:55 +0200335rtc_common_configs = [ webrtc_root + ":common_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800336
kthelgasonc0977102017-04-24 00:57:16 -0700337if (is_mac || is_ios) {
338 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
339}
340
mbonadei9aa3f0a2017-01-24 06:58:22 -0800341# Global public configuration that should be applied to all WebRTC targets. You
342# normally shouldn't need to include this in your target as it's automatically
343# included when using the rtc_* templates. It set the defines, include paths and
344# compilation warnings that should be propagated to dependents of the targets
345# depending on the target having this config.
346rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
347
348# Common configs to remove or add in all rtc targets.
349rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100350if (!build_with_chromium && is_clang) {
351 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
352}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800353rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200354rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200355rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800356
357set_defaults("rtc_test") {
358 configs = rtc_add_configs
359 suppressed_configs = []
360}
361
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200362set_defaults("rtc_library") {
363 configs = rtc_add_configs
364 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200365 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200366}
367
mbonadei9aa3f0a2017-01-24 06:58:22 -0800368set_defaults("rtc_source_set") {
369 configs = rtc_add_configs
370 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200371 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800372}
373
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200374set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800375 configs = rtc_add_configs
376 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200377 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800378}
379
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200380set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800381 configs = rtc_add_configs
382 suppressed_configs = []
383}
384
385set_defaults("rtc_shared_library") {
386 configs = rtc_add_configs
387 suppressed_configs = []
388}
389
Per Kjellandera7f2d842018-01-10 15:54:53 +0000390webrtc_default_visibility = [ webrtc_root + "/*" ]
391if (build_with_chromium) {
392 # Allow Chromium's WebRTC overrides targets to bypass the regular
393 # visibility restrictions.
394 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
395}
396
Karl Wibergbb23c832018-04-22 19:55:00 +0200397# ---- Poisons ----
398#
399# The general idea is that some targets declare that they contain some
400# kind of poison, which makes it impossible for other targets to
401# depend on them (even transitively) unless they declare themselves
402# immune to that particular type of poison.
403#
404# Targets that *contain* poison of type foo should contain the line
405#
406# poisonous = [ "foo" ]
407#
408# and targets that *are immune but arent't themselves poisonous*
409# should contain
410#
411# allow_poison = [ "foo" ]
412#
413# This useful in cases where we have some large target or set of
414# targets and want to ensure that most other targets do not
415# transitively depend on them. For example, almost no high-level
416# target should depend on the audio codecs, since we want WebRTC users
417# to be able to inject any subset of them and actually end up with a
418# binary that doesn't include the codecs they didn't inject.
419#
420# Test-only targets (`testonly` set to true) and non-public targets
421# (`visibility` not containing "*") are automatically immune to all
422# types of poison.
423#
424# Here's the complete list of all types of poison. It must be kept in
425# 1:1 correspondence with the set of //:poison_* targets.
426#
427all_poison_types = [
428 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
429 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200430
Danil Chapovalov41300af2019-07-10 12:44:43 +0200431 # Default task queue implementation.
432 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200433
434 # JSON parsing should not be needed in the "slim and modular" WebRTC.
435 "rtc_json",
436
437 # Software video codecs (VP8 and VP9 through libvpx).
438 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200439]
440
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000441absl_include_config = "//third_party/abseil-cpp:absl_include_config"
442absl_define_config = "//third_party/abseil-cpp:absl_define_config"
443
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200444# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
445# that are testonly.
446absl_flags_config = webrtc_root + ":absl_flags_configs"
447
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100448# WebRTC wrapper of Chromium's test() template. This template just adds some
449# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
450# target.
451# The parameter `is_xctest` is different from the one in the Chromium's test()
452# template (and it is not forwarded to it). In rtc_test(), the argument
453# `is_xctest` is used to avoid to take dependencies that are not needed
454# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800455template("rtc_test") {
456 test(target_name) {
457 forward_variables_from(invoker,
458 "*",
459 [
460 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100461 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800462 "public_configs",
463 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200464 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800465 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100466
467 # Always override to public because when target_os is Android the `test`
468 # template can override it to [ "*" ] and we want to avoid conditional
469 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100470 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800471 configs += invoker.configs
472 configs -= rtc_remove_configs
473 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000474 public_configs = [
475 rtc_common_inherited_config,
476 absl_include_config,
477 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200478 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000479 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800480 if (defined(invoker.public_configs)) {
481 public_configs += invoker.public_configs
482 }
sakald7fdb802017-05-26 01:51:53 -0700483 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800484 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 18:53:11 -0400485 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200486 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200487 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 19:03:37 +0200488 deps += [
489 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
490 webrtc_root + "test:native_test_java",
491 ]
sakald7fdb802017-05-26 01:51:53 -0700492 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100493
494 # When not targeting a simulator, building //base/test:google_test_runner
495 # fails, so it is added only when the test is not a real XCTest and when
496 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100497 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100498 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
499 xctest_module_target = "//base/test:google_test_runner"
500 }
501 }
Andrey Logvin78646002021-01-29 10:50:19 +0000502
503 # If absl_deps is [], no action is needed. If not [], then it needs to be
504 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
505 # otherwise it just needs to be added to deps.
506 if (defined(absl_deps) && absl_deps != []) {
507 if (!defined(deps)) {
508 deps = []
509 }
510 if (build_with_chromium) {
511 deps += [ "//third_party/abseil-cpp:absl" ]
512 } else {
513 deps += absl_deps
514 }
515 }
516
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100517 if (using_sanitizer) {
518 if (is_linux) {
519 if (!defined(invoker.data)) {
520 data = []
521 }
522 data +=
523 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
524 }
525 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800526 }
527}
528
529template("rtc_source_set") {
530 source_set(target_name) {
531 forward_variables_from(invoker,
532 "*",
533 [
534 "configs",
535 "public_configs",
536 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200537 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800538 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200539 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000540 if (!defined(visibility)) {
541 visibility = webrtc_default_visibility
542 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200543
544 # What's your poison?
545 if (defined(testonly) && testonly) {
546 assert(!defined(poisonous))
547 assert(!defined(allow_poison))
548 } else {
549 if (!defined(poisonous)) {
550 poisonous = []
551 }
552 if (!defined(allow_poison)) {
553 allow_poison = []
554 }
555 if (!defined(assert_no_deps)) {
556 assert_no_deps = []
557 }
558 if (!defined(deps)) {
559 deps = []
560 }
561 foreach(p, poisonous) {
562 deps += [ webrtc_root + ":poison_" + p ]
563 }
564 foreach(poison_type, all_poison_types) {
565 allow_dep = true
566 foreach(v, visibility) {
567 if (v == "*") {
568 allow_dep = false
569 }
570 }
571 foreach(p, allow_poison + poisonous) {
572 if (p == poison_type) {
573 allow_dep = true
574 }
575 }
576 if (!allow_dep) {
577 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
578 }
579 }
580 }
581
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100582 # Chromium should only depend on the WebRTC component in order to
583 # avoid to statically link WebRTC in a component build.
584 if (build_with_chromium) {
585 publicly_visible = false
586 foreach(v, visibility) {
587 if (v == "*") {
588 publicly_visible = true
589 }
590 }
591 if (publicly_visible) {
592 visibility = []
593 visibility = webrtc_default_visibility
594 }
595 }
596
Mirko Bonadei96ede162018-09-06 13:45:44 +0200597 if (!defined(testonly) || !testonly) {
598 configs += rtc_prod_configs
599 }
600
mbonadei9aa3f0a2017-01-24 06:58:22 -0800601 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200602 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800603 configs -= rtc_remove_configs
604 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000605 public_configs = [
606 rtc_common_inherited_config,
607 absl_include_config,
608 absl_define_config,
609 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200610 if (defined(testonly) && testonly) {
611 public_configs += [ absl_flags_config ]
612 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800613 if (defined(invoker.public_configs)) {
614 public_configs += invoker.public_configs
615 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200616
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200617 # If absl_deps is [], no action is needed. If not [], then it needs to be
618 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200619 # otherwise it just needs to be added to deps.
620 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200621 if (!defined(deps)) {
622 deps = []
623 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200624 if (build_with_chromium) {
625 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200626 } else {
627 deps += absl_deps
628 }
629 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800630 }
631}
632
mbonadei9aa3f0a2017-01-24 06:58:22 -0800633template("rtc_static_library") {
634 static_library(target_name) {
635 forward_variables_from(invoker,
636 "*",
637 [
638 "configs",
639 "public_configs",
640 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200641 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800642 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200643 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000644 if (!defined(visibility)) {
645 visibility = webrtc_default_visibility
646 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200647
648 # What's your poison?
649 if (defined(testonly) && testonly) {
650 assert(!defined(poisonous))
651 assert(!defined(allow_poison))
652 } else {
653 if (!defined(poisonous)) {
654 poisonous = []
655 }
656 if (!defined(allow_poison)) {
657 allow_poison = []
658 }
659 if (!defined(assert_no_deps)) {
660 assert_no_deps = []
661 }
662 if (!defined(deps)) {
663 deps = []
664 }
665 foreach(p, poisonous) {
666 deps += [ webrtc_root + ":poison_" + p ]
667 }
668 foreach(poison_type, all_poison_types) {
669 allow_dep = true
670 foreach(v, visibility) {
671 if (v == "*") {
672 allow_dep = false
673 }
674 }
675 foreach(p, allow_poison + poisonous) {
676 if (p == poison_type) {
677 allow_dep = true
678 }
679 }
680 if (!allow_dep) {
681 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
682 }
683 }
684 }
685
Mirko Bonadei96ede162018-09-06 13:45:44 +0200686 if (!defined(testonly) || !testonly) {
687 configs += rtc_prod_configs
688 }
689
mbonadei9aa3f0a2017-01-24 06:58:22 -0800690 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200691 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800692 configs -= rtc_remove_configs
693 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000694 public_configs = [
695 rtc_common_inherited_config,
696 absl_include_config,
697 absl_define_config,
698 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200699 if (defined(testonly) && testonly) {
700 public_configs += [ absl_flags_config ]
701 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800702 if (defined(invoker.public_configs)) {
703 public_configs += invoker.public_configs
704 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200705
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200706 # If absl_deps is [], no action is needed. If not [], then it needs to be
707 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200708 # otherwise it just needs to be added to deps.
709 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200710 if (!defined(deps)) {
711 deps = []
712 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200713 if (build_with_chromium) {
714 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200715 } else {
716 deps += absl_deps
717 }
718 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800719 }
720}
721
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200722# This template automatically switches the target type between source_set
723# and static_library.
724#
725# This should be the default target type for all the WebRTC targets with
726# one exception. Do not use this template for header only targets, in that case
727# rtc_source_set must be used in order to avoid build errors (e.g. libtool
728# complains if the output .a file is empty).
729#
730# How does it work:
731# Since all files in a source_set are linked into a final binary, while files
732# in a static library are only linked in if at least one symbol in them is
733# referenced, in component builds source_sets are easy to deal with because
734# all their object files are passed to the linker to create a shared library.
735# In release builds instead, static_libraries are preferred since they allow
736# the linker to discard dead code.
737# For the same reason, testonly targets will always be expanded to
738# source_set in order to be sure that tests are present in the test binary.
739template("rtc_library") {
740 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
741 target_type = "source_set"
742 } else {
743 target_type = "static_library"
744 }
745 target(target_type, target_name) {
746 forward_variables_from(invoker,
747 "*",
748 [
749 "configs",
750 "public_configs",
751 "suppressed_configs",
752 "visibility",
753 ])
754 forward_variables_from(invoker, [ "visibility" ])
755 if (!defined(visibility)) {
756 visibility = webrtc_default_visibility
757 }
758
759 # What's your poison?
760 if (defined(testonly) && testonly) {
761 assert(!defined(poisonous))
762 assert(!defined(allow_poison))
763 } else {
764 if (!defined(poisonous)) {
765 poisonous = []
766 }
767 if (!defined(allow_poison)) {
768 allow_poison = []
769 }
770 if (!defined(assert_no_deps)) {
771 assert_no_deps = []
772 }
773 if (!defined(deps)) {
774 deps = []
775 }
776 foreach(p, poisonous) {
777 deps += [ webrtc_root + ":poison_" + p ]
778 }
779 foreach(poison_type, all_poison_types) {
780 allow_dep = true
781 foreach(v, visibility) {
782 if (v == "*") {
783 allow_dep = false
784 }
785 }
786 foreach(p, allow_poison + poisonous) {
787 if (p == poison_type) {
788 allow_dep = true
789 }
790 }
791 if (!allow_dep) {
792 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
793 }
794 }
795 }
796
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100797 # Chromium should only depend on the WebRTC component in order to
798 # avoid to statically link WebRTC in a component build.
799 if (build_with_chromium) {
800 publicly_visible = false
801 foreach(v, visibility) {
802 if (v == "*") {
803 publicly_visible = true
804 }
805 }
806 if (publicly_visible) {
807 visibility = []
808 visibility = webrtc_default_visibility
809 }
810 }
811
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200812 if (!defined(testonly) || !testonly) {
813 configs += rtc_prod_configs
814 }
815
816 configs += invoker.configs
817 configs += rtc_library_impl_config
818 configs -= rtc_remove_configs
819 configs -= invoker.suppressed_configs
820 public_configs = [
821 rtc_common_inherited_config,
822 absl_include_config,
823 absl_define_config,
824 ]
825 if (defined(testonly) && testonly) {
826 public_configs += [ absl_flags_config ]
827 }
828 if (defined(invoker.public_configs)) {
829 public_configs += invoker.public_configs
830 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200831
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200832 # If absl_deps is [], no action is needed. If not [], then it needs to be
833 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200834 # otherwise it just needs to be added to deps.
835 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200836 if (!defined(deps)) {
837 deps = []
838 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200839 if (build_with_chromium) {
840 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200841 } else {
842 deps += absl_deps
843 }
844 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200845 }
846}
847
848template("rtc_executable") {
849 executable(target_name) {
850 forward_variables_from(invoker,
851 "*",
852 [
853 "deps",
854 "configs",
855 "public_configs",
856 "suppressed_configs",
857 "visibility",
858 ])
859 forward_variables_from(invoker, [ "visibility" ])
860 if (!defined(visibility)) {
861 visibility = webrtc_default_visibility
862 }
863 configs += invoker.configs
864 configs -= rtc_remove_configs
865 configs -= invoker.suppressed_configs
866 deps = invoker.deps
867
868 public_configs = [
869 rtc_common_inherited_config,
870 absl_include_config,
871 absl_define_config,
872 ]
873 if (defined(testonly) && testonly) {
874 public_configs += [ absl_flags_config ]
875 }
876 if (defined(invoker.public_configs)) {
877 public_configs += invoker.public_configs
878 }
879 if (is_win) {
880 deps += [
881 # Give executables the default manifest on Windows (a no-op elsewhere).
882 "//build/win:default_exe_manifest",
883 ]
884 }
885 }
886}
887
mbonadei9aa3f0a2017-01-24 06:58:22 -0800888template("rtc_shared_library") {
889 shared_library(target_name) {
890 forward_variables_from(invoker,
891 "*",
892 [
893 "configs",
894 "public_configs",
895 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200896 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800897 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200898 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000899 if (!defined(visibility)) {
900 visibility = webrtc_default_visibility
901 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200902
903 # What's your poison?
904 if (defined(testonly) && testonly) {
905 assert(!defined(poisonous))
906 assert(!defined(allow_poison))
907 } else {
908 if (!defined(poisonous)) {
909 poisonous = []
910 }
911 if (!defined(allow_poison)) {
912 allow_poison = []
913 }
914 if (!defined(assert_no_deps)) {
915 assert_no_deps = []
916 }
917 if (!defined(deps)) {
918 deps = []
919 }
920 foreach(p, poisonous) {
921 deps += [ webrtc_root + ":poison_" + p ]
922 }
923 foreach(poison_type, all_poison_types) {
924 allow_dep = true
925 foreach(v, visibility) {
926 if (v == "*") {
927 allow_dep = false
928 }
929 }
930 foreach(p, allow_poison + poisonous) {
931 if (p == poison_type) {
932 allow_dep = true
933 }
934 }
935 if (!allow_dep) {
936 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
937 }
938 }
939 }
940
mbonadei9aa3f0a2017-01-24 06:58:22 -0800941 configs += invoker.configs
942 configs -= rtc_remove_configs
943 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000944 public_configs = [
945 rtc_common_inherited_config,
946 absl_include_config,
947 absl_define_config,
948 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200949 if (defined(testonly) && testonly) {
950 public_configs += [ absl_flags_config ]
951 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800952 if (defined(invoker.public_configs)) {
953 public_configs += invoker.public_configs
954 }
955 }
956}
kthelgason4065a572017-02-14 04:58:56 -0800957
958if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400959 # TODO: Generate module.modulemap file to enable use in Swift
960 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100961 template("ios_framework_bundle_with_umbrella_header") {
962 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900963 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100964 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900965 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
966
967 action_foreach("create_bracket_include_headers_$target_name") {
968 script = "//tools_webrtc/apple/copy_framework_header.py"
969 sources = invoker.sources
970 output_name = invoker.output_name
971 outputs = [
972 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
973 ]
974 args = [
975 "--input",
976 "{{source}}",
977 "--output",
978 rebase_path(target_gen_dir, root_build_dir) +
979 "/$output_name.framework/WebRTC/{{source_file_part}}",
980 ]
981 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100982
983 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900984 forward_variables_from(invoker, "*", [ "public_headers" ])
985 public_headers = get_target_outputs(
986 ":create_bracket_include_headers_$this_target_name")
987 deps += [
988 ":copy_umbrella_header_$target_name",
989 ":create_bracket_include_headers_$target_name",
990 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100991 }
992
993 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900994 public_headers = get_target_outputs(
995 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100996
997 script = "//tools_webrtc/ios/generate_umbrella_header.py"
998
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100999 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001000 args = [
1001 "--out",
1002 rebase_path(umbrella_header_path, root_build_dir),
1003 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +02001004 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001005 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001006 }
1007
Jordan Rose53d3fc92021-07-06 12:16:41 -07001008 if (target_environment == "catalyst") {
1009 # Catalyst frameworks use the same layout as regular Mac frameworks.
1010 headers_dir = "Versions/A/Headers"
1011 } else {
1012 headers_dir = "Headers"
1013 }
Anders Carlssondc6b4772018-01-15 13:31:03 +01001014 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001015 sources = [ umbrella_header_path ]
1016 outputs =
Jordan Rose53d3fc92021-07-06 12:16:41 -07001017 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001018
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001019 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001020 }
1021 }
1022
1023 set_defaults("ios_framework_bundle_with_umbrella_header") {
1024 configs = default_shared_library_configs
1025 }
kthelgason4065a572017-02-14 04:58:56 -08001026}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001027
Anders Carlsson37bbf792018-09-05 16:29:27 +02001028if (is_mac) {
1029 template("mac_framework_bundle_with_umbrella_header") {
1030 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001031 this_target_name = target_name
1032 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001033 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +02001034
1035 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -08001036 forward_variables_from(invoker, "*", [ "configs" ])
1037 if (defined(invoker.configs)) {
1038 configs += invoker.configs
1039 }
Anders Carlsson37bbf792018-09-05 16:29:27 +02001040
1041 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001042 framework_contents = [
1043 "Headers",
1044 "Modules",
1045 "Resources",
1046 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001047
1048 ldflags = [
1049 "-all_load",
1050 "-install_name",
1051 "@rpath/$output_name.framework/$output_name",
1052 ]
1053
1054 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001055 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001056 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001057 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001058 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001059 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001060 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001061 ]
1062 }
1063
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001064 action_foreach("create_bracket_include_headers_$this_target_name") {
1065 script = "//tools_webrtc/apple/copy_framework_header.py"
1066 sources = invoker.sources
1067 output_name = invoker.output_name
1068 outputs = [
1069 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1070 ]
1071 args = [
1072 "--input",
1073 "{{source}}",
1074 "--output",
1075 rebase_path(target_gen_dir, root_build_dir) +
1076 "/$output_name.framework/WebRTC/{{source_file_part}}",
1077 ]
1078 }
1079
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001080 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001081 sources = get_target_outputs(
1082 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001083
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001084 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001085 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001086 }
1087
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001088 action("modulemap_$this_target_name") {
1089 script = "//tools_webrtc/ios/generate_modulemap.py"
1090 args = [
1091 "--out",
1092 rebase_path(modulemap_path, root_build_dir),
1093 "--name",
1094 output_name,
1095 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001096 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001097 }
1098
1099 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001100 sources = [ modulemap_path ]
1101 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1102 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001103 }
1104
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001105 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001106 sources = get_target_outputs(
1107 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001108
1109 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1110
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001111 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001112 args = [
1113 "--out",
1114 rebase_path(umbrella_header_path, root_build_dir),
1115 "--sources",
1116 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001117 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001118 }
1119
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001120 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001121 sources = [ umbrella_header_path ]
1122 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001123
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001124 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001125 }
1126 }
1127}
1128
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001129if (is_android) {
1130 template("rtc_android_library") {
1131 android_library(target_name) {
1132 forward_variables_from(invoker,
1133 "*",
1134 [
1135 "configs",
1136 "public_configs",
1137 "suppressed_configs",
1138 "visibility",
1139 ])
1140
Oleh Prypin05aee742018-11-23 17:29:44 +01001141 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001142
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001143 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001144 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001145
1146 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001147 if (defined(invoker.errorprone_args)) {
1148 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001149 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001150
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001151 if (!defined(deps)) {
1152 deps = []
1153 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001154
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001155 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001156 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001157 }
1158 }
1159
1160 template("rtc_android_apk") {
1161 android_apk(target_name) {
1162 forward_variables_from(invoker,
1163 "*",
1164 [
1165 "configs",
1166 "public_configs",
1167 "suppressed_configs",
1168 "visibility",
1169 ])
1170
1171 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001172 errorprone_args = []
1173 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001174
1175 if (!defined(deps)) {
1176 deps = []
1177 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001178
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001179 no_build_hooks = true
1180 }
1181 }
1182
1183 template("rtc_instrumentation_test_apk") {
1184 instrumentation_test_apk(target_name) {
1185 forward_variables_from(invoker,
1186 "*",
1187 [
1188 "configs",
1189 "public_configs",
1190 "suppressed_configs",
1191 "visibility",
1192 ])
1193
1194 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001195 errorprone_args = []
1196 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001197
1198 if (!defined(deps)) {
1199 deps = []
1200 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001201
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001202 no_build_hooks = true
1203 }
1204 }
1205}