blob: 5a1c43c88883fb512f2332461a00d11c3d977446 [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 Bonadei5f078452021-07-30 20:32:5542# This declare_args is separated from the next one because args declared
43# in this one, can be read from the next one (args defined in the same
44# declare_args cannot be referenced in that scope).
mbonadei9aa3f0a2017-01-24 14:58:2245declare_args() {
Mirko Bonadei028248c2018-10-10 10:19:0246 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
47 # expand to code that will manage symbols visibility.
48 rtc_enable_symbol_export = false
Mirko Bonadei5f078452021-07-30 20:32:5549}
50
51declare_args() {
Mirko Bonadei2bfa0712023-08-07 09:54:3552 # If set to true, C++ code will refer to the new JNI Generator symbols.
53 # If set to false the old ones will be used (to provide a nice update path).
54 rtc_jni_generator_legacy_symbols = false
55
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
mbonadei9aa3f0a2017-01-24 14:58:22134 # Set this to true to enable BWE test logging.
135 rtc_enable_bwe_test_logging = false
136
Joachim Bauch93e91342017-12-07 00:25:53137 # Set this to false to skip building examples.
138 rtc_build_examples = true
139
140 # Set this to false to skip building tools.
141 rtc_build_tools = true
142
Joachim Bauch75f18fc2017-12-20 20:25:47143 # Set this to false to skip building code that requires X11.
Maksim Sisovef4d0b62021-09-20 06:02:01144 rtc_use_x11 = ozone_platform_x11
Joachim Bauch75f18fc2017-12-20 20:25:47145
Tomas Popela318da512018-11-13 05:32:23146 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 13:37:51147 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
148 # only when using the sysroot as PipeWire is not available in older and
149 # supported Ubuntu and Debian distributions.
Artem Titov4d6a76d2021-09-03 10:07:20150 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 13:37:51151
Jan Gruliche1e05af2021-09-21 18:36:16152 # Set this to link PipeWire and required libraries directly instead of using the dlopen.
Tomas Popela762543f2018-12-12 13:37:51153 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 05:32:23154
mbonadei9aa3f0a2017-01-24 14:58:22155 # Enable to use the Mozilla internal settings.
156 build_with_mozilla = false
157
Philipp Hanckee95ebda2020-09-17 14:13:20158 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
159 # and NDK r16 or above.
henrika883d00f2018-03-16 09:09:49160 rtc_enable_android_aaudio = false
161
mbonadei9aa3f0a2017-01-24 14:58:22162 # Set to "func", "block", "edge" for coverage generation.
163 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
164 # It is recommend to set include_examples=0.
165 # Use llvm's sancov -html-report for human readable reports.
166 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
167 rtc_sanitize_coverage = ""
168
Philipp Hanckeaeac9f82020-09-11 09:58:18169 # Selects fixed-point code where possible.
170 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 14:58:22171 if (current_cpu == "arm" || current_cpu == "arm64") {
172 rtc_prefer_fixed_point = true
173 }
174
mbonadei9aa3f0a2017-01-24 14:58:22175 # Determines whether NEON code will be built.
176 rtc_build_with_neon =
177 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
178
179 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
180 # all platforms except Android and iOS. Because FFmpeg can be built
Artem Titov22a6b2d2021-07-27 14:25:56181 # with/without H.264 support, `ffmpeg_branding` has to separately be set to a
mbonadei9aa3f0a2017-01-24 14:58:22182 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Artem Titov22a6b2d2021-07-27 14:25:56183 # H.264, compilation succeeds but `H264DecoderImpl` fails to initialize.
mbonadei9aa3f0a2017-01-24 14:58:22184 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
185 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 09:47:18186 #
187 # Enabling H264 when building with MSVC is currently not supported, see
188 # bugs.webrtc.org/9213#c13 for more info.
189 rtc_use_h264 =
190 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 14:58:22191
qwu16972f2832023-08-15 09:16:54192 # Enable to use H265
193 rtc_use_h265 = proprietary_codecs
194
Markus Handell8e75bd42020-06-05 09:47:40195 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
196 rtc_use_absl_mutex = false
197
mbonadei9aa3f0a2017-01-24 14:58:22198 # By default, use normal platform audio support or dummy audio, but don't
199 # use file-based audio playout and record.
200 rtc_use_dummy_audio_file_devices = false
201
henrika7be78832017-06-13 15:34:16202 # When set to true, replace the audio output with a sinus tone at 440Hz.
203 # The ADM will ask for audio data from WebRTC but instead of reading real
204 # audio samples from NetEQ, a sinus tone will be generated and replace the
205 # real audio samples.
206 rtc_audio_device_plays_sinus_tone = false
207
Anders Carlsson358f2e02018-06-04 08:24:37208 if (is_ios) {
209 # Build broadcast extension in AppRTCMobile for iOS. This results in the
210 # binary only running on iOS 11+, which is why it is disabled by default.
211 rtc_apprtcmobile_broadcast_extension = false
212 }
Anders Carlsson7bca8ca2018-08-30 07:30:29213
Kári Tristan Helgasonba50cb32023-06-28 12:32:04214 # Determines whether OpenGL is available on iOS.
215 rtc_ios_use_opengl_rendering = is_ios && target_environment != "catalyst"
Jordan Rose53d3fc92021-07-06 19:16:41216
Jiawei Ou08745302019-02-12 19:36:13217 # When set to false, builtin audio encoder/decoder factories and all the
218 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
219 # (they will still be included in libjingle_peerconnection_so.so and
220 # WebRTC.framework)
221 rtc_include_builtin_audio_codecs = true
222
Mirko Bonadei20574f42019-03-28 06:50:07223 # When set to true and in a standalone build, it will undefine UNICODE and
224 # _UNICODE (which are always defined globally by the Chromium Windows
225 # toolchain).
226 # This is only needed for testing purposes, WebRTC wants to be sure it
227 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
228 # wide character functions.
229 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 20:47:54230
231 # When set to true, a capturer implementation that uses the
Austin Orion66241e42021-04-22 20:22:25232 # Windows.Graphics.Capture APIs will be available for use. This introduces a
233 # dependency on the Win 10 SDK v10.0.17763.0.
Austin Orion78f04d82021-04-23 19:37:26234 rtc_enable_win_wgc = is_win
philipelb09d8722021-11-23 10:00:24235
236 # Includes the dav1d decoder in the internal decoder factory when set to true.
237 rtc_include_dav1d_in_internal_decoder_factory = true
Emil Lundmark6bf20cc2022-09-21 13:20:22238
Emil Lundmark9109e852023-02-28 12:57:01239 # When enabled, a run-time check will make sure that all field trial keys have
240 # been registered in accordance with the field trial policy, see
241 # g3doc/field-trials.md. The value can be set to the following:
242 #
243 # "dcheck": RTC_DCHECKs that the field trial has been registered. RTC_DCHECK
244 # must be enabled separately.
245 #
246 # "warn": RTC_LOGs a message with LS_WARNING severity if the field trial
247 # hasn't been registered.
248 rtc_strict_field_trials = ""
Mirko Bonadei91304312023-07-26 11:01:43249
250 # If different from "", symbols exported with RTC_OBJC_EXPORT will be prefixed
251 # with this string.
252 # See the definition of RTC_OBJC_TYPE_PREFIX in the code.
253 rtc_objc_prefix = ""
Arthur Sonzogni47faf322023-08-22 09:55:36254
255 # Embedders can define dependencies needed by WebRTC. Dependencies can be
256 # configs or targets. This can be defined in their `.gn` file.
257 #
258 # In practise, this is use by Chromium: Targets from
259 # `//third_party/webrtc_overrides` are depending on Chrome's `//base`, but
260 # WebRTC does not declare its public dependencies. See webrtc:8603. Instead
261 # WebRTC is using a global common dependencies.
262 rtc_common_public_deps = [] # no-presubmit-check TODO(webrtc:8603)
Dan Minor9c686132018-01-15 15:20:00263}
mbonadei9aa3f0a2017-01-24 14:58:22264
Dan Minor9c686132018-01-15 15:20:00265if (!build_with_mozilla) {
266 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 14:58:22267}
268
269# A second declare_args block, so that declarations within it can
270# depend on the possibly overridden variables in the first
271# declare_args block.
272declare_args() {
Dan Minor9c686132018-01-15 15:20:00273 # Enables the use of protocol buffers for debug recordings.
274 rtc_enable_protobuf = !build_with_mozilla
275
276 # Set this to disable building with support for SCTP data channels.
277 rtc_enable_sctp = !build_with_mozilla
278
279 # Disable these to not build components which can be externally provided.
280 rtc_build_json = !build_with_mozilla
281 rtc_build_libsrtp = !build_with_mozilla
282 rtc_build_libvpx = !build_with_mozilla
283 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 15:20:00284 rtc_build_opus = !build_with_mozilla
285 rtc_build_ssl = !build_with_mozilla
Dan Minor9c686132018-01-15 15:20:00286
287 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 17:05:00288 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
289 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 15:20:00290 rtc_enable_libevent = false
291 rtc_build_libevent = false
292 } else {
293 rtc_enable_libevent = true
294 rtc_build_libevent = !build_with_mozilla
295 }
296
mbonadei9aa3f0a2017-01-24 14:58:22297 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
298 rtc_include_pulse_audio = !build_with_chromium
299
300 # Chromium uses its own IO handling, so the internal ADM is only built for
301 # standalone WebRTC.
302 rtc_include_internal_audio_device = !build_with_chromium
303
Zhaoliang Ma72e43212020-08-17 09:13:41304 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 10:02:32305 # TODO: Make sure that AVX2 works also for non-clang compilers.
306 if (is_clang == true) {
307 rtc_enable_avx2 = true
308 } else {
309 rtc_enable_avx2 = false
310 }
Zhaoliang Ma72e43212020-08-17 09:13:41311
Philipp Hancke1a89bc82021-03-02 20:23:24312 # Set this to true to build the unit tests.
313 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 15:20:00314 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 11:27:07315
316 # Set this to false to skip building code that also requires X11 extensions
317 # such as Xdamage, Xfixes.
318 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 15:24:46319
320 # Set this to true to fully remove logging from WebRTC.
321 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 13:24:31322
323 # Set this to true to disable trace events.
324 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 16:09:30325
326 # Set this to true to disable detailed error message and logging for
327 # RTC_CHECKs.
328 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 12:06:53329
330 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 14:02:53331 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 13:24:40332
333 # Set this to true to exclude the transient suppressor in the audio processing
334 # module from the build.
335 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 14:58:22336}
337
Florent Castellia80c3e52021-04-15 13:02:56338declare_args() {
Florent Castellia6983c62021-05-06 08:50:07339 # Enable the dcsctp backend for DataChannels and related unittests
340 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
341
Florent Castelli023be3c2022-03-15 15:01:52342 # Enable gRPC used for negotiation in multiprocess tests
343 rtc_enable_grpc = rtc_enable_protobuf && (is_linux || is_mac)
Florent Castellia80c3e52021-04-15 13:02:56344}
345
mbonadei9aa3f0a2017-01-24 14:58:22346# Make it possible to provide custom locations for some libraries (move these
347# up into declare_args should we need to actually use them for the GN build).
348rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 14:58:22349rtc_opus_dir = "//third_party/opus"
350
351# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 11:27:07352rtc_desktop_capture_supported =
353 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 09:10:11354 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 14:58:22355
356###############################################################################
357# Templates
358#
359
Mirko Bonadei92ea95e2017-09-15 04:47:31360# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 14:58:22361# chromium.
362# We need absolute paths for all configs in templates as they are shared in
363# different subdirectories.
364webrtc_root = get_path_info(".", "abspath")
365
366# Global configuration that should be applied to all WebRTC targets.
367# You normally shouldn't need to include this in your target as it's
368# automatically included when using the rtc_* templates.
369# It sets defines, include paths and compilation warnings accordingly,
370# both for WebRTC stand-alone builds and for the scenario when WebRTC
371# native code is built as part of Chromium.
Mirko Bonadei5f078452021-07-30 20:32:55372rtc_common_configs = [ webrtc_root + ":common_config" ]
mbonadei9aa3f0a2017-01-24 14:58:22373
kthelgasonc0977102017-04-24 07:57:16374if (is_mac || is_ios) {
Christoffer Janssonfe2e7ea2023-08-02 07:41:23375 if (filter_include(default_compiler_configs,
376 [ "//build/config/compiler:enable_arc" ]) == []) {
377 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
378 }
kthelgasonc0977102017-04-24 07:57:16379}
380
mbonadei9aa3f0a2017-01-24 14:58:22381# Global public configuration that should be applied to all WebRTC targets. You
382# normally shouldn't need to include this in your target as it's automatically
383# included when using the rtc_* templates. It set the defines, include paths and
384# compilation warnings that should be propagated to dependents of the targets
385# depending on the target having this config.
386rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
387
388# Common configs to remove or add in all rtc targets.
389rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 09:32:56390if (!build_with_chromium && is_clang) {
391 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
392}
mbonadei9aa3f0a2017-01-24 14:58:22393rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede16a2018-09-06 11:45:44394rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 11:15:54395rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 14:58:22396
397set_defaults("rtc_test") {
398 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36399 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22400 suppressed_configs = []
401}
402
Mirko Bonadei86d053c2019-10-17 19:32:04403set_defaults("rtc_library") {
404 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36405 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
Mirko Bonadei86d053c2019-10-17 19:32:04406 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 19:23:41407 absl_deps = []
Mirko Bonadei86d053c2019-10-17 19:32:04408}
409
mbonadei9aa3f0a2017-01-24 14:58:22410set_defaults("rtc_source_set") {
411 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36412 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22413 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 19:23:41414 absl_deps = []
mbonadei9aa3f0a2017-01-24 14:58:22415}
416
Mirko Bonadei86d053c2019-10-17 19:32:04417set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 14:58:22418 configs = rtc_add_configs
Arthur Sonzogni47faf322023-08-22 09:55:36419 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
mbonadei9aa3f0a2017-01-24 14:58:22420 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 19:23:41421 absl_deps = []
mbonadei9aa3f0a2017-01-24 14:58:22422}
423
Mirko Bonadei86d053c2019-10-17 19:32:04424set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 14:58:22425 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
430set_defaults("rtc_shared_library") {
431 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
Per Kjellandera7f2d842018-01-10 15:54:53436webrtc_default_visibility = [ webrtc_root + "/*" ]
437if (build_with_chromium) {
438 # Allow Chromium's WebRTC overrides targets to bypass the regular
439 # visibility restrictions.
440 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
441}
442
Karl Wibergbb23c832018-04-22 17:55:00443# ---- Poisons ----
444#
445# The general idea is that some targets declare that they contain some
446# kind of poison, which makes it impossible for other targets to
447# depend on them (even transitively) unless they declare themselves
448# immune to that particular type of poison.
449#
450# Targets that *contain* poison of type foo should contain the line
451#
452# poisonous = [ "foo" ]
453#
454# and targets that *are immune but arent't themselves poisonous*
455# should contain
456#
457# allow_poison = [ "foo" ]
458#
459# This useful in cases where we have some large target or set of
460# targets and want to ensure that most other targets do not
461# transitively depend on them. For example, almost no high-level
462# target should depend on the audio codecs, since we want WebRTC users
463# to be able to inject any subset of them and actually end up with a
464# binary that doesn't include the codecs they didn't inject.
465#
466# Test-only targets (`testonly` set to true) and non-public targets
467# (`visibility` not containing "*") are automatically immune to all
468# types of poison.
469#
470# Here's the complete list of all types of poison. It must be kept in
471# 1:1 correspondence with the set of //:poison_* targets.
472#
473all_poison_types = [
474 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
475 "audio_codecs",
Anders Carlsson1f433e42018-04-24 14:39:05476
Danil Chapovalov41300af2019-07-10 10:44:43477 # Default task queue implementation.
478 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 08:45:58479
Sam Zackrisson03cb7e52021-12-06 14:40:04480 # Default echo detector implementation.
481 "default_echo_detector",
482
Sam Zackrisson492fdf42019-10-25 08:45:58483 # JSON parsing should not be needed in the "slim and modular" WebRTC.
484 "rtc_json",
485
486 # Software video codecs (VP8 and VP9 through libvpx).
487 "software_video_codecs",
Karl Wibergbb23c832018-04-22 17:55:00488]
489
Mirko Bonadei9a89a492018-05-29 14:22:32490absl_include_config = "//third_party/abseil-cpp:absl_include_config"
491absl_define_config = "//third_party/abseil-cpp:absl_define_config"
492
Mirko Bonadei2ab97f62019-07-18 11:44:12493# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
494# that are testonly.
495absl_flags_config = webrtc_root + ":absl_flags_configs"
496
Mirko Bonadeie99b6cc2020-11-25 15:41:37497# WebRTC wrapper of Chromium's test() template. This template just adds some
498# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
499# target.
500# The parameter `is_xctest` is different from the one in the Chromium's test()
501# template (and it is not forwarded to it). In rtc_test(), the argument
502# `is_xctest` is used to avoid to take dependencies that are not needed
503# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 14:58:22504template("rtc_test") {
505 test(target_name) {
506 forward_variables_from(invoker,
507 "*",
508 [
509 "configs",
Mirko Bonadeie99b6cc2020-11-25 15:41:37510 "is_xctest",
mbonadei9aa3f0a2017-01-24 14:58:22511 "public_configs",
512 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19513 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22514 ])
Mirko Bonadeidd411942017-11-21 14:35:27515
516 # Always override to public because when target_os is Android the `test`
517 # template can override it to [ "*" ] and we want to avoid conditional
518 # visibility.
Mirko Bonadei21558812017-11-21 11:47:34519 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 14:58:22520 configs += invoker.configs
521 configs -= rtc_remove_configs
522 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32523 public_configs = [
524 rtc_common_inherited_config,
525 absl_include_config,
526 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 11:44:12527 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32528 ]
mbonadei9aa3f0a2017-01-24 14:58:22529 if (defined(invoker.public_configs)) {
530 public_configs += invoker.public_configs
531 }
sakald7fdb802017-05-26 08:51:53532 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 13:48:37533 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 22:53:11534 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 20:57:49535 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 21:00:41536 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 17:03:37537 deps += [
538 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
539 webrtc_root + "test:native_test_java",
540 ]
sakald7fdb802017-05-26 08:51:53541 }
Mirko Bonadeie99b6cc2020-11-25 15:41:37542
Björn Terelius49850c32022-05-04 08:59:56543 # Build //test:google_test_runner_objc when the test is not a real XCTest.
Jeremy Leconteb8ba8c92022-03-15 08:08:29544 if (is_ios && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 15:41:37545 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
Björn Terelius49850c32022-05-04 08:59:56546 xctest_module_target = "//test:google_test_runner_objc"
Mirko Bonadeie99b6cc2020-11-25 15:41:37547 }
548 }
Andrey Logvin78646002021-01-29 10:50:19549
550 # If absl_deps is [], no action is needed. If not [], then it needs to be
551 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
552 # otherwise it just needs to be added to deps.
553 if (defined(absl_deps) && absl_deps != []) {
554 if (!defined(deps)) {
555 deps = []
556 }
557 if (build_with_chromium) {
558 deps += [ "//third_party/abseil-cpp:absl" ]
559 } else {
560 deps += absl_deps
561 }
562 }
563
Jeremy Leconted15f3e12022-02-18 09:16:32564 # TODO(crbug.com/webrtc/13556): Adding the .app folder in the runtime_deps
565 # shoulnd't be necessary. this code should be removed and the same solution
566 # as Chromium should be used.
567 if (is_ios) {
568 if (!defined(invoker.data)) {
569 data = []
570 }
571 data += [ "${root_out_dir}/${target_name}.app" ]
572 }
mbonadei9aa3f0a2017-01-24 14:58:22573 }
574}
575
576template("rtc_source_set") {
577 source_set(target_name) {
578 forward_variables_from(invoker,
579 "*",
580 [
581 "configs",
582 "public_configs",
583 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19584 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22585 ])
Karl Wiberg138d4ac2017-10-16 09:16:19586 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53587 if (!defined(visibility)) {
588 visibility = webrtc_default_visibility
589 }
Karl Wibergbb23c832018-04-22 17:55:00590
591 # What's your poison?
592 if (defined(testonly) && testonly) {
593 assert(!defined(poisonous))
594 assert(!defined(allow_poison))
595 } else {
596 if (!defined(poisonous)) {
597 poisonous = []
598 }
599 if (!defined(allow_poison)) {
600 allow_poison = []
601 }
602 if (!defined(assert_no_deps)) {
603 assert_no_deps = []
604 }
605 if (!defined(deps)) {
606 deps = []
607 }
608 foreach(p, poisonous) {
609 deps += [ webrtc_root + ":poison_" + p ]
610 }
611 foreach(poison_type, all_poison_types) {
612 allow_dep = true
613 foreach(v, visibility) {
614 if (v == "*") {
615 allow_dep = false
616 }
617 }
618 foreach(p, allow_poison + poisonous) {
619 if (p == poison_type) {
620 allow_dep = true
621 }
622 }
623 if (!allow_dep) {
624 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
625 }
626 }
627 }
628
Mirko Bonadei92dd35d2019-11-15 15:08:41629 # Chromium should only depend on the WebRTC component in order to
630 # avoid to statically link WebRTC in a component build.
631 if (build_with_chromium) {
632 publicly_visible = false
633 foreach(v, visibility) {
634 if (v == "*") {
635 publicly_visible = true
636 }
637 }
638 if (publicly_visible) {
639 visibility = []
640 visibility = webrtc_default_visibility
641 }
642 }
643
Mirko Bonadei96ede16a2018-09-06 11:45:44644 if (!defined(testonly) || !testonly) {
645 configs += rtc_prod_configs
646 }
647
mbonadei9aa3f0a2017-01-24 14:58:22648 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 11:15:54649 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 14:58:22650 configs -= rtc_remove_configs
651 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32652 public_configs = [
653 rtc_common_inherited_config,
654 absl_include_config,
655 absl_define_config,
656 ]
Mirko Bonadei2ab97f62019-07-18 11:44:12657 if (defined(testonly) && testonly) {
658 public_configs += [ absl_flags_config ]
659 }
mbonadei9aa3f0a2017-01-24 14:58:22660 if (defined(invoker.public_configs)) {
661 public_configs += invoker.public_configs
662 }
Mirko Bonadei8b7cfa12020-06-03 19:23:41663
Mirko Bonadei96115cf2020-06-23 21:39:56664 # If absl_deps is [], no action is needed. If not [], then it needs to be
665 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 19:23:41666 # otherwise it just needs to be added to deps.
667 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 12:30:41668 if (!defined(deps)) {
669 deps = []
670 }
Mirko Bonadei08ce9862020-06-11 09:25:32671 if (build_with_chromium) {
672 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 19:23:41673 } else {
674 deps += absl_deps
675 }
676 }
mbonadei9aa3f0a2017-01-24 14:58:22677 }
678}
679
mbonadei9aa3f0a2017-01-24 14:58:22680template("rtc_static_library") {
681 static_library(target_name) {
682 forward_variables_from(invoker,
683 "*",
684 [
685 "configs",
686 "public_configs",
687 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19688 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22689 ])
Karl Wiberg138d4ac2017-10-16 09:16:19690 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53691 if (!defined(visibility)) {
692 visibility = webrtc_default_visibility
693 }
Karl Wibergbb23c832018-04-22 17:55:00694
695 # What's your poison?
696 if (defined(testonly) && testonly) {
697 assert(!defined(poisonous))
698 assert(!defined(allow_poison))
699 } else {
700 if (!defined(poisonous)) {
701 poisonous = []
702 }
703 if (!defined(allow_poison)) {
704 allow_poison = []
705 }
706 if (!defined(assert_no_deps)) {
707 assert_no_deps = []
708 }
709 if (!defined(deps)) {
710 deps = []
711 }
712 foreach(p, poisonous) {
713 deps += [ webrtc_root + ":poison_" + p ]
714 }
715 foreach(poison_type, all_poison_types) {
716 allow_dep = true
717 foreach(v, visibility) {
718 if (v == "*") {
719 allow_dep = false
720 }
721 }
722 foreach(p, allow_poison + poisonous) {
723 if (p == poison_type) {
724 allow_dep = true
725 }
726 }
727 if (!allow_dep) {
728 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
729 }
730 }
731 }
732
Mirko Bonadei96ede16a2018-09-06 11:45:44733 if (!defined(testonly) || !testonly) {
734 configs += rtc_prod_configs
735 }
736
mbonadei9aa3f0a2017-01-24 14:58:22737 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 11:15:54738 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 14:58:22739 configs -= rtc_remove_configs
740 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32741 public_configs = [
742 rtc_common_inherited_config,
743 absl_include_config,
744 absl_define_config,
745 ]
Mirko Bonadei2ab97f62019-07-18 11:44:12746 if (defined(testonly) && testonly) {
747 public_configs += [ absl_flags_config ]
748 }
mbonadei9aa3f0a2017-01-24 14:58:22749 if (defined(invoker.public_configs)) {
750 public_configs += invoker.public_configs
751 }
Mirko Bonadei8b7cfa12020-06-03 19:23:41752
Mirko Bonadei96115cf2020-06-23 21:39:56753 # If absl_deps is [], no action is needed. If not [], then it needs to be
754 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 19:23:41755 # otherwise it just needs to be added to deps.
756 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 12:30:41757 if (!defined(deps)) {
758 deps = []
759 }
Mirko Bonadei08ce9862020-06-11 09:25:32760 if (build_with_chromium) {
761 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 19:23:41762 } else {
763 deps += absl_deps
764 }
765 }
mbonadei9aa3f0a2017-01-24 14:58:22766 }
767}
768
Mirko Bonadei86d053c2019-10-17 19:32:04769# This template automatically switches the target type between source_set
770# and static_library.
771#
Florent Castelli87b6e7b2022-04-26 00:22:35772# This should be the default target type for all the WebRTC targets.
Mirko Bonadei86d053c2019-10-17 19:32:04773#
774# How does it work:
775# Since all files in a source_set are linked into a final binary, while files
776# in a static library are only linked in if at least one symbol in them is
777# referenced, in component builds source_sets are easy to deal with because
778# all their object files are passed to the linker to create a shared library.
779# In release builds instead, static_libraries are preferred since they allow
780# the linker to discard dead code.
781# For the same reason, testonly targets will always be expanded to
782# source_set in order to be sure that tests are present in the test binary.
783template("rtc_library") {
Florent Castelli87b6e7b2022-04-26 00:22:35784 header_only = true
785 if (defined(invoker.sources)) {
786 non_header_sources = filter_exclude(invoker.sources,
787 [
788 "*.h",
789 "*.hh",
790 "*.inc",
791 ])
792 if (non_header_sources != []) {
793 header_only = false
794 }
795 }
796
797 # Header only libraries should use source_set as a static_library with no
798 # source files will cause issues with macOS libtool.
799 if (header_only || is_component_build ||
800 (defined(invoker.testonly) && invoker.testonly)) {
Mirko Bonadei86d053c2019-10-17 19:32:04801 target_type = "source_set"
802 } else {
803 target_type = "static_library"
804 }
805 target(target_type, target_name) {
806 forward_variables_from(invoker,
807 "*",
808 [
809 "configs",
810 "public_configs",
811 "suppressed_configs",
812 "visibility",
813 ])
814 forward_variables_from(invoker, [ "visibility" ])
815 if (!defined(visibility)) {
816 visibility = webrtc_default_visibility
817 }
818
819 # What's your poison?
820 if (defined(testonly) && testonly) {
821 assert(!defined(poisonous))
822 assert(!defined(allow_poison))
823 } else {
824 if (!defined(poisonous)) {
825 poisonous = []
826 }
827 if (!defined(allow_poison)) {
828 allow_poison = []
829 }
830 if (!defined(assert_no_deps)) {
831 assert_no_deps = []
832 }
833 if (!defined(deps)) {
834 deps = []
835 }
836 foreach(p, poisonous) {
837 deps += [ webrtc_root + ":poison_" + p ]
838 }
839 foreach(poison_type, all_poison_types) {
840 allow_dep = true
841 foreach(v, visibility) {
842 if (v == "*") {
843 allow_dep = false
844 }
845 }
846 foreach(p, allow_poison + poisonous) {
847 if (p == poison_type) {
848 allow_dep = true
849 }
850 }
851 if (!allow_dep) {
852 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
853 }
854 }
855 }
856
Mirko Bonadei92dd35d2019-11-15 15:08:41857 # Chromium should only depend on the WebRTC component in order to
858 # avoid to statically link WebRTC in a component build.
859 if (build_with_chromium) {
860 publicly_visible = false
861 foreach(v, visibility) {
862 if (v == "*") {
863 publicly_visible = true
864 }
865 }
866 if (publicly_visible) {
867 visibility = []
868 visibility = webrtc_default_visibility
869 }
870 }
871
Mirko Bonadei86d053c2019-10-17 19:32:04872 if (!defined(testonly) || !testonly) {
873 configs += rtc_prod_configs
874 }
875
876 configs += invoker.configs
877 configs += rtc_library_impl_config
878 configs -= rtc_remove_configs
879 configs -= invoker.suppressed_configs
880 public_configs = [
881 rtc_common_inherited_config,
882 absl_include_config,
883 absl_define_config,
884 ]
885 if (defined(testonly) && testonly) {
886 public_configs += [ absl_flags_config ]
887 }
888 if (defined(invoker.public_configs)) {
889 public_configs += invoker.public_configs
890 }
Mirko Bonadei8b7cfa12020-06-03 19:23:41891
Mirko Bonadei96115cf2020-06-23 21:39:56892 # If absl_deps is [], no action is needed. If not [], then it needs to be
893 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 19:23:41894 # otherwise it just needs to be added to deps.
895 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 12:30:41896 if (!defined(deps)) {
897 deps = []
898 }
Mirko Bonadei08ce9862020-06-11 09:25:32899 if (build_with_chromium) {
900 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 19:23:41901 } else {
902 deps += absl_deps
903 }
904 }
Mirko Bonadei86d053c2019-10-17 19:32:04905 }
906}
907
908template("rtc_executable") {
909 executable(target_name) {
910 forward_variables_from(invoker,
911 "*",
912 [
913 "deps",
914 "configs",
915 "public_configs",
916 "suppressed_configs",
917 "visibility",
918 ])
919 forward_variables_from(invoker, [ "visibility" ])
920 if (!defined(visibility)) {
921 visibility = webrtc_default_visibility
922 }
923 configs += invoker.configs
924 configs -= rtc_remove_configs
925 configs -= invoker.suppressed_configs
926 deps = invoker.deps
927
928 public_configs = [
929 rtc_common_inherited_config,
930 absl_include_config,
931 absl_define_config,
932 ]
933 if (defined(testonly) && testonly) {
934 public_configs += [ absl_flags_config ]
935 }
936 if (defined(invoker.public_configs)) {
937 public_configs += invoker.public_configs
938 }
939 if (is_win) {
940 deps += [
941 # Give executables the default manifest on Windows (a no-op elsewhere).
942 "//build/win:default_exe_manifest",
943 ]
944 }
945 }
946}
947
mbonadei9aa3f0a2017-01-24 14:58:22948template("rtc_shared_library") {
949 shared_library(target_name) {
950 forward_variables_from(invoker,
951 "*",
952 [
953 "configs",
954 "public_configs",
955 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 09:16:19956 "visibility",
mbonadei9aa3f0a2017-01-24 14:58:22957 ])
Karl Wiberg138d4ac2017-10-16 09:16:19958 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53959 if (!defined(visibility)) {
960 visibility = webrtc_default_visibility
961 }
Karl Wibergbb23c832018-04-22 17:55:00962
963 # What's your poison?
964 if (defined(testonly) && testonly) {
965 assert(!defined(poisonous))
966 assert(!defined(allow_poison))
967 } else {
968 if (!defined(poisonous)) {
969 poisonous = []
970 }
971 if (!defined(allow_poison)) {
972 allow_poison = []
973 }
974 if (!defined(assert_no_deps)) {
975 assert_no_deps = []
976 }
977 if (!defined(deps)) {
978 deps = []
979 }
980 foreach(p, poisonous) {
981 deps += [ webrtc_root + ":poison_" + p ]
982 }
983 foreach(poison_type, all_poison_types) {
984 allow_dep = true
985 foreach(v, visibility) {
986 if (v == "*") {
987 allow_dep = false
988 }
989 }
990 foreach(p, allow_poison + poisonous) {
991 if (p == poison_type) {
992 allow_dep = true
993 }
994 }
995 if (!allow_dep) {
996 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
997 }
998 }
999 }
1000
mbonadei9aa3f0a2017-01-24 14:58:221001 configs += invoker.configs
1002 configs -= rtc_remove_configs
1003 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:321004 public_configs = [
1005 rtc_common_inherited_config,
1006 absl_include_config,
1007 absl_define_config,
1008 ]
Mirko Bonadei2ab97f62019-07-18 11:44:121009 if (defined(testonly) && testonly) {
1010 public_configs += [ absl_flags_config ]
1011 }
mbonadei9aa3f0a2017-01-24 14:58:221012 if (defined(invoker.public_configs)) {
1013 public_configs += invoker.public_configs
1014 }
1015 }
1016}
kthelgason4065a5762017-02-14 12:58:561017
Byoungchan Lee26b23b82022-04-08 09:23:141018if (is_mac || is_ios) {
1019 template("apple_framework_bundle_with_umbrella_header") {
Anders Carlssondc6b4772018-01-15 12:31:031020 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281021 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 12:31:031022 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281023 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
Byoungchan Lee26b23b82022-04-08 09:23:141024 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281025
1026 action_foreach("create_bracket_include_headers_$target_name") {
1027 script = "//tools_webrtc/apple/copy_framework_header.py"
1028 sources = invoker.sources
1029 output_name = invoker.output_name
1030 outputs = [
1031 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1032 ]
1033 args = [
1034 "--input",
1035 "{{source}}",
1036 "--output",
1037 rebase_path(target_gen_dir, root_build_dir) +
1038 "/$output_name.framework/WebRTC/{{source_file_part}}",
1039 ]
1040 }
Anders Carlssondc6b4772018-01-15 12:31:031041
Byoungchan Lee26b23b82022-04-08 09:23:141042 if (is_mac) {
1043 mac_framework_bundle(target_name) {
1044 forward_variables_from(invoker, "*", [ "configs" ])
1045 if (defined(invoker.configs)) {
1046 configs += invoker.configs
1047 }
1048
1049 framework_version = "A"
1050 framework_contents = [
1051 "Headers",
1052 "Modules",
1053 "Resources",
1054 ]
1055
1056 ldflags = [
1057 "-all_load",
1058 "-install_name",
1059 "@rpath/$output_name.framework/$output_name",
1060 ]
1061
1062 deps += [
1063 ":copy_framework_headers_$this_target_name",
1064 ":copy_modulemap_$this_target_name",
1065 ":copy_umbrella_header_$this_target_name",
1066 ":create_bracket_include_headers_$this_target_name",
1067 ":modulemap_$this_target_name",
1068 ":umbrella_header_$this_target_name",
1069 ]
1070 }
1071 }
1072 if (is_ios) {
1073 ios_framework_bundle(target_name) {
1074 forward_variables_from(invoker,
1075 "*",
1076 [
1077 "configs",
1078 "public_headers",
1079 ])
1080 if (defined(invoker.configs)) {
1081 configs += invoker.configs
1082 }
1083 public_headers = get_target_outputs(
1084 ":create_bracket_include_headers_$this_target_name")
1085
1086 deps += [
1087 ":copy_umbrella_header_$this_target_name",
1088 ":create_bracket_include_headers_$this_target_name",
1089 ]
1090 }
Anders Carlssondc6b4772018-01-15 12:31:031091 }
1092
Byoungchan Lee26b23b82022-04-08 09:23:141093 if (is_mac || target_environment == "catalyst") {
Jordan Rose53d3fc92021-07-06 19:16:411094 # Catalyst frameworks use the same layout as regular Mac frameworks.
1095 headers_dir = "Versions/A/Headers"
1096 } else {
1097 headers_dir = "Headers"
1098 }
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281099
Anders Carlsson95c56ee2018-09-06 13:48:171100 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281101 sources = get_target_outputs(
1102 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 14:29:271103
Mirko Bonadeiccbe95f2020-01-21 11:10:101104 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281105 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 14:29:271106 }
1107
Joel Sutherlandd2fb1bf2018-10-02 20:08:251108 action("modulemap_$this_target_name") {
1109 script = "//tools_webrtc/ios/generate_modulemap.py"
1110 args = [
1111 "--out",
1112 rebase_path(modulemap_path, root_build_dir),
1113 "--name",
1114 output_name,
1115 ]
Mirko Bonadeiccbe95f2020-01-21 11:10:101116 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 20:08:251117 }
1118
1119 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 11:10:101120 sources = [ modulemap_path ]
1121 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1122 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 20:08:251123 }
1124
Anders Carlsson95c56ee2018-09-06 13:48:171125 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281126 sources = get_target_outputs(
1127 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 14:29:271128
1129 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1130
Mirko Bonadeiccbe95f2020-01-21 11:10:101131 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 14:29:271132 args = [
1133 "--out",
1134 rebase_path(umbrella_header_path, root_build_dir),
1135 "--sources",
1136 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-16 22:49:281137 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 14:29:271138 }
1139
Byoungchan Lee26b23b82022-04-08 09:23:141140 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 11:10:101141 sources = [ umbrella_header_path ]
Byoungchan Lee26b23b82022-04-08 09:23:141142 outputs =
1143 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 14:29:271144
Byoungchan Lee26b23b82022-04-08 09:23:141145 deps = [ ":umbrella_header_$target_name" ]
Anders Carlsson37bbf792018-09-05 14:29:271146 }
1147 }
1148}
1149
Mirko Bonadeifbb3b7d2017-11-07 15:36:331150if (is_android) {
1151 template("rtc_android_library") {
1152 android_library(target_name) {
1153 forward_variables_from(invoker,
1154 "*",
1155 [
1156 "configs",
1157 "public_configs",
1158 "suppressed_configs",
1159 "visibility",
1160 ])
1161
Oleh Prypin05aee742018-11-23 16:29:441162 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 15:32:491163
Mirko Bonadeifbb3b7d2017-11-07 15:36:331164 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 16:29:441165 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 15:32:491166
1167 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 16:29:441168 if (defined(invoker.errorprone_args)) {
1169 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 15:32:491170 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:331171
Sami Kalliomäkidc526512018-03-27 15:07:271172 if (!defined(deps)) {
1173 deps = []
1174 }
Sami Kalliomäkidc526512018-03-27 15:07:271175
Mirko Bonadeifbb3b7d2017-11-07 15:36:331176 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 19:23:411177 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:331178 }
1179 }
1180
1181 template("rtc_android_apk") {
1182 android_apk(target_name) {
1183 forward_variables_from(invoker,
1184 "*",
1185 [
1186 "configs",
1187 "public_configs",
1188 "suppressed_configs",
1189 "visibility",
1190 ])
1191
1192 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 11:10:081193 errorprone_args = []
1194 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 15:07:271195
1196 if (!defined(deps)) {
1197 deps = []
1198 }
Sami Kalliomäkidc526512018-03-27 15:07:271199
Mirko Bonadeifbb3b7d2017-11-07 15:36:331200 no_build_hooks = true
1201 }
1202 }
1203
1204 template("rtc_instrumentation_test_apk") {
1205 instrumentation_test_apk(target_name) {
1206 forward_variables_from(invoker,
1207 "*",
1208 [
1209 "configs",
1210 "public_configs",
1211 "suppressed_configs",
1212 "visibility",
1213 ])
1214
1215 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 11:10:081216 errorprone_args = []
1217 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 15:07:271218
1219 if (!defined(deps)) {
1220 deps = []
1221 }
Sami Kalliomäkidc526512018-03-27 15:07:271222
Mirko Bonadeifbb3b7d2017-11-07 15:36:331223 no_build_hooks = true
1224 }
1225 }
1226}