blob: 8ab7b27f0c05f928c9cbd1b554dbbc6669a458bb [file] [log] [blame]
mbonadei9aa3f0a2017-01-24 06:58:22 -08001# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS. All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
mbonadei9aa3f0a2017-01-24 06:58:22 -08008import("//build/config/arm.gni")
9import("//build/config/features.gni")
10import("//build/config/mips.gni")
Maksim Sisovef4d0b62021-09-20 09:02:01 +030011import("//build/config/ozone.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080012import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 06:32:23 +010013import("//build/config/sysroot.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080014import("//build_overrides/build.gni")
mbonadei96606272017-03-03 19:41:59 -080015
16if (!build_with_chromium && is_component_build) {
17 print("The Gn argument `is_component_build` is currently " +
18 "ignored for WebRTC builds.")
19 print("Component builds are supported by Chromium and the argument " +
20 "`is_component_build` makes it possible to create shared libraries " +
21 "instead of static libraries.")
22 print("If an app depends on WebRTC it makes sense to just depend on the " +
23 "WebRTC static library, so there is no difference between " +
24 "`is_component_build=true` and `is_component_build=false`.")
25 print(
Fanny Linderborg0d2dc1f2021-07-14 14:02:11 +000026 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/main/docs/component_build.md")
mbonadei96606272017-03-03 19:41:59 -080027 assert(!is_component_build, "Component builds are not supported in WebRTC.")
28}
29
kthelgason4065a572017-02-14 04:58:56 -080030if (is_ios) {
31 import("//build/config/ios/rules.gni")
32}
mbonadei9aa3f0a2017-01-24 06:58:22 -080033
Anders Carlsson37bbf792018-09-05 16:29:27 +020034if (is_mac) {
35 import("//build/config/mac/rules.gni")
36}
37
Christoffer Jansson25e41562022-09-23 08:38:54 +020038if (is_fuchsia) {
39 import("//build/config/fuchsia/config.gni")
40}
41
Mirko Bonadei5f078452021-07-30 22:32:55 +020042# 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 06:58:22 -080045declare_args() {
Mirko Bonadei028248c2018-10-10 12:19:02 +020046 # 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 22:32:55 +020049}
50
51declare_args() {
Mirko Bonadei339965f2021-10-12 13:23:44 +020052 # Setting this to true, will make RTC_DLOG() expand to log statements instead
Mirko Bonadei56ed4682021-10-12 08:55:42 +020053 # of being removed by the preprocessor.
54 # This is useful for example to be able to get RTC_DLOGs on a release build.
55 rtc_dlog_always_on = false
56
Mirko Bonadei5f078452021-07-30 22:32:55 +020057 # Setting this to true will make RTC_OBJC_EXPORT expand to code that will
58 # manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported
59 # if C++ symbols are but setting this arg to true while keeping
60 # rtc_enable_symbol_export=false will only export RTC_OBJC_EXPORT
61 # annotated symbols.
62 rtc_enable_objc_symbol_export = rtc_enable_symbol_export
Mirko Bonadei028248c2018-10-10 12:19:02 +020063
Mirko Bonadei31b0b452018-08-22 10:37:11 +020064 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020065 # will tell the pre-processor to remove the default definition of symbols
66 # needed to use field_trial. In that case a new implementation needs to be
67 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020068 if (build_with_chromium) {
69 # When WebRTC is built as part of Chromium it should exclude the default
70 # implementation of field_trial unless it is building for NACL or
71 # Chromecast.
Ryan Keanecf7802d2022-06-10 21:33:18 +000072 rtc_exclude_field_trial_default = !is_nacl && !is_castos && !is_cast_android
Mirko Bonadei31b0b452018-08-22 10:37:11 +020073 } else {
74 rtc_exclude_field_trial_default = false
75 }
Mirko Bonadei70400902018-08-21 15:44:28 +020076
Mirko Bonadei906add42018-09-05 16:03:16 +020077 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
78 # will tell the pre-processor to remove the default definition of symbols
79 # needed to use metrics. In that case a new implementation needs to be
80 # provided.
81 rtc_exclude_metrics_default = build_with_chromium
82
Johannes Kronda20c732021-02-19 16:39:41 +010083 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which
84 # will tell the pre-processor to remove the default definition of the
85 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
86 # that case a new implementation needs to be provided.
Johannes Kronbb52bdf2021-02-25 10:10:08 +010087 rtc_exclude_system_time = build_with_chromium
Johannes Kronda20c732021-02-19 16:39:41 +010088
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070089 # Setting this to false will require the API user to pass in their own
90 # SSLCertificateVerifier to verify the certificates presented from a
91 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
92 rtc_builtin_ssl_root_certificates = true
93
Karl Wibergeb254b42017-11-01 15:08:12 +010094 # Include the iLBC audio codec?
Olga Sharonova5fbd7582020-07-09 09:50:42 +000095 rtc_include_ilbc = true
Karl Wibergeb254b42017-11-01 15:08:12 +010096
mbonadei9aa3f0a2017-01-24 06:58:22 -080097 # Disable this to avoid building the Opus audio codec.
98 rtc_include_opus = true
99
minyue2e03c662017-02-01 17:31:11 -0800100 # Enable this if the Opus version upon which WebRTC is built supports direct
101 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +0200102 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -0800103
mbonadei9aa3f0a2017-01-24 06:58:22 -0800104 # Enable this to let the Opus audio codec change complexity on the fly.
105 rtc_opus_variable_complexity = false
106
mbonadei9aa3f0a2017-01-24 06:58:22 -0800107 # Used to specify an external Jsoncpp include path when not compiling the
108 # library that comes with WebRTC (i.e. rtc_build_json == 0).
109 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
110
111 # Used to specify an external OpenSSL include path when not compiling the
112 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
113 rtc_ssl_root = ""
114
mbonadei9aa3f0a2017-01-24 06:58:22 -0800115 # Enable when an external authentication mechanism is used for performing
116 # packet authentication for RTP packets instead of libsrtp.
117 rtc_enable_external_auth = build_with_chromium
118
119 # Selects whether debug dumps for the audio processing module
120 # should be generated.
121 apm_debug_dump = false
122
Per Åhgrencc73ed32020-04-26 23:56:17 +0200123 # Selects whether the audio processing module should be excluded.
124 rtc_exclude_audio_processing_module = false
125
mbonadei9aa3f0a2017-01-24 06:58:22 -0800126 # Set this to true to enable BWE test logging.
127 rtc_enable_bwe_test_logging = false
128
Joachim Bauch93e91342017-12-07 01:25:53 +0100129 # Set this to false to skip building examples.
130 rtc_build_examples = true
131
132 # Set this to false to skip building tools.
133 rtc_build_tools = true
134
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100135 # Set this to false to skip building code that requires X11.
Maksim Sisovef4d0b62021-09-20 09:02:01 +0300136 rtc_use_x11 = ozone_platform_x11
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100137
Tomas Popela318da512018-11-13 06:32:23 +0100138 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 14:37:51 +0100139 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
140 # only when using the sysroot as PipeWire is not available in older and
141 # supported Ubuntu and Debian distributions.
Artem Titov4d6a76d2021-09-03 10:07:20 +0000142 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 14:37:51 +0100143
Jan Gruliche1e05af2021-09-21 20:36:16 +0200144 # Set this to link PipeWire and required libraries directly instead of using the dlopen.
Tomas Popela762543f2018-12-12 14:37:51 +0100145 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 06:32:23 +0100146
mbonadei9aa3f0a2017-01-24 06:58:22 -0800147 # Enable to use the Mozilla internal settings.
148 build_with_mozilla = false
149
Philipp Hanckee95ebda2020-09-17 16:13:20 +0200150 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
151 # and NDK r16 or above.
henrika883d00f2018-03-16 10:09:49 +0100152 rtc_enable_android_aaudio = false
153
mbonadei9aa3f0a2017-01-24 06:58:22 -0800154 # Set to "func", "block", "edge" for coverage generation.
155 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
156 # It is recommend to set include_examples=0.
157 # Use llvm's sancov -html-report for human readable reports.
158 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
159 rtc_sanitize_coverage = ""
160
Philipp Hanckeaeac9f82020-09-11 11:58:18 +0200161 # Selects fixed-point code where possible.
162 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800163 if (current_cpu == "arm" || current_cpu == "arm64") {
164 rtc_prefer_fixed_point = true
165 }
166
mbonadei9aa3f0a2017-01-24 06:58:22 -0800167 # Determines whether NEON code will be built.
168 rtc_build_with_neon =
169 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
170
171 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
172 # all platforms except Android and iOS. Because FFmpeg can be built
Artem Titov22a6b2d2021-07-27 16:25:56 +0200173 # with/without H.264 support, `ffmpeg_branding` has to separately be set to a
mbonadei9aa3f0a2017-01-24 06:58:22 -0800174 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Artem Titov22a6b2d2021-07-27 16:25:56 +0200175 # H.264, compilation succeeds but `H264DecoderImpl` fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800176 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
177 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100178 #
179 # Enabling H264 when building with MSVC is currently not supported, see
180 # bugs.webrtc.org/9213#c13 for more info.
181 rtc_use_h264 =
182 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800183
Markus Handell8e75bd42020-06-05 11:47:40 +0200184 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
185 rtc_use_absl_mutex = false
186
mbonadei9aa3f0a2017-01-24 06:58:22 -0800187 # By default, use normal platform audio support or dummy audio, but don't
188 # use file-based audio playout and record.
189 rtc_use_dummy_audio_file_devices = false
190
henrika7be78832017-06-13 17:34:16 +0200191 # When set to true, replace the audio output with a sinus tone at 440Hz.
192 # The ADM will ask for audio data from WebRTC but instead of reading real
193 # audio samples from NetEQ, a sinus tone will be generated and replace the
194 # real audio samples.
195 rtc_audio_device_plays_sinus_tone = false
196
Anders Carlsson358f2e02018-06-04 10:24:37 +0200197 if (is_ios) {
198 # Build broadcast extension in AppRTCMobile for iOS. This results in the
199 # binary only running on iOS 11+, which is why it is disabled by default.
200 rtc_apprtcmobile_broadcast_extension = false
201 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200202
Jordan Rose53d3fc92021-07-06 12:16:41 -0700203 # Determines whether OpenGL is available on iOS/macOS.
204 rtc_ios_macos_use_opengl_rendering =
205 !(is_ios && target_environment == "catalyst")
206
Jiawei Ou08745302019-02-12 11:36:13 -0800207 # When set to false, builtin audio encoder/decoder factories and all the
208 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
209 # (they will still be included in libjingle_peerconnection_so.so and
210 # WebRTC.framework)
211 rtc_include_builtin_audio_codecs = true
212
213 # When set to false, builtin video encoder/decoder factories and all the
214 # video codecs they depends on will not be included in libwebrtc.{a|lib}
215 # (they will still be included in libjingle_peerconnection_so.so and
216 # WebRTC.framework)
217 rtc_include_builtin_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100218
219 # When set to true and in a standalone build, it will undefine UNICODE and
220 # _UNICODE (which are always defined globally by the Chromium Windows
221 # toolchain).
222 # This is only needed for testing purposes, WebRTC wants to be sure it
223 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
224 # wide character functions.
225 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 13:47:54 -0700226
227 # When set to true, a capturer implementation that uses the
Austin Orion66241e42021-04-22 13:22:25 -0700228 # Windows.Graphics.Capture APIs will be available for use. This introduces a
229 # dependency on the Win 10 SDK v10.0.17763.0.
Austin Orion78f04d82021-04-23 12:37:26 -0700230 rtc_enable_win_wgc = is_win
philipelb09d8722021-11-23 11:00:24 +0100231
232 # Includes the dav1d decoder in the internal decoder factory when set to true.
233 rtc_include_dav1d_in_internal_decoder_factory = true
Dan Minor9c686132018-01-15 10:20:00 -0500234}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800235
Dan Minor9c686132018-01-15 10:20:00 -0500236if (!build_with_mozilla) {
237 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800238}
239
240# A second declare_args block, so that declarations within it can
241# depend on the possibly overridden variables in the first
242# declare_args block.
243declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500244 # Enables the use of protocol buffers for debug recordings.
245 rtc_enable_protobuf = !build_with_mozilla
246
247 # Set this to disable building with support for SCTP data channels.
248 rtc_enable_sctp = !build_with_mozilla
249
250 # Disable these to not build components which can be externally provided.
251 rtc_build_json = !build_with_mozilla
252 rtc_build_libsrtp = !build_with_mozilla
253 rtc_build_libvpx = !build_with_mozilla
254 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500255 rtc_build_opus = !build_with_mozilla
256 rtc_build_ssl = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500257
258 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200259 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
260 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500261 rtc_enable_libevent = false
262 rtc_build_libevent = false
263 } else {
264 rtc_enable_libevent = true
265 rtc_build_libevent = !build_with_mozilla
266 }
267
mbonadei9aa3f0a2017-01-24 06:58:22 -0800268 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
269 rtc_include_pulse_audio = !build_with_chromium
270
271 # Chromium uses its own IO handling, so the internal ADM is only built for
272 # standalone WebRTC.
273 rtc_include_internal_audio_device = !build_with_chromium
274
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800275 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 12:02:32 +0200276 # TODO: Make sure that AVX2 works also for non-clang compilers.
277 if (is_clang == true) {
278 rtc_enable_avx2 = true
279 } else {
280 rtc_enable_avx2 = false
281 }
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800282
Philipp Hancke1a89bc82021-03-02 21:23:24 +0100283 # Set this to true to build the unit tests.
284 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 10:20:00 -0500285 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200286
287 # Set this to false to skip building code that also requires X11 extensions
288 # such as Xdamage, Xfixes.
289 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100290
291 # Set this to true to fully remove logging from WebRTC.
292 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100293
294 # Set this to true to disable trace events.
295 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100296
297 # Set this to true to disable detailed error message and logging for
298 # RTC_CHECKs.
299 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100300
301 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100302 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200303
304 # Set this to true to exclude the transient suppressor in the audio processing
305 # module from the build.
306 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800307}
308
Florent Castellia80c3e52021-04-15 15:02:56 +0200309declare_args() {
Florent Castellia6983c62021-05-06 10:50:07 +0200310 # Enable the dcsctp backend for DataChannels and related unittests
311 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
312
Florent Castelli023be3c2022-03-15 16:01:52 +0100313 # Enable gRPC used for negotiation in multiprocess tests
314 rtc_enable_grpc = rtc_enable_protobuf && (is_linux || is_mac)
Florent Castellia80c3e52021-04-15 15:02:56 +0200315}
316
mbonadei9aa3f0a2017-01-24 06:58:22 -0800317# Make it possible to provide custom locations for some libraries (move these
318# up into declare_args should we need to actually use them for the GN build).
319rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800320rtc_opus_dir = "//third_party/opus"
321
322# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200323rtc_desktop_capture_supported =
324 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900325 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800326
327###############################################################################
328# Templates
329#
330
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200331# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800332# chromium.
333# We need absolute paths for all configs in templates as they are shared in
334# different subdirectories.
335webrtc_root = get_path_info(".", "abspath")
336
337# Global configuration that should be applied to all WebRTC targets.
338# You normally shouldn't need to include this in your target as it's
339# automatically included when using the rtc_* templates.
340# It sets defines, include paths and compilation warnings accordingly,
341# both for WebRTC stand-alone builds and for the scenario when WebRTC
342# native code is built as part of Chromium.
Mirko Bonadei5f078452021-07-30 22:32:55 +0200343rtc_common_configs = [ webrtc_root + ":common_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800344
kthelgasonc0977102017-04-24 00:57:16 -0700345if (is_mac || is_ios) {
346 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
347}
348
mbonadei9aa3f0a2017-01-24 06:58:22 -0800349# Global public configuration that should be applied to all WebRTC targets. You
350# normally shouldn't need to include this in your target as it's automatically
351# included when using the rtc_* templates. It set the defines, include paths and
352# compilation warnings that should be propagated to dependents of the targets
353# depending on the target having this config.
354rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
355
356# Common configs to remove or add in all rtc targets.
357rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100358if (!build_with_chromium && is_clang) {
359 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
360}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800361rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200362rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200363rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800364
365set_defaults("rtc_test") {
366 configs = rtc_add_configs
367 suppressed_configs = []
368}
369
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200370set_defaults("rtc_library") {
371 configs = rtc_add_configs
372 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200373 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200374}
375
mbonadei9aa3f0a2017-01-24 06:58:22 -0800376set_defaults("rtc_source_set") {
377 configs = rtc_add_configs
378 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200379 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800380}
381
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200382set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800383 configs = rtc_add_configs
384 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200385 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800386}
387
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200388set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800389 configs = rtc_add_configs
390 suppressed_configs = []
391}
392
393set_defaults("rtc_shared_library") {
394 configs = rtc_add_configs
395 suppressed_configs = []
396}
397
Per Kjellandera7f2d842018-01-10 15:54:53 +0000398webrtc_default_visibility = [ webrtc_root + "/*" ]
399if (build_with_chromium) {
400 # Allow Chromium's WebRTC overrides targets to bypass the regular
401 # visibility restrictions.
402 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
403}
404
Karl Wibergbb23c832018-04-22 19:55:00 +0200405# ---- Poisons ----
406#
407# The general idea is that some targets declare that they contain some
408# kind of poison, which makes it impossible for other targets to
409# depend on them (even transitively) unless they declare themselves
410# immune to that particular type of poison.
411#
412# Targets that *contain* poison of type foo should contain the line
413#
414# poisonous = [ "foo" ]
415#
416# and targets that *are immune but arent't themselves poisonous*
417# should contain
418#
419# allow_poison = [ "foo" ]
420#
421# This useful in cases where we have some large target or set of
422# targets and want to ensure that most other targets do not
423# transitively depend on them. For example, almost no high-level
424# target should depend on the audio codecs, since we want WebRTC users
425# to be able to inject any subset of them and actually end up with a
426# binary that doesn't include the codecs they didn't inject.
427#
428# Test-only targets (`testonly` set to true) and non-public targets
429# (`visibility` not containing "*") are automatically immune to all
430# types of poison.
431#
432# Here's the complete list of all types of poison. It must be kept in
433# 1:1 correspondence with the set of //:poison_* targets.
434#
435all_poison_types = [
436 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
437 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200438
Danil Chapovalov41300af2019-07-10 12:44:43 +0200439 # Default task queue implementation.
440 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200441
Sam Zackrisson03cb7e52021-12-06 15:40:04 +0100442 # Default echo detector implementation.
443 "default_echo_detector",
444
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200445 # JSON parsing should not be needed in the "slim and modular" WebRTC.
446 "rtc_json",
447
448 # Software video codecs (VP8 and VP9 through libvpx).
449 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200450]
451
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000452absl_include_config = "//third_party/abseil-cpp:absl_include_config"
453absl_define_config = "//third_party/abseil-cpp:absl_define_config"
454
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200455# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
456# that are testonly.
457absl_flags_config = webrtc_root + ":absl_flags_configs"
458
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100459# WebRTC wrapper of Chromium's test() template. This template just adds some
460# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
461# target.
462# The parameter `is_xctest` is different from the one in the Chromium's test()
463# template (and it is not forwarded to it). In rtc_test(), the argument
464# `is_xctest` is used to avoid to take dependencies that are not needed
465# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800466template("rtc_test") {
467 test(target_name) {
468 forward_variables_from(invoker,
469 "*",
470 [
471 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100472 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800473 "public_configs",
474 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200475 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800476 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100477
478 # Always override to public because when target_os is Android the `test`
479 # template can override it to [ "*" ] and we want to avoid conditional
480 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100481 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800482 configs += invoker.configs
483 configs -= rtc_remove_configs
484 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000485 public_configs = [
486 rtc_common_inherited_config,
487 absl_include_config,
488 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200489 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000490 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800491 if (defined(invoker.public_configs)) {
492 public_configs += invoker.public_configs
493 }
sakald7fdb802017-05-26 01:51:53 -0700494 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800495 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 18:53:11 -0400496 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200497 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200498 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 19:03:37 +0200499 deps += [
500 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
501 webrtc_root + "test:native_test_java",
502 ]
sakald7fdb802017-05-26 01:51:53 -0700503 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100504
Björn Terelius49850c32022-05-04 10:59:56 +0200505 # Build //test:google_test_runner_objc when the test is not a real XCTest.
Jeremy Leconteb8ba8c92022-03-15 09:08:29 +0100506 if (is_ios && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100507 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
Björn Terelius49850c32022-05-04 10:59:56 +0200508 xctest_module_target = "//test:google_test_runner_objc"
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100509 }
510 }
Andrey Logvin78646002021-01-29 10:50:19 +0000511
512 # If absl_deps is [], no action is needed. If not [], then it needs to be
513 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
514 # otherwise it just needs to be added to deps.
515 if (defined(absl_deps) && absl_deps != []) {
516 if (!defined(deps)) {
517 deps = []
518 }
519 if (build_with_chromium) {
520 deps += [ "//third_party/abseil-cpp:absl" ]
521 } else {
522 deps += absl_deps
523 }
524 }
525
Jeremy Leconted15f3e12022-02-18 10:16:32 +0100526 # TODO(crbug.com/webrtc/13556): Adding the .app folder in the runtime_deps
527 # shoulnd't be necessary. this code should be removed and the same solution
528 # as Chromium should be used.
529 if (is_ios) {
530 if (!defined(invoker.data)) {
531 data = []
532 }
533 data += [ "${root_out_dir}/${target_name}.app" ]
534 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800535 }
536}
537
538template("rtc_source_set") {
539 source_set(target_name) {
540 forward_variables_from(invoker,
541 "*",
542 [
543 "configs",
544 "public_configs",
545 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200546 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800547 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200548 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000549 if (!defined(visibility)) {
550 visibility = webrtc_default_visibility
551 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200552
553 # What's your poison?
554 if (defined(testonly) && testonly) {
555 assert(!defined(poisonous))
556 assert(!defined(allow_poison))
557 } else {
558 if (!defined(poisonous)) {
559 poisonous = []
560 }
561 if (!defined(allow_poison)) {
562 allow_poison = []
563 }
564 if (!defined(assert_no_deps)) {
565 assert_no_deps = []
566 }
567 if (!defined(deps)) {
568 deps = []
569 }
570 foreach(p, poisonous) {
571 deps += [ webrtc_root + ":poison_" + p ]
572 }
573 foreach(poison_type, all_poison_types) {
574 allow_dep = true
575 foreach(v, visibility) {
576 if (v == "*") {
577 allow_dep = false
578 }
579 }
580 foreach(p, allow_poison + poisonous) {
581 if (p == poison_type) {
582 allow_dep = true
583 }
584 }
585 if (!allow_dep) {
586 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
587 }
588 }
589 }
590
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100591 # Chromium should only depend on the WebRTC component in order to
592 # avoid to statically link WebRTC in a component build.
593 if (build_with_chromium) {
594 publicly_visible = false
595 foreach(v, visibility) {
596 if (v == "*") {
597 publicly_visible = true
598 }
599 }
600 if (publicly_visible) {
601 visibility = []
602 visibility = webrtc_default_visibility
603 }
604 }
605
Mirko Bonadei96ede162018-09-06 13:45:44 +0200606 if (!defined(testonly) || !testonly) {
607 configs += rtc_prod_configs
608 }
609
mbonadei9aa3f0a2017-01-24 06:58:22 -0800610 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200611 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800612 configs -= rtc_remove_configs
613 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000614 public_configs = [
615 rtc_common_inherited_config,
616 absl_include_config,
617 absl_define_config,
618 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200619 if (defined(testonly) && testonly) {
620 public_configs += [ absl_flags_config ]
621 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800622 if (defined(invoker.public_configs)) {
623 public_configs += invoker.public_configs
624 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200625
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200626 # If absl_deps is [], no action is needed. If not [], then it needs to be
627 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200628 # otherwise it just needs to be added to deps.
629 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200630 if (!defined(deps)) {
631 deps = []
632 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200633 if (build_with_chromium) {
634 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200635 } else {
636 deps += absl_deps
637 }
638 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800639 }
640}
641
mbonadei9aa3f0a2017-01-24 06:58:22 -0800642template("rtc_static_library") {
643 static_library(target_name) {
644 forward_variables_from(invoker,
645 "*",
646 [
647 "configs",
648 "public_configs",
649 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200650 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800651 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200652 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000653 if (!defined(visibility)) {
654 visibility = webrtc_default_visibility
655 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200656
657 # What's your poison?
658 if (defined(testonly) && testonly) {
659 assert(!defined(poisonous))
660 assert(!defined(allow_poison))
661 } else {
662 if (!defined(poisonous)) {
663 poisonous = []
664 }
665 if (!defined(allow_poison)) {
666 allow_poison = []
667 }
668 if (!defined(assert_no_deps)) {
669 assert_no_deps = []
670 }
671 if (!defined(deps)) {
672 deps = []
673 }
674 foreach(p, poisonous) {
675 deps += [ webrtc_root + ":poison_" + p ]
676 }
677 foreach(poison_type, all_poison_types) {
678 allow_dep = true
679 foreach(v, visibility) {
680 if (v == "*") {
681 allow_dep = false
682 }
683 }
684 foreach(p, allow_poison + poisonous) {
685 if (p == poison_type) {
686 allow_dep = true
687 }
688 }
689 if (!allow_dep) {
690 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
691 }
692 }
693 }
694
Mirko Bonadei96ede162018-09-06 13:45:44 +0200695 if (!defined(testonly) || !testonly) {
696 configs += rtc_prod_configs
697 }
698
mbonadei9aa3f0a2017-01-24 06:58:22 -0800699 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200700 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800701 configs -= rtc_remove_configs
702 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000703 public_configs = [
704 rtc_common_inherited_config,
705 absl_include_config,
706 absl_define_config,
707 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200708 if (defined(testonly) && testonly) {
709 public_configs += [ absl_flags_config ]
710 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800711 if (defined(invoker.public_configs)) {
712 public_configs += invoker.public_configs
713 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200714
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200715 # If absl_deps is [], no action is needed. If not [], then it needs to be
716 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200717 # otherwise it just needs to be added to deps.
718 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200719 if (!defined(deps)) {
720 deps = []
721 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200722 if (build_with_chromium) {
723 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200724 } else {
725 deps += absl_deps
726 }
727 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800728 }
729}
730
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200731# This template automatically switches the target type between source_set
732# and static_library.
733#
Florent Castelli87b6e7b2022-04-26 02:22:35 +0200734# This should be the default target type for all the WebRTC targets.
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200735#
736# How does it work:
737# Since all files in a source_set are linked into a final binary, while files
738# in a static library are only linked in if at least one symbol in them is
739# referenced, in component builds source_sets are easy to deal with because
740# all their object files are passed to the linker to create a shared library.
741# In release builds instead, static_libraries are preferred since they allow
742# the linker to discard dead code.
743# For the same reason, testonly targets will always be expanded to
744# source_set in order to be sure that tests are present in the test binary.
745template("rtc_library") {
Florent Castelli87b6e7b2022-04-26 02:22:35 +0200746 header_only = true
747 if (defined(invoker.sources)) {
748 non_header_sources = filter_exclude(invoker.sources,
749 [
750 "*.h",
751 "*.hh",
752 "*.inc",
753 ])
754 if (non_header_sources != []) {
755 header_only = false
756 }
757 }
758
759 # Header only libraries should use source_set as a static_library with no
760 # source files will cause issues with macOS libtool.
761 if (header_only || is_component_build ||
762 (defined(invoker.testonly) && invoker.testonly)) {
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200763 target_type = "source_set"
764 } else {
765 target_type = "static_library"
766 }
767 target(target_type, target_name) {
768 forward_variables_from(invoker,
769 "*",
770 [
771 "configs",
772 "public_configs",
773 "suppressed_configs",
774 "visibility",
775 ])
776 forward_variables_from(invoker, [ "visibility" ])
777 if (!defined(visibility)) {
778 visibility = webrtc_default_visibility
779 }
780
781 # What's your poison?
782 if (defined(testonly) && testonly) {
783 assert(!defined(poisonous))
784 assert(!defined(allow_poison))
785 } else {
786 if (!defined(poisonous)) {
787 poisonous = []
788 }
789 if (!defined(allow_poison)) {
790 allow_poison = []
791 }
792 if (!defined(assert_no_deps)) {
793 assert_no_deps = []
794 }
795 if (!defined(deps)) {
796 deps = []
797 }
798 foreach(p, poisonous) {
799 deps += [ webrtc_root + ":poison_" + p ]
800 }
801 foreach(poison_type, all_poison_types) {
802 allow_dep = true
803 foreach(v, visibility) {
804 if (v == "*") {
805 allow_dep = false
806 }
807 }
808 foreach(p, allow_poison + poisonous) {
809 if (p == poison_type) {
810 allow_dep = true
811 }
812 }
813 if (!allow_dep) {
814 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
815 }
816 }
817 }
818
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100819 # Chromium should only depend on the WebRTC component in order to
820 # avoid to statically link WebRTC in a component build.
821 if (build_with_chromium) {
822 publicly_visible = false
823 foreach(v, visibility) {
824 if (v == "*") {
825 publicly_visible = true
826 }
827 }
828 if (publicly_visible) {
829 visibility = []
830 visibility = webrtc_default_visibility
831 }
832 }
833
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200834 if (!defined(testonly) || !testonly) {
835 configs += rtc_prod_configs
836 }
837
838 configs += invoker.configs
839 configs += rtc_library_impl_config
840 configs -= rtc_remove_configs
841 configs -= invoker.suppressed_configs
842 public_configs = [
843 rtc_common_inherited_config,
844 absl_include_config,
845 absl_define_config,
846 ]
847 if (defined(testonly) && testonly) {
848 public_configs += [ absl_flags_config ]
849 }
850 if (defined(invoker.public_configs)) {
851 public_configs += invoker.public_configs
852 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200853
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200854 # If absl_deps is [], no action is needed. If not [], then it needs to be
855 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200856 # otherwise it just needs to be added to deps.
857 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200858 if (!defined(deps)) {
859 deps = []
860 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200861 if (build_with_chromium) {
862 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200863 } else {
864 deps += absl_deps
865 }
866 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200867 }
868}
869
870template("rtc_executable") {
871 executable(target_name) {
872 forward_variables_from(invoker,
873 "*",
874 [
875 "deps",
876 "configs",
877 "public_configs",
878 "suppressed_configs",
879 "visibility",
880 ])
881 forward_variables_from(invoker, [ "visibility" ])
882 if (!defined(visibility)) {
883 visibility = webrtc_default_visibility
884 }
885 configs += invoker.configs
886 configs -= rtc_remove_configs
887 configs -= invoker.suppressed_configs
888 deps = invoker.deps
889
890 public_configs = [
891 rtc_common_inherited_config,
892 absl_include_config,
893 absl_define_config,
894 ]
895 if (defined(testonly) && testonly) {
896 public_configs += [ absl_flags_config ]
897 }
898 if (defined(invoker.public_configs)) {
899 public_configs += invoker.public_configs
900 }
901 if (is_win) {
902 deps += [
903 # Give executables the default manifest on Windows (a no-op elsewhere).
904 "//build/win:default_exe_manifest",
905 ]
906 }
907 }
908}
909
mbonadei9aa3f0a2017-01-24 06:58:22 -0800910template("rtc_shared_library") {
911 shared_library(target_name) {
912 forward_variables_from(invoker,
913 "*",
914 [
915 "configs",
916 "public_configs",
917 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200918 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800919 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200920 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000921 if (!defined(visibility)) {
922 visibility = webrtc_default_visibility
923 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200924
925 # What's your poison?
926 if (defined(testonly) && testonly) {
927 assert(!defined(poisonous))
928 assert(!defined(allow_poison))
929 } else {
930 if (!defined(poisonous)) {
931 poisonous = []
932 }
933 if (!defined(allow_poison)) {
934 allow_poison = []
935 }
936 if (!defined(assert_no_deps)) {
937 assert_no_deps = []
938 }
939 if (!defined(deps)) {
940 deps = []
941 }
942 foreach(p, poisonous) {
943 deps += [ webrtc_root + ":poison_" + p ]
944 }
945 foreach(poison_type, all_poison_types) {
946 allow_dep = true
947 foreach(v, visibility) {
948 if (v == "*") {
949 allow_dep = false
950 }
951 }
952 foreach(p, allow_poison + poisonous) {
953 if (p == poison_type) {
954 allow_dep = true
955 }
956 }
957 if (!allow_dep) {
958 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
959 }
960 }
961 }
962
mbonadei9aa3f0a2017-01-24 06:58:22 -0800963 configs += invoker.configs
964 configs -= rtc_remove_configs
965 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000966 public_configs = [
967 rtc_common_inherited_config,
968 absl_include_config,
969 absl_define_config,
970 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200971 if (defined(testonly) && testonly) {
972 public_configs += [ absl_flags_config ]
973 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800974 if (defined(invoker.public_configs)) {
975 public_configs += invoker.public_configs
976 }
977 }
978}
kthelgason4065a572017-02-14 04:58:56 -0800979
Byoungchan Lee26b23b82022-04-08 18:23:14 +0900980if (is_mac || is_ios) {
981 template("apple_framework_bundle_with_umbrella_header") {
Anders Carlssondc6b4772018-01-15 13:31:03 +0100982 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900983 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100984 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900985 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
Byoungchan Lee26b23b82022-04-08 18:23:14 +0900986 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900987
988 action_foreach("create_bracket_include_headers_$target_name") {
989 script = "//tools_webrtc/apple/copy_framework_header.py"
990 sources = invoker.sources
991 output_name = invoker.output_name
992 outputs = [
993 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
994 ]
995 args = [
996 "--input",
997 "{{source}}",
998 "--output",
999 rebase_path(target_gen_dir, root_build_dir) +
1000 "/$output_name.framework/WebRTC/{{source_file_part}}",
1001 ]
1002 }
Anders Carlssondc6b4772018-01-15 13:31:03 +01001003
Byoungchan Lee26b23b82022-04-08 18:23:14 +09001004 if (is_mac) {
1005 mac_framework_bundle(target_name) {
1006 forward_variables_from(invoker, "*", [ "configs" ])
1007 if (defined(invoker.configs)) {
1008 configs += invoker.configs
1009 }
1010
1011 framework_version = "A"
1012 framework_contents = [
1013 "Headers",
1014 "Modules",
1015 "Resources",
1016 ]
1017
1018 ldflags = [
1019 "-all_load",
1020 "-install_name",
1021 "@rpath/$output_name.framework/$output_name",
1022 ]
1023
1024 deps += [
1025 ":copy_framework_headers_$this_target_name",
1026 ":copy_modulemap_$this_target_name",
1027 ":copy_umbrella_header_$this_target_name",
1028 ":create_bracket_include_headers_$this_target_name",
1029 ":modulemap_$this_target_name",
1030 ":umbrella_header_$this_target_name",
1031 ]
1032 }
1033 }
1034 if (is_ios) {
1035 ios_framework_bundle(target_name) {
1036 forward_variables_from(invoker,
1037 "*",
1038 [
1039 "configs",
1040 "public_headers",
1041 ])
1042 if (defined(invoker.configs)) {
1043 configs += invoker.configs
1044 }
1045 public_headers = get_target_outputs(
1046 ":create_bracket_include_headers_$this_target_name")
1047
1048 deps += [
1049 ":copy_umbrella_header_$this_target_name",
1050 ":create_bracket_include_headers_$this_target_name",
1051 ]
1052 }
Anders Carlssondc6b4772018-01-15 13:31:03 +01001053 }
1054
Byoungchan Lee26b23b82022-04-08 18:23:14 +09001055 if (is_mac || target_environment == "catalyst") {
Jordan Rose53d3fc92021-07-06 12:16:41 -07001056 # Catalyst frameworks use the same layout as regular Mac frameworks.
1057 headers_dir = "Versions/A/Headers"
1058 } else {
1059 headers_dir = "Headers"
1060 }
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001061
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001062 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001063 sources = get_target_outputs(
1064 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001065
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001066 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001067 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001068 }
1069
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001070 action("modulemap_$this_target_name") {
1071 script = "//tools_webrtc/ios/generate_modulemap.py"
1072 args = [
1073 "--out",
1074 rebase_path(modulemap_path, root_build_dir),
1075 "--name",
1076 output_name,
1077 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001078 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001079 }
1080
1081 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001082 sources = [ modulemap_path ]
1083 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1084 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001085 }
1086
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001087 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001088 sources = get_target_outputs(
1089 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001090
1091 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1092
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001093 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001094 args = [
1095 "--out",
1096 rebase_path(umbrella_header_path, root_build_dir),
1097 "--sources",
1098 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001099 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001100 }
1101
Byoungchan Lee26b23b82022-04-08 18:23:14 +09001102 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001103 sources = [ umbrella_header_path ]
Byoungchan Lee26b23b82022-04-08 18:23:14 +09001104 outputs =
1105 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001106
Byoungchan Lee26b23b82022-04-08 18:23:14 +09001107 deps = [ ":umbrella_header_$target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001108 }
1109 }
1110}
1111
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001112if (is_android) {
1113 template("rtc_android_library") {
1114 android_library(target_name) {
1115 forward_variables_from(invoker,
1116 "*",
1117 [
1118 "configs",
1119 "public_configs",
1120 "suppressed_configs",
1121 "visibility",
1122 ])
1123
Oleh Prypin05aee742018-11-23 17:29:44 +01001124 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001125
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001126 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001127 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001128
1129 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001130 if (defined(invoker.errorprone_args)) {
1131 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001132 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001133
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001134 if (!defined(deps)) {
1135 deps = []
1136 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001137
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001138 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001139 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001140 }
1141 }
1142
1143 template("rtc_android_apk") {
1144 android_apk(target_name) {
1145 forward_variables_from(invoker,
1146 "*",
1147 [
1148 "configs",
1149 "public_configs",
1150 "suppressed_configs",
1151 "visibility",
1152 ])
1153
1154 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001155 errorprone_args = []
1156 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001157
1158 if (!defined(deps)) {
1159 deps = []
1160 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001161
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001162 no_build_hooks = true
1163 }
1164 }
1165
1166 template("rtc_instrumentation_test_apk") {
1167 instrumentation_test_apk(target_name) {
1168 forward_variables_from(invoker,
1169 "*",
1170 [
1171 "configs",
1172 "public_configs",
1173 "suppressed_configs",
1174 "visibility",
1175 ])
1176
1177 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001178 errorprone_args = []
1179 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001180
1181 if (!defined(deps)) {
1182 deps = []
1183 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001184
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001185 no_build_hooks = true
1186 }
1187 }
1188}