blob: b4ed469e227c55f5b3c86c332343534a7a1ec461 [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
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070062 # Setting this to false will require the API user to pass in their own
63 # SSLCertificateVerifier to verify the certificates presented from a
64 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
65 rtc_builtin_ssl_root_certificates = true
66
Karl Wibergeb254b42017-11-01 15:08:12 +010067 # Include the iLBC audio codec?
Olga Sharonova5fbd7582020-07-09 09:50:42 +000068 rtc_include_ilbc = true
Karl Wibergeb254b42017-11-01 15:08:12 +010069
mbonadei9aa3f0a2017-01-24 06:58:22 -080070 # Disable this to avoid building the Opus audio codec.
71 rtc_include_opus = true
72
minyue2e03c662017-02-01 17:31:11 -080073 # Enable this if the Opus version upon which WebRTC is built supports direct
74 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020075 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080076
mbonadei9aa3f0a2017-01-24 06:58:22 -080077 # Enable this to let the Opus audio codec change complexity on the fly.
78 rtc_opus_variable_complexity = false
79
mbonadei9aa3f0a2017-01-24 06:58:22 -080080 # Used to specify an external Jsoncpp include path when not compiling the
81 # library that comes with WebRTC (i.e. rtc_build_json == 0).
82 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
83
84 # Used to specify an external OpenSSL include path when not compiling the
85 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
86 rtc_ssl_root = ""
87
mbonadei9aa3f0a2017-01-24 06:58:22 -080088 # Enable when an external authentication mechanism is used for performing
89 # packet authentication for RTP packets instead of libsrtp.
90 rtc_enable_external_auth = build_with_chromium
91
92 # Selects whether debug dumps for the audio processing module
93 # should be generated.
94 apm_debug_dump = false
95
Per Åhgrencc73ed32020-04-26 23:56:17 +020096 # Selects whether the audio processing module should be excluded.
97 rtc_exclude_audio_processing_module = false
98
mbonadei9aa3f0a2017-01-24 06:58:22 -080099 # Set this to true to enable BWE test logging.
100 rtc_enable_bwe_test_logging = false
101
Joachim Bauch93e91342017-12-07 01:25:53 +0100102 # Set this to false to skip building examples.
103 rtc_build_examples = true
104
105 # Set this to false to skip building tools.
106 rtc_build_tools = true
107
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100108 # Set this to false to skip building code that requires X11.
109 rtc_use_x11 = use_x11
110
Tomas Popela318da512018-11-13 06:32:23 +0100111 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 14:37:51 +0100112 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
113 # only when using the sysroot as PipeWire is not available in older and
114 # supported Ubuntu and Debian distributions.
Xiaohan Wang9f32f3b2020-10-01 14:46:54 -0700115 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 14:37:51 +0100116
117 # Set this to link PipeWire directly instead of using the dlopen.
118 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 06:32:23 +0100119
Jan Grulichc3c81292020-12-02 09:03:34 +0100120 # Set this to use certain PipeWire version
Jan Grulich14b036d2021-02-04 09:53:20 +0100121 # Currently WebRTC supports PipeWire 0.2 and PipeWire 0.3 (default)
122 rtc_pipewire_version = "0.3"
Jan Grulichc3c81292020-12-02 09:03:34 +0100123
mbonadei9aa3f0a2017-01-24 06:58:22 -0800124 # Enable to use the Mozilla internal settings.
125 build_with_mozilla = false
126
Philipp Hanckee95ebda2020-09-17 16:13:20 +0200127 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
128 # and NDK r16 or above.
henrika883d00f2018-03-16 10:09:49 +0100129 rtc_enable_android_aaudio = false
130
mbonadei9aa3f0a2017-01-24 06:58:22 -0800131 # Set to "func", "block", "edge" for coverage generation.
132 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
133 # It is recommend to set include_examples=0.
134 # Use llvm's sancov -html-report for human readable reports.
135 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
136 rtc_sanitize_coverage = ""
137
Philipp Hanckeaeac9f82020-09-11 11:58:18 +0200138 # Selects fixed-point code where possible.
139 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800140 if (current_cpu == "arm" || current_cpu == "arm64") {
141 rtc_prefer_fixed_point = true
142 }
143
mbonadei9aa3f0a2017-01-24 06:58:22 -0800144 # Determines whether NEON code will be built.
145 rtc_build_with_neon =
146 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
147
148 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
149 # all platforms except Android and iOS. Because FFmpeg can be built
150 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
151 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200152 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800153 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
154 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100155 #
156 # Enabling H264 when building with MSVC is currently not supported, see
157 # bugs.webrtc.org/9213#c13 for more info.
158 rtc_use_h264 =
159 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800160
Markus Handell8e75bd42020-06-05 11:47:40 +0200161 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
162 rtc_use_absl_mutex = false
163
mbonadei9aa3f0a2017-01-24 06:58:22 -0800164 # By default, use normal platform audio support or dummy audio, but don't
165 # use file-based audio playout and record.
166 rtc_use_dummy_audio_file_devices = false
167
henrika7be78832017-06-13 17:34:16 +0200168 # When set to true, replace the audio output with a sinus tone at 440Hz.
169 # The ADM will ask for audio data from WebRTC but instead of reading real
170 # audio samples from NetEQ, a sinus tone will be generated and replace the
171 # real audio samples.
172 rtc_audio_device_plays_sinus_tone = false
173
Anders Carlsson358f2e02018-06-04 10:24:37 +0200174 if (is_ios) {
175 # Build broadcast extension in AppRTCMobile for iOS. This results in the
176 # binary only running on iOS 11+, which is why it is disabled by default.
177 rtc_apprtcmobile_broadcast_extension = false
178 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200179
180 # Determines whether Metal is available on iOS/macOS.
181 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Jiawei Ou08745302019-02-12 11:36:13 -0800182
183 # When set to false, builtin audio encoder/decoder factories and all the
184 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
185 # (they will still be included in libjingle_peerconnection_so.so and
186 # WebRTC.framework)
187 rtc_include_builtin_audio_codecs = true
188
189 # When set to false, builtin video encoder/decoder factories and all the
190 # video codecs they depends 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_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100194
195 # When set to true and in a standalone build, it will undefine UNICODE and
196 # _UNICODE (which are always defined globally by the Chromium Windows
197 # toolchain).
198 # This is only needed for testing purposes, WebRTC wants to be sure it
199 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
200 # wide character functions.
201 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 13:47:54 -0700202
203 # When set to true, a capturer implementation that uses the
204 # Windows.Graphics.Capture APIs will be available for use. These APIs are
205 # available in the Win 10 SDK v10.0.19041.
206 rtc_enable_win_wgc = false
Dan Minor9c686132018-01-15 10:20:00 -0500207}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800208
Dan Minor9c686132018-01-15 10:20:00 -0500209if (!build_with_mozilla) {
210 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800211}
212
213# A second declare_args block, so that declarations within it can
214# depend on the possibly overridden variables in the first
215# declare_args block.
216declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500217 # Enables the use of protocol buffers for debug recordings.
218 rtc_enable_protobuf = !build_with_mozilla
219
220 # Set this to disable building with support for SCTP data channels.
221 rtc_enable_sctp = !build_with_mozilla
222
223 # Disable these to not build components which can be externally provided.
224 rtc_build_json = !build_with_mozilla
225 rtc_build_libsrtp = !build_with_mozilla
226 rtc_build_libvpx = !build_with_mozilla
227 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500228 rtc_build_opus = !build_with_mozilla
229 rtc_build_ssl = !build_with_mozilla
230 rtc_build_usrsctp = !build_with_mozilla
231
232 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200233 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
234 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500235 rtc_enable_libevent = false
236 rtc_build_libevent = false
237 } else {
238 rtc_enable_libevent = true
239 rtc_build_libevent = !build_with_mozilla
240 }
241
Dan Minor9c686132018-01-15 10:20:00 -0500242 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
243 # build environments, even if available for Chromium builds.
244 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
245
mbonadei9aa3f0a2017-01-24 06:58:22 -0800246 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
247 rtc_include_pulse_audio = !build_with_chromium
248
249 # Chromium uses its own IO handling, so the internal ADM is only built for
250 # standalone WebRTC.
251 rtc_include_internal_audio_device = !build_with_chromium
252
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800253 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 12:02:32 +0200254 # TODO: Make sure that AVX2 works also for non-clang compilers.
255 if (is_clang == true) {
256 rtc_enable_avx2 = true
257 } else {
258 rtc_enable_avx2 = false
259 }
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800260
mbonadei9aa3f0a2017-01-24 06:58:22 -0800261 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500262 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200263
264 # Set this to false to skip building code that also requires X11 extensions
265 # such as Xdamage, Xfixes.
266 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100267
268 # Set this to true to fully remove logging from WebRTC.
269 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100270
271 # Set this to true to disable trace events.
272 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100273
274 # Set this to true to disable detailed error message and logging for
275 # RTC_CHECKs.
276 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100277
278 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100279 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200280
281 # Set this to true to exclude the transient suppressor in the audio processing
282 # module from the build.
283 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800284}
285
286# Make it possible to provide custom locations for some libraries (move these
287# up into declare_args should we need to actually use them for the GN build).
288rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800289rtc_opus_dir = "//third_party/opus"
290
291# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200292rtc_desktop_capture_supported =
293 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900294 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800295
296###############################################################################
297# Templates
298#
299
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200300# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800301# chromium.
302# We need absolute paths for all configs in templates as they are shared in
303# different subdirectories.
304webrtc_root = get_path_info(".", "abspath")
305
306# Global configuration that should be applied to all WebRTC targets.
307# You normally shouldn't need to include this in your target as it's
308# automatically included when using the rtc_* templates.
309# It sets defines, include paths and compilation warnings accordingly,
310# both for WebRTC stand-alone builds and for the scenario when WebRTC
311# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700312rtc_common_configs = [
313 webrtc_root + ":common_config",
314 "//build/config/compiler:no_size_t_to_int_warning",
315]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800316
kthelgasonc0977102017-04-24 00:57:16 -0700317if (is_mac || is_ios) {
318 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
319}
320
mbonadei9aa3f0a2017-01-24 06:58:22 -0800321# Global public configuration that should be applied to all WebRTC targets. You
322# normally shouldn't need to include this in your target as it's automatically
323# included when using the rtc_* templates. It set the defines, include paths and
324# compilation warnings that should be propagated to dependents of the targets
325# depending on the target having this config.
326rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
327
328# Common configs to remove or add in all rtc targets.
329rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100330if (!build_with_chromium && is_clang) {
331 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
332}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800333rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200334rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200335rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800336
337set_defaults("rtc_test") {
338 configs = rtc_add_configs
339 suppressed_configs = []
340}
341
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200342set_defaults("rtc_library") {
343 configs = rtc_add_configs
344 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200345 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200346}
347
mbonadei9aa3f0a2017-01-24 06:58:22 -0800348set_defaults("rtc_source_set") {
349 configs = rtc_add_configs
350 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200351 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800352}
353
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200354set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800355 configs = rtc_add_configs
356 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200357 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800358}
359
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200360set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800361 configs = rtc_add_configs
362 suppressed_configs = []
363}
364
365set_defaults("rtc_shared_library") {
366 configs = rtc_add_configs
367 suppressed_configs = []
368}
369
Per Kjellandera7f2d842018-01-10 15:54:53 +0000370webrtc_default_visibility = [ webrtc_root + "/*" ]
371if (build_with_chromium) {
372 # Allow Chromium's WebRTC overrides targets to bypass the regular
373 # visibility restrictions.
374 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
375}
376
Karl Wibergbb23c832018-04-22 19:55:00 +0200377# ---- Poisons ----
378#
379# The general idea is that some targets declare that they contain some
380# kind of poison, which makes it impossible for other targets to
381# depend on them (even transitively) unless they declare themselves
382# immune to that particular type of poison.
383#
384# Targets that *contain* poison of type foo should contain the line
385#
386# poisonous = [ "foo" ]
387#
388# and targets that *are immune but arent't themselves poisonous*
389# should contain
390#
391# allow_poison = [ "foo" ]
392#
393# This useful in cases where we have some large target or set of
394# targets and want to ensure that most other targets do not
395# transitively depend on them. For example, almost no high-level
396# target should depend on the audio codecs, since we want WebRTC users
397# to be able to inject any subset of them and actually end up with a
398# binary that doesn't include the codecs they didn't inject.
399#
400# Test-only targets (`testonly` set to true) and non-public targets
401# (`visibility` not containing "*") are automatically immune to all
402# types of poison.
403#
404# Here's the complete list of all types of poison. It must be kept in
405# 1:1 correspondence with the set of //:poison_* targets.
406#
407all_poison_types = [
408 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
409 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200410
Danil Chapovalov41300af2019-07-10 12:44:43 +0200411 # Default task queue implementation.
412 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200413
414 # JSON parsing should not be needed in the "slim and modular" WebRTC.
415 "rtc_json",
416
417 # Software video codecs (VP8 and VP9 through libvpx).
418 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200419]
420
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000421absl_include_config = "//third_party/abseil-cpp:absl_include_config"
422absl_define_config = "//third_party/abseil-cpp:absl_define_config"
423
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200424# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
425# that are testonly.
426absl_flags_config = webrtc_root + ":absl_flags_configs"
427
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100428# WebRTC wrapper of Chromium's test() template. This template just adds some
429# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
430# target.
431# The parameter `is_xctest` is different from the one in the Chromium's test()
432# template (and it is not forwarded to it). In rtc_test(), the argument
433# `is_xctest` is used to avoid to take dependencies that are not needed
434# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800435template("rtc_test") {
436 test(target_name) {
437 forward_variables_from(invoker,
438 "*",
439 [
440 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100441 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800442 "public_configs",
443 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200444 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800445 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100446
447 # Always override to public because when target_os is Android the `test`
448 # template can override it to [ "*" ] and we want to avoid conditional
449 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100450 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800451 configs += invoker.configs
452 configs -= rtc_remove_configs
453 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000454 public_configs = [
455 rtc_common_inherited_config,
456 absl_include_config,
457 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200458 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000459 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800460 if (defined(invoker.public_configs)) {
461 public_configs += invoker.public_configs
462 }
sakald7fdb802017-05-26 01:51:53 -0700463 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800464 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200465 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200466 target_sdk_version = 23
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800467 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700468 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100469
470 # When not targeting a simulator, building //base/test:google_test_runner
471 # fails, so it is added only when the test is not a real XCTest and when
472 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100473 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100474 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
475 xctest_module_target = "//base/test:google_test_runner"
476 }
477 }
Andrey Logvin78646002021-01-29 10:50:19 +0000478
479 # If absl_deps is [], no action is needed. If not [], then it needs to be
480 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
481 # otherwise it just needs to be added to deps.
482 if (defined(absl_deps) && absl_deps != []) {
483 if (!defined(deps)) {
484 deps = []
485 }
486 if (build_with_chromium) {
487 deps += [ "//third_party/abseil-cpp:absl" ]
488 } else {
489 deps += absl_deps
490 }
491 }
492
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100493 if (using_sanitizer) {
494 if (is_linux) {
495 if (!defined(invoker.data)) {
496 data = []
497 }
498 data +=
499 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
500 }
501 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800502 }
503}
504
505template("rtc_source_set") {
506 source_set(target_name) {
507 forward_variables_from(invoker,
508 "*",
509 [
510 "configs",
511 "public_configs",
512 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200513 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800514 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200515 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000516 if (!defined(visibility)) {
517 visibility = webrtc_default_visibility
518 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200519
520 # What's your poison?
521 if (defined(testonly) && testonly) {
522 assert(!defined(poisonous))
523 assert(!defined(allow_poison))
524 } else {
525 if (!defined(poisonous)) {
526 poisonous = []
527 }
528 if (!defined(allow_poison)) {
529 allow_poison = []
530 }
531 if (!defined(assert_no_deps)) {
532 assert_no_deps = []
533 }
534 if (!defined(deps)) {
535 deps = []
536 }
537 foreach(p, poisonous) {
538 deps += [ webrtc_root + ":poison_" + p ]
539 }
540 foreach(poison_type, all_poison_types) {
541 allow_dep = true
542 foreach(v, visibility) {
543 if (v == "*") {
544 allow_dep = false
545 }
546 }
547 foreach(p, allow_poison + poisonous) {
548 if (p == poison_type) {
549 allow_dep = true
550 }
551 }
552 if (!allow_dep) {
553 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
554 }
555 }
556 }
557
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100558 # Chromium should only depend on the WebRTC component in order to
559 # avoid to statically link WebRTC in a component build.
560 if (build_with_chromium) {
561 publicly_visible = false
562 foreach(v, visibility) {
563 if (v == "*") {
564 publicly_visible = true
565 }
566 }
567 if (publicly_visible) {
568 visibility = []
569 visibility = webrtc_default_visibility
570 }
571 }
572
Mirko Bonadei96ede162018-09-06 13:45:44 +0200573 if (!defined(testonly) || !testonly) {
574 configs += rtc_prod_configs
575 }
576
mbonadei9aa3f0a2017-01-24 06:58:22 -0800577 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200578 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800579 configs -= rtc_remove_configs
580 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000581 public_configs = [
582 rtc_common_inherited_config,
583 absl_include_config,
584 absl_define_config,
585 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200586 if (defined(testonly) && testonly) {
587 public_configs += [ absl_flags_config ]
588 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800589 if (defined(invoker.public_configs)) {
590 public_configs += invoker.public_configs
591 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200592
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200593 # If absl_deps is [], no action is needed. If not [], then it needs to be
594 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200595 # otherwise it just needs to be added to deps.
596 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200597 if (!defined(deps)) {
598 deps = []
599 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200600 if (build_with_chromium) {
601 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200602 } else {
603 deps += absl_deps
604 }
605 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800606 }
607}
608
mbonadei9aa3f0a2017-01-24 06:58:22 -0800609template("rtc_static_library") {
610 static_library(target_name) {
611 forward_variables_from(invoker,
612 "*",
613 [
614 "configs",
615 "public_configs",
616 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200617 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800618 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200619 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000620 if (!defined(visibility)) {
621 visibility = webrtc_default_visibility
622 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200623
624 # What's your poison?
625 if (defined(testonly) && testonly) {
626 assert(!defined(poisonous))
627 assert(!defined(allow_poison))
628 } else {
629 if (!defined(poisonous)) {
630 poisonous = []
631 }
632 if (!defined(allow_poison)) {
633 allow_poison = []
634 }
635 if (!defined(assert_no_deps)) {
636 assert_no_deps = []
637 }
638 if (!defined(deps)) {
639 deps = []
640 }
641 foreach(p, poisonous) {
642 deps += [ webrtc_root + ":poison_" + p ]
643 }
644 foreach(poison_type, all_poison_types) {
645 allow_dep = true
646 foreach(v, visibility) {
647 if (v == "*") {
648 allow_dep = false
649 }
650 }
651 foreach(p, allow_poison + poisonous) {
652 if (p == poison_type) {
653 allow_dep = true
654 }
655 }
656 if (!allow_dep) {
657 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
658 }
659 }
660 }
661
Mirko Bonadei96ede162018-09-06 13:45:44 +0200662 if (!defined(testonly) || !testonly) {
663 configs += rtc_prod_configs
664 }
665
mbonadei9aa3f0a2017-01-24 06:58:22 -0800666 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200667 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800668 configs -= rtc_remove_configs
669 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000670 public_configs = [
671 rtc_common_inherited_config,
672 absl_include_config,
673 absl_define_config,
674 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200675 if (defined(testonly) && testonly) {
676 public_configs += [ absl_flags_config ]
677 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800678 if (defined(invoker.public_configs)) {
679 public_configs += invoker.public_configs
680 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200681
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200682 # If absl_deps is [], no action is needed. If not [], then it needs to be
683 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200684 # otherwise it just needs to be added to deps.
685 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200686 if (!defined(deps)) {
687 deps = []
688 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200689 if (build_with_chromium) {
690 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200691 } else {
692 deps += absl_deps
693 }
694 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800695 }
696}
697
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200698# This template automatically switches the target type between source_set
699# and static_library.
700#
701# This should be the default target type for all the WebRTC targets with
702# one exception. Do not use this template for header only targets, in that case
703# rtc_source_set must be used in order to avoid build errors (e.g. libtool
704# complains if the output .a file is empty).
705#
706# How does it work:
707# Since all files in a source_set are linked into a final binary, while files
708# in a static library are only linked in if at least one symbol in them is
709# referenced, in component builds source_sets are easy to deal with because
710# all their object files are passed to the linker to create a shared library.
711# In release builds instead, static_libraries are preferred since they allow
712# the linker to discard dead code.
713# For the same reason, testonly targets will always be expanded to
714# source_set in order to be sure that tests are present in the test binary.
715template("rtc_library") {
716 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
717 target_type = "source_set"
718 } else {
719 target_type = "static_library"
720 }
721 target(target_type, target_name) {
722 forward_variables_from(invoker,
723 "*",
724 [
725 "configs",
726 "public_configs",
727 "suppressed_configs",
728 "visibility",
729 ])
730 forward_variables_from(invoker, [ "visibility" ])
731 if (!defined(visibility)) {
732 visibility = webrtc_default_visibility
733 }
734
735 # What's your poison?
736 if (defined(testonly) && testonly) {
737 assert(!defined(poisonous))
738 assert(!defined(allow_poison))
739 } else {
740 if (!defined(poisonous)) {
741 poisonous = []
742 }
743 if (!defined(allow_poison)) {
744 allow_poison = []
745 }
746 if (!defined(assert_no_deps)) {
747 assert_no_deps = []
748 }
749 if (!defined(deps)) {
750 deps = []
751 }
752 foreach(p, poisonous) {
753 deps += [ webrtc_root + ":poison_" + p ]
754 }
755 foreach(poison_type, all_poison_types) {
756 allow_dep = true
757 foreach(v, visibility) {
758 if (v == "*") {
759 allow_dep = false
760 }
761 }
762 foreach(p, allow_poison + poisonous) {
763 if (p == poison_type) {
764 allow_dep = true
765 }
766 }
767 if (!allow_dep) {
768 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
769 }
770 }
771 }
772
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100773 # Chromium should only depend on the WebRTC component in order to
774 # avoid to statically link WebRTC in a component build.
775 if (build_with_chromium) {
776 publicly_visible = false
777 foreach(v, visibility) {
778 if (v == "*") {
779 publicly_visible = true
780 }
781 }
782 if (publicly_visible) {
783 visibility = []
784 visibility = webrtc_default_visibility
785 }
786 }
787
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200788 if (!defined(testonly) || !testonly) {
789 configs += rtc_prod_configs
790 }
791
792 configs += invoker.configs
793 configs += rtc_library_impl_config
794 configs -= rtc_remove_configs
795 configs -= invoker.suppressed_configs
796 public_configs = [
797 rtc_common_inherited_config,
798 absl_include_config,
799 absl_define_config,
800 ]
801 if (defined(testonly) && testonly) {
802 public_configs += [ absl_flags_config ]
803 }
804 if (defined(invoker.public_configs)) {
805 public_configs += invoker.public_configs
806 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200807
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200808 # If absl_deps is [], no action is needed. If not [], then it needs to be
809 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200810 # otherwise it just needs to be added to deps.
811 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200812 if (!defined(deps)) {
813 deps = []
814 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200815 if (build_with_chromium) {
816 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200817 } else {
818 deps += absl_deps
819 }
820 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200821 }
822}
823
824template("rtc_executable") {
825 executable(target_name) {
826 forward_variables_from(invoker,
827 "*",
828 [
829 "deps",
830 "configs",
831 "public_configs",
832 "suppressed_configs",
833 "visibility",
834 ])
835 forward_variables_from(invoker, [ "visibility" ])
836 if (!defined(visibility)) {
837 visibility = webrtc_default_visibility
838 }
839 configs += invoker.configs
840 configs -= rtc_remove_configs
841 configs -= invoker.suppressed_configs
842 deps = invoker.deps
843
844 public_configs = [
845 rtc_common_inherited_config,
846 absl_include_config,
847 absl_define_config,
848 ]
849 if (defined(testonly) && testonly) {
850 public_configs += [ absl_flags_config ]
851 }
852 if (defined(invoker.public_configs)) {
853 public_configs += invoker.public_configs
854 }
855 if (is_win) {
856 deps += [
857 # Give executables the default manifest on Windows (a no-op elsewhere).
858 "//build/win:default_exe_manifest",
859 ]
860 }
861 }
862}
863
mbonadei9aa3f0a2017-01-24 06:58:22 -0800864template("rtc_shared_library") {
865 shared_library(target_name) {
866 forward_variables_from(invoker,
867 "*",
868 [
869 "configs",
870 "public_configs",
871 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200872 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800873 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200874 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000875 if (!defined(visibility)) {
876 visibility = webrtc_default_visibility
877 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200878
879 # What's your poison?
880 if (defined(testonly) && testonly) {
881 assert(!defined(poisonous))
882 assert(!defined(allow_poison))
883 } else {
884 if (!defined(poisonous)) {
885 poisonous = []
886 }
887 if (!defined(allow_poison)) {
888 allow_poison = []
889 }
890 if (!defined(assert_no_deps)) {
891 assert_no_deps = []
892 }
893 if (!defined(deps)) {
894 deps = []
895 }
896 foreach(p, poisonous) {
897 deps += [ webrtc_root + ":poison_" + p ]
898 }
899 foreach(poison_type, all_poison_types) {
900 allow_dep = true
901 foreach(v, visibility) {
902 if (v == "*") {
903 allow_dep = false
904 }
905 }
906 foreach(p, allow_poison + poisonous) {
907 if (p == poison_type) {
908 allow_dep = true
909 }
910 }
911 if (!allow_dep) {
912 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
913 }
914 }
915 }
916
mbonadei9aa3f0a2017-01-24 06:58:22 -0800917 configs += invoker.configs
918 configs -= rtc_remove_configs
919 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000920 public_configs = [
921 rtc_common_inherited_config,
922 absl_include_config,
923 absl_define_config,
924 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200925 if (defined(testonly) && testonly) {
926 public_configs += [ absl_flags_config ]
927 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800928 if (defined(invoker.public_configs)) {
929 public_configs += invoker.public_configs
930 }
931 }
932}
kthelgason4065a572017-02-14 04:58:56 -0800933
934if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400935 # TODO: Generate module.modulemap file to enable use in Swift
936 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100937 template("ios_framework_bundle_with_umbrella_header") {
938 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900939 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100940 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900941 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
942
943 action_foreach("create_bracket_include_headers_$target_name") {
944 script = "//tools_webrtc/apple/copy_framework_header.py"
945 sources = invoker.sources
946 output_name = invoker.output_name
947 outputs = [
948 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
949 ]
950 args = [
951 "--input",
952 "{{source}}",
953 "--output",
954 rebase_path(target_gen_dir, root_build_dir) +
955 "/$output_name.framework/WebRTC/{{source_file_part}}",
956 ]
957 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100958
959 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900960 forward_variables_from(invoker, "*", [ "public_headers" ])
961 public_headers = get_target_outputs(
962 ":create_bracket_include_headers_$this_target_name")
963 deps += [
964 ":copy_umbrella_header_$target_name",
965 ":create_bracket_include_headers_$target_name",
966 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100967 }
968
969 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900970 public_headers = get_target_outputs(
971 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100972
973 script = "//tools_webrtc/ios/generate_umbrella_header.py"
974
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100975 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100976 args = [
977 "--out",
978 rebase_path(umbrella_header_path, root_build_dir),
979 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200980 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900981 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100982 }
983
984 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100985 sources = [ umbrella_header_path ]
986 outputs =
987 [ "$root_out_dir/$output_name.framework/Headers/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100988
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100989 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100990 }
991 }
992
993 set_defaults("ios_framework_bundle_with_umbrella_header") {
994 configs = default_shared_library_configs
995 }
kthelgason4065a572017-02-14 04:58:56 -0800996}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000997
Anders Carlsson37bbf792018-09-05 16:29:27 +0200998if (is_mac) {
999 template("mac_framework_bundle_with_umbrella_header") {
1000 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001001 this_target_name = target_name
1002 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001003 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +02001004
1005 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -08001006 forward_variables_from(invoker, "*", [ "configs" ])
1007 if (defined(invoker.configs)) {
1008 configs += invoker.configs
1009 }
Anders Carlsson37bbf792018-09-05 16:29:27 +02001010
1011 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001012 framework_contents = [
1013 "Headers",
1014 "Modules",
1015 "Resources",
1016 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001017
1018 ldflags = [
1019 "-all_load",
1020 "-install_name",
1021 "@rpath/$output_name.framework/$output_name",
1022 ]
1023
1024 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001025 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001026 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001027 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001028 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001029 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001030 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001031 ]
1032 }
1033
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001034 action_foreach("create_bracket_include_headers_$this_target_name") {
1035 script = "//tools_webrtc/apple/copy_framework_header.py"
1036 sources = invoker.sources
1037 output_name = invoker.output_name
1038 outputs = [
1039 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1040 ]
1041 args = [
1042 "--input",
1043 "{{source}}",
1044 "--output",
1045 rebase_path(target_gen_dir, root_build_dir) +
1046 "/$output_name.framework/WebRTC/{{source_file_part}}",
1047 ]
1048 }
1049
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001050 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001051 sources = get_target_outputs(
1052 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001053
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001054 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001055 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001056 }
1057
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001058 action("modulemap_$this_target_name") {
1059 script = "//tools_webrtc/ios/generate_modulemap.py"
1060 args = [
1061 "--out",
1062 rebase_path(modulemap_path, root_build_dir),
1063 "--name",
1064 output_name,
1065 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001066 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001067 }
1068
1069 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001070 sources = [ modulemap_path ]
1071 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1072 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001073 }
1074
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001075 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001076 sources = get_target_outputs(
1077 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001078
1079 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1080
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001081 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001082 args = [
1083 "--out",
1084 rebase_path(umbrella_header_path, root_build_dir),
1085 "--sources",
1086 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001087 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001088 }
1089
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001090 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001091 sources = [ umbrella_header_path ]
1092 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001093
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001094 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001095 }
1096 }
1097}
1098
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001099if (is_android) {
1100 template("rtc_android_library") {
1101 android_library(target_name) {
1102 forward_variables_from(invoker,
1103 "*",
1104 [
1105 "configs",
1106 "public_configs",
1107 "suppressed_configs",
1108 "visibility",
1109 ])
1110
Oleh Prypin05aee742018-11-23 17:29:44 +01001111 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001112
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001113 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001114 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001115
1116 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001117 if (defined(invoker.errorprone_args)) {
1118 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001119 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001120
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001121 if (!defined(deps)) {
1122 deps = []
1123 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001124
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001125 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001126 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001127 }
1128 }
1129
1130 template("rtc_android_apk") {
1131 android_apk(target_name) {
1132 forward_variables_from(invoker,
1133 "*",
1134 [
1135 "configs",
1136 "public_configs",
1137 "suppressed_configs",
1138 "visibility",
1139 ])
1140
1141 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001142 errorprone_args = []
1143 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001144
1145 if (!defined(deps)) {
1146 deps = []
1147 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001148
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001149 no_build_hooks = true
1150 }
1151 }
1152
1153 template("rtc_instrumentation_test_apk") {
1154 instrumentation_test_apk(target_name) {
1155 forward_variables_from(invoker,
1156 "*",
1157 [
1158 "configs",
1159 "public_configs",
1160 "suppressed_configs",
1161 "visibility",
1162 ])
1163
1164 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001165 errorprone_args = []
1166 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001167
1168 if (!defined(deps)) {
1169 deps = []
1170 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001171
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001172 no_build_hooks = true
1173 }
1174 }
1175}