blob: 66ed8434ff052c1ec280737bc67f0659138abaa7 [file] [log] [blame]
mbonadei9aa3f0a2017-01-24 14:58:221# 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 14:58:228import("//build/config/arm.gni")
9import("//build/config/features.gni")
10import("//build/config/mips.gni")
Maksim Sisovef4d0b62021-09-20 06:02:0111import("//build/config/ozone.gni")
mbonadei9aa3f0a2017-01-24 14:58:2212import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 05:32:2313import("//build/config/sysroot.gni")
mbonadei9aa3f0a2017-01-24 14:58:2214import("//build_overrides/build.gni")
mbonadei96606272017-03-04 03:41:5915
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:1126 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/main/docs/component_build.md")
mbonadei96606272017-03-04 03:41:5927 assert(!is_component_build, "Component builds are not supported in WebRTC.")
28}
29
kthelgason4065a5762017-02-14 12:58:5630if (is_ios) {
31 import("//build/config/ios/rules.gni")
32}
mbonadei9aa3f0a2017-01-24 14:58:2233
Anders Carlsson37bbf792018-09-05 14:29:2734if (is_mac) {
35 import("//build/config/mac/rules.gni")
36}
37
Christoffer Jansson25e41562022-09-23 06:38:5438if (is_fuchsia) {
39 import("//build/config/fuchsia/config.gni")
40}
41
Mirko Bonadeie3b42632024-03-27 12:13:5242if (build_with_chromium) {
43 import("//media/media_options.gni")
44}
45
Mirko Bonadei5f078452021-07-30 20:32:5546# This declare_args is separated from the next one because args declared
47# in this one, can be read from the next one (args defined in the same
48# declare_args cannot be referenced in that scope).
mbonadei9aa3f0a2017-01-24 14:58:2249declare_args() {
Mirko Bonadei028248c2018-10-10 10:19:0250 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
51 # expand to code that will manage symbols visibility.
52 rtc_enable_symbol_export = false
Mirko Bonadei5f078452021-07-30 20:32:5553}
54
55declare_args() {
Mirko Bonadei339965f2021-10-12 11:23:4456 # Setting this to true, will make RTC_DLOG() expand to log statements instead
Mirko Bonadei56ed4682021-10-12 06:55:4257 # of being removed by the preprocessor.
58 # This is useful for example to be able to get RTC_DLOGs on a release build.
59 rtc_dlog_always_on = false
60
Peter Kasting1e6d77c2023-03-13 23:01:0061 # Enables additional build targets that rely on
62 # //third_party/google_benchmarks.
63 rtc_enable_google_benchmarks = true
64
Mirko Bonadei5f078452021-07-30 20:32:5565 # Setting this to true will make RTC_OBJC_EXPORT expand to code that will
66 # manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported
67 # if C++ symbols are but setting this arg to true while keeping
68 # rtc_enable_symbol_export=false will only export RTC_OBJC_EXPORT
69 # annotated symbols.
70 rtc_enable_objc_symbol_export = rtc_enable_symbol_export
Mirko Bonadei028248c2018-10-10 10:19:0271
Mirko Bonadei31b0b452018-08-22 08:37:1172 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 13:44:2873 # will tell the pre-processor to remove the default definition of symbols
74 # needed to use field_trial. In that case a new implementation needs to be
75 # provided.
Mirko Bonadei31b0b452018-08-22 08:37:1176 if (build_with_chromium) {
77 # When WebRTC is built as part of Chromium it should exclude the default
78 # implementation of field_trial unless it is building for NACL or
79 # Chromecast.
Ryan Keanecf7802d2022-06-10 21:33:1880 rtc_exclude_field_trial_default = !is_nacl && !is_castos && !is_cast_android
Mirko Bonadei31b0b452018-08-22 08:37:1181 } else {
82 rtc_exclude_field_trial_default = false
83 }
Mirko Bonadei70400902018-08-21 13:44:2884
Mirko Bonadei906add42018-09-05 14:03:1685 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
86 # will tell the pre-processor to remove the default definition of symbols
87 # needed to use metrics. In that case a new implementation needs to be
88 # provided.
89 rtc_exclude_metrics_default = build_with_chromium
90
Johannes Kronda20c732021-02-19 15:39:4191 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which
92 # will tell the pre-processor to remove the default definition of the
93 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
94 # that case a new implementation needs to be provided.
Johannes Kronbb52bdf2021-02-25 09:10:0895 rtc_exclude_system_time = build_with_chromium
Johannes Kronda20c732021-02-19 15:39:4196
Benjamin Wrightd6f86e82018-05-08 20:12:2597 # Setting this to false will require the API user to pass in their own
98 # SSLCertificateVerifier to verify the certificates presented from a
99 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
100 rtc_builtin_ssl_root_certificates = true
101
Karl Wibergeb254b42017-11-01 14:08:12102 # Include the iLBC audio codec?
Olga Sharonova5fbd7582020-07-09 09:50:42103 rtc_include_ilbc = true
Karl Wibergeb254b42017-11-01 14:08:12104
mbonadei9aa3f0a2017-01-24 14:58:22105 # Disable this to avoid building the Opus audio codec.
106 rtc_include_opus = true
107
minyue2e03c662017-02-02 01:31:11108 # Enable this if the Opus version upon which WebRTC is built supports direct
109 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 15:45:49110 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-02 01:31:11111
mbonadei9aa3f0a2017-01-24 14:58:22112 # Enable this to let the Opus audio codec change complexity on the fly.
113 rtc_opus_variable_complexity = false
114
mbonadei9aa3f0a2017-01-24 14:58:22115 # Used to specify an external Jsoncpp include path when not compiling the
116 # library that comes with WebRTC (i.e. rtc_build_json == 0).
117 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
118
119 # Used to specify an external OpenSSL include path when not compiling the
120 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
121 rtc_ssl_root = ""
122
mbonadei9aa3f0a2017-01-24 14:58:22123 # Enable when an external authentication mechanism is used for performing
124 # packet authentication for RTP packets instead of libsrtp.
125 rtc_enable_external_auth = build_with_chromium
126
127 # Selects whether debug dumps for the audio processing module
128 # should be generated.
129 apm_debug_dump = false
130
Per Åhgrencc73ed32020-04-26 21:56:17131 # Selects whether the audio processing module should be excluded.
132 rtc_exclude_audio_processing_module = false
133
Joachim Bauch93e91342017-12-07 00:25:53134 # Set this to false to skip building examples.
135 rtc_build_examples = true
136
137 # Set this to false to skip building tools.
138 rtc_build_tools = true
139
Joachim Bauch75f18fc2017-12-20 20:25:47140 # Set this to false to skip building code that requires X11.
Maksim Sisovef4d0b62021-09-20 06:02:01141 rtc_use_x11 = ozone_platform_x11
Joachim Bauch75f18fc2017-12-20 20:25:47142
Tomas Popela318da512018-11-13 05:32:23143 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 13:37:51144 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
145 # only when using the sysroot as PipeWire is not available in older and
146 # supported Ubuntu and Debian distributions.
Artem Titov4d6a76d2021-09-03 10:07:20147 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 13:37:51148
Jan Gruliche1e05af2021-09-21 18:36:16149 # Set this to link PipeWire and required libraries directly instead of using the dlopen.
Tomas Popela762543f2018-12-12 13:37:51150 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 05:32:23151
mbonadei9aa3f0a2017-01-24 14:58:22152 # Enable to use the Mozilla internal settings.
153 build_with_mozilla = false
154
Philipp Hanckee95ebda2020-09-17 14:13:20155 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
156 # and NDK r16 or above.
henrika883d00f2018-03-16 09:09:49157 rtc_enable_android_aaudio = false
158
mbonadei9aa3f0a2017-01-24 14:58:22159 # Set to "func", "block", "edge" for coverage generation.
160 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
161 # It is recommend to set include_examples=0.
162 # Use llvm's sancov -html-report for human readable reports.
163 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
164 rtc_sanitize_coverage = ""
165
Philipp Hanckeaeac9f82020-09-11 09:58:18166 # Selects fixed-point code where possible.
167 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 14:58:22168 if (current_cpu == "arm" || current_cpu == "arm64") {
169 rtc_prefer_fixed_point = true
170 }
171
mbonadei9aa3f0a2017-01-24 14:58:22172 # Determines whether NEON code will be built.
173 rtc_build_with_neon =
174 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
175
176 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
177 # all platforms except Android and iOS. Because FFmpeg can be built
Artem Titov22a6b2d2021-07-27 14:25:56178 # with/without H.264 support, `ffmpeg_branding` has to separately be set to a
mbonadei9aa3f0a2017-01-24 14:58:22179 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Artem Titov22a6b2d2021-07-27 14:25:56180 # H.264, compilation succeeds but `H264DecoderImpl` fails to initialize.
mbonadei9aa3f0a2017-01-24 14:58:22181 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
182 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 09:47:18183 #
184 # Enabling H264 when building with MSVC is currently not supported, see
185 # bugs.webrtc.org/9213#c13 for more info.
186 rtc_use_h264 =
187 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 14:58:22188
Jan Grulich0f862522024-04-29 14:16:28189 # Use system OpenH264
190 rtc_system_openh264 = false
191
qwu16972f2832023-08-15 09:16:54192 # Enable to use H265
Mirko Bonadeie3b42632024-03-27 12:13:52193 if (build_with_chromium) {
194 rtc_use_h265 = enable_hevc_parser_and_hw_decoder
195 } else {
196 rtc_use_h265 = proprietary_codecs
197 }
qwu16972f2832023-08-15 09:16:54198
Markus Handell8e75bd42020-06-05 09:47:40199 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
200 rtc_use_absl_mutex = false
201
mbonadei9aa3f0a2017-01-24 14:58:22202 # By default, use normal platform audio support or dummy audio, but don't
203 # use file-based audio playout and record.
204 rtc_use_dummy_audio_file_devices = false
205
henrika7be78832017-06-13 15:34:16206 # When set to true, replace the audio output with a sinus tone at 440Hz.
207 # The ADM will ask for audio data from WebRTC but instead of reading real
208 # audio samples from NetEQ, a sinus tone will be generated and replace the
209 # real audio samples.
210 rtc_audio_device_plays_sinus_tone = false
211
Anders Carlsson358f2e02018-06-04 08:24:37212 if (is_ios) {
213 # Build broadcast extension in AppRTCMobile for iOS. This results in the
214 # binary only running on iOS 11+, which is why it is disabled by default.
215 rtc_apprtcmobile_broadcast_extension = false
216 }
Anders Carlsson7bca8ca2018-08-30 07:30:29217
Kári Tristan Helgasonba50cb32023-06-28 12:32:04218 # Determines whether OpenGL is available on iOS.
219 rtc_ios_use_opengl_rendering = is_ios && target_environment != "catalyst"
Jordan Rose53d3fc92021-07-06 19:16:41220
Jiawei Ou08745302019-02-12 19:36:13221 # When set to false, builtin audio encoder/decoder factories and all the
222 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
223 # (they will still be included in libjingle_peerconnection_so.so and
224 # WebRTC.framework)
225 rtc_include_builtin_audio_codecs = true
226
Mirko Bonadei20574f42019-03-28 06:50:07227 # When set to true and in a standalone build, it will undefine UNICODE and
228 # _UNICODE (which are always defined globally by the Chromium Windows
229 # toolchain).
230 # This is only needed for testing purposes, WebRTC wants to be sure it
231 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
232 # wide character functions.
233 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 20:47:54234
235 # When set to true, a capturer implementation that uses the
Austin Orion66241e42021-04-22 20:22:25236 # Windows.Graphics.Capture APIs will be available for use. This introduces a
237 # dependency on the Win 10 SDK v10.0.17763.0.
Austin Orion78f04d82021-04-23 19:37:26238 rtc_enable_win_wgc = is_win
philipelb09d8722021-11-23 10:00:24239
240 # Includes the dav1d decoder in the internal decoder factory when set to true.
241 rtc_include_dav1d_in_internal_decoder_factory = true
Emil Lundmark6bf20cc2022-09-21 13:20:22242
Emil Lundmark9109e852023-02-28 12:57:01243 # When enabled, a run-time check will make sure that all field trial keys have
244 # been registered in accordance with the field trial policy, see
245 # g3doc/field-trials.md. The value can be set to the following:
246 #
247 # "dcheck": RTC_DCHECKs that the field trial has been registered. RTC_DCHECK
248 # must be enabled separately.
249 #
250 # "warn": RTC_LOGs a message with LS_WARNING severity if the field trial
251 # hasn't been registered.
252 rtc_strict_field_trials = ""
Mirko Bonadei91304312023-07-26 11:01:43253
254 # If different from "", symbols exported with RTC_OBJC_EXPORT will be prefixed
255 # with this string.
256 # See the definition of RTC_OBJC_TYPE_PREFIX in the code.
257 rtc_objc_prefix = ""
Arthur Sonzogni47faf322023-08-22 09:55:36258
259 # Embedders can define dependencies needed by WebRTC. Dependencies can be
260 # configs or targets. This can be defined in their `.gn` file.
261 #
262 # In practise, this is use by Chromium: Targets from
263 # `//third_party/webrtc_overrides` are depending on Chrome's `//base`, but
264 # WebRTC does not declare its public dependencies. See webrtc:8603. Instead
265 # WebRTC is using a global common dependencies.
266 rtc_common_public_deps = [] # no-presubmit-check TODO(webrtc:8603)
Evan Shrubsoledb50b032024-04-24 13:27:00267
268 # When true, include the Perfetto library.
269 rtc_use_perfetto = false
Dan Minor9c686132018-01-15 15:20:00270}
mbonadei9aa3f0a2017-01-24 14:58:22271
Dan Minor9c686132018-01-15 15:20:00272if (!build_with_mozilla) {
273 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 14:58:22274}
275
276# A second declare_args block, so that declarations within it can
277# depend on the possibly overridden variables in the first
278# declare_args block.
279declare_args() {
Dan Minor9c686132018-01-15 15:20:00280 # Enables the use of protocol buffers for debug recordings.
281 rtc_enable_protobuf = !build_with_mozilla
282
283 # Set this to disable building with support for SCTP data channels.
284 rtc_enable_sctp = !build_with_mozilla
285
286 # Disable these to not build components which can be externally provided.
287 rtc_build_json = !build_with_mozilla
288 rtc_build_libsrtp = !build_with_mozilla
289 rtc_build_libvpx = !build_with_mozilla
290 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 15:20:00291 rtc_build_opus = !build_with_mozilla
292 rtc_build_ssl = !build_with_mozilla
Dan Minor9c686132018-01-15 15:20:00293
294 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 17:05:00295 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
296 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 15:20:00297 rtc_enable_libevent = false
298 rtc_build_libevent = false
299 } else {
300 rtc_enable_libevent = true
301 rtc_build_libevent = !build_with_mozilla
302 }
303
mbonadei9aa3f0a2017-01-24 14:58:22304 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
305 rtc_include_pulse_audio = !build_with_chromium
306
307 # Chromium uses its own IO handling, so the internal ADM is only built for
308 # standalone WebRTC.
309 rtc_include_internal_audio_device = !build_with_chromium
310
Zhaoliang Ma72e43212020-08-17 09:13:41311 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 10:02:32312 # TODO: Make sure that AVX2 works also for non-clang compilers.
313 if (is_clang == true) {
314 rtc_enable_avx2 = true
315 } else {
316 rtc_enable_avx2 = false
317 }
Zhaoliang Ma72e43212020-08-17 09:13:41318
Philipp Hancke1a89bc82021-03-02 20:23:24319 # Set this to true to build the unit tests.
320 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 15:20:00321 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 11:27:07322
323 # Set this to false to skip building code that also requires X11 extensions
324 # such as Xdamage, Xfixes.
325 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 15:24:46326
327 # Set this to true to fully remove logging from WebRTC.
328 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 13:24:31329
330 # Set this to true to disable trace events.
331 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 16:09:30332
333 # Set this to true to disable detailed error message and logging for
334 # RTC_CHECKs.
335 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 12:06:53336
337 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 14:02:53338 rtc_disable_metrics = false
mbonadei9aa3f0a2017-01-24 14:58:22339}
340
Florent Castellia80c3e52021-04-15 13:02:56341declare_args() {
Florent Castellia6983c62021-05-06 08:50:07342 # Enable the dcsctp backend for DataChannels and related unittests
343 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
344
Florent Castelli023be3c2022-03-15 15:01:52345 # Enable gRPC used for negotiation in multiprocess tests
346 rtc_enable_grpc = rtc_enable_protobuf && (is_linux || is_mac)
Florent Castellia80c3e52021-04-15 13:02:56347}
348
mbonadei9aa3f0a2017-01-24 14:58:22349# Make it possible to provide custom locations for some libraries (move these
350# up into declare_args should we need to actually use them for the GN build).
351rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 14:58:22352rtc_opus_dir = "//third_party/opus"
353
354# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 11:27:07355rtc_desktop_capture_supported =
356 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 09:10:11357 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 14:58:22358
359###############################################################################
360# Templates
361#
362
Mirko Bonadei92ea95e2017-09-15 04:47:31363# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 14:58:22364# chromium.
365# We need absolute paths for all configs in templates as they are shared in
366# different subdirectories.
367webrtc_root = get_path_info(".", "abspath")
368
369# Global configuration that should be applied to all WebRTC targets.
370# You normally shouldn't need to include this in your target as it's
371# automatically included when using the rtc_* templates.
372# It sets defines, include paths and compilation warnings accordingly,
373# both for WebRTC stand-alone builds and for the scenario when WebRTC
374# native code is built as part of Chromium.
Mirko Bonadei5f078452021-07-30 20:32:55375rtc_common_configs = [ webrtc_root + ":common_config" ]
mbonadei9aa3f0a2017-01-24 14:58:22376
kthelgasonc0977102017-04-24 07:57:16377if (is_mac || is_ios) {
Christoffer Janssonfe2e7ea2023-08-02 07:41:23378 if (filter_include(default_compiler_configs,
379 [ "//build/config/compiler:enable_arc" ]) == []) {
380 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
381 }
kthelgasonc0977102017-04-24 07:57:16382}
Evan Shrubsole047238e2024-04-29 11:36:58383
Evan Shrubsolefa870372024-05-02 11:59:39384if (build_with_chromium) {
Evan Shrubsole047238e2024-04-29 11:36:58385 rtc_use_perfetto = true
386}
387
mbonadei9aa3f0a2017-01-24 14:58:22388# Global public configuration that should be applied to all WebRTC targets. You
389# normally shouldn't need to include this in your target as it's automatically
390# included when using the rtc_* templates. It set the defines, include paths and
391# compilation warnings that should be propagated to dependents of the targets
392# depending on the target having this config.
393rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
394
395# Common configs to remove or add in all rtc targets.
396rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 09:32:56397if (!build_with_chromium && is_clang) {
398 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
399}
mbonadei9aa3f0a2017-01-24 14:58:22400rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede16a2018-09-06 11:45:44401rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 11:15:54402rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 14:58:22403
404set_defaults("rtc_test") {
405 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36406 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22407 suppressed_configs = []
408}
409
Mirko Bonadei86d053c2019-10-17 19:32:04410set_defaults("rtc_library") {
411 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36412 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
Mirko Bonadei86d053c2019-10-17 19:32:04413 suppressed_configs = []
414}
415
mbonadei9aa3f0a2017-01-24 14:58:22416set_defaults("rtc_source_set") {
417 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36418 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22419 suppressed_configs = []
420}
421
Mirko Bonadei86d053c2019-10-17 19:32:04422set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 14:58:22423 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36424 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22425 suppressed_configs = []
426}
427
Mirko Bonadei86d053c2019-10-17 19:32:04428set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 14:58:22429 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36430 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22431 suppressed_configs = []
432}
433
434set_defaults("rtc_shared_library") {
435 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36436 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22437 suppressed_configs = []
438}
439
Per Kjellandera7f2d842018-01-10 15:54:53440webrtc_default_visibility = [ webrtc_root + "/*" ]
441if (build_with_chromium) {
442 # Allow Chromium's WebRTC overrides targets to bypass the regular
443 # visibility restrictions.
444 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
445}
446
Karl Wibergbb23c832018-04-22 17:55:00447# ---- Poisons ----
448#
449# The general idea is that some targets declare that they contain some
450# kind of poison, which makes it impossible for other targets to
451# depend on them (even transitively) unless they declare themselves
452# immune to that particular type of poison.
453#
454# Targets that *contain* poison of type foo should contain the line
455#
456# poisonous = [ "foo" ]
457#
458# and targets that *are immune but arent't themselves poisonous*
459# should contain
460#
461# allow_poison = [ "foo" ]
462#
463# This useful in cases where we have some large target or set of
464# targets and want to ensure that most other targets do not
465# transitively depend on them. For example, almost no high-level
466# target should depend on the audio codecs, since we want WebRTC users
467# to be able to inject any subset of them and actually end up with a
468# binary that doesn't include the codecs they didn't inject.
469#
470# Test-only targets (`testonly` set to true) and non-public targets
471# (`visibility` not containing "*") are automatically immune to all
472# types of poison.
473#
474# Here's the complete list of all types of poison. It must be kept in
475# 1:1 correspondence with the set of //:poison_* targets.
476#
477all_poison_types = [
478 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
479 "audio_codecs",
Anders Carlsson1f433e42018-04-24 14:39:05480
Sam Zackrisson03cb7e52021-12-06 14:40:04481 # Default echo detector implementation.
482 "default_echo_detector",
483
Danil Chapovalov9fdceb82023-11-27 09:57:22484 # Implementations of the utilities exposed through `Environment`.
485 # Most webrtc classes must use propagated `Environment`. Only few top-level
486 # classes are allowed to create `Environment` from individual utilities.
487 "environment_construction",
488
Sam Zackrisson492fdf42019-10-25 08:45:58489 # Software video codecs (VP8 and VP9 through libvpx).
490 "software_video_codecs",
Karl Wibergbb23c832018-04-22 17:55:00491]
492
Mirko Bonadei9a89a492018-05-29 14:22:32493absl_include_config = "//third_party/abseil-cpp:absl_include_config"
494absl_define_config = "//third_party/abseil-cpp:absl_define_config"
495
Mirko Bonadei2ab97f62019-07-18 11:44:12496# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
497# that are testonly.
498absl_flags_config = webrtc_root + ":absl_flags_configs"
499
Mirko Bonadeie99b6cc2020-11-25 15:41:37500# WebRTC wrapper of Chromium's test() template. This template just adds some
501# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
502# target.
503# The parameter `is_xctest` is different from the one in the Chromium's test()
504# template (and it is not forwarded to it). In rtc_test(), the argument
505# `is_xctest` is used to avoid to take dependencies that are not needed
506# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 14:58:22507template("rtc_test") {
508 test(target_name) {
509 forward_variables_from(invoker,
510 "*",
511 [
512 "configs",
Mirko Bonadeie99b6cc2020-11-25 15:41:37513 "is_xctest",
mbonadei9aa3f0a2017-01-24 14:58:22514 "public_configs",
515 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19516 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22517 ])
Mirko Bonadeidd411942017-11-21 14:35:27518
519 # Always override to public because when target_os is Android the `test`
520 # template can override it to [ "*" ] and we want to avoid conditional
521 # visibility.
Mirko Bonadei21558812017-11-21 11:47:34522 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 14:58:22523 configs += invoker.configs
524 configs -= rtc_remove_configs
525 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32526 public_configs = [
527 rtc_common_inherited_config,
528 absl_include_config,
529 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 11:44:12530 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32531 ]
mbonadei9aa3f0a2017-01-24 14:58:22532 if (defined(invoker.public_configs)) {
533 public_configs += invoker.public_configs
534 }
sakald7fdb802017-05-26 08:51:53535 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 13:48:37536 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 22:53:11537 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 20:57:49538 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 21:00:41539 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 17:03:37540 deps += [
541 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
542 webrtc_root + "test:native_test_java",
543 ]
sakald7fdb802017-05-26 08:51:53544 }
Mirko Bonadeie99b6cc2020-11-25 15:41:37545
Björn Terelius49850c32022-05-04 08:59:56546 # Build //test:google_test_runner_objc when the test is not a real XCTest.
Jeremy Leconteb8ba8c92022-03-15 08:08:29547 if (is_ios && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 15:41:37548 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
Björn Terelius49850c32022-05-04 08:59:56549 xctest_module_target = "//test:google_test_runner_objc"
Mirko Bonadeie99b6cc2020-11-25 15:41:37550 }
551 }
Andrey Logvin78646002021-01-29 10:50:19552
Florent Castelliae5d5032024-05-27 10:19:05553 assert(
554 !defined(absl_deps),
555 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.")
Florent Castelli3ffa0e82024-05-20 09:57:05556
Florent Castelliae5d5032024-05-27 10:19:05557 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Florent Castelli3ffa0e82024-05-20 09:57:05558 if (build_with_chromium && defined(deps)) {
Florent Castelliae5d5032024-05-27 10:19:05559 absl_dependencies =
560 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05561 if (absl_dependencies != []) {
Florent Castelliae5d5032024-05-27 10:19:05562 filtered_deps =
563 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05564 deps = []
565 deps = filtered_deps
Andrey Logvin78646002021-01-29 10:50:19566 deps += [ "//third_party/abseil-cpp:absl" ]
Andrey Logvin78646002021-01-29 10:50:19567 }
568 }
569
Jeremy Leconted15f3e12022-02-18 09:16:32570 # TODO(crbug.com/webrtc/13556): Adding the .app folder in the runtime_deps
571 # shoulnd't be necessary. this code should be removed and the same solution
572 # as Chromium should be used.
573 if (is_ios) {
574 if (!defined(invoker.data)) {
575 data = []
576 }
577 data += [ "${root_out_dir}/${target_name}.app" ]
578 }
mbonadei9aa3f0a2017-01-24 14:58:22579 }
580}
581
582template("rtc_source_set") {
583 source_set(target_name) {
584 forward_variables_from(invoker,
585 "*",
586 [
587 "configs",
588 "public_configs",
589 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19590 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22591 ])
Karl Wiberg138d4ac2017-10-16 09:16:19592 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53593 if (!defined(visibility)) {
594 visibility = webrtc_default_visibility
595 }
Karl Wibergbb23c832018-04-22 17:55:00596
597 # What's your poison?
598 if (defined(testonly) && testonly) {
599 assert(!defined(poisonous))
600 assert(!defined(allow_poison))
601 } else {
602 if (!defined(poisonous)) {
603 poisonous = []
604 }
605 if (!defined(allow_poison)) {
606 allow_poison = []
607 }
608 if (!defined(assert_no_deps)) {
609 assert_no_deps = []
610 }
611 if (!defined(deps)) {
612 deps = []
613 }
614 foreach(p, poisonous) {
615 deps += [ webrtc_root + ":poison_" + p ]
616 }
617 foreach(poison_type, all_poison_types) {
618 allow_dep = true
619 foreach(v, visibility) {
620 if (v == "*") {
621 allow_dep = false
622 }
623 }
624 foreach(p, allow_poison + poisonous) {
625 if (p == poison_type) {
626 allow_dep = true
627 }
628 }
629 if (!allow_dep) {
630 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
631 }
632 }
633 }
634
Mirko Bonadei92dd35d2019-11-15 15:08:41635 # Chromium should only depend on the WebRTC component in order to
636 # avoid to statically link WebRTC in a component build.
637 if (build_with_chromium) {
638 publicly_visible = false
639 foreach(v, visibility) {
640 if (v == "*") {
641 publicly_visible = true
642 }
643 }
644 if (publicly_visible) {
645 visibility = []
646 visibility = webrtc_default_visibility
647 }
648 }
649
Mirko Bonadei96ede16a2018-09-06 11:45:44650 if (!defined(testonly) || !testonly) {
651 configs += rtc_prod_configs
652 }
653
mbonadei9aa3f0a2017-01-24 14:58:22654 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 11:15:54655 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 14:58:22656 configs -= rtc_remove_configs
657 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32658 public_configs = [
659 rtc_common_inherited_config,
660 absl_include_config,
661 absl_define_config,
662 ]
Mirko Bonadei2ab97f62019-07-18 11:44:12663 if (defined(testonly) && testonly) {
664 public_configs += [ absl_flags_config ]
665 }
mbonadei9aa3f0a2017-01-24 14:58:22666 if (defined(invoker.public_configs)) {
667 public_configs += invoker.public_configs
668 }
Mirko Bonadei8b7cfa12020-06-03 19:23:41669
Florent Castelliae5d5032024-05-27 10:19:05670 assert(
671 !defined(absl_deps),
672 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.")
Florent Castelli3ffa0e82024-05-20 09:57:05673
Florent Castelliae5d5032024-05-27 10:19:05674 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Florent Castelli3ffa0e82024-05-20 09:57:05675 if (build_with_chromium && defined(deps)) {
Florent Castelliae5d5032024-05-27 10:19:05676 absl_dependencies =
677 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05678 if (absl_dependencies != []) {
Florent Castelliae5d5032024-05-27 10:19:05679 filtered_deps =
680 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05681 deps = []
682 deps = filtered_deps
Mirko Bonadei08ce9862020-06-11 09:25:32683 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 19:23:41684 }
685 }
mbonadei9aa3f0a2017-01-24 14:58:22686 }
687}
688
mbonadei9aa3f0a2017-01-24 14:58:22689template("rtc_static_library") {
690 static_library(target_name) {
691 forward_variables_from(invoker,
692 "*",
693 [
694 "configs",
695 "public_configs",
696 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19697 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22698 ])
Karl Wiberg138d4ac2017-10-16 09:16:19699 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53700 if (!defined(visibility)) {
701 visibility = webrtc_default_visibility
702 }
Karl Wibergbb23c832018-04-22 17:55:00703
704 # What's your poison?
705 if (defined(testonly) && testonly) {
706 assert(!defined(poisonous))
707 assert(!defined(allow_poison))
708 } else {
709 if (!defined(poisonous)) {
710 poisonous = []
711 }
712 if (!defined(allow_poison)) {
713 allow_poison = []
714 }
715 if (!defined(assert_no_deps)) {
716 assert_no_deps = []
717 }
718 if (!defined(deps)) {
719 deps = []
720 }
721 foreach(p, poisonous) {
722 deps += [ webrtc_root + ":poison_" + p ]
723 }
724 foreach(poison_type, all_poison_types) {
725 allow_dep = true
726 foreach(v, visibility) {
727 if (v == "*") {
728 allow_dep = false
729 }
730 }
731 foreach(p, allow_poison + poisonous) {
732 if (p == poison_type) {
733 allow_dep = true
734 }
735 }
736 if (!allow_dep) {
737 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
738 }
739 }
740 }
741
Mirko Bonadei96ede16a2018-09-06 11:45:44742 if (!defined(testonly) || !testonly) {
743 configs += rtc_prod_configs
744 }
745
mbonadei9aa3f0a2017-01-24 14:58:22746 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 11:15:54747 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 14:58:22748 configs -= rtc_remove_configs
749 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32750 public_configs = [
751 rtc_common_inherited_config,
752 absl_include_config,
753 absl_define_config,
754 ]
Mirko Bonadei2ab97f62019-07-18 11:44:12755 if (defined(testonly) && testonly) {
756 public_configs += [ absl_flags_config ]
757 }
mbonadei9aa3f0a2017-01-24 14:58:22758 if (defined(invoker.public_configs)) {
759 public_configs += invoker.public_configs
760 }
Mirko Bonadei8b7cfa12020-06-03 19:23:41761
Florent Castelliae5d5032024-05-27 10:19:05762 assert(
763 !defined(absl_deps),
764 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.")
Florent Castelli3ffa0e82024-05-20 09:57:05765
Florent Castelliae5d5032024-05-27 10:19:05766 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Florent Castelli3ffa0e82024-05-20 09:57:05767 if (build_with_chromium && defined(deps)) {
Florent Castelliae5d5032024-05-27 10:19:05768 absl_dependencies =
769 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05770 if (absl_dependencies != []) {
Florent Castelliae5d5032024-05-27 10:19:05771 filtered_deps =
772 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05773 deps = []
774 deps = filtered_deps
Mirko Bonadei08ce9862020-06-11 09:25:32775 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 19:23:41776 }
777 }
mbonadei9aa3f0a2017-01-24 14:58:22778 }
779}
780
Mirko Bonadei86d053c2019-10-17 19:32:04781# This template automatically switches the target type between source_set
782# and static_library.
783#
Florent Castelli87b6e7b2022-04-26 00:22:35784# This should be the default target type for all the WebRTC targets.
Mirko Bonadei86d053c2019-10-17 19:32:04785#
786# How does it work:
787# Since all files in a source_set are linked into a final binary, while files
788# in a static library are only linked in if at least one symbol in them is
789# referenced, in component builds source_sets are easy to deal with because
790# all their object files are passed to the linker to create a shared library.
791# In release builds instead, static_libraries are preferred since they allow
792# the linker to discard dead code.
793# For the same reason, testonly targets will always be expanded to
794# source_set in order to be sure that tests are present in the test binary.
795template("rtc_library") {
Florent Castelli87b6e7b2022-04-26 00:22:35796 header_only = true
797 if (defined(invoker.sources)) {
798 non_header_sources = filter_exclude(invoker.sources,
799 [
800 "*.h",
801 "*.hh",
802 "*.inc",
803 ])
804 if (non_header_sources != []) {
805 header_only = false
806 }
807 }
808
809 # Header only libraries should use source_set as a static_library with no
810 # source files will cause issues with macOS libtool.
811 if (header_only || is_component_build ||
812 (defined(invoker.testonly) && invoker.testonly)) {
Mirko Bonadei86d053c2019-10-17 19:32:04813 target_type = "source_set"
814 } else {
815 target_type = "static_library"
816 }
817 target(target_type, target_name) {
818 forward_variables_from(invoker,
819 "*",
820 [
821 "configs",
822 "public_configs",
823 "suppressed_configs",
824 "visibility",
825 ])
826 forward_variables_from(invoker, [ "visibility" ])
827 if (!defined(visibility)) {
828 visibility = webrtc_default_visibility
829 }
830
831 # What's your poison?
832 if (defined(testonly) && testonly) {
833 assert(!defined(poisonous))
834 assert(!defined(allow_poison))
835 } else {
836 if (!defined(poisonous)) {
837 poisonous = []
838 }
839 if (!defined(allow_poison)) {
840 allow_poison = []
841 }
842 if (!defined(assert_no_deps)) {
843 assert_no_deps = []
844 }
845 if (!defined(deps)) {
846 deps = []
847 }
848 foreach(p, poisonous) {
849 deps += [ webrtc_root + ":poison_" + p ]
850 }
851 foreach(poison_type, all_poison_types) {
852 allow_dep = true
853 foreach(v, visibility) {
854 if (v == "*") {
855 allow_dep = false
856 }
857 }
858 foreach(p, allow_poison + poisonous) {
859 if (p == poison_type) {
860 allow_dep = true
861 }
862 }
863 if (!allow_dep) {
864 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
865 }
866 }
867 }
868
Mirko Bonadei92dd35d2019-11-15 15:08:41869 # Chromium should only depend on the WebRTC component in order to
870 # avoid to statically link WebRTC in a component build.
871 if (build_with_chromium) {
872 publicly_visible = false
873 foreach(v, visibility) {
874 if (v == "*") {
875 publicly_visible = true
876 }
877 }
878 if (publicly_visible) {
879 visibility = []
880 visibility = webrtc_default_visibility
881 }
882 }
883
Mirko Bonadei86d053c2019-10-17 19:32:04884 if (!defined(testonly) || !testonly) {
885 configs += rtc_prod_configs
886 }
887
888 configs += invoker.configs
889 configs += rtc_library_impl_config
890 configs -= rtc_remove_configs
891 configs -= invoker.suppressed_configs
892 public_configs = [
893 rtc_common_inherited_config,
894 absl_include_config,
895 absl_define_config,
896 ]
897 if (defined(testonly) && testonly) {
898 public_configs += [ absl_flags_config ]
899 }
900 if (defined(invoker.public_configs)) {
901 public_configs += invoker.public_configs
902 }
Mirko Bonadei8b7cfa12020-06-03 19:23:41903
Florent Castelliae5d5032024-05-27 10:19:05904 assert(
905 !defined(absl_deps),
906 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.")
Florent Castelli3ffa0e82024-05-20 09:57:05907
Florent Castelliae5d5032024-05-27 10:19:05908 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Florent Castelli3ffa0e82024-05-20 09:57:05909 if (build_with_chromium && defined(deps)) {
Florent Castelliae5d5032024-05-27 10:19:05910 absl_dependencies =
911 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05912 if (absl_dependencies != []) {
Florent Castelliae5d5032024-05-27 10:19:05913 filtered_deps =
914 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05915 deps = []
916 deps = filtered_deps
Mirko Bonadei08ce9862020-06-11 09:25:32917 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 19:23:41918 }
919 }
Mirko Bonadei86d053c2019-10-17 19:32:04920 }
921}
922
923template("rtc_executable") {
924 executable(target_name) {
925 forward_variables_from(invoker,
926 "*",
927 [
928 "deps",
929 "configs",
930 "public_configs",
931 "suppressed_configs",
932 "visibility",
933 ])
934 forward_variables_from(invoker, [ "visibility" ])
935 if (!defined(visibility)) {
936 visibility = webrtc_default_visibility
937 }
938 configs += invoker.configs
939 configs -= rtc_remove_configs
940 configs -= invoker.suppressed_configs
941 deps = invoker.deps
942
943 public_configs = [
944 rtc_common_inherited_config,
945 absl_include_config,
946 absl_define_config,
947 ]
948 if (defined(testonly) && testonly) {
949 public_configs += [ absl_flags_config ]
950 }
951 if (defined(invoker.public_configs)) {
952 public_configs += invoker.public_configs
953 }
954 if (is_win) {
955 deps += [
956 # Give executables the default manifest on Windows (a no-op elsewhere).
957 "//build/win:default_exe_manifest",
958 ]
959 }
960 }
961}
962
mbonadei9aa3f0a2017-01-24 14:58:22963template("rtc_shared_library") {
964 shared_library(target_name) {
965 forward_variables_from(invoker,
966 "*",
967 [
968 "configs",
969 "public_configs",
970 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19971 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22972 ])
Karl Wiberg138d4ac2017-10-16 09:16:19973 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53974 if (!defined(visibility)) {
975 visibility = webrtc_default_visibility
976 }
Karl Wibergbb23c832018-04-22 17:55:00977
978 # What's your poison?
979 if (defined(testonly) && testonly) {
980 assert(!defined(poisonous))
981 assert(!defined(allow_poison))
982 } else {
983 if (!defined(poisonous)) {
984 poisonous = []
985 }
986 if (!defined(allow_poison)) {
987 allow_poison = []
988 }
989 if (!defined(assert_no_deps)) {
990 assert_no_deps = []
991 }
992 if (!defined(deps)) {
993 deps = []
994 }
995 foreach(p, poisonous) {
996 deps += [ webrtc_root + ":poison_" + p ]
997 }
998 foreach(poison_type, all_poison_types) {
999 allow_dep = true
1000 foreach(v, visibility) {
1001 if (v == "*") {
1002 allow_dep = false
1003 }
1004 }
1005 foreach(p, allow_poison + poisonous) {
1006 if (p == poison_type) {
1007 allow_dep = true
1008 }
1009 }
1010 if (!allow_dep) {
1011 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
1012 }
1013 }
1014 }
1015
mbonadei9aa3f0a2017-01-24 14:58:221016 configs += invoker.configs
1017 configs -= rtc_remove_configs
1018 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:321019 public_configs = [
1020 rtc_common_inherited_config,
1021 absl_include_config,
1022 absl_define_config,
1023 ]
Mirko Bonadei2ab97f62019-07-18 11:44:121024 if (defined(testonly) && testonly) {
1025 public_configs += [ absl_flags_config ]
1026 }
mbonadei9aa3f0a2017-01-24 14:58:221027 if (defined(invoker.public_configs)) {
1028 public_configs += invoker.public_configs
1029 }
1030 }
1031}
kthelgason4065a5762017-02-14 12:58:561032
Byoungchan Lee26b23b82022-04-08 09:23:141033if (is_mac || is_ios) {
1034 template("apple_framework_bundle_with_umbrella_header") {
Anders Carlssondc6b4772018-01-15 12:31:031035 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281036 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 12:31:031037 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281038 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
Byoungchan Lee26b23b82022-04-08 09:23:141039 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Byoungchan Lee1ce9a172024-04-30 08:14:181040 privacy_manifest_path = "$target_gen_dir/$target_name/PrivacyInfo.xcprivacy"
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281041
1042 action_foreach("create_bracket_include_headers_$target_name") {
1043 script = "//tools_webrtc/apple/copy_framework_header.py"
1044 sources = invoker.sources
1045 output_name = invoker.output_name
1046 outputs = [
1047 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1048 ]
1049 args = [
1050 "--input",
1051 "{{source}}",
1052 "--output",
1053 rebase_path(target_gen_dir, root_build_dir) +
1054 "/$output_name.framework/WebRTC/{{source_file_part}}",
1055 ]
1056 }
Anders Carlssondc6b4772018-01-15 12:31:031057
Byoungchan Lee26b23b82022-04-08 09:23:141058 if (is_mac) {
1059 mac_framework_bundle(target_name) {
1060 forward_variables_from(invoker, "*", [ "configs" ])
1061 if (defined(invoker.configs)) {
1062 configs += invoker.configs
1063 }
1064
1065 framework_version = "A"
1066 framework_contents = [
1067 "Headers",
1068 "Modules",
1069 "Resources",
1070 ]
1071
1072 ldflags = [
1073 "-all_load",
1074 "-install_name",
1075 "@rpath/$output_name.framework/$output_name",
1076 ]
1077
1078 deps += [
1079 ":copy_framework_headers_$this_target_name",
1080 ":copy_modulemap_$this_target_name",
Byoungchan Lee1ce9a172024-04-30 08:14:181081 ":copy_privacy_manifest_$this_target_name",
Byoungchan Lee26b23b82022-04-08 09:23:141082 ":copy_umbrella_header_$this_target_name",
1083 ":create_bracket_include_headers_$this_target_name",
1084 ":modulemap_$this_target_name",
1085 ":umbrella_header_$this_target_name",
1086 ]
1087 }
1088 }
1089 if (is_ios) {
1090 ios_framework_bundle(target_name) {
1091 forward_variables_from(invoker,
1092 "*",
1093 [
1094 "configs",
1095 "public_headers",
1096 ])
1097 if (defined(invoker.configs)) {
1098 configs += invoker.configs
1099 }
1100 public_headers = get_target_outputs(
1101 ":create_bracket_include_headers_$this_target_name")
1102
1103 deps += [
Byoungchan Lee1ce9a172024-04-30 08:14:181104 ":copy_privacy_manifest_$this_target_name",
Byoungchan Lee26b23b82022-04-08 09:23:141105 ":copy_umbrella_header_$this_target_name",
1106 ":create_bracket_include_headers_$this_target_name",
1107 ]
1108 }
Anders Carlssondc6b4772018-01-15 12:31:031109 }
1110
Byoungchan Lee26b23b82022-04-08 09:23:141111 if (is_mac || target_environment == "catalyst") {
Jordan Rose53d3fc92021-07-06 19:16:411112 # Catalyst frameworks use the same layout as regular Mac frameworks.
1113 headers_dir = "Versions/A/Headers"
Byoungchan Lee1ce9a172024-04-30 08:14:181114
1115 # The path to the privacy manifest file differs between Mac and iOS.
1116 # https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/adding_a_privacy_manifest_to_your_app_or_third-party_sdk
1117 privacy_manifest_out_path = "Versions/A/Resources/PrivacyInfo.xcprivacy"
Jordan Rose53d3fc92021-07-06 19:16:411118 } else {
1119 headers_dir = "Headers"
Byoungchan Lee1ce9a172024-04-30 08:14:181120 privacy_manifest_out_path = "PrivacyInfo.xcprivacy"
Jordan Rose53d3fc92021-07-06 19:16:411121 }
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281122
Anders Carlsson95c56ee2018-09-06 13:48:171123 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281124 sources = get_target_outputs(
1125 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 14:29:271126
Mirko Bonadeiccbe95f2020-01-21 11:10:101127 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281128 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 14:29:271129 }
1130
Joel Sutherlandd2fb1bf2018-10-02 20:08:251131 action("modulemap_$this_target_name") {
1132 script = "//tools_webrtc/ios/generate_modulemap.py"
1133 args = [
1134 "--out",
1135 rebase_path(modulemap_path, root_build_dir),
1136 "--name",
1137 output_name,
1138 ]
Mirko Bonadeiccbe95f2020-01-21 11:10:101139 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 20:08:251140 }
1141
1142 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 11:10:101143 sources = [ modulemap_path ]
1144 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1145 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 20:08:251146 }
1147
Anders Carlsson95c56ee2018-09-06 13:48:171148 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281149 sources = get_target_outputs(
1150 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 14:29:271151
1152 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1153
Mirko Bonadeiccbe95f2020-01-21 11:10:101154 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 14:29:271155 args = [
1156 "--out",
1157 rebase_path(umbrella_header_path, root_build_dir),
1158 "--sources",
1159 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281160 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 14:29:271161 }
1162
Byoungchan Lee26b23b82022-04-08 09:23:141163 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 11:10:101164 sources = [ umbrella_header_path ]
Byoungchan Lee26b23b82022-04-08 09:23:141165 outputs =
1166 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 14:29:271167
Byoungchan Lee26b23b82022-04-08 09:23:141168 deps = [ ":umbrella_header_$target_name" ]
Anders Carlsson37bbf792018-09-05 14:29:271169 }
Byoungchan Lee1ce9a172024-04-30 08:14:181170
1171 action("create_privacy_manifest_$target_name") {
1172 script = "//tools_webrtc/apple/generate_privacy_manifest.py"
1173
1174 args = [
1175 "--output",
1176 rebase_path(privacy_manifest_path),
1177 ]
1178
1179 outputs = [ privacy_manifest_path ]
1180 }
1181
1182 copy("copy_privacy_manifest_$target_name") {
1183 sources = [ privacy_manifest_path ]
1184 outputs =
1185 [ "$root_out_dir/$output_name.framework/$privacy_manifest_out_path" ]
1186
1187 deps = [ ":create_privacy_manifest_$target_name" ]
1188 }
Anders Carlsson37bbf792018-09-05 14:29:271189 }
1190}
1191
Mirko Bonadeifbb3b7d2017-11-07 15:36:331192if (is_android) {
1193 template("rtc_android_library") {
1194 android_library(target_name) {
1195 forward_variables_from(invoker,
1196 "*",
1197 [
1198 "configs",
1199 "public_configs",
1200 "suppressed_configs",
1201 "visibility",
1202 ])
1203
Oleh Prypin05aee742018-11-23 16:29:441204 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 15:32:491205
Mirko Bonadeifbb3b7d2017-11-07 15:36:331206 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 16:29:441207 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 15:32:491208
1209 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 16:29:441210 if (defined(invoker.errorprone_args)) {
1211 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 15:32:491212 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:331213
Sami Kalliomäkidc526512018-03-27 15:07:271214 if (!defined(deps)) {
1215 deps = []
1216 }
Sami Kalliomäkidc526512018-03-27 15:07:271217
Mirko Bonadeifbb3b7d2017-11-07 15:36:331218 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 19:23:411219 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:331220 }
1221 }
1222
1223 template("rtc_android_apk") {
1224 android_apk(target_name) {
1225 forward_variables_from(invoker,
1226 "*",
1227 [
1228 "configs",
1229 "public_configs",
1230 "suppressed_configs",
1231 "visibility",
1232 ])
1233
1234 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 11:10:081235 errorprone_args = []
1236 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 15:07:271237
1238 if (!defined(deps)) {
1239 deps = []
1240 }
Sami Kalliomäkidc526512018-03-27 15:07:271241
Mirko Bonadeifbb3b7d2017-11-07 15:36:331242 no_build_hooks = true
1243 }
1244 }
1245
1246 template("rtc_instrumentation_test_apk") {
1247 instrumentation_test_apk(target_name) {
1248 forward_variables_from(invoker,
1249 "*",
1250 [
1251 "configs",
1252 "public_configs",
1253 "suppressed_configs",
1254 "visibility",
1255 ])
1256
1257 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 11:10:081258 errorprone_args = []
1259 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 15:07:271260
1261 if (!defined(deps)) {
1262 deps = []
1263 }
Sami Kalliomäkidc526512018-03-27 15:07:271264
Mirko Bonadeifbb3b7d2017-11-07 15:36:331265 no_build_hooks = true
1266 }
1267 }
1268}