blob: cb7c65dd034c0bfeeba98228c559b573c5e5ce6c [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 Bonadei2bfa0712023-08-07 09:54:3556 # If set to true, C++ code will refer to the new JNI Generator symbols.
57 # If set to false the old ones will be used (to provide a nice update path).
58 rtc_jni_generator_legacy_symbols = false
59
Mirko Bonadei339965f2021-10-12 11:23:4460 # Setting this to true, will make RTC_DLOG() expand to log statements instead
Mirko Bonadei56ed4682021-10-12 06:55:4261 # of being removed by the preprocessor.
62 # This is useful for example to be able to get RTC_DLOGs on a release build.
63 rtc_dlog_always_on = false
64
Peter Kasting1e6d77c2023-03-13 23:01:0065 # Enables additional build targets that rely on
66 # //third_party/google_benchmarks.
67 rtc_enable_google_benchmarks = true
68
Mirko Bonadei5f078452021-07-30 20:32:5569 # Setting this to true will make RTC_OBJC_EXPORT expand to code that will
70 # manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported
71 # if C++ symbols are but setting this arg to true while keeping
72 # rtc_enable_symbol_export=false will only export RTC_OBJC_EXPORT
73 # annotated symbols.
74 rtc_enable_objc_symbol_export = rtc_enable_symbol_export
Mirko Bonadei028248c2018-10-10 10:19:0275
Mirko Bonadei31b0b452018-08-22 08:37:1176 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 13:44:2877 # will tell the pre-processor to remove the default definition of symbols
78 # needed to use field_trial. In that case a new implementation needs to be
79 # provided.
Mirko Bonadei31b0b452018-08-22 08:37:1180 if (build_with_chromium) {
81 # When WebRTC is built as part of Chromium it should exclude the default
82 # implementation of field_trial unless it is building for NACL or
83 # Chromecast.
Ryan Keanecf7802d2022-06-10 21:33:1884 rtc_exclude_field_trial_default = !is_nacl && !is_castos && !is_cast_android
Mirko Bonadei31b0b452018-08-22 08:37:1185 } else {
86 rtc_exclude_field_trial_default = false
87 }
Mirko Bonadei70400902018-08-21 13:44:2888
Mirko Bonadei906add42018-09-05 14:03:1689 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
90 # will tell the pre-processor to remove the default definition of symbols
91 # needed to use metrics. In that case a new implementation needs to be
92 # provided.
93 rtc_exclude_metrics_default = build_with_chromium
94
Johannes Kronda20c732021-02-19 15:39:4195 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which
96 # will tell the pre-processor to remove the default definition of the
97 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
98 # that case a new implementation needs to be provided.
Johannes Kronbb52bdf2021-02-25 09:10:0899 rtc_exclude_system_time = build_with_chromium
Johannes Kronda20c732021-02-19 15:39:41100
Benjamin Wrightd6f86e82018-05-08 20:12:25101 # Setting this to false will require the API user to pass in their own
102 # SSLCertificateVerifier to verify the certificates presented from a
103 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
104 rtc_builtin_ssl_root_certificates = true
105
Karl Wibergeb254b42017-11-01 14:08:12106 # Include the iLBC audio codec?
Olga Sharonova5fbd7582020-07-09 09:50:42107 rtc_include_ilbc = true
Karl Wibergeb254b42017-11-01 14:08:12108
mbonadei9aa3f0a2017-01-24 14:58:22109 # Disable this to avoid building the Opus audio codec.
110 rtc_include_opus = true
111
minyue2e03c662017-02-02 01:31:11112 # Enable this if the Opus version upon which WebRTC is built supports direct
113 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 15:45:49114 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-02 01:31:11115
mbonadei9aa3f0a2017-01-24 14:58:22116 # Enable this to let the Opus audio codec change complexity on the fly.
117 rtc_opus_variable_complexity = false
118
mbonadei9aa3f0a2017-01-24 14:58:22119 # Used to specify an external Jsoncpp include path when not compiling the
120 # library that comes with WebRTC (i.e. rtc_build_json == 0).
121 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
122
123 # Used to specify an external OpenSSL include path when not compiling the
124 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
125 rtc_ssl_root = ""
126
mbonadei9aa3f0a2017-01-24 14:58:22127 # Enable when an external authentication mechanism is used for performing
128 # packet authentication for RTP packets instead of libsrtp.
129 rtc_enable_external_auth = build_with_chromium
130
131 # Selects whether debug dumps for the audio processing module
132 # should be generated.
133 apm_debug_dump = false
134
Per Åhgrencc73ed32020-04-26 21:56:17135 # Selects whether the audio processing module should be excluded.
136 rtc_exclude_audio_processing_module = false
137
Joachim Bauch93e91342017-12-07 00:25:53138 # Set this to false to skip building examples.
139 rtc_build_examples = true
140
141 # Set this to false to skip building tools.
142 rtc_build_tools = true
143
Joachim Bauch75f18fc2017-12-20 20:25:47144 # Set this to false to skip building code that requires X11.
Maksim Sisovef4d0b62021-09-20 06:02:01145 rtc_use_x11 = ozone_platform_x11
Joachim Bauch75f18fc2017-12-20 20:25:47146
Tomas Popela318da512018-11-13 05:32:23147 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 13:37:51148 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
149 # only when using the sysroot as PipeWire is not available in older and
150 # supported Ubuntu and Debian distributions.
Artem Titov4d6a76d2021-09-03 10:07:20151 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 13:37:51152
Jan Gruliche1e05af2021-09-21 18:36:16153 # Set this to link PipeWire and required libraries directly instead of using the dlopen.
Tomas Popela762543f2018-12-12 13:37:51154 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 05:32:23155
mbonadei9aa3f0a2017-01-24 14:58:22156 # Enable to use the Mozilla internal settings.
157 build_with_mozilla = false
158
Philipp Hanckee95ebda2020-09-17 14:13:20159 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
160 # and NDK r16 or above.
henrika883d00f2018-03-16 09:09:49161 rtc_enable_android_aaudio = false
162
mbonadei9aa3f0a2017-01-24 14:58:22163 # Set to "func", "block", "edge" for coverage generation.
164 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
165 # It is recommend to set include_examples=0.
166 # Use llvm's sancov -html-report for human readable reports.
167 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
168 rtc_sanitize_coverage = ""
169
Philipp Hanckeaeac9f82020-09-11 09:58:18170 # Selects fixed-point code where possible.
171 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 14:58:22172 if (current_cpu == "arm" || current_cpu == "arm64") {
173 rtc_prefer_fixed_point = true
174 }
175
mbonadei9aa3f0a2017-01-24 14:58:22176 # Determines whether NEON code will be built.
177 rtc_build_with_neon =
178 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
179
180 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
181 # all platforms except Android and iOS. Because FFmpeg can be built
Artem Titov22a6b2d2021-07-27 14:25:56182 # with/without H.264 support, `ffmpeg_branding` has to separately be set to a
mbonadei9aa3f0a2017-01-24 14:58:22183 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Artem Titov22a6b2d2021-07-27 14:25:56184 # H.264, compilation succeeds but `H264DecoderImpl` fails to initialize.
mbonadei9aa3f0a2017-01-24 14:58:22185 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
186 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 09:47:18187 #
188 # Enabling H264 when building with MSVC is currently not supported, see
189 # bugs.webrtc.org/9213#c13 for more info.
190 rtc_use_h264 =
191 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 14:58:22192
Jan Grulich0f862522024-04-29 14:16:28193 # Use system OpenH264
194 rtc_system_openh264 = false
195
qwu16972f2832023-08-15 09:16:54196 # Enable to use H265
Mirko Bonadeie3b42632024-03-27 12:13:52197 if (build_with_chromium) {
198 rtc_use_h265 = enable_hevc_parser_and_hw_decoder
199 } else {
200 rtc_use_h265 = proprietary_codecs
201 }
qwu16972f2832023-08-15 09:16:54202
Markus Handell8e75bd42020-06-05 09:47:40203 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
204 rtc_use_absl_mutex = false
205
mbonadei9aa3f0a2017-01-24 14:58:22206 # By default, use normal platform audio support or dummy audio, but don't
207 # use file-based audio playout and record.
208 rtc_use_dummy_audio_file_devices = false
209
henrika7be78832017-06-13 15:34:16210 # When set to true, replace the audio output with a sinus tone at 440Hz.
211 # The ADM will ask for audio data from WebRTC but instead of reading real
212 # audio samples from NetEQ, a sinus tone will be generated and replace the
213 # real audio samples.
214 rtc_audio_device_plays_sinus_tone = false
215
Anders Carlsson358f2e02018-06-04 08:24:37216 if (is_ios) {
217 # Build broadcast extension in AppRTCMobile for iOS. This results in the
218 # binary only running on iOS 11+, which is why it is disabled by default.
219 rtc_apprtcmobile_broadcast_extension = false
220 }
Anders Carlsson7bca8ca2018-08-30 07:30:29221
Kári Tristan Helgasonba50cb32023-06-28 12:32:04222 # Determines whether OpenGL is available on iOS.
223 rtc_ios_use_opengl_rendering = is_ios && target_environment != "catalyst"
Jordan Rose53d3fc92021-07-06 19:16:41224
Jiawei Ou08745302019-02-12 19:36:13225 # When set to false, builtin audio encoder/decoder factories and all the
226 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
227 # (they will still be included in libjingle_peerconnection_so.so and
228 # WebRTC.framework)
229 rtc_include_builtin_audio_codecs = true
230
Mirko Bonadei20574f42019-03-28 06:50:07231 # When set to true and in a standalone build, it will undefine UNICODE and
232 # _UNICODE (which are always defined globally by the Chromium Windows
233 # toolchain).
234 # This is only needed for testing purposes, WebRTC wants to be sure it
235 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
236 # wide character functions.
237 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 20:47:54238
239 # When set to true, a capturer implementation that uses the
Austin Orion66241e42021-04-22 20:22:25240 # Windows.Graphics.Capture APIs will be available for use. This introduces a
241 # dependency on the Win 10 SDK v10.0.17763.0.
Austin Orion78f04d82021-04-23 19:37:26242 rtc_enable_win_wgc = is_win
philipelb09d8722021-11-23 10:00:24243
244 # Includes the dav1d decoder in the internal decoder factory when set to true.
245 rtc_include_dav1d_in_internal_decoder_factory = true
Emil Lundmark6bf20cc2022-09-21 13:20:22246
Emil Lundmark9109e852023-02-28 12:57:01247 # When enabled, a run-time check will make sure that all field trial keys have
248 # been registered in accordance with the field trial policy, see
249 # g3doc/field-trials.md. The value can be set to the following:
250 #
251 # "dcheck": RTC_DCHECKs that the field trial has been registered. RTC_DCHECK
252 # must be enabled separately.
253 #
254 # "warn": RTC_LOGs a message with LS_WARNING severity if the field trial
255 # hasn't been registered.
256 rtc_strict_field_trials = ""
Mirko Bonadei91304312023-07-26 11:01:43257
258 # If different from "", symbols exported with RTC_OBJC_EXPORT will be prefixed
259 # with this string.
260 # See the definition of RTC_OBJC_TYPE_PREFIX in the code.
261 rtc_objc_prefix = ""
Arthur Sonzogni47faf322023-08-22 09:55:36262
263 # Embedders can define dependencies needed by WebRTC. Dependencies can be
264 # configs or targets. This can be defined in their `.gn` file.
265 #
266 # In practise, this is use by Chromium: Targets from
267 # `//third_party/webrtc_overrides` are depending on Chrome's `//base`, but
268 # WebRTC does not declare its public dependencies. See webrtc:8603. Instead
269 # WebRTC is using a global common dependencies.
270 rtc_common_public_deps = [] # no-presubmit-check TODO(webrtc:8603)
Evan Shrubsoledb50b032024-04-24 13:27:00271
272 # When true, include the Perfetto library.
273 rtc_use_perfetto = false
Dan Minor9c686132018-01-15 15:20:00274}
mbonadei9aa3f0a2017-01-24 14:58:22275
Dan Minor9c686132018-01-15 15:20:00276if (!build_with_mozilla) {
277 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 14:58:22278}
279
280# A second declare_args block, so that declarations within it can
281# depend on the possibly overridden variables in the first
282# declare_args block.
283declare_args() {
Dan Minor9c686132018-01-15 15:20:00284 # Enables the use of protocol buffers for debug recordings.
285 rtc_enable_protobuf = !build_with_mozilla
286
287 # Set this to disable building with support for SCTP data channels.
288 rtc_enable_sctp = !build_with_mozilla
289
290 # Disable these to not build components which can be externally provided.
291 rtc_build_json = !build_with_mozilla
292 rtc_build_libsrtp = !build_with_mozilla
293 rtc_build_libvpx = !build_with_mozilla
294 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 15:20:00295 rtc_build_opus = !build_with_mozilla
296 rtc_build_ssl = !build_with_mozilla
Dan Minor9c686132018-01-15 15:20:00297
298 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 17:05:00299 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
300 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 15:20:00301 rtc_enable_libevent = false
302 rtc_build_libevent = false
303 } else {
304 rtc_enable_libevent = true
305 rtc_build_libevent = !build_with_mozilla
306 }
307
mbonadei9aa3f0a2017-01-24 14:58:22308 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
309 rtc_include_pulse_audio = !build_with_chromium
310
311 # Chromium uses its own IO handling, so the internal ADM is only built for
312 # standalone WebRTC.
313 rtc_include_internal_audio_device = !build_with_chromium
314
Zhaoliang Ma72e43212020-08-17 09:13:41315 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 10:02:32316 # TODO: Make sure that AVX2 works also for non-clang compilers.
317 if (is_clang == true) {
318 rtc_enable_avx2 = true
319 } else {
320 rtc_enable_avx2 = false
321 }
Zhaoliang Ma72e43212020-08-17 09:13:41322
Philipp Hancke1a89bc82021-03-02 20:23:24323 # Set this to true to build the unit tests.
324 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 15:20:00325 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 11:27:07326
327 # Set this to false to skip building code that also requires X11 extensions
328 # such as Xdamage, Xfixes.
329 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 15:24:46330
331 # Set this to true to fully remove logging from WebRTC.
332 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 13:24:31333
334 # Set this to true to disable trace events.
335 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 16:09:30336
337 # Set this to true to disable detailed error message and logging for
338 # RTC_CHECKs.
339 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 12:06:53340
341 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 14:02:53342 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 13:24:40343
344 # Set this to true to exclude the transient suppressor in the audio processing
345 # module from the build.
346 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 14:58:22347}
348
Florent Castellia80c3e52021-04-15 13:02:56349declare_args() {
Florent Castellia6983c62021-05-06 08:50:07350 # Enable the dcsctp backend for DataChannels and related unittests
351 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
352
Florent Castelli023be3c2022-03-15 15:01:52353 # Enable gRPC used for negotiation in multiprocess tests
354 rtc_enable_grpc = rtc_enable_protobuf && (is_linux || is_mac)
Florent Castellia80c3e52021-04-15 13:02:56355}
356
mbonadei9aa3f0a2017-01-24 14:58:22357# Make it possible to provide custom locations for some libraries (move these
358# up into declare_args should we need to actually use them for the GN build).
359rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 14:58:22360rtc_opus_dir = "//third_party/opus"
361
362# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 11:27:07363rtc_desktop_capture_supported =
364 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 09:10:11365 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 14:58:22366
367###############################################################################
368# Templates
369#
370
Mirko Bonadei92ea95e2017-09-15 04:47:31371# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 14:58:22372# chromium.
373# We need absolute paths for all configs in templates as they are shared in
374# different subdirectories.
375webrtc_root = get_path_info(".", "abspath")
376
377# Global configuration that should be applied to all WebRTC targets.
378# You normally shouldn't need to include this in your target as it's
379# automatically included when using the rtc_* templates.
380# It sets defines, include paths and compilation warnings accordingly,
381# both for WebRTC stand-alone builds and for the scenario when WebRTC
382# native code is built as part of Chromium.
Mirko Bonadei5f078452021-07-30 20:32:55383rtc_common_configs = [ webrtc_root + ":common_config" ]
mbonadei9aa3f0a2017-01-24 14:58:22384
kthelgasonc0977102017-04-24 07:57:16385if (is_mac || is_ios) {
Christoffer Janssonfe2e7ea2023-08-02 07:41:23386 if (filter_include(default_compiler_configs,
387 [ "//build/config/compiler:enable_arc" ]) == []) {
388 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
389 }
kthelgasonc0977102017-04-24 07:57:16390}
Evan Shrubsole047238e2024-04-29 11:36:58391
Evan Shrubsolefa870372024-05-02 11:59:39392if (build_with_chromium) {
Evan Shrubsole047238e2024-04-29 11:36:58393 rtc_use_perfetto = true
394}
395
mbonadei9aa3f0a2017-01-24 14:58:22396# Global public configuration that should be applied to all WebRTC targets. You
397# normally shouldn't need to include this in your target as it's automatically
398# included when using the rtc_* templates. It set the defines, include paths and
399# compilation warnings that should be propagated to dependents of the targets
400# depending on the target having this config.
401rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
402
403# Common configs to remove or add in all rtc targets.
404rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 09:32:56405if (!build_with_chromium && is_clang) {
406 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
407}
mbonadei9aa3f0a2017-01-24 14:58:22408rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede16a2018-09-06 11:45:44409rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 11:15:54410rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 14:58:22411
412set_defaults("rtc_test") {
413 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36414 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22415 suppressed_configs = []
416}
417
Mirko Bonadei86d053c2019-10-17 19:32:04418set_defaults("rtc_library") {
419 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36420 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
Mirko Bonadei86d053c2019-10-17 19:32:04421 suppressed_configs = []
422}
423
mbonadei9aa3f0a2017-01-24 14:58:22424set_defaults("rtc_source_set") {
425 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36426 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22427 suppressed_configs = []
428}
429
Mirko Bonadei86d053c2019-10-17 19:32:04430set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 14:58:22431 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36432 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22433 suppressed_configs = []
434}
435
Mirko Bonadei86d053c2019-10-17 19:32:04436set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 14:58:22437 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36438 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22439 suppressed_configs = []
440}
441
442set_defaults("rtc_shared_library") {
443 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36444 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22445 suppressed_configs = []
446}
447
Per Kjellandera7f2d842018-01-10 15:54:53448webrtc_default_visibility = [ webrtc_root + "/*" ]
449if (build_with_chromium) {
450 # Allow Chromium's WebRTC overrides targets to bypass the regular
451 # visibility restrictions.
452 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
453}
454
Karl Wibergbb23c832018-04-22 17:55:00455# ---- Poisons ----
456#
457# The general idea is that some targets declare that they contain some
458# kind of poison, which makes it impossible for other targets to
459# depend on them (even transitively) unless they declare themselves
460# immune to that particular type of poison.
461#
462# Targets that *contain* poison of type foo should contain the line
463#
464# poisonous = [ "foo" ]
465#
466# and targets that *are immune but arent't themselves poisonous*
467# should contain
468#
469# allow_poison = [ "foo" ]
470#
471# This useful in cases where we have some large target or set of
472# targets and want to ensure that most other targets do not
473# transitively depend on them. For example, almost no high-level
474# target should depend on the audio codecs, since we want WebRTC users
475# to be able to inject any subset of them and actually end up with a
476# binary that doesn't include the codecs they didn't inject.
477#
478# Test-only targets (`testonly` set to true) and non-public targets
479# (`visibility` not containing "*") are automatically immune to all
480# types of poison.
481#
482# Here's the complete list of all types of poison. It must be kept in
483# 1:1 correspondence with the set of //:poison_* targets.
484#
485all_poison_types = [
486 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
487 "audio_codecs",
Anders Carlsson1f433e42018-04-24 14:39:05488
Sam Zackrisson03cb7e52021-12-06 14:40:04489 # Default echo detector implementation.
490 "default_echo_detector",
491
Danil Chapovalov9fdceb82023-11-27 09:57:22492 # Implementations of the utilities exposed through `Environment`.
493 # Most webrtc classes must use propagated `Environment`. Only few top-level
494 # classes are allowed to create `Environment` from individual utilities.
495 "environment_construction",
496
Sam Zackrisson492fdf42019-10-25 08:45:58497 # Software video codecs (VP8 and VP9 through libvpx).
498 "software_video_codecs",
Karl Wibergbb23c832018-04-22 17:55:00499]
500
Mirko Bonadei9a89a492018-05-29 14:22:32501absl_include_config = "//third_party/abseil-cpp:absl_include_config"
502absl_define_config = "//third_party/abseil-cpp:absl_define_config"
503
Mirko Bonadei2ab97f62019-07-18 11:44:12504# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
505# that are testonly.
506absl_flags_config = webrtc_root + ":absl_flags_configs"
507
Mirko Bonadeie99b6cc2020-11-25 15:41:37508# WebRTC wrapper of Chromium's test() template. This template just adds some
509# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
510# target.
511# The parameter `is_xctest` is different from the one in the Chromium's test()
512# template (and it is not forwarded to it). In rtc_test(), the argument
513# `is_xctest` is used to avoid to take dependencies that are not needed
514# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 14:58:22515template("rtc_test") {
516 test(target_name) {
517 forward_variables_from(invoker,
518 "*",
519 [
520 "configs",
Mirko Bonadeie99b6cc2020-11-25 15:41:37521 "is_xctest",
mbonadei9aa3f0a2017-01-24 14:58:22522 "public_configs",
523 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19524 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22525 ])
Mirko Bonadeidd411942017-11-21 14:35:27526
527 # Always override to public because when target_os is Android the `test`
528 # template can override it to [ "*" ] and we want to avoid conditional
529 # visibility.
Mirko Bonadei21558812017-11-21 11:47:34530 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 14:58:22531 configs += invoker.configs
532 configs -= rtc_remove_configs
533 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32534 public_configs = [
535 rtc_common_inherited_config,
536 absl_include_config,
537 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 11:44:12538 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32539 ]
mbonadei9aa3f0a2017-01-24 14:58:22540 if (defined(invoker.public_configs)) {
541 public_configs += invoker.public_configs
542 }
sakald7fdb802017-05-26 08:51:53543 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 13:48:37544 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 22:53:11545 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 20:57:49546 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 21:00:41547 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 17:03:37548 deps += [
549 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
550 webrtc_root + "test:native_test_java",
551 ]
sakald7fdb802017-05-26 08:51:53552 }
Mirko Bonadeie99b6cc2020-11-25 15:41:37553
Björn Terelius49850c32022-05-04 08:59:56554 # Build //test:google_test_runner_objc when the test is not a real XCTest.
Jeremy Leconteb8ba8c92022-03-15 08:08:29555 if (is_ios && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 15:41:37556 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
Björn Terelius49850c32022-05-04 08:59:56557 xctest_module_target = "//test:google_test_runner_objc"
Mirko Bonadeie99b6cc2020-11-25 15:41:37558 }
559 }
Andrey Logvin78646002021-01-29 10:50:19560
Florent Castelliae5d5032024-05-27 10:19:05561 assert(
562 !defined(absl_deps),
563 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.")
Florent Castelli3ffa0e82024-05-20 09:57:05564
Florent Castelliae5d5032024-05-27 10:19:05565 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Florent Castelli3ffa0e82024-05-20 09:57:05566 if (build_with_chromium && defined(deps)) {
Florent Castelliae5d5032024-05-27 10:19:05567 absl_dependencies =
568 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05569 if (absl_dependencies != []) {
Florent Castelliae5d5032024-05-27 10:19:05570 filtered_deps =
571 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05572 deps = []
573 deps = filtered_deps
Andrey Logvin78646002021-01-29 10:50:19574 deps += [ "//third_party/abseil-cpp:absl" ]
Andrey Logvin78646002021-01-29 10:50:19575 }
576 }
577
Jeremy Leconted15f3e12022-02-18 09:16:32578 # TODO(crbug.com/webrtc/13556): Adding the .app folder in the runtime_deps
579 # shoulnd't be necessary. this code should be removed and the same solution
580 # as Chromium should be used.
581 if (is_ios) {
582 if (!defined(invoker.data)) {
583 data = []
584 }
585 data += [ "${root_out_dir}/${target_name}.app" ]
586 }
mbonadei9aa3f0a2017-01-24 14:58:22587 }
588}
589
590template("rtc_source_set") {
591 source_set(target_name) {
592 forward_variables_from(invoker,
593 "*",
594 [
595 "configs",
596 "public_configs",
597 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19598 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22599 ])
Karl Wiberg138d4ac2017-10-16 09:16:19600 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53601 if (!defined(visibility)) {
602 visibility = webrtc_default_visibility
603 }
Karl Wibergbb23c832018-04-22 17:55:00604
605 # What's your poison?
606 if (defined(testonly) && testonly) {
607 assert(!defined(poisonous))
608 assert(!defined(allow_poison))
609 } else {
610 if (!defined(poisonous)) {
611 poisonous = []
612 }
613 if (!defined(allow_poison)) {
614 allow_poison = []
615 }
616 if (!defined(assert_no_deps)) {
617 assert_no_deps = []
618 }
619 if (!defined(deps)) {
620 deps = []
621 }
622 foreach(p, poisonous) {
623 deps += [ webrtc_root + ":poison_" + p ]
624 }
625 foreach(poison_type, all_poison_types) {
626 allow_dep = true
627 foreach(v, visibility) {
628 if (v == "*") {
629 allow_dep = false
630 }
631 }
632 foreach(p, allow_poison + poisonous) {
633 if (p == poison_type) {
634 allow_dep = true
635 }
636 }
637 if (!allow_dep) {
638 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
639 }
640 }
641 }
642
Mirko Bonadei92dd35d2019-11-15 15:08:41643 # Chromium should only depend on the WebRTC component in order to
644 # avoid to statically link WebRTC in a component build.
645 if (build_with_chromium) {
646 publicly_visible = false
647 foreach(v, visibility) {
648 if (v == "*") {
649 publicly_visible = true
650 }
651 }
652 if (publicly_visible) {
653 visibility = []
654 visibility = webrtc_default_visibility
655 }
656 }
657
Mirko Bonadei96ede16a2018-09-06 11:45:44658 if (!defined(testonly) || !testonly) {
659 configs += rtc_prod_configs
660 }
661
mbonadei9aa3f0a2017-01-24 14:58:22662 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 11:15:54663 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 14:58:22664 configs -= rtc_remove_configs
665 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32666 public_configs = [
667 rtc_common_inherited_config,
668 absl_include_config,
669 absl_define_config,
670 ]
Mirko Bonadei2ab97f62019-07-18 11:44:12671 if (defined(testonly) && testonly) {
672 public_configs += [ absl_flags_config ]
673 }
mbonadei9aa3f0a2017-01-24 14:58:22674 if (defined(invoker.public_configs)) {
675 public_configs += invoker.public_configs
676 }
Mirko Bonadei8b7cfa12020-06-03 19:23:41677
Florent Castelliae5d5032024-05-27 10:19:05678 assert(
679 !defined(absl_deps),
680 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.")
Florent Castelli3ffa0e82024-05-20 09:57:05681
Florent Castelliae5d5032024-05-27 10:19:05682 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Florent Castelli3ffa0e82024-05-20 09:57:05683 if (build_with_chromium && defined(deps)) {
Florent Castelliae5d5032024-05-27 10:19:05684 absl_dependencies =
685 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05686 if (absl_dependencies != []) {
Florent Castelliae5d5032024-05-27 10:19:05687 filtered_deps =
688 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05689 deps = []
690 deps = filtered_deps
Mirko Bonadei08ce9862020-06-11 09:25:32691 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 19:23:41692 }
693 }
mbonadei9aa3f0a2017-01-24 14:58:22694 }
695}
696
mbonadei9aa3f0a2017-01-24 14:58:22697template("rtc_static_library") {
698 static_library(target_name) {
699 forward_variables_from(invoker,
700 "*",
701 [
702 "configs",
703 "public_configs",
704 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19705 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22706 ])
Karl Wiberg138d4ac2017-10-16 09:16:19707 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53708 if (!defined(visibility)) {
709 visibility = webrtc_default_visibility
710 }
Karl Wibergbb23c832018-04-22 17:55:00711
712 # What's your poison?
713 if (defined(testonly) && testonly) {
714 assert(!defined(poisonous))
715 assert(!defined(allow_poison))
716 } else {
717 if (!defined(poisonous)) {
718 poisonous = []
719 }
720 if (!defined(allow_poison)) {
721 allow_poison = []
722 }
723 if (!defined(assert_no_deps)) {
724 assert_no_deps = []
725 }
726 if (!defined(deps)) {
727 deps = []
728 }
729 foreach(p, poisonous) {
730 deps += [ webrtc_root + ":poison_" + p ]
731 }
732 foreach(poison_type, all_poison_types) {
733 allow_dep = true
734 foreach(v, visibility) {
735 if (v == "*") {
736 allow_dep = false
737 }
738 }
739 foreach(p, allow_poison + poisonous) {
740 if (p == poison_type) {
741 allow_dep = true
742 }
743 }
744 if (!allow_dep) {
745 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
746 }
747 }
748 }
749
Mirko Bonadei96ede16a2018-09-06 11:45:44750 if (!defined(testonly) || !testonly) {
751 configs += rtc_prod_configs
752 }
753
mbonadei9aa3f0a2017-01-24 14:58:22754 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 11:15:54755 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 14:58:22756 configs -= rtc_remove_configs
757 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32758 public_configs = [
759 rtc_common_inherited_config,
760 absl_include_config,
761 absl_define_config,
762 ]
Mirko Bonadei2ab97f62019-07-18 11:44:12763 if (defined(testonly) && testonly) {
764 public_configs += [ absl_flags_config ]
765 }
mbonadei9aa3f0a2017-01-24 14:58:22766 if (defined(invoker.public_configs)) {
767 public_configs += invoker.public_configs
768 }
Mirko Bonadei8b7cfa12020-06-03 19:23:41769
Florent Castelliae5d5032024-05-27 10:19:05770 assert(
771 !defined(absl_deps),
772 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.")
Florent Castelli3ffa0e82024-05-20 09:57:05773
Florent Castelliae5d5032024-05-27 10:19:05774 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Florent Castelli3ffa0e82024-05-20 09:57:05775 if (build_with_chromium && defined(deps)) {
Florent Castelliae5d5032024-05-27 10:19:05776 absl_dependencies =
777 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05778 if (absl_dependencies != []) {
Florent Castelliae5d5032024-05-27 10:19:05779 filtered_deps =
780 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05781 deps = []
782 deps = filtered_deps
Mirko Bonadei08ce9862020-06-11 09:25:32783 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 19:23:41784 }
785 }
mbonadei9aa3f0a2017-01-24 14:58:22786 }
787}
788
Mirko Bonadei86d053c2019-10-17 19:32:04789# This template automatically switches the target type between source_set
790# and static_library.
791#
Florent Castelli87b6e7b2022-04-26 00:22:35792# This should be the default target type for all the WebRTC targets.
Mirko Bonadei86d053c2019-10-17 19:32:04793#
794# How does it work:
795# Since all files in a source_set are linked into a final binary, while files
796# in a static library are only linked in if at least one symbol in them is
797# referenced, in component builds source_sets are easy to deal with because
798# all their object files are passed to the linker to create a shared library.
799# In release builds instead, static_libraries are preferred since they allow
800# the linker to discard dead code.
801# For the same reason, testonly targets will always be expanded to
802# source_set in order to be sure that tests are present in the test binary.
803template("rtc_library") {
Florent Castelli87b6e7b2022-04-26 00:22:35804 header_only = true
805 if (defined(invoker.sources)) {
806 non_header_sources = filter_exclude(invoker.sources,
807 [
808 "*.h",
809 "*.hh",
810 "*.inc",
811 ])
812 if (non_header_sources != []) {
813 header_only = false
814 }
815 }
816
817 # Header only libraries should use source_set as a static_library with no
818 # source files will cause issues with macOS libtool.
819 if (header_only || is_component_build ||
820 (defined(invoker.testonly) && invoker.testonly)) {
Mirko Bonadei86d053c2019-10-17 19:32:04821 target_type = "source_set"
822 } else {
823 target_type = "static_library"
824 }
825 target(target_type, target_name) {
826 forward_variables_from(invoker,
827 "*",
828 [
829 "configs",
830 "public_configs",
831 "suppressed_configs",
832 "visibility",
833 ])
834 forward_variables_from(invoker, [ "visibility" ])
835 if (!defined(visibility)) {
836 visibility = webrtc_default_visibility
837 }
838
839 # What's your poison?
840 if (defined(testonly) && testonly) {
841 assert(!defined(poisonous))
842 assert(!defined(allow_poison))
843 } else {
844 if (!defined(poisonous)) {
845 poisonous = []
846 }
847 if (!defined(allow_poison)) {
848 allow_poison = []
849 }
850 if (!defined(assert_no_deps)) {
851 assert_no_deps = []
852 }
853 if (!defined(deps)) {
854 deps = []
855 }
856 foreach(p, poisonous) {
857 deps += [ webrtc_root + ":poison_" + p ]
858 }
859 foreach(poison_type, all_poison_types) {
860 allow_dep = true
861 foreach(v, visibility) {
862 if (v == "*") {
863 allow_dep = false
864 }
865 }
866 foreach(p, allow_poison + poisonous) {
867 if (p == poison_type) {
868 allow_dep = true
869 }
870 }
871 if (!allow_dep) {
872 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
873 }
874 }
875 }
876
Mirko Bonadei92dd35d2019-11-15 15:08:41877 # Chromium should only depend on the WebRTC component in order to
878 # avoid to statically link WebRTC in a component build.
879 if (build_with_chromium) {
880 publicly_visible = false
881 foreach(v, visibility) {
882 if (v == "*") {
883 publicly_visible = true
884 }
885 }
886 if (publicly_visible) {
887 visibility = []
888 visibility = webrtc_default_visibility
889 }
890 }
891
Mirko Bonadei86d053c2019-10-17 19:32:04892 if (!defined(testonly) || !testonly) {
893 configs += rtc_prod_configs
894 }
895
896 configs += invoker.configs
897 configs += rtc_library_impl_config
898 configs -= rtc_remove_configs
899 configs -= invoker.suppressed_configs
900 public_configs = [
901 rtc_common_inherited_config,
902 absl_include_config,
903 absl_define_config,
904 ]
905 if (defined(testonly) && testonly) {
906 public_configs += [ absl_flags_config ]
907 }
908 if (defined(invoker.public_configs)) {
909 public_configs += invoker.public_configs
910 }
Mirko Bonadei8b7cfa12020-06-03 19:23:41911
Florent Castelliae5d5032024-05-27 10:19:05912 assert(
913 !defined(absl_deps),
914 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.")
Florent Castelli3ffa0e82024-05-20 09:57:05915
Florent Castelliae5d5032024-05-27 10:19:05916 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Florent Castelli3ffa0e82024-05-20 09:57:05917 if (build_with_chromium && defined(deps)) {
Florent Castelliae5d5032024-05-27 10:19:05918 absl_dependencies =
919 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05920 if (absl_dependencies != []) {
Florent Castelliae5d5032024-05-27 10:19:05921 filtered_deps =
922 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ])
Florent Castelli3ffa0e82024-05-20 09:57:05923 deps = []
924 deps = filtered_deps
Mirko Bonadei08ce9862020-06-11 09:25:32925 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 19:23:41926 }
927 }
Mirko Bonadei86d053c2019-10-17 19:32:04928 }
929}
930
931template("rtc_executable") {
932 executable(target_name) {
933 forward_variables_from(invoker,
934 "*",
935 [
936 "deps",
937 "configs",
938 "public_configs",
939 "suppressed_configs",
940 "visibility",
941 ])
942 forward_variables_from(invoker, [ "visibility" ])
943 if (!defined(visibility)) {
944 visibility = webrtc_default_visibility
945 }
946 configs += invoker.configs
947 configs -= rtc_remove_configs
948 configs -= invoker.suppressed_configs
949 deps = invoker.deps
950
951 public_configs = [
952 rtc_common_inherited_config,
953 absl_include_config,
954 absl_define_config,
955 ]
956 if (defined(testonly) && testonly) {
957 public_configs += [ absl_flags_config ]
958 }
959 if (defined(invoker.public_configs)) {
960 public_configs += invoker.public_configs
961 }
962 if (is_win) {
963 deps += [
964 # Give executables the default manifest on Windows (a no-op elsewhere).
965 "//build/win:default_exe_manifest",
966 ]
967 }
968 }
969}
970
mbonadei9aa3f0a2017-01-24 14:58:22971template("rtc_shared_library") {
972 shared_library(target_name) {
973 forward_variables_from(invoker,
974 "*",
975 [
976 "configs",
977 "public_configs",
978 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19979 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22980 ])
Karl Wiberg138d4ac2017-10-16 09:16:19981 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53982 if (!defined(visibility)) {
983 visibility = webrtc_default_visibility
984 }
Karl Wibergbb23c832018-04-22 17:55:00985
986 # What's your poison?
987 if (defined(testonly) && testonly) {
988 assert(!defined(poisonous))
989 assert(!defined(allow_poison))
990 } else {
991 if (!defined(poisonous)) {
992 poisonous = []
993 }
994 if (!defined(allow_poison)) {
995 allow_poison = []
996 }
997 if (!defined(assert_no_deps)) {
998 assert_no_deps = []
999 }
1000 if (!defined(deps)) {
1001 deps = []
1002 }
1003 foreach(p, poisonous) {
1004 deps += [ webrtc_root + ":poison_" + p ]
1005 }
1006 foreach(poison_type, all_poison_types) {
1007 allow_dep = true
1008 foreach(v, visibility) {
1009 if (v == "*") {
1010 allow_dep = false
1011 }
1012 }
1013 foreach(p, allow_poison + poisonous) {
1014 if (p == poison_type) {
1015 allow_dep = true
1016 }
1017 }
1018 if (!allow_dep) {
1019 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
1020 }
1021 }
1022 }
1023
mbonadei9aa3f0a2017-01-24 14:58:221024 configs += invoker.configs
1025 configs -= rtc_remove_configs
1026 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:321027 public_configs = [
1028 rtc_common_inherited_config,
1029 absl_include_config,
1030 absl_define_config,
1031 ]
Mirko Bonadei2ab97f62019-07-18 11:44:121032 if (defined(testonly) && testonly) {
1033 public_configs += [ absl_flags_config ]
1034 }
mbonadei9aa3f0a2017-01-24 14:58:221035 if (defined(invoker.public_configs)) {
1036 public_configs += invoker.public_configs
1037 }
1038 }
1039}
kthelgason4065a5762017-02-14 12:58:561040
Byoungchan Lee26b23b82022-04-08 09:23:141041if (is_mac || is_ios) {
1042 template("apple_framework_bundle_with_umbrella_header") {
Anders Carlssondc6b4772018-01-15 12:31:031043 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281044 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 12:31:031045 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281046 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
Byoungchan Lee26b23b82022-04-08 09:23:141047 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Byoungchan Lee1ce9a172024-04-30 08:14:181048 privacy_manifest_path = "$target_gen_dir/$target_name/PrivacyInfo.xcprivacy"
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281049
1050 action_foreach("create_bracket_include_headers_$target_name") {
1051 script = "//tools_webrtc/apple/copy_framework_header.py"
1052 sources = invoker.sources
1053 output_name = invoker.output_name
1054 outputs = [
1055 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1056 ]
1057 args = [
1058 "--input",
1059 "{{source}}",
1060 "--output",
1061 rebase_path(target_gen_dir, root_build_dir) +
1062 "/$output_name.framework/WebRTC/{{source_file_part}}",
1063 ]
1064 }
Anders Carlssondc6b4772018-01-15 12:31:031065
Byoungchan Lee26b23b82022-04-08 09:23:141066 if (is_mac) {
1067 mac_framework_bundle(target_name) {
1068 forward_variables_from(invoker, "*", [ "configs" ])
1069 if (defined(invoker.configs)) {
1070 configs += invoker.configs
1071 }
1072
1073 framework_version = "A"
1074 framework_contents = [
1075 "Headers",
1076 "Modules",
1077 "Resources",
1078 ]
1079
1080 ldflags = [
1081 "-all_load",
1082 "-install_name",
1083 "@rpath/$output_name.framework/$output_name",
1084 ]
1085
1086 deps += [
1087 ":copy_framework_headers_$this_target_name",
1088 ":copy_modulemap_$this_target_name",
Byoungchan Lee1ce9a172024-04-30 08:14:181089 ":copy_privacy_manifest_$this_target_name",
Byoungchan Lee26b23b82022-04-08 09:23:141090 ":copy_umbrella_header_$this_target_name",
1091 ":create_bracket_include_headers_$this_target_name",
1092 ":modulemap_$this_target_name",
1093 ":umbrella_header_$this_target_name",
1094 ]
1095 }
1096 }
1097 if (is_ios) {
1098 ios_framework_bundle(target_name) {
1099 forward_variables_from(invoker,
1100 "*",
1101 [
1102 "configs",
1103 "public_headers",
1104 ])
1105 if (defined(invoker.configs)) {
1106 configs += invoker.configs
1107 }
1108 public_headers = get_target_outputs(
1109 ":create_bracket_include_headers_$this_target_name")
1110
1111 deps += [
Byoungchan Lee1ce9a172024-04-30 08:14:181112 ":copy_privacy_manifest_$this_target_name",
Byoungchan Lee26b23b82022-04-08 09:23:141113 ":copy_umbrella_header_$this_target_name",
1114 ":create_bracket_include_headers_$this_target_name",
1115 ]
1116 }
Anders Carlssondc6b4772018-01-15 12:31:031117 }
1118
Byoungchan Lee26b23b82022-04-08 09:23:141119 if (is_mac || target_environment == "catalyst") {
Jordan Rose53d3fc92021-07-06 19:16:411120 # Catalyst frameworks use the same layout as regular Mac frameworks.
1121 headers_dir = "Versions/A/Headers"
Byoungchan Lee1ce9a172024-04-30 08:14:181122
1123 # The path to the privacy manifest file differs between Mac and iOS.
1124 # https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/adding_a_privacy_manifest_to_your_app_or_third-party_sdk
1125 privacy_manifest_out_path = "Versions/A/Resources/PrivacyInfo.xcprivacy"
Jordan Rose53d3fc92021-07-06 19:16:411126 } else {
1127 headers_dir = "Headers"
Byoungchan Lee1ce9a172024-04-30 08:14:181128 privacy_manifest_out_path = "PrivacyInfo.xcprivacy"
Jordan Rose53d3fc92021-07-06 19:16:411129 }
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281130
Anders Carlsson95c56ee2018-09-06 13:48:171131 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281132 sources = get_target_outputs(
1133 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 14:29:271134
Mirko Bonadeiccbe95f2020-01-21 11:10:101135 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281136 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 14:29:271137 }
1138
Joel Sutherlandd2fb1bf2018-10-02 20:08:251139 action("modulemap_$this_target_name") {
1140 script = "//tools_webrtc/ios/generate_modulemap.py"
1141 args = [
1142 "--out",
1143 rebase_path(modulemap_path, root_build_dir),
1144 "--name",
1145 output_name,
1146 ]
Mirko Bonadeiccbe95f2020-01-21 11:10:101147 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 20:08:251148 }
1149
1150 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 11:10:101151 sources = [ modulemap_path ]
1152 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1153 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 20:08:251154 }
1155
Anders Carlsson95c56ee2018-09-06 13:48:171156 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281157 sources = get_target_outputs(
1158 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 14:29:271159
1160 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1161
Mirko Bonadeiccbe95f2020-01-21 11:10:101162 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 14:29:271163 args = [
1164 "--out",
1165 rebase_path(umbrella_header_path, root_build_dir),
1166 "--sources",
1167 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281168 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 14:29:271169 }
1170
Byoungchan Lee26b23b82022-04-08 09:23:141171 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 11:10:101172 sources = [ umbrella_header_path ]
Byoungchan Lee26b23b82022-04-08 09:23:141173 outputs =
1174 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 14:29:271175
Byoungchan Lee26b23b82022-04-08 09:23:141176 deps = [ ":umbrella_header_$target_name" ]
Anders Carlsson37bbf792018-09-05 14:29:271177 }
Byoungchan Lee1ce9a172024-04-30 08:14:181178
1179 action("create_privacy_manifest_$target_name") {
1180 script = "//tools_webrtc/apple/generate_privacy_manifest.py"
1181
1182 args = [
1183 "--output",
1184 rebase_path(privacy_manifest_path),
1185 ]
1186
1187 outputs = [ privacy_manifest_path ]
1188 }
1189
1190 copy("copy_privacy_manifest_$target_name") {
1191 sources = [ privacy_manifest_path ]
1192 outputs =
1193 [ "$root_out_dir/$output_name.framework/$privacy_manifest_out_path" ]
1194
1195 deps = [ ":create_privacy_manifest_$target_name" ]
1196 }
Anders Carlsson37bbf792018-09-05 14:29:271197 }
1198}
1199
Mirko Bonadeifbb3b7d2017-11-07 15:36:331200if (is_android) {
1201 template("rtc_android_library") {
1202 android_library(target_name) {
1203 forward_variables_from(invoker,
1204 "*",
1205 [
1206 "configs",
1207 "public_configs",
1208 "suppressed_configs",
1209 "visibility",
1210 ])
1211
Oleh Prypin05aee742018-11-23 16:29:441212 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 15:32:491213
Mirko Bonadeifbb3b7d2017-11-07 15:36:331214 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 16:29:441215 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 15:32:491216
1217 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 16:29:441218 if (defined(invoker.errorprone_args)) {
1219 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 15:32:491220 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:331221
Sami Kalliomäkidc526512018-03-27 15:07:271222 if (!defined(deps)) {
1223 deps = []
1224 }
Sami Kalliomäkidc526512018-03-27 15:07:271225
Mirko Bonadeifbb3b7d2017-11-07 15:36:331226 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 19:23:411227 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:331228 }
1229 }
1230
1231 template("rtc_android_apk") {
1232 android_apk(target_name) {
1233 forward_variables_from(invoker,
1234 "*",
1235 [
1236 "configs",
1237 "public_configs",
1238 "suppressed_configs",
1239 "visibility",
1240 ])
1241
1242 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 11:10:081243 errorprone_args = []
1244 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 15:07:271245
1246 if (!defined(deps)) {
1247 deps = []
1248 }
Sami Kalliomäkidc526512018-03-27 15:07:271249
Mirko Bonadeifbb3b7d2017-11-07 15:36:331250 no_build_hooks = true
1251 }
1252 }
1253
1254 template("rtc_instrumentation_test_apk") {
1255 instrumentation_test_apk(target_name) {
1256 forward_variables_from(invoker,
1257 "*",
1258 [
1259 "configs",
1260 "public_configs",
1261 "suppressed_configs",
1262 "visibility",
1263 ])
1264
1265 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 11:10:081266 errorprone_args = []
1267 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 15:07:271268
1269 if (!defined(deps)) {
1270 deps = []
1271 }
Sami Kalliomäkidc526512018-03-27 15:07:271272
Mirko Bonadeifbb3b7d2017-11-07 15:36:331273 no_build_hooks = true
1274 }
1275 }
1276}