blob: 496cac84da6dcc9113ad59dc4558cbe395b1e73f [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() {
Florent Castellia6983c62021-05-06 10:50:07 +0200289 # Enable the dcsctp backend for DataChannels and related unittests
290 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
291
Florent Castellia80c3e52021-04-15 15:02:56 +0200292 # Enable the usrsctp backend for DataChannels and related unittests
293 rtc_build_usrsctp = !build_with_mozilla && rtc_enable_sctp
294}
295
mbonadei9aa3f0a2017-01-24 06:58:22 -0800296# Make it possible to provide custom locations for some libraries (move these
297# up into declare_args should we need to actually use them for the GN build).
298rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800299rtc_opus_dir = "//third_party/opus"
300
301# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200302rtc_desktop_capture_supported =
303 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900304 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800305
306###############################################################################
307# Templates
308#
309
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200310# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800311# chromium.
312# We need absolute paths for all configs in templates as they are shared in
313# different subdirectories.
314webrtc_root = get_path_info(".", "abspath")
315
316# Global configuration that should be applied to all WebRTC targets.
317# You normally shouldn't need to include this in your target as it's
318# automatically included when using the rtc_* templates.
319# It sets defines, include paths and compilation warnings accordingly,
320# both for WebRTC stand-alone builds and for the scenario when WebRTC
321# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700322rtc_common_configs = [
323 webrtc_root + ":common_config",
324 "//build/config/compiler:no_size_t_to_int_warning",
325]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800326
kthelgasonc0977102017-04-24 00:57:16 -0700327if (is_mac || is_ios) {
328 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
329}
330
mbonadei9aa3f0a2017-01-24 06:58:22 -0800331# Global public configuration that should be applied to all WebRTC targets. You
332# normally shouldn't need to include this in your target as it's automatically
333# included when using the rtc_* templates. It set the defines, include paths and
334# compilation warnings that should be propagated to dependents of the targets
335# depending on the target having this config.
336rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
337
338# Common configs to remove or add in all rtc targets.
339rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100340if (!build_with_chromium && is_clang) {
341 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
342}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800343rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200344rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200345rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800346
347set_defaults("rtc_test") {
348 configs = rtc_add_configs
349 suppressed_configs = []
350}
351
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200352set_defaults("rtc_library") {
353 configs = rtc_add_configs
354 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200355 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200356}
357
mbonadei9aa3f0a2017-01-24 06:58:22 -0800358set_defaults("rtc_source_set") {
359 configs = rtc_add_configs
360 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200361 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800362}
363
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200364set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800365 configs = rtc_add_configs
366 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200367 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800368}
369
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200370set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800371 configs = rtc_add_configs
372 suppressed_configs = []
373}
374
375set_defaults("rtc_shared_library") {
376 configs = rtc_add_configs
377 suppressed_configs = []
378}
379
Per Kjellandera7f2d842018-01-10 15:54:53 +0000380webrtc_default_visibility = [ webrtc_root + "/*" ]
381if (build_with_chromium) {
382 # Allow Chromium's WebRTC overrides targets to bypass the regular
383 # visibility restrictions.
384 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
385}
386
Karl Wibergbb23c832018-04-22 19:55:00 +0200387# ---- Poisons ----
388#
389# The general idea is that some targets declare that they contain some
390# kind of poison, which makes it impossible for other targets to
391# depend on them (even transitively) unless they declare themselves
392# immune to that particular type of poison.
393#
394# Targets that *contain* poison of type foo should contain the line
395#
396# poisonous = [ "foo" ]
397#
398# and targets that *are immune but arent't themselves poisonous*
399# should contain
400#
401# allow_poison = [ "foo" ]
402#
403# This useful in cases where we have some large target or set of
404# targets and want to ensure that most other targets do not
405# transitively depend on them. For example, almost no high-level
406# target should depend on the audio codecs, since we want WebRTC users
407# to be able to inject any subset of them and actually end up with a
408# binary that doesn't include the codecs they didn't inject.
409#
410# Test-only targets (`testonly` set to true) and non-public targets
411# (`visibility` not containing "*") are automatically immune to all
412# types of poison.
413#
414# Here's the complete list of all types of poison. It must be kept in
415# 1:1 correspondence with the set of //:poison_* targets.
416#
417all_poison_types = [
418 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
419 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200420
Danil Chapovalov41300af2019-07-10 12:44:43 +0200421 # Default task queue implementation.
422 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200423
424 # JSON parsing should not be needed in the "slim and modular" WebRTC.
425 "rtc_json",
426
427 # Software video codecs (VP8 and VP9 through libvpx).
428 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200429]
430
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000431absl_include_config = "//third_party/abseil-cpp:absl_include_config"
432absl_define_config = "//third_party/abseil-cpp:absl_define_config"
433
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200434# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
435# that are testonly.
436absl_flags_config = webrtc_root + ":absl_flags_configs"
437
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100438# WebRTC wrapper of Chromium's test() template. This template just adds some
439# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
440# target.
441# The parameter `is_xctest` is different from the one in the Chromium's test()
442# template (and it is not forwarded to it). In rtc_test(), the argument
443# `is_xctest` is used to avoid to take dependencies that are not needed
444# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800445template("rtc_test") {
446 test(target_name) {
447 forward_variables_from(invoker,
448 "*",
449 [
450 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100451 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800452 "public_configs",
453 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200454 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800455 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100456
457 # Always override to public because when target_os is Android the `test`
458 # template can override it to [ "*" ] and we want to avoid conditional
459 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100460 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800461 configs += invoker.configs
462 configs -= rtc_remove_configs
463 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000464 public_configs = [
465 rtc_common_inherited_config,
466 absl_include_config,
467 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200468 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000469 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800470 if (defined(invoker.public_configs)) {
471 public_configs += invoker.public_configs
472 }
sakald7fdb802017-05-26 01:51:53 -0700473 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800474 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 18:53:11 -0400475 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200476 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200477 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 19:03:37 +0200478 deps += [
479 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
480 webrtc_root + "test:native_test_java",
481 ]
sakald7fdb802017-05-26 01:51:53 -0700482 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100483
484 # When not targeting a simulator, building //base/test:google_test_runner
485 # fails, so it is added only when the test is not a real XCTest and when
486 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100487 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100488 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
489 xctest_module_target = "//base/test:google_test_runner"
490 }
491 }
Andrey Logvin78646002021-01-29 10:50:19 +0000492
493 # If absl_deps is [], no action is needed. If not [], then it needs to be
494 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
495 # otherwise it just needs to be added to deps.
496 if (defined(absl_deps) && absl_deps != []) {
497 if (!defined(deps)) {
498 deps = []
499 }
500 if (build_with_chromium) {
501 deps += [ "//third_party/abseil-cpp:absl" ]
502 } else {
503 deps += absl_deps
504 }
505 }
506
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100507 if (using_sanitizer) {
508 if (is_linux) {
509 if (!defined(invoker.data)) {
510 data = []
511 }
512 data +=
513 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
514 }
515 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800516 }
517}
518
519template("rtc_source_set") {
520 source_set(target_name) {
521 forward_variables_from(invoker,
522 "*",
523 [
524 "configs",
525 "public_configs",
526 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200527 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800528 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200529 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000530 if (!defined(visibility)) {
531 visibility = webrtc_default_visibility
532 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200533
534 # What's your poison?
535 if (defined(testonly) && testonly) {
536 assert(!defined(poisonous))
537 assert(!defined(allow_poison))
538 } else {
539 if (!defined(poisonous)) {
540 poisonous = []
541 }
542 if (!defined(allow_poison)) {
543 allow_poison = []
544 }
545 if (!defined(assert_no_deps)) {
546 assert_no_deps = []
547 }
548 if (!defined(deps)) {
549 deps = []
550 }
551 foreach(p, poisonous) {
552 deps += [ webrtc_root + ":poison_" + p ]
553 }
554 foreach(poison_type, all_poison_types) {
555 allow_dep = true
556 foreach(v, visibility) {
557 if (v == "*") {
558 allow_dep = false
559 }
560 }
561 foreach(p, allow_poison + poisonous) {
562 if (p == poison_type) {
563 allow_dep = true
564 }
565 }
566 if (!allow_dep) {
567 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
568 }
569 }
570 }
571
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100572 # Chromium should only depend on the WebRTC component in order to
573 # avoid to statically link WebRTC in a component build.
574 if (build_with_chromium) {
575 publicly_visible = false
576 foreach(v, visibility) {
577 if (v == "*") {
578 publicly_visible = true
579 }
580 }
581 if (publicly_visible) {
582 visibility = []
583 visibility = webrtc_default_visibility
584 }
585 }
586
Mirko Bonadei96ede162018-09-06 13:45:44 +0200587 if (!defined(testonly) || !testonly) {
588 configs += rtc_prod_configs
589 }
590
mbonadei9aa3f0a2017-01-24 06:58:22 -0800591 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200592 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800593 configs -= rtc_remove_configs
594 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000595 public_configs = [
596 rtc_common_inherited_config,
597 absl_include_config,
598 absl_define_config,
599 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200600 if (defined(testonly) && testonly) {
601 public_configs += [ absl_flags_config ]
602 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800603 if (defined(invoker.public_configs)) {
604 public_configs += invoker.public_configs
605 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200606
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200607 # If absl_deps is [], no action is needed. If not [], then it needs to be
608 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200609 # otherwise it just needs to be added to deps.
610 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200611 if (!defined(deps)) {
612 deps = []
613 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200614 if (build_with_chromium) {
615 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200616 } else {
617 deps += absl_deps
618 }
619 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800620 }
621}
622
mbonadei9aa3f0a2017-01-24 06:58:22 -0800623template("rtc_static_library") {
624 static_library(target_name) {
625 forward_variables_from(invoker,
626 "*",
627 [
628 "configs",
629 "public_configs",
630 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200631 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800632 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200633 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000634 if (!defined(visibility)) {
635 visibility = webrtc_default_visibility
636 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200637
638 # What's your poison?
639 if (defined(testonly) && testonly) {
640 assert(!defined(poisonous))
641 assert(!defined(allow_poison))
642 } else {
643 if (!defined(poisonous)) {
644 poisonous = []
645 }
646 if (!defined(allow_poison)) {
647 allow_poison = []
648 }
649 if (!defined(assert_no_deps)) {
650 assert_no_deps = []
651 }
652 if (!defined(deps)) {
653 deps = []
654 }
655 foreach(p, poisonous) {
656 deps += [ webrtc_root + ":poison_" + p ]
657 }
658 foreach(poison_type, all_poison_types) {
659 allow_dep = true
660 foreach(v, visibility) {
661 if (v == "*") {
662 allow_dep = false
663 }
664 }
665 foreach(p, allow_poison + poisonous) {
666 if (p == poison_type) {
667 allow_dep = true
668 }
669 }
670 if (!allow_dep) {
671 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
672 }
673 }
674 }
675
Mirko Bonadei96ede162018-09-06 13:45:44 +0200676 if (!defined(testonly) || !testonly) {
677 configs += rtc_prod_configs
678 }
679
mbonadei9aa3f0a2017-01-24 06:58:22 -0800680 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200681 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800682 configs -= rtc_remove_configs
683 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000684 public_configs = [
685 rtc_common_inherited_config,
686 absl_include_config,
687 absl_define_config,
688 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200689 if (defined(testonly) && testonly) {
690 public_configs += [ absl_flags_config ]
691 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800692 if (defined(invoker.public_configs)) {
693 public_configs += invoker.public_configs
694 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200695
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200696 # If absl_deps is [], no action is needed. If not [], then it needs to be
697 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200698 # otherwise it just needs to be added to deps.
699 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200700 if (!defined(deps)) {
701 deps = []
702 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200703 if (build_with_chromium) {
704 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200705 } else {
706 deps += absl_deps
707 }
708 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800709 }
710}
711
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200712# This template automatically switches the target type between source_set
713# and static_library.
714#
715# This should be the default target type for all the WebRTC targets with
716# one exception. Do not use this template for header only targets, in that case
717# rtc_source_set must be used in order to avoid build errors (e.g. libtool
718# complains if the output .a file is empty).
719#
720# How does it work:
721# Since all files in a source_set are linked into a final binary, while files
722# in a static library are only linked in if at least one symbol in them is
723# referenced, in component builds source_sets are easy to deal with because
724# all their object files are passed to the linker to create a shared library.
725# In release builds instead, static_libraries are preferred since they allow
726# the linker to discard dead code.
727# For the same reason, testonly targets will always be expanded to
728# source_set in order to be sure that tests are present in the test binary.
729template("rtc_library") {
730 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
731 target_type = "source_set"
732 } else {
733 target_type = "static_library"
734 }
735 target(target_type, target_name) {
736 forward_variables_from(invoker,
737 "*",
738 [
739 "configs",
740 "public_configs",
741 "suppressed_configs",
742 "visibility",
743 ])
744 forward_variables_from(invoker, [ "visibility" ])
745 if (!defined(visibility)) {
746 visibility = webrtc_default_visibility
747 }
748
749 # What's your poison?
750 if (defined(testonly) && testonly) {
751 assert(!defined(poisonous))
752 assert(!defined(allow_poison))
753 } else {
754 if (!defined(poisonous)) {
755 poisonous = []
756 }
757 if (!defined(allow_poison)) {
758 allow_poison = []
759 }
760 if (!defined(assert_no_deps)) {
761 assert_no_deps = []
762 }
763 if (!defined(deps)) {
764 deps = []
765 }
766 foreach(p, poisonous) {
767 deps += [ webrtc_root + ":poison_" + p ]
768 }
769 foreach(poison_type, all_poison_types) {
770 allow_dep = true
771 foreach(v, visibility) {
772 if (v == "*") {
773 allow_dep = false
774 }
775 }
776 foreach(p, allow_poison + poisonous) {
777 if (p == poison_type) {
778 allow_dep = true
779 }
780 }
781 if (!allow_dep) {
782 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
783 }
784 }
785 }
786
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100787 # Chromium should only depend on the WebRTC component in order to
788 # avoid to statically link WebRTC in a component build.
789 if (build_with_chromium) {
790 publicly_visible = false
791 foreach(v, visibility) {
792 if (v == "*") {
793 publicly_visible = true
794 }
795 }
796 if (publicly_visible) {
797 visibility = []
798 visibility = webrtc_default_visibility
799 }
800 }
801
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200802 if (!defined(testonly) || !testonly) {
803 configs += rtc_prod_configs
804 }
805
806 configs += invoker.configs
807 configs += rtc_library_impl_config
808 configs -= rtc_remove_configs
809 configs -= invoker.suppressed_configs
810 public_configs = [
811 rtc_common_inherited_config,
812 absl_include_config,
813 absl_define_config,
814 ]
815 if (defined(testonly) && testonly) {
816 public_configs += [ absl_flags_config ]
817 }
818 if (defined(invoker.public_configs)) {
819 public_configs += invoker.public_configs
820 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200821
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200822 # If absl_deps is [], no action is needed. If not [], then it needs to be
823 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200824 # otherwise it just needs to be added to deps.
825 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200826 if (!defined(deps)) {
827 deps = []
828 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200829 if (build_with_chromium) {
830 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200831 } else {
832 deps += absl_deps
833 }
834 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200835 }
836}
837
838template("rtc_executable") {
839 executable(target_name) {
840 forward_variables_from(invoker,
841 "*",
842 [
843 "deps",
844 "configs",
845 "public_configs",
846 "suppressed_configs",
847 "visibility",
848 ])
849 forward_variables_from(invoker, [ "visibility" ])
850 if (!defined(visibility)) {
851 visibility = webrtc_default_visibility
852 }
853 configs += invoker.configs
854 configs -= rtc_remove_configs
855 configs -= invoker.suppressed_configs
856 deps = invoker.deps
857
858 public_configs = [
859 rtc_common_inherited_config,
860 absl_include_config,
861 absl_define_config,
862 ]
863 if (defined(testonly) && testonly) {
864 public_configs += [ absl_flags_config ]
865 }
866 if (defined(invoker.public_configs)) {
867 public_configs += invoker.public_configs
868 }
869 if (is_win) {
870 deps += [
871 # Give executables the default manifest on Windows (a no-op elsewhere).
872 "//build/win:default_exe_manifest",
873 ]
874 }
875 }
876}
877
mbonadei9aa3f0a2017-01-24 06:58:22 -0800878template("rtc_shared_library") {
879 shared_library(target_name) {
880 forward_variables_from(invoker,
881 "*",
882 [
883 "configs",
884 "public_configs",
885 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200886 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800887 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200888 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000889 if (!defined(visibility)) {
890 visibility = webrtc_default_visibility
891 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200892
893 # What's your poison?
894 if (defined(testonly) && testonly) {
895 assert(!defined(poisonous))
896 assert(!defined(allow_poison))
897 } else {
898 if (!defined(poisonous)) {
899 poisonous = []
900 }
901 if (!defined(allow_poison)) {
902 allow_poison = []
903 }
904 if (!defined(assert_no_deps)) {
905 assert_no_deps = []
906 }
907 if (!defined(deps)) {
908 deps = []
909 }
910 foreach(p, poisonous) {
911 deps += [ webrtc_root + ":poison_" + p ]
912 }
913 foreach(poison_type, all_poison_types) {
914 allow_dep = true
915 foreach(v, visibility) {
916 if (v == "*") {
917 allow_dep = false
918 }
919 }
920 foreach(p, allow_poison + poisonous) {
921 if (p == poison_type) {
922 allow_dep = true
923 }
924 }
925 if (!allow_dep) {
926 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
927 }
928 }
929 }
930
mbonadei9aa3f0a2017-01-24 06:58:22 -0800931 configs += invoker.configs
932 configs -= rtc_remove_configs
933 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000934 public_configs = [
935 rtc_common_inherited_config,
936 absl_include_config,
937 absl_define_config,
938 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200939 if (defined(testonly) && testonly) {
940 public_configs += [ absl_flags_config ]
941 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800942 if (defined(invoker.public_configs)) {
943 public_configs += invoker.public_configs
944 }
945 }
946}
kthelgason4065a572017-02-14 04:58:56 -0800947
948if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400949 # TODO: Generate module.modulemap file to enable use in Swift
950 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100951 template("ios_framework_bundle_with_umbrella_header") {
952 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900953 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100954 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900955 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
956
957 action_foreach("create_bracket_include_headers_$target_name") {
958 script = "//tools_webrtc/apple/copy_framework_header.py"
959 sources = invoker.sources
960 output_name = invoker.output_name
961 outputs = [
962 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
963 ]
964 args = [
965 "--input",
966 "{{source}}",
967 "--output",
968 rebase_path(target_gen_dir, root_build_dir) +
969 "/$output_name.framework/WebRTC/{{source_file_part}}",
970 ]
971 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100972
973 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900974 forward_variables_from(invoker, "*", [ "public_headers" ])
975 public_headers = get_target_outputs(
976 ":create_bracket_include_headers_$this_target_name")
977 deps += [
978 ":copy_umbrella_header_$target_name",
979 ":create_bracket_include_headers_$target_name",
980 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100981 }
982
983 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900984 public_headers = get_target_outputs(
985 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100986
987 script = "//tools_webrtc/ios/generate_umbrella_header.py"
988
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100989 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100990 args = [
991 "--out",
992 rebase_path(umbrella_header_path, root_build_dir),
993 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200994 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900995 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100996 }
997
998 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100999 sources = [ umbrella_header_path ]
1000 outputs =
1001 [ "$root_out_dir/$output_name.framework/Headers/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001002
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001003 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001004 }
1005 }
1006
1007 set_defaults("ios_framework_bundle_with_umbrella_header") {
1008 configs = default_shared_library_configs
1009 }
kthelgason4065a572017-02-14 04:58:56 -08001010}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001011
Anders Carlsson37bbf792018-09-05 16:29:27 +02001012if (is_mac) {
1013 template("mac_framework_bundle_with_umbrella_header") {
1014 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001015 this_target_name = target_name
1016 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001017 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +02001018
1019 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -08001020 forward_variables_from(invoker, "*", [ "configs" ])
1021 if (defined(invoker.configs)) {
1022 configs += invoker.configs
1023 }
Anders Carlsson37bbf792018-09-05 16:29:27 +02001024
1025 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001026 framework_contents = [
1027 "Headers",
1028 "Modules",
1029 "Resources",
1030 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001031
1032 ldflags = [
1033 "-all_load",
1034 "-install_name",
1035 "@rpath/$output_name.framework/$output_name",
1036 ]
1037
1038 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001039 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001040 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001041 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001042 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001043 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001044 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001045 ]
1046 }
1047
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001048 action_foreach("create_bracket_include_headers_$this_target_name") {
1049 script = "//tools_webrtc/apple/copy_framework_header.py"
1050 sources = invoker.sources
1051 output_name = invoker.output_name
1052 outputs = [
1053 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1054 ]
1055 args = [
1056 "--input",
1057 "{{source}}",
1058 "--output",
1059 rebase_path(target_gen_dir, root_build_dir) +
1060 "/$output_name.framework/WebRTC/{{source_file_part}}",
1061 ]
1062 }
1063
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001064 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001065 sources = get_target_outputs(
1066 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001067
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001068 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001069 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001070 }
1071
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001072 action("modulemap_$this_target_name") {
1073 script = "//tools_webrtc/ios/generate_modulemap.py"
1074 args = [
1075 "--out",
1076 rebase_path(modulemap_path, root_build_dir),
1077 "--name",
1078 output_name,
1079 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001080 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001081 }
1082
1083 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001084 sources = [ modulemap_path ]
1085 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1086 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001087 }
1088
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001089 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001090 sources = get_target_outputs(
1091 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001092
1093 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1094
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001095 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001096 args = [
1097 "--out",
1098 rebase_path(umbrella_header_path, root_build_dir),
1099 "--sources",
1100 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001101 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001102 }
1103
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001104 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001105 sources = [ umbrella_header_path ]
1106 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001107
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001108 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001109 }
1110 }
1111}
1112
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001113if (is_android) {
1114 template("rtc_android_library") {
1115 android_library(target_name) {
1116 forward_variables_from(invoker,
1117 "*",
1118 [
1119 "configs",
1120 "public_configs",
1121 "suppressed_configs",
1122 "visibility",
1123 ])
1124
Oleh Prypin05aee742018-11-23 17:29:44 +01001125 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001126
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001127 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001128 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001129
1130 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001131 if (defined(invoker.errorprone_args)) {
1132 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001133 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001134
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001135 if (!defined(deps)) {
1136 deps = []
1137 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001138
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001139 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001140 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001141 }
1142 }
1143
1144 template("rtc_android_apk") {
1145 android_apk(target_name) {
1146 forward_variables_from(invoker,
1147 "*",
1148 [
1149 "configs",
1150 "public_configs",
1151 "suppressed_configs",
1152 "visibility",
1153 ])
1154
1155 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001156 errorprone_args = []
1157 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001158
1159 if (!defined(deps)) {
1160 deps = []
1161 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001162
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001163 no_build_hooks = true
1164 }
1165 }
1166
1167 template("rtc_instrumentation_test_apk") {
1168 instrumentation_test_apk(target_name) {
1169 forward_variables_from(invoker,
1170 "*",
1171 [
1172 "configs",
1173 "public_configs",
1174 "suppressed_configs",
1175 "visibility",
1176 ])
1177
1178 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001179 errorprone_args = []
1180 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001181
1182 if (!defined(deps)) {
1183 deps = []
1184 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001185
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001186 no_build_hooks = true
1187 }
1188 }
1189}