blob: 1d76567029b8190f9a78931d3b9ecb0d560873e8 [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(
26 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md")
27 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
186 # Determines whether Metal is available on iOS/macOS.
187 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Jiawei Ou08745302019-02-12 11:36:13 -0800188
189 # When set to false, builtin audio encoder/decoder factories and all the
190 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
191 # (they will still be included in libjingle_peerconnection_so.so and
192 # WebRTC.framework)
193 rtc_include_builtin_audio_codecs = true
194
195 # When set to false, builtin video encoder/decoder factories and all the
196 # video codecs they depends on will not be included in libwebrtc.{a|lib}
197 # (they will still be included in libjingle_peerconnection_so.so and
198 # WebRTC.framework)
199 rtc_include_builtin_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100200
201 # When set to true and in a standalone build, it will undefine UNICODE and
202 # _UNICODE (which are always defined globally by the Chromium Windows
203 # toolchain).
204 # This is only needed for testing purposes, WebRTC wants to be sure it
205 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
206 # wide character functions.
207 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 13:47:54 -0700208
209 # When set to true, a capturer implementation that uses the
Austin Orion66241e42021-04-22 13:22:25 -0700210 # Windows.Graphics.Capture APIs will be available for use. This introduces a
211 # dependency on the Win 10 SDK v10.0.17763.0.
Austin Orion25b0dee2020-10-01 13:47:54 -0700212 rtc_enable_win_wgc = false
Dan Minor9c686132018-01-15 10:20:00 -0500213}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800214
Dan Minor9c686132018-01-15 10:20:00 -0500215if (!build_with_mozilla) {
216 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800217}
218
219# A second declare_args block, so that declarations within it can
220# depend on the possibly overridden variables in the first
221# declare_args block.
222declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500223 # Enables the use of protocol buffers for debug recordings.
224 rtc_enable_protobuf = !build_with_mozilla
225
226 # Set this to disable building with support for SCTP data channels.
227 rtc_enable_sctp = !build_with_mozilla
228
229 # Disable these to not build components which can be externally provided.
230 rtc_build_json = !build_with_mozilla
231 rtc_build_libsrtp = !build_with_mozilla
232 rtc_build_libvpx = !build_with_mozilla
233 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500234 rtc_build_opus = !build_with_mozilla
235 rtc_build_ssl = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500236
237 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200238 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
239 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500240 rtc_enable_libevent = false
241 rtc_build_libevent = false
242 } else {
243 rtc_enable_libevent = true
244 rtc_build_libevent = !build_with_mozilla
245 }
246
mbonadei9aa3f0a2017-01-24 06:58:22 -0800247 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
248 rtc_include_pulse_audio = !build_with_chromium
249
250 # Chromium uses its own IO handling, so the internal ADM is only built for
251 # standalone WebRTC.
252 rtc_include_internal_audio_device = !build_with_chromium
253
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800254 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 12:02:32 +0200255 # TODO: Make sure that AVX2 works also for non-clang compilers.
256 if (is_clang == true) {
257 rtc_enable_avx2 = true
258 } else {
259 rtc_enable_avx2 = false
260 }
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800261
Philipp Hancke1a89bc82021-03-02 21:23:24 +0100262 # Set this to true to build the unit tests.
263 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 10:20:00 -0500264 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200265
266 # Set this to false to skip building code that also requires X11 extensions
267 # such as Xdamage, Xfixes.
268 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100269
270 # Set this to true to fully remove logging from WebRTC.
271 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100272
273 # Set this to true to disable trace events.
274 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100275
276 # Set this to true to disable detailed error message and logging for
277 # RTC_CHECKs.
278 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100279
280 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100281 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200282
283 # Set this to true to exclude the transient suppressor in the audio processing
284 # module from the build.
285 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800286}
287
Florent Castellia80c3e52021-04-15 15:02:56 +0200288declare_args() {
289 # Enable the usrsctp backend for DataChannels and related unittests
290 rtc_build_usrsctp = !build_with_mozilla && rtc_enable_sctp
291}
292
mbonadei9aa3f0a2017-01-24 06:58:22 -0800293# Make it possible to provide custom locations for some libraries (move these
294# up into declare_args should we need to actually use them for the GN build).
295rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800296rtc_opus_dir = "//third_party/opus"
297
298# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200299rtc_desktop_capture_supported =
300 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900301 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800302
303###############################################################################
304# Templates
305#
306
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200307# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800308# chromium.
309# We need absolute paths for all configs in templates as they are shared in
310# different subdirectories.
311webrtc_root = get_path_info(".", "abspath")
312
313# Global configuration that should be applied to all WebRTC targets.
314# You normally shouldn't need to include this in your target as it's
315# automatically included when using the rtc_* templates.
316# It sets defines, include paths and compilation warnings accordingly,
317# both for WebRTC stand-alone builds and for the scenario when WebRTC
318# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700319rtc_common_configs = [
320 webrtc_root + ":common_config",
321 "//build/config/compiler:no_size_t_to_int_warning",
322]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800323
kthelgasonc0977102017-04-24 00:57:16 -0700324if (is_mac || is_ios) {
325 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
326}
327
mbonadei9aa3f0a2017-01-24 06:58:22 -0800328# Global public configuration that should be applied to all WebRTC targets. You
329# normally shouldn't need to include this in your target as it's automatically
330# included when using the rtc_* templates. It set the defines, include paths and
331# compilation warnings that should be propagated to dependents of the targets
332# depending on the target having this config.
333rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
334
335# Common configs to remove or add in all rtc targets.
336rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100337if (!build_with_chromium && is_clang) {
338 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
339}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800340rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200341rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200342rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800343
344set_defaults("rtc_test") {
345 configs = rtc_add_configs
346 suppressed_configs = []
347}
348
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200349set_defaults("rtc_library") {
350 configs = rtc_add_configs
351 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200352 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200353}
354
mbonadei9aa3f0a2017-01-24 06:58:22 -0800355set_defaults("rtc_source_set") {
356 configs = rtc_add_configs
357 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200358 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800359}
360
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200361set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800362 configs = rtc_add_configs
363 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200364 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800365}
366
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200367set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800368 configs = rtc_add_configs
369 suppressed_configs = []
370}
371
372set_defaults("rtc_shared_library") {
373 configs = rtc_add_configs
374 suppressed_configs = []
375}
376
Per Kjellandera7f2d842018-01-10 15:54:53 +0000377webrtc_default_visibility = [ webrtc_root + "/*" ]
378if (build_with_chromium) {
379 # Allow Chromium's WebRTC overrides targets to bypass the regular
380 # visibility restrictions.
381 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
382}
383
Karl Wibergbb23c832018-04-22 19:55:00 +0200384# ---- Poisons ----
385#
386# The general idea is that some targets declare that they contain some
387# kind of poison, which makes it impossible for other targets to
388# depend on them (even transitively) unless they declare themselves
389# immune to that particular type of poison.
390#
391# Targets that *contain* poison of type foo should contain the line
392#
393# poisonous = [ "foo" ]
394#
395# and targets that *are immune but arent't themselves poisonous*
396# should contain
397#
398# allow_poison = [ "foo" ]
399#
400# This useful in cases where we have some large target or set of
401# targets and want to ensure that most other targets do not
402# transitively depend on them. For example, almost no high-level
403# target should depend on the audio codecs, since we want WebRTC users
404# to be able to inject any subset of them and actually end up with a
405# binary that doesn't include the codecs they didn't inject.
406#
407# Test-only targets (`testonly` set to true) and non-public targets
408# (`visibility` not containing "*") are automatically immune to all
409# types of poison.
410#
411# Here's the complete list of all types of poison. It must be kept in
412# 1:1 correspondence with the set of //:poison_* targets.
413#
414all_poison_types = [
415 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
416 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200417
Danil Chapovalov41300af2019-07-10 12:44:43 +0200418 # Default task queue implementation.
419 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200420
421 # JSON parsing should not be needed in the "slim and modular" WebRTC.
422 "rtc_json",
423
424 # Software video codecs (VP8 and VP9 through libvpx).
425 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200426]
427
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000428absl_include_config = "//third_party/abseil-cpp:absl_include_config"
429absl_define_config = "//third_party/abseil-cpp:absl_define_config"
430
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200431# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
432# that are testonly.
433absl_flags_config = webrtc_root + ":absl_flags_configs"
434
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100435# WebRTC wrapper of Chromium's test() template. This template just adds some
436# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
437# target.
438# The parameter `is_xctest` is different from the one in the Chromium's test()
439# template (and it is not forwarded to it). In rtc_test(), the argument
440# `is_xctest` is used to avoid to take dependencies that are not needed
441# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800442template("rtc_test") {
443 test(target_name) {
444 forward_variables_from(invoker,
445 "*",
446 [
447 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100448 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800449 "public_configs",
450 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200451 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800452 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100453
454 # Always override to public because when target_os is Android the `test`
455 # template can override it to [ "*" ] and we want to avoid conditional
456 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100457 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800458 configs += invoker.configs
459 configs -= rtc_remove_configs
460 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000461 public_configs = [
462 rtc_common_inherited_config,
463 absl_include_config,
464 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200465 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000466 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800467 if (defined(invoker.public_configs)) {
468 public_configs += invoker.public_configs
469 }
sakald7fdb802017-05-26 01:51:53 -0700470 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800471 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 18:53:11 -0400472 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200473 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200474 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 19:03:37 +0200475 deps += [
476 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
477 webrtc_root + "test:native_test_java",
478 ]
sakald7fdb802017-05-26 01:51:53 -0700479 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100480
481 # When not targeting a simulator, building //base/test:google_test_runner
482 # fails, so it is added only when the test is not a real XCTest and when
483 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100484 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100485 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
486 xctest_module_target = "//base/test:google_test_runner"
487 }
488 }
Andrey Logvin78646002021-01-29 10:50:19 +0000489
490 # If absl_deps is [], no action is needed. If not [], then it needs to be
491 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
492 # otherwise it just needs to be added to deps.
493 if (defined(absl_deps) && absl_deps != []) {
494 if (!defined(deps)) {
495 deps = []
496 }
497 if (build_with_chromium) {
498 deps += [ "//third_party/abseil-cpp:absl" ]
499 } else {
500 deps += absl_deps
501 }
502 }
503
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100504 if (using_sanitizer) {
505 if (is_linux) {
506 if (!defined(invoker.data)) {
507 data = []
508 }
509 data +=
510 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
511 }
512 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800513 }
514}
515
516template("rtc_source_set") {
517 source_set(target_name) {
518 forward_variables_from(invoker,
519 "*",
520 [
521 "configs",
522 "public_configs",
523 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200524 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800525 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200526 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000527 if (!defined(visibility)) {
528 visibility = webrtc_default_visibility
529 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200530
531 # What's your poison?
532 if (defined(testonly) && testonly) {
533 assert(!defined(poisonous))
534 assert(!defined(allow_poison))
535 } else {
536 if (!defined(poisonous)) {
537 poisonous = []
538 }
539 if (!defined(allow_poison)) {
540 allow_poison = []
541 }
542 if (!defined(assert_no_deps)) {
543 assert_no_deps = []
544 }
545 if (!defined(deps)) {
546 deps = []
547 }
548 foreach(p, poisonous) {
549 deps += [ webrtc_root + ":poison_" + p ]
550 }
551 foreach(poison_type, all_poison_types) {
552 allow_dep = true
553 foreach(v, visibility) {
554 if (v == "*") {
555 allow_dep = false
556 }
557 }
558 foreach(p, allow_poison + poisonous) {
559 if (p == poison_type) {
560 allow_dep = true
561 }
562 }
563 if (!allow_dep) {
564 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
565 }
566 }
567 }
568
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100569 # Chromium should only depend on the WebRTC component in order to
570 # avoid to statically link WebRTC in a component build.
571 if (build_with_chromium) {
572 publicly_visible = false
573 foreach(v, visibility) {
574 if (v == "*") {
575 publicly_visible = true
576 }
577 }
578 if (publicly_visible) {
579 visibility = []
580 visibility = webrtc_default_visibility
581 }
582 }
583
Mirko Bonadei96ede162018-09-06 13:45:44 +0200584 if (!defined(testonly) || !testonly) {
585 configs += rtc_prod_configs
586 }
587
mbonadei9aa3f0a2017-01-24 06:58:22 -0800588 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200589 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800590 configs -= rtc_remove_configs
591 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000592 public_configs = [
593 rtc_common_inherited_config,
594 absl_include_config,
595 absl_define_config,
596 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200597 if (defined(testonly) && testonly) {
598 public_configs += [ absl_flags_config ]
599 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800600 if (defined(invoker.public_configs)) {
601 public_configs += invoker.public_configs
602 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200603
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200604 # If absl_deps is [], no action is needed. If not [], then it needs to be
605 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200606 # otherwise it just needs to be added to deps.
607 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200608 if (!defined(deps)) {
609 deps = []
610 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200611 if (build_with_chromium) {
612 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200613 } else {
614 deps += absl_deps
615 }
616 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800617 }
618}
619
mbonadei9aa3f0a2017-01-24 06:58:22 -0800620template("rtc_static_library") {
621 static_library(target_name) {
622 forward_variables_from(invoker,
623 "*",
624 [
625 "configs",
626 "public_configs",
627 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200628 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800629 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200630 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000631 if (!defined(visibility)) {
632 visibility = webrtc_default_visibility
633 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200634
635 # What's your poison?
636 if (defined(testonly) && testonly) {
637 assert(!defined(poisonous))
638 assert(!defined(allow_poison))
639 } else {
640 if (!defined(poisonous)) {
641 poisonous = []
642 }
643 if (!defined(allow_poison)) {
644 allow_poison = []
645 }
646 if (!defined(assert_no_deps)) {
647 assert_no_deps = []
648 }
649 if (!defined(deps)) {
650 deps = []
651 }
652 foreach(p, poisonous) {
653 deps += [ webrtc_root + ":poison_" + p ]
654 }
655 foreach(poison_type, all_poison_types) {
656 allow_dep = true
657 foreach(v, visibility) {
658 if (v == "*") {
659 allow_dep = false
660 }
661 }
662 foreach(p, allow_poison + poisonous) {
663 if (p == poison_type) {
664 allow_dep = true
665 }
666 }
667 if (!allow_dep) {
668 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
669 }
670 }
671 }
672
Mirko Bonadei96ede162018-09-06 13:45:44 +0200673 if (!defined(testonly) || !testonly) {
674 configs += rtc_prod_configs
675 }
676
mbonadei9aa3f0a2017-01-24 06:58:22 -0800677 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200678 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800679 configs -= rtc_remove_configs
680 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000681 public_configs = [
682 rtc_common_inherited_config,
683 absl_include_config,
684 absl_define_config,
685 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200686 if (defined(testonly) && testonly) {
687 public_configs += [ absl_flags_config ]
688 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800689 if (defined(invoker.public_configs)) {
690 public_configs += invoker.public_configs
691 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200692
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200693 # If absl_deps is [], no action is needed. If not [], then it needs to be
694 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200695 # otherwise it just needs to be added to deps.
696 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200697 if (!defined(deps)) {
698 deps = []
699 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200700 if (build_with_chromium) {
701 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200702 } else {
703 deps += absl_deps
704 }
705 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800706 }
707}
708
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200709# This template automatically switches the target type between source_set
710# and static_library.
711#
712# This should be the default target type for all the WebRTC targets with
713# one exception. Do not use this template for header only targets, in that case
714# rtc_source_set must be used in order to avoid build errors (e.g. libtool
715# complains if the output .a file is empty).
716#
717# How does it work:
718# Since all files in a source_set are linked into a final binary, while files
719# in a static library are only linked in if at least one symbol in them is
720# referenced, in component builds source_sets are easy to deal with because
721# all their object files are passed to the linker to create a shared library.
722# In release builds instead, static_libraries are preferred since they allow
723# the linker to discard dead code.
724# For the same reason, testonly targets will always be expanded to
725# source_set in order to be sure that tests are present in the test binary.
726template("rtc_library") {
727 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
728 target_type = "source_set"
729 } else {
730 target_type = "static_library"
731 }
732 target(target_type, target_name) {
733 forward_variables_from(invoker,
734 "*",
735 [
736 "configs",
737 "public_configs",
738 "suppressed_configs",
739 "visibility",
740 ])
741 forward_variables_from(invoker, [ "visibility" ])
742 if (!defined(visibility)) {
743 visibility = webrtc_default_visibility
744 }
745
746 # What's your poison?
747 if (defined(testonly) && testonly) {
748 assert(!defined(poisonous))
749 assert(!defined(allow_poison))
750 } else {
751 if (!defined(poisonous)) {
752 poisonous = []
753 }
754 if (!defined(allow_poison)) {
755 allow_poison = []
756 }
757 if (!defined(assert_no_deps)) {
758 assert_no_deps = []
759 }
760 if (!defined(deps)) {
761 deps = []
762 }
763 foreach(p, poisonous) {
764 deps += [ webrtc_root + ":poison_" + p ]
765 }
766 foreach(poison_type, all_poison_types) {
767 allow_dep = true
768 foreach(v, visibility) {
769 if (v == "*") {
770 allow_dep = false
771 }
772 }
773 foreach(p, allow_poison + poisonous) {
774 if (p == poison_type) {
775 allow_dep = true
776 }
777 }
778 if (!allow_dep) {
779 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
780 }
781 }
782 }
783
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100784 # Chromium should only depend on the WebRTC component in order to
785 # avoid to statically link WebRTC in a component build.
786 if (build_with_chromium) {
787 publicly_visible = false
788 foreach(v, visibility) {
789 if (v == "*") {
790 publicly_visible = true
791 }
792 }
793 if (publicly_visible) {
794 visibility = []
795 visibility = webrtc_default_visibility
796 }
797 }
798
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200799 if (!defined(testonly) || !testonly) {
800 configs += rtc_prod_configs
801 }
802
803 configs += invoker.configs
804 configs += rtc_library_impl_config
805 configs -= rtc_remove_configs
806 configs -= invoker.suppressed_configs
807 public_configs = [
808 rtc_common_inherited_config,
809 absl_include_config,
810 absl_define_config,
811 ]
812 if (defined(testonly) && testonly) {
813 public_configs += [ absl_flags_config ]
814 }
815 if (defined(invoker.public_configs)) {
816 public_configs += invoker.public_configs
817 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200818
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200819 # If absl_deps is [], no action is needed. If not [], then it needs to be
820 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200821 # otherwise it just needs to be added to deps.
822 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200823 if (!defined(deps)) {
824 deps = []
825 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200826 if (build_with_chromium) {
827 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200828 } else {
829 deps += absl_deps
830 }
831 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200832 }
833}
834
835template("rtc_executable") {
836 executable(target_name) {
837 forward_variables_from(invoker,
838 "*",
839 [
840 "deps",
841 "configs",
842 "public_configs",
843 "suppressed_configs",
844 "visibility",
845 ])
846 forward_variables_from(invoker, [ "visibility" ])
847 if (!defined(visibility)) {
848 visibility = webrtc_default_visibility
849 }
850 configs += invoker.configs
851 configs -= rtc_remove_configs
852 configs -= invoker.suppressed_configs
853 deps = invoker.deps
854
855 public_configs = [
856 rtc_common_inherited_config,
857 absl_include_config,
858 absl_define_config,
859 ]
860 if (defined(testonly) && testonly) {
861 public_configs += [ absl_flags_config ]
862 }
863 if (defined(invoker.public_configs)) {
864 public_configs += invoker.public_configs
865 }
866 if (is_win) {
867 deps += [
868 # Give executables the default manifest on Windows (a no-op elsewhere).
869 "//build/win:default_exe_manifest",
870 ]
871 }
872 }
873}
874
mbonadei9aa3f0a2017-01-24 06:58:22 -0800875template("rtc_shared_library") {
876 shared_library(target_name) {
877 forward_variables_from(invoker,
878 "*",
879 [
880 "configs",
881 "public_configs",
882 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200883 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800884 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200885 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000886 if (!defined(visibility)) {
887 visibility = webrtc_default_visibility
888 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200889
890 # What's your poison?
891 if (defined(testonly) && testonly) {
892 assert(!defined(poisonous))
893 assert(!defined(allow_poison))
894 } else {
895 if (!defined(poisonous)) {
896 poisonous = []
897 }
898 if (!defined(allow_poison)) {
899 allow_poison = []
900 }
901 if (!defined(assert_no_deps)) {
902 assert_no_deps = []
903 }
904 if (!defined(deps)) {
905 deps = []
906 }
907 foreach(p, poisonous) {
908 deps += [ webrtc_root + ":poison_" + p ]
909 }
910 foreach(poison_type, all_poison_types) {
911 allow_dep = true
912 foreach(v, visibility) {
913 if (v == "*") {
914 allow_dep = false
915 }
916 }
917 foreach(p, allow_poison + poisonous) {
918 if (p == poison_type) {
919 allow_dep = true
920 }
921 }
922 if (!allow_dep) {
923 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
924 }
925 }
926 }
927
mbonadei9aa3f0a2017-01-24 06:58:22 -0800928 configs += invoker.configs
929 configs -= rtc_remove_configs
930 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000931 public_configs = [
932 rtc_common_inherited_config,
933 absl_include_config,
934 absl_define_config,
935 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200936 if (defined(testonly) && testonly) {
937 public_configs += [ absl_flags_config ]
938 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800939 if (defined(invoker.public_configs)) {
940 public_configs += invoker.public_configs
941 }
942 }
943}
kthelgason4065a572017-02-14 04:58:56 -0800944
945if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400946 # TODO: Generate module.modulemap file to enable use in Swift
947 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100948 template("ios_framework_bundle_with_umbrella_header") {
949 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900950 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100951 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900952 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
953
954 action_foreach("create_bracket_include_headers_$target_name") {
955 script = "//tools_webrtc/apple/copy_framework_header.py"
956 sources = invoker.sources
957 output_name = invoker.output_name
958 outputs = [
959 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
960 ]
961 args = [
962 "--input",
963 "{{source}}",
964 "--output",
965 rebase_path(target_gen_dir, root_build_dir) +
966 "/$output_name.framework/WebRTC/{{source_file_part}}",
967 ]
968 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100969
970 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900971 forward_variables_from(invoker, "*", [ "public_headers" ])
972 public_headers = get_target_outputs(
973 ":create_bracket_include_headers_$this_target_name")
974 deps += [
975 ":copy_umbrella_header_$target_name",
976 ":create_bracket_include_headers_$target_name",
977 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100978 }
979
980 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900981 public_headers = get_target_outputs(
982 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100983
984 script = "//tools_webrtc/ios/generate_umbrella_header.py"
985
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100986 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100987 args = [
988 "--out",
989 rebase_path(umbrella_header_path, root_build_dir),
990 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200991 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900992 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100993 }
994
995 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100996 sources = [ umbrella_header_path ]
997 outputs =
998 [ "$root_out_dir/$output_name.framework/Headers/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100999
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001000 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001001 }
1002 }
1003
1004 set_defaults("ios_framework_bundle_with_umbrella_header") {
1005 configs = default_shared_library_configs
1006 }
kthelgason4065a572017-02-14 04:58:56 -08001007}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001008
Anders Carlsson37bbf792018-09-05 16:29:27 +02001009if (is_mac) {
1010 template("mac_framework_bundle_with_umbrella_header") {
1011 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001012 this_target_name = target_name
1013 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001014 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +02001015
1016 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -08001017 forward_variables_from(invoker, "*", [ "configs" ])
1018 if (defined(invoker.configs)) {
1019 configs += invoker.configs
1020 }
Anders Carlsson37bbf792018-09-05 16:29:27 +02001021
1022 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001023 framework_contents = [
1024 "Headers",
1025 "Modules",
1026 "Resources",
1027 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001028
1029 ldflags = [
1030 "-all_load",
1031 "-install_name",
1032 "@rpath/$output_name.framework/$output_name",
1033 ]
1034
1035 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001036 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001037 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001038 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001039 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001040 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001041 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001042 ]
1043 }
1044
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001045 action_foreach("create_bracket_include_headers_$this_target_name") {
1046 script = "//tools_webrtc/apple/copy_framework_header.py"
1047 sources = invoker.sources
1048 output_name = invoker.output_name
1049 outputs = [
1050 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1051 ]
1052 args = [
1053 "--input",
1054 "{{source}}",
1055 "--output",
1056 rebase_path(target_gen_dir, root_build_dir) +
1057 "/$output_name.framework/WebRTC/{{source_file_part}}",
1058 ]
1059 }
1060
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001061 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001062 sources = get_target_outputs(
1063 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001064
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001065 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001066 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001067 }
1068
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001069 action("modulemap_$this_target_name") {
1070 script = "//tools_webrtc/ios/generate_modulemap.py"
1071 args = [
1072 "--out",
1073 rebase_path(modulemap_path, root_build_dir),
1074 "--name",
1075 output_name,
1076 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001077 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001078 }
1079
1080 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001081 sources = [ modulemap_path ]
1082 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1083 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001084 }
1085
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001086 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001087 sources = get_target_outputs(
1088 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001089
1090 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1091
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001092 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001093 args = [
1094 "--out",
1095 rebase_path(umbrella_header_path, root_build_dir),
1096 "--sources",
1097 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001098 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001099 }
1100
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001101 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001102 sources = [ umbrella_header_path ]
1103 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001104
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001105 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001106 }
1107 }
1108}
1109
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001110if (is_android) {
1111 template("rtc_android_library") {
1112 android_library(target_name) {
1113 forward_variables_from(invoker,
1114 "*",
1115 [
1116 "configs",
1117 "public_configs",
1118 "suppressed_configs",
1119 "visibility",
1120 ])
1121
Oleh Prypin05aee742018-11-23 17:29:44 +01001122 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001123
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001124 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001125 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001126
1127 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001128 if (defined(invoker.errorprone_args)) {
1129 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001130 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001131
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001132 if (!defined(deps)) {
1133 deps = []
1134 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001135
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001136 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001137 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001138 }
1139 }
1140
1141 template("rtc_android_apk") {
1142 android_apk(target_name) {
1143 forward_variables_from(invoker,
1144 "*",
1145 [
1146 "configs",
1147 "public_configs",
1148 "suppressed_configs",
1149 "visibility",
1150 ])
1151
1152 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001153 errorprone_args = []
1154 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001155
1156 if (!defined(deps)) {
1157 deps = []
1158 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001159
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001160 no_build_hooks = true
1161 }
1162 }
1163
1164 template("rtc_instrumentation_test_apk") {
1165 instrumentation_test_apk(target_name) {
1166 forward_variables_from(invoker,
1167 "*",
1168 [
1169 "configs",
1170 "public_configs",
1171 "suppressed_configs",
1172 "visibility",
1173 ])
1174
1175 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001176 errorprone_args = []
1177 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001178
1179 if (!defined(deps)) {
1180 deps = []
1181 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001182
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001183 no_build_hooks = true
1184 }
1185 }
1186}