blob: a338d723ed35525c3fe40d325db1f3abc5cc58e5 [file] [log] [blame]
mbonadei9aa3f0a2017-01-24 06:58:22 -08001# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS. All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
mbonadei9aa3f0a2017-01-24 06:58:22 -08008import("//build/config/arm.gni")
9import("//build/config/features.gni")
10import("//build/config/mips.gni")
11import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 06:32:23 +010012import("//build/config/sysroot.gni")
ehmaldonado0d729b32017-02-10 01:38:23 -080013import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080014import("//build_overrides/build.gni")
mbonadei96606272017-03-03 19:41:59 -080015
16if (!build_with_chromium && is_component_build) {
17 print("The Gn argument `is_component_build` is currently " +
18 "ignored for WebRTC builds.")
19 print("Component builds are supported by Chromium and the argument " +
20 "`is_component_build` makes it possible to create shared libraries " +
21 "instead of static libraries.")
22 print("If an app depends on WebRTC it makes sense to just depend on the " +
23 "WebRTC static library, so there is no difference between " +
24 "`is_component_build=true` and `is_component_build=false`.")
25 print(
Fanny Linderborg0d2dc1f2021-07-14 14:02:11 +000026 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/main/docs/component_build.md")
mbonadei96606272017-03-03 19:41:59 -080027 assert(!is_component_build, "Component builds are not supported in WebRTC.")
28}
29
kthelgason4065a572017-02-14 04:58:56 -080030if (is_ios) {
31 import("//build/config/ios/rules.gni")
32}
mbonadei9aa3f0a2017-01-24 06:58:22 -080033
Anders Carlsson37bbf792018-09-05 16:29:27 +020034if (is_mac) {
35 import("//build/config/mac/rules.gni")
36}
37
mbonadei9aa3f0a2017-01-24 06:58:22 -080038declare_args() {
Mirko Bonadei028248c2018-10-10 12:19:02 +020039 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
40 # expand to code that will manage symbols visibility.
41 rtc_enable_symbol_export = false
42
Mirko Bonadei31b0b452018-08-22 10:37:11 +020043 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020044 # will tell the pre-processor to remove the default definition of symbols
45 # needed to use field_trial. In that case a new implementation needs to be
46 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020047 if (build_with_chromium) {
48 # When WebRTC is built as part of Chromium it should exclude the default
49 # implementation of field_trial unless it is building for NACL or
50 # Chromecast.
51 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
52 } else {
53 rtc_exclude_field_trial_default = false
54 }
Mirko Bonadei70400902018-08-21 15:44:28 +020055
Mirko Bonadei906add42018-09-05 16:03:16 +020056 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
57 # will tell the pre-processor to remove the default definition of symbols
58 # needed to use metrics. In that case a new implementation needs to be
59 # provided.
60 rtc_exclude_metrics_default = build_with_chromium
61
Johannes Kronda20c732021-02-19 16:39:41 +010062 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which
63 # will tell the pre-processor to remove the default definition of the
64 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
65 # that case a new implementation needs to be provided.
Johannes Kronbb52bdf2021-02-25 10:10:08 +010066 rtc_exclude_system_time = build_with_chromium
Johannes Kronda20c732021-02-19 16:39:41 +010067
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070068 # Setting this to false will require the API user to pass in their own
69 # SSLCertificateVerifier to verify the certificates presented from a
70 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
71 rtc_builtin_ssl_root_certificates = true
72
Karl Wibergeb254b42017-11-01 15:08:12 +010073 # Include the iLBC audio codec?
Olga Sharonova5fbd7582020-07-09 09:50:42 +000074 rtc_include_ilbc = true
Karl Wibergeb254b42017-11-01 15:08:12 +010075
mbonadei9aa3f0a2017-01-24 06:58:22 -080076 # Disable this to avoid building the Opus audio codec.
77 rtc_include_opus = true
78
minyue2e03c662017-02-01 17:31:11 -080079 # Enable this if the Opus version upon which WebRTC is built supports direct
80 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020081 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080082
mbonadei9aa3f0a2017-01-24 06:58:22 -080083 # Enable this to let the Opus audio codec change complexity on the fly.
84 rtc_opus_variable_complexity = false
85
mbonadei9aa3f0a2017-01-24 06:58:22 -080086 # Used to specify an external Jsoncpp include path when not compiling the
87 # library that comes with WebRTC (i.e. rtc_build_json == 0).
88 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
89
90 # Used to specify an external OpenSSL include path when not compiling the
91 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
92 rtc_ssl_root = ""
93
mbonadei9aa3f0a2017-01-24 06:58:22 -080094 # Enable when an external authentication mechanism is used for performing
95 # packet authentication for RTP packets instead of libsrtp.
96 rtc_enable_external_auth = build_with_chromium
97
98 # Selects whether debug dumps for the audio processing module
99 # should be generated.
100 apm_debug_dump = false
101
Per Åhgrencc73ed32020-04-26 23:56:17 +0200102 # Selects whether the audio processing module should be excluded.
103 rtc_exclude_audio_processing_module = false
104
mbonadei9aa3f0a2017-01-24 06:58:22 -0800105 # Set this to true to enable BWE test logging.
106 rtc_enable_bwe_test_logging = false
107
Joachim Bauch93e91342017-12-07 01:25:53 +0100108 # Set this to false to skip building examples.
109 rtc_build_examples = true
110
111 # Set this to false to skip building tools.
112 rtc_build_tools = true
113
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100114 # Set this to false to skip building code that requires X11.
115 rtc_use_x11 = use_x11
116
Tomas Popela318da512018-11-13 06:32:23 +0100117 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 14:37:51 +0100118 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
119 # only when using the sysroot as PipeWire is not available in older and
120 # supported Ubuntu and Debian distributions.
Xiaohan Wang9f32f3b2020-10-01 14:46:54 -0700121 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 14:37:51 +0100122
123 # Set this to link PipeWire directly instead of using the dlopen.
124 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 06:32:23 +0100125
Jan Grulichc3c81292020-12-02 09:03:34 +0100126 # Set this to use certain PipeWire version
Jan Grulich14b036d2021-02-04 09:53:20 +0100127 # Currently WebRTC supports PipeWire 0.2 and PipeWire 0.3 (default)
128 rtc_pipewire_version = "0.3"
Jan Grulichc3c81292020-12-02 09:03:34 +0100129
mbonadei9aa3f0a2017-01-24 06:58:22 -0800130 # Enable to use the Mozilla internal settings.
131 build_with_mozilla = false
132
Philipp Hanckee95ebda2020-09-17 16:13:20 +0200133 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
134 # and NDK r16 or above.
henrika883d00f2018-03-16 10:09:49 +0100135 rtc_enable_android_aaudio = false
136
mbonadei9aa3f0a2017-01-24 06:58:22 -0800137 # Set to "func", "block", "edge" for coverage generation.
138 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
139 # It is recommend to set include_examples=0.
140 # Use llvm's sancov -html-report for human readable reports.
141 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
142 rtc_sanitize_coverage = ""
143
Philipp Hanckeaeac9f82020-09-11 11:58:18 +0200144 # Selects fixed-point code where possible.
145 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800146 if (current_cpu == "arm" || current_cpu == "arm64") {
147 rtc_prefer_fixed_point = true
148 }
149
mbonadei9aa3f0a2017-01-24 06:58:22 -0800150 # Determines whether NEON code will be built.
151 rtc_build_with_neon =
152 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
153
154 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
155 # all platforms except Android and iOS. Because FFmpeg can be built
156 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
157 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200158 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800159 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
160 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100161 #
162 # Enabling H264 when building with MSVC is currently not supported, see
163 # bugs.webrtc.org/9213#c13 for more info.
164 rtc_use_h264 =
165 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800166
Markus Handell8e75bd42020-06-05 11:47:40 +0200167 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
168 rtc_use_absl_mutex = false
169
mbonadei9aa3f0a2017-01-24 06:58:22 -0800170 # By default, use normal platform audio support or dummy audio, but don't
171 # use file-based audio playout and record.
172 rtc_use_dummy_audio_file_devices = false
173
henrika7be78832017-06-13 17:34:16 +0200174 # When set to true, replace the audio output with a sinus tone at 440Hz.
175 # The ADM will ask for audio data from WebRTC but instead of reading real
176 # audio samples from NetEQ, a sinus tone will be generated and replace the
177 # real audio samples.
178 rtc_audio_device_plays_sinus_tone = false
179
Anders Carlsson358f2e02018-06-04 10:24:37 +0200180 if (is_ios) {
181 # Build broadcast extension in AppRTCMobile for iOS. This results in the
182 # binary only running on iOS 11+, which is why it is disabled by default.
183 rtc_apprtcmobile_broadcast_extension = false
184 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200185
Jordan Rose53d3fc92021-07-06 12:16:41 -0700186 # Determines whether OpenGL is available on iOS/macOS.
187 rtc_ios_macos_use_opengl_rendering =
188 !(is_ios && target_environment == "catalyst")
189
Jiawei Ou08745302019-02-12 11:36:13 -0800190 # When set to false, builtin audio encoder/decoder factories and all the
191 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
192 # (they will still be included in libjingle_peerconnection_so.so and
193 # WebRTC.framework)
194 rtc_include_builtin_audio_codecs = true
195
196 # When set to false, builtin video encoder/decoder factories and all the
197 # video codecs they depends on will not be included in libwebrtc.{a|lib}
198 # (they will still be included in libjingle_peerconnection_so.so and
199 # WebRTC.framework)
200 rtc_include_builtin_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100201
202 # When set to true and in a standalone build, it will undefine UNICODE and
203 # _UNICODE (which are always defined globally by the Chromium Windows
204 # toolchain).
205 # This is only needed for testing purposes, WebRTC wants to be sure it
206 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
207 # wide character functions.
208 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 13:47:54 -0700209
210 # When set to true, a capturer implementation that uses the
Austin Orion66241e42021-04-22 13:22:25 -0700211 # Windows.Graphics.Capture APIs will be available for use. This introduces a
212 # dependency on the Win 10 SDK v10.0.17763.0.
Austin Orion78f04d82021-04-23 12:37:26 -0700213 rtc_enable_win_wgc = is_win
Dan Minor9c686132018-01-15 10:20:00 -0500214}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800215
Dan Minor9c686132018-01-15 10:20:00 -0500216if (!build_with_mozilla) {
217 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800218}
219
220# A second declare_args block, so that declarations within it can
221# depend on the possibly overridden variables in the first
222# declare_args block.
223declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500224 # Enables the use of protocol buffers for debug recordings.
225 rtc_enable_protobuf = !build_with_mozilla
226
227 # Set this to disable building with support for SCTP data channels.
228 rtc_enable_sctp = !build_with_mozilla
229
230 # Disable these to not build components which can be externally provided.
231 rtc_build_json = !build_with_mozilla
232 rtc_build_libsrtp = !build_with_mozilla
233 rtc_build_libvpx = !build_with_mozilla
234 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500235 rtc_build_opus = !build_with_mozilla
236 rtc_build_ssl = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500237
238 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200239 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
240 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500241 rtc_enable_libevent = false
242 rtc_build_libevent = false
243 } else {
244 rtc_enable_libevent = true
245 rtc_build_libevent = !build_with_mozilla
246 }
247
mbonadei9aa3f0a2017-01-24 06:58:22 -0800248 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
249 rtc_include_pulse_audio = !build_with_chromium
250
251 # Chromium uses its own IO handling, so the internal ADM is only built for
252 # standalone WebRTC.
253 rtc_include_internal_audio_device = !build_with_chromium
254
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800255 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 12:02:32 +0200256 # TODO: Make sure that AVX2 works also for non-clang compilers.
257 if (is_clang == true) {
258 rtc_enable_avx2 = true
259 } else {
260 rtc_enable_avx2 = false
261 }
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800262
Philipp Hancke1a89bc82021-03-02 21:23:24 +0100263 # Set this to true to build the unit tests.
264 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 10:20:00 -0500265 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200266
267 # Set this to false to skip building code that also requires X11 extensions
268 # such as Xdamage, Xfixes.
269 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100270
271 # Set this to true to fully remove logging from WebRTC.
272 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100273
274 # Set this to true to disable trace events.
275 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100276
277 # Set this to true to disable detailed error message and logging for
278 # RTC_CHECKs.
279 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100280
281 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100282 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200283
284 # Set this to true to exclude the transient suppressor in the audio processing
285 # module from the build.
286 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800287}
288
Florent Castellia80c3e52021-04-15 15:02:56 +0200289declare_args() {
Florent Castellia6983c62021-05-06 10:50:07 +0200290 # Enable the dcsctp backend for DataChannels and related unittests
291 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
292
Florent Castellia80c3e52021-04-15 15:02:56 +0200293 # Enable the usrsctp backend for DataChannels and related unittests
294 rtc_build_usrsctp = !build_with_mozilla && rtc_enable_sctp
295}
296
mbonadei9aa3f0a2017-01-24 06:58:22 -0800297# Make it possible to provide custom locations for some libraries (move these
298# up into declare_args should we need to actually use them for the GN build).
299rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800300rtc_opus_dir = "//third_party/opus"
301
302# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200303rtc_desktop_capture_supported =
304 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900305 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800306
307###############################################################################
308# Templates
309#
310
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200311# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800312# chromium.
313# We need absolute paths for all configs in templates as they are shared in
314# different subdirectories.
315webrtc_root = get_path_info(".", "abspath")
316
317# Global configuration that should be applied to all WebRTC targets.
318# You normally shouldn't need to include this in your target as it's
319# automatically included when using the rtc_* templates.
320# It sets defines, include paths and compilation warnings accordingly,
321# both for WebRTC stand-alone builds and for the scenario when WebRTC
322# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700323rtc_common_configs = [
324 webrtc_root + ":common_config",
325 "//build/config/compiler:no_size_t_to_int_warning",
326]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800327
kthelgasonc0977102017-04-24 00:57:16 -0700328if (is_mac || is_ios) {
329 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
330}
331
mbonadei9aa3f0a2017-01-24 06:58:22 -0800332# Global public configuration that should be applied to all WebRTC targets. You
333# normally shouldn't need to include this in your target as it's automatically
334# included when using the rtc_* templates. It set the defines, include paths and
335# compilation warnings that should be propagated to dependents of the targets
336# depending on the target having this config.
337rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
338
339# Common configs to remove or add in all rtc targets.
340rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100341if (!build_with_chromium && is_clang) {
342 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
343}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800344rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200345rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200346rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800347
348set_defaults("rtc_test") {
349 configs = rtc_add_configs
350 suppressed_configs = []
351}
352
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200353set_defaults("rtc_library") {
354 configs = rtc_add_configs
355 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200356 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200357}
358
mbonadei9aa3f0a2017-01-24 06:58:22 -0800359set_defaults("rtc_source_set") {
360 configs = rtc_add_configs
361 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200362 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800363}
364
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200365set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800366 configs = rtc_add_configs
367 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200368 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800369}
370
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200371set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800372 configs = rtc_add_configs
373 suppressed_configs = []
374}
375
376set_defaults("rtc_shared_library") {
377 configs = rtc_add_configs
378 suppressed_configs = []
379}
380
Per Kjellandera7f2d842018-01-10 15:54:53 +0000381webrtc_default_visibility = [ webrtc_root + "/*" ]
382if (build_with_chromium) {
383 # Allow Chromium's WebRTC overrides targets to bypass the regular
384 # visibility restrictions.
385 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
386}
387
Karl Wibergbb23c832018-04-22 19:55:00 +0200388# ---- Poisons ----
389#
390# The general idea is that some targets declare that they contain some
391# kind of poison, which makes it impossible for other targets to
392# depend on them (even transitively) unless they declare themselves
393# immune to that particular type of poison.
394#
395# Targets that *contain* poison of type foo should contain the line
396#
397# poisonous = [ "foo" ]
398#
399# and targets that *are immune but arent't themselves poisonous*
400# should contain
401#
402# allow_poison = [ "foo" ]
403#
404# This useful in cases where we have some large target or set of
405# targets and want to ensure that most other targets do not
406# transitively depend on them. For example, almost no high-level
407# target should depend on the audio codecs, since we want WebRTC users
408# to be able to inject any subset of them and actually end up with a
409# binary that doesn't include the codecs they didn't inject.
410#
411# Test-only targets (`testonly` set to true) and non-public targets
412# (`visibility` not containing "*") are automatically immune to all
413# types of poison.
414#
415# Here's the complete list of all types of poison. It must be kept in
416# 1:1 correspondence with the set of //:poison_* targets.
417#
418all_poison_types = [
419 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
420 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200421
Danil Chapovalov41300af2019-07-10 12:44:43 +0200422 # Default task queue implementation.
423 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200424
425 # JSON parsing should not be needed in the "slim and modular" WebRTC.
426 "rtc_json",
427
428 # Software video codecs (VP8 and VP9 through libvpx).
429 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200430]
431
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000432absl_include_config = "//third_party/abseil-cpp:absl_include_config"
433absl_define_config = "//third_party/abseil-cpp:absl_define_config"
434
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200435# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
436# that are testonly.
437absl_flags_config = webrtc_root + ":absl_flags_configs"
438
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100439# WebRTC wrapper of Chromium's test() template. This template just adds some
440# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
441# target.
442# The parameter `is_xctest` is different from the one in the Chromium's test()
443# template (and it is not forwarded to it). In rtc_test(), the argument
444# `is_xctest` is used to avoid to take dependencies that are not needed
445# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800446template("rtc_test") {
447 test(target_name) {
448 forward_variables_from(invoker,
449 "*",
450 [
451 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100452 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800453 "public_configs",
454 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200455 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800456 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100457
458 # Always override to public because when target_os is Android the `test`
459 # template can override it to [ "*" ] and we want to avoid conditional
460 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100461 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800462 configs += invoker.configs
463 configs -= rtc_remove_configs
464 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000465 public_configs = [
466 rtc_common_inherited_config,
467 absl_include_config,
468 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200469 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000470 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800471 if (defined(invoker.public_configs)) {
472 public_configs += invoker.public_configs
473 }
sakald7fdb802017-05-26 01:51:53 -0700474 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800475 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 18:53:11 -0400476 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200477 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200478 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 19:03:37 +0200479 deps += [
480 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
481 webrtc_root + "test:native_test_java",
482 ]
sakald7fdb802017-05-26 01:51:53 -0700483 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100484
485 # When not targeting a simulator, building //base/test:google_test_runner
486 # fails, so it is added only when the test is not a real XCTest and when
487 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100488 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100489 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
490 xctest_module_target = "//base/test:google_test_runner"
491 }
492 }
Andrey Logvin78646002021-01-29 10:50:19 +0000493
494 # If absl_deps is [], no action is needed. If not [], then it needs to be
495 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
496 # otherwise it just needs to be added to deps.
497 if (defined(absl_deps) && absl_deps != []) {
498 if (!defined(deps)) {
499 deps = []
500 }
501 if (build_with_chromium) {
502 deps += [ "//third_party/abseil-cpp:absl" ]
503 } else {
504 deps += absl_deps
505 }
506 }
507
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100508 if (using_sanitizer) {
509 if (is_linux) {
510 if (!defined(invoker.data)) {
511 data = []
512 }
513 data +=
514 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
515 }
516 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800517 }
518}
519
520template("rtc_source_set") {
521 source_set(target_name) {
522 forward_variables_from(invoker,
523 "*",
524 [
525 "configs",
526 "public_configs",
527 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200528 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800529 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200530 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000531 if (!defined(visibility)) {
532 visibility = webrtc_default_visibility
533 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200534
535 # What's your poison?
536 if (defined(testonly) && testonly) {
537 assert(!defined(poisonous))
538 assert(!defined(allow_poison))
539 } else {
540 if (!defined(poisonous)) {
541 poisonous = []
542 }
543 if (!defined(allow_poison)) {
544 allow_poison = []
545 }
546 if (!defined(assert_no_deps)) {
547 assert_no_deps = []
548 }
549 if (!defined(deps)) {
550 deps = []
551 }
552 foreach(p, poisonous) {
553 deps += [ webrtc_root + ":poison_" + p ]
554 }
555 foreach(poison_type, all_poison_types) {
556 allow_dep = true
557 foreach(v, visibility) {
558 if (v == "*") {
559 allow_dep = false
560 }
561 }
562 foreach(p, allow_poison + poisonous) {
563 if (p == poison_type) {
564 allow_dep = true
565 }
566 }
567 if (!allow_dep) {
568 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
569 }
570 }
571 }
572
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100573 # Chromium should only depend on the WebRTC component in order to
574 # avoid to statically link WebRTC in a component build.
575 if (build_with_chromium) {
576 publicly_visible = false
577 foreach(v, visibility) {
578 if (v == "*") {
579 publicly_visible = true
580 }
581 }
582 if (publicly_visible) {
583 visibility = []
584 visibility = webrtc_default_visibility
585 }
586 }
587
Mirko Bonadei96ede162018-09-06 13:45:44 +0200588 if (!defined(testonly) || !testonly) {
589 configs += rtc_prod_configs
590 }
591
mbonadei9aa3f0a2017-01-24 06:58:22 -0800592 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200593 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800594 configs -= rtc_remove_configs
595 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000596 public_configs = [
597 rtc_common_inherited_config,
598 absl_include_config,
599 absl_define_config,
600 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200601 if (defined(testonly) && testonly) {
602 public_configs += [ absl_flags_config ]
603 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800604 if (defined(invoker.public_configs)) {
605 public_configs += invoker.public_configs
606 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200607
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200608 # If absl_deps is [], no action is needed. If not [], then it needs to be
609 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200610 # otherwise it just needs to be added to deps.
611 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200612 if (!defined(deps)) {
613 deps = []
614 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200615 if (build_with_chromium) {
616 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200617 } else {
618 deps += absl_deps
619 }
620 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800621 }
622}
623
mbonadei9aa3f0a2017-01-24 06:58:22 -0800624template("rtc_static_library") {
625 static_library(target_name) {
626 forward_variables_from(invoker,
627 "*",
628 [
629 "configs",
630 "public_configs",
631 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200632 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800633 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200634 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000635 if (!defined(visibility)) {
636 visibility = webrtc_default_visibility
637 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200638
639 # What's your poison?
640 if (defined(testonly) && testonly) {
641 assert(!defined(poisonous))
642 assert(!defined(allow_poison))
643 } else {
644 if (!defined(poisonous)) {
645 poisonous = []
646 }
647 if (!defined(allow_poison)) {
648 allow_poison = []
649 }
650 if (!defined(assert_no_deps)) {
651 assert_no_deps = []
652 }
653 if (!defined(deps)) {
654 deps = []
655 }
656 foreach(p, poisonous) {
657 deps += [ webrtc_root + ":poison_" + p ]
658 }
659 foreach(poison_type, all_poison_types) {
660 allow_dep = true
661 foreach(v, visibility) {
662 if (v == "*") {
663 allow_dep = false
664 }
665 }
666 foreach(p, allow_poison + poisonous) {
667 if (p == poison_type) {
668 allow_dep = true
669 }
670 }
671 if (!allow_dep) {
672 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
673 }
674 }
675 }
676
Mirko Bonadei96ede162018-09-06 13:45:44 +0200677 if (!defined(testonly) || !testonly) {
678 configs += rtc_prod_configs
679 }
680
mbonadei9aa3f0a2017-01-24 06:58:22 -0800681 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200682 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800683 configs -= rtc_remove_configs
684 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000685 public_configs = [
686 rtc_common_inherited_config,
687 absl_include_config,
688 absl_define_config,
689 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200690 if (defined(testonly) && testonly) {
691 public_configs += [ absl_flags_config ]
692 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800693 if (defined(invoker.public_configs)) {
694 public_configs += invoker.public_configs
695 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200696
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200697 # If absl_deps is [], no action is needed. If not [], then it needs to be
698 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200699 # otherwise it just needs to be added to deps.
700 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200701 if (!defined(deps)) {
702 deps = []
703 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200704 if (build_with_chromium) {
705 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200706 } else {
707 deps += absl_deps
708 }
709 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800710 }
711}
712
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200713# This template automatically switches the target type between source_set
714# and static_library.
715#
716# This should be the default target type for all the WebRTC targets with
717# one exception. Do not use this template for header only targets, in that case
718# rtc_source_set must be used in order to avoid build errors (e.g. libtool
719# complains if the output .a file is empty).
720#
721# How does it work:
722# Since all files in a source_set are linked into a final binary, while files
723# in a static library are only linked in if at least one symbol in them is
724# referenced, in component builds source_sets are easy to deal with because
725# all their object files are passed to the linker to create a shared library.
726# In release builds instead, static_libraries are preferred since they allow
727# the linker to discard dead code.
728# For the same reason, testonly targets will always be expanded to
729# source_set in order to be sure that tests are present in the test binary.
730template("rtc_library") {
731 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
732 target_type = "source_set"
733 } else {
734 target_type = "static_library"
735 }
736 target(target_type, target_name) {
737 forward_variables_from(invoker,
738 "*",
739 [
740 "configs",
741 "public_configs",
742 "suppressed_configs",
743 "visibility",
744 ])
745 forward_variables_from(invoker, [ "visibility" ])
746 if (!defined(visibility)) {
747 visibility = webrtc_default_visibility
748 }
749
750 # What's your poison?
751 if (defined(testonly) && testonly) {
752 assert(!defined(poisonous))
753 assert(!defined(allow_poison))
754 } else {
755 if (!defined(poisonous)) {
756 poisonous = []
757 }
758 if (!defined(allow_poison)) {
759 allow_poison = []
760 }
761 if (!defined(assert_no_deps)) {
762 assert_no_deps = []
763 }
764 if (!defined(deps)) {
765 deps = []
766 }
767 foreach(p, poisonous) {
768 deps += [ webrtc_root + ":poison_" + p ]
769 }
770 foreach(poison_type, all_poison_types) {
771 allow_dep = true
772 foreach(v, visibility) {
773 if (v == "*") {
774 allow_dep = false
775 }
776 }
777 foreach(p, allow_poison + poisonous) {
778 if (p == poison_type) {
779 allow_dep = true
780 }
781 }
782 if (!allow_dep) {
783 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
784 }
785 }
786 }
787
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100788 # Chromium should only depend on the WebRTC component in order to
789 # avoid to statically link WebRTC in a component build.
790 if (build_with_chromium) {
791 publicly_visible = false
792 foreach(v, visibility) {
793 if (v == "*") {
794 publicly_visible = true
795 }
796 }
797 if (publicly_visible) {
798 visibility = []
799 visibility = webrtc_default_visibility
800 }
801 }
802
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200803 if (!defined(testonly) || !testonly) {
804 configs += rtc_prod_configs
805 }
806
807 configs += invoker.configs
808 configs += rtc_library_impl_config
809 configs -= rtc_remove_configs
810 configs -= invoker.suppressed_configs
811 public_configs = [
812 rtc_common_inherited_config,
813 absl_include_config,
814 absl_define_config,
815 ]
816 if (defined(testonly) && testonly) {
817 public_configs += [ absl_flags_config ]
818 }
819 if (defined(invoker.public_configs)) {
820 public_configs += invoker.public_configs
821 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200822
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200823 # If absl_deps is [], no action is needed. If not [], then it needs to be
824 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200825 # otherwise it just needs to be added to deps.
826 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200827 if (!defined(deps)) {
828 deps = []
829 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200830 if (build_with_chromium) {
831 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200832 } else {
833 deps += absl_deps
834 }
835 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200836 }
837}
838
839template("rtc_executable") {
840 executable(target_name) {
841 forward_variables_from(invoker,
842 "*",
843 [
844 "deps",
845 "configs",
846 "public_configs",
847 "suppressed_configs",
848 "visibility",
849 ])
850 forward_variables_from(invoker, [ "visibility" ])
851 if (!defined(visibility)) {
852 visibility = webrtc_default_visibility
853 }
854 configs += invoker.configs
855 configs -= rtc_remove_configs
856 configs -= invoker.suppressed_configs
857 deps = invoker.deps
858
859 public_configs = [
860 rtc_common_inherited_config,
861 absl_include_config,
862 absl_define_config,
863 ]
864 if (defined(testonly) && testonly) {
865 public_configs += [ absl_flags_config ]
866 }
867 if (defined(invoker.public_configs)) {
868 public_configs += invoker.public_configs
869 }
870 if (is_win) {
871 deps += [
872 # Give executables the default manifest on Windows (a no-op elsewhere).
873 "//build/win:default_exe_manifest",
874 ]
875 }
876 }
877}
878
mbonadei9aa3f0a2017-01-24 06:58:22 -0800879template("rtc_shared_library") {
880 shared_library(target_name) {
881 forward_variables_from(invoker,
882 "*",
883 [
884 "configs",
885 "public_configs",
886 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200887 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800888 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200889 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000890 if (!defined(visibility)) {
891 visibility = webrtc_default_visibility
892 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200893
894 # What's your poison?
895 if (defined(testonly) && testonly) {
896 assert(!defined(poisonous))
897 assert(!defined(allow_poison))
898 } else {
899 if (!defined(poisonous)) {
900 poisonous = []
901 }
902 if (!defined(allow_poison)) {
903 allow_poison = []
904 }
905 if (!defined(assert_no_deps)) {
906 assert_no_deps = []
907 }
908 if (!defined(deps)) {
909 deps = []
910 }
911 foreach(p, poisonous) {
912 deps += [ webrtc_root + ":poison_" + p ]
913 }
914 foreach(poison_type, all_poison_types) {
915 allow_dep = true
916 foreach(v, visibility) {
917 if (v == "*") {
918 allow_dep = false
919 }
920 }
921 foreach(p, allow_poison + poisonous) {
922 if (p == poison_type) {
923 allow_dep = true
924 }
925 }
926 if (!allow_dep) {
927 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
928 }
929 }
930 }
931
mbonadei9aa3f0a2017-01-24 06:58:22 -0800932 configs += invoker.configs
933 configs -= rtc_remove_configs
934 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000935 public_configs = [
936 rtc_common_inherited_config,
937 absl_include_config,
938 absl_define_config,
939 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200940 if (defined(testonly) && testonly) {
941 public_configs += [ absl_flags_config ]
942 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800943 if (defined(invoker.public_configs)) {
944 public_configs += invoker.public_configs
945 }
946 }
947}
kthelgason4065a572017-02-14 04:58:56 -0800948
949if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400950 # TODO: Generate module.modulemap file to enable use in Swift
951 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100952 template("ios_framework_bundle_with_umbrella_header") {
953 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900954 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100955 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900956 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
957
958 action_foreach("create_bracket_include_headers_$target_name") {
959 script = "//tools_webrtc/apple/copy_framework_header.py"
960 sources = invoker.sources
961 output_name = invoker.output_name
962 outputs = [
963 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
964 ]
965 args = [
966 "--input",
967 "{{source}}",
968 "--output",
969 rebase_path(target_gen_dir, root_build_dir) +
970 "/$output_name.framework/WebRTC/{{source_file_part}}",
971 ]
972 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100973
974 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900975 forward_variables_from(invoker, "*", [ "public_headers" ])
976 public_headers = get_target_outputs(
977 ":create_bracket_include_headers_$this_target_name")
978 deps += [
979 ":copy_umbrella_header_$target_name",
980 ":create_bracket_include_headers_$target_name",
981 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100982 }
983
984 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900985 public_headers = get_target_outputs(
986 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100987
988 script = "//tools_webrtc/ios/generate_umbrella_header.py"
989
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100990 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100991 args = [
992 "--out",
993 rebase_path(umbrella_header_path, root_build_dir),
994 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200995 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900996 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100997 }
998
Jordan Rose53d3fc92021-07-06 12:16:41 -0700999 if (target_environment == "catalyst") {
1000 # Catalyst frameworks use the same layout as regular Mac frameworks.
1001 headers_dir = "Versions/A/Headers"
1002 } else {
1003 headers_dir = "Headers"
1004 }
Anders Carlssondc6b4772018-01-15 13:31:03 +01001005 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001006 sources = [ umbrella_header_path ]
1007 outputs =
Jordan Rose53d3fc92021-07-06 12:16:41 -07001008 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001009
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001010 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001011 }
1012 }
1013
1014 set_defaults("ios_framework_bundle_with_umbrella_header") {
1015 configs = default_shared_library_configs
1016 }
kthelgason4065a572017-02-14 04:58:56 -08001017}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001018
Anders Carlsson37bbf792018-09-05 16:29:27 +02001019if (is_mac) {
1020 template("mac_framework_bundle_with_umbrella_header") {
1021 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001022 this_target_name = target_name
1023 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001024 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +02001025
1026 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -08001027 forward_variables_from(invoker, "*", [ "configs" ])
1028 if (defined(invoker.configs)) {
1029 configs += invoker.configs
1030 }
Anders Carlsson37bbf792018-09-05 16:29:27 +02001031
1032 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001033 framework_contents = [
1034 "Headers",
1035 "Modules",
1036 "Resources",
1037 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001038
1039 ldflags = [
1040 "-all_load",
1041 "-install_name",
1042 "@rpath/$output_name.framework/$output_name",
1043 ]
1044
1045 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001046 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001047 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001048 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001049 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001050 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001051 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001052 ]
1053 }
1054
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001055 action_foreach("create_bracket_include_headers_$this_target_name") {
1056 script = "//tools_webrtc/apple/copy_framework_header.py"
1057 sources = invoker.sources
1058 output_name = invoker.output_name
1059 outputs = [
1060 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1061 ]
1062 args = [
1063 "--input",
1064 "{{source}}",
1065 "--output",
1066 rebase_path(target_gen_dir, root_build_dir) +
1067 "/$output_name.framework/WebRTC/{{source_file_part}}",
1068 ]
1069 }
1070
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001071 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001072 sources = get_target_outputs(
1073 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001074
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001075 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001076 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001077 }
1078
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001079 action("modulemap_$this_target_name") {
1080 script = "//tools_webrtc/ios/generate_modulemap.py"
1081 args = [
1082 "--out",
1083 rebase_path(modulemap_path, root_build_dir),
1084 "--name",
1085 output_name,
1086 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001087 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001088 }
1089
1090 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001091 sources = [ modulemap_path ]
1092 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1093 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001094 }
1095
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001096 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001097 sources = get_target_outputs(
1098 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001099
1100 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1101
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001102 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001103 args = [
1104 "--out",
1105 rebase_path(umbrella_header_path, root_build_dir),
1106 "--sources",
1107 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001108 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001109 }
1110
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001111 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001112 sources = [ umbrella_header_path ]
1113 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001114
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001115 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001116 }
1117 }
1118}
1119
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001120if (is_android) {
1121 template("rtc_android_library") {
1122 android_library(target_name) {
1123 forward_variables_from(invoker,
1124 "*",
1125 [
1126 "configs",
1127 "public_configs",
1128 "suppressed_configs",
1129 "visibility",
1130 ])
1131
Oleh Prypin05aee742018-11-23 17:29:44 +01001132 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001133
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001134 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001135 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001136
1137 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001138 if (defined(invoker.errorprone_args)) {
1139 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001140 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001141
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001142 if (!defined(deps)) {
1143 deps = []
1144 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001145
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001146 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001147 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001148 }
1149 }
1150
1151 template("rtc_android_apk") {
1152 android_apk(target_name) {
1153 forward_variables_from(invoker,
1154 "*",
1155 [
1156 "configs",
1157 "public_configs",
1158 "suppressed_configs",
1159 "visibility",
1160 ])
1161
1162 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001163 errorprone_args = []
1164 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001165
1166 if (!defined(deps)) {
1167 deps = []
1168 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001169
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001170 no_build_hooks = true
1171 }
1172 }
1173
1174 template("rtc_instrumentation_test_apk") {
1175 instrumentation_test_apk(target_name) {
1176 forward_variables_from(invoker,
1177 "*",
1178 [
1179 "configs",
1180 "public_configs",
1181 "suppressed_configs",
1182 "visibility",
1183 ])
1184
1185 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001186 errorprone_args = []
1187 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001188
1189 if (!defined(deps)) {
1190 deps = []
1191 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001192
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001193 no_build_hooks = true
1194 }
1195 }
1196}