blob: bf2343a847d05f4f275a8282c89b8f6a587fcf77 [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
121 # Currently we support PipeWire 0.2 (default) and PipeWire 0.3
122 rtc_pipewire_version = "0.2"
123
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 }
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100478 if (using_sanitizer) {
479 if (is_linux) {
480 if (!defined(invoker.data)) {
481 data = []
482 }
483 data +=
484 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
485 }
486 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800487 }
488}
489
490template("rtc_source_set") {
491 source_set(target_name) {
492 forward_variables_from(invoker,
493 "*",
494 [
495 "configs",
496 "public_configs",
497 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200498 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800499 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200500 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000501 if (!defined(visibility)) {
502 visibility = webrtc_default_visibility
503 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200504
505 # What's your poison?
506 if (defined(testonly) && testonly) {
507 assert(!defined(poisonous))
508 assert(!defined(allow_poison))
509 } else {
510 if (!defined(poisonous)) {
511 poisonous = []
512 }
513 if (!defined(allow_poison)) {
514 allow_poison = []
515 }
516 if (!defined(assert_no_deps)) {
517 assert_no_deps = []
518 }
519 if (!defined(deps)) {
520 deps = []
521 }
522 foreach(p, poisonous) {
523 deps += [ webrtc_root + ":poison_" + p ]
524 }
525 foreach(poison_type, all_poison_types) {
526 allow_dep = true
527 foreach(v, visibility) {
528 if (v == "*") {
529 allow_dep = false
530 }
531 }
532 foreach(p, allow_poison + poisonous) {
533 if (p == poison_type) {
534 allow_dep = true
535 }
536 }
537 if (!allow_dep) {
538 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
539 }
540 }
541 }
542
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100543 # Chromium should only depend on the WebRTC component in order to
544 # avoid to statically link WebRTC in a component build.
545 if (build_with_chromium) {
546 publicly_visible = false
547 foreach(v, visibility) {
548 if (v == "*") {
549 publicly_visible = true
550 }
551 }
552 if (publicly_visible) {
553 visibility = []
554 visibility = webrtc_default_visibility
555 }
556 }
557
Mirko Bonadei96ede162018-09-06 13:45:44 +0200558 if (!defined(testonly) || !testonly) {
559 configs += rtc_prod_configs
560 }
561
mbonadei9aa3f0a2017-01-24 06:58:22 -0800562 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200563 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800564 configs -= rtc_remove_configs
565 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000566 public_configs = [
567 rtc_common_inherited_config,
568 absl_include_config,
569 absl_define_config,
570 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200571 if (defined(testonly) && testonly) {
572 public_configs += [ absl_flags_config ]
573 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800574 if (defined(invoker.public_configs)) {
575 public_configs += invoker.public_configs
576 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200577
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200578 # If absl_deps is [], no action is needed. If not [], then it needs to be
579 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200580 # otherwise it just needs to be added to deps.
581 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200582 if (!defined(deps)) {
583 deps = []
584 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200585 if (build_with_chromium) {
586 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200587 } else {
588 deps += absl_deps
589 }
590 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800591 }
592}
593
mbonadei9aa3f0a2017-01-24 06:58:22 -0800594template("rtc_static_library") {
595 static_library(target_name) {
596 forward_variables_from(invoker,
597 "*",
598 [
599 "configs",
600 "public_configs",
601 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200602 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800603 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200604 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000605 if (!defined(visibility)) {
606 visibility = webrtc_default_visibility
607 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200608
609 # What's your poison?
610 if (defined(testonly) && testonly) {
611 assert(!defined(poisonous))
612 assert(!defined(allow_poison))
613 } else {
614 if (!defined(poisonous)) {
615 poisonous = []
616 }
617 if (!defined(allow_poison)) {
618 allow_poison = []
619 }
620 if (!defined(assert_no_deps)) {
621 assert_no_deps = []
622 }
623 if (!defined(deps)) {
624 deps = []
625 }
626 foreach(p, poisonous) {
627 deps += [ webrtc_root + ":poison_" + p ]
628 }
629 foreach(poison_type, all_poison_types) {
630 allow_dep = true
631 foreach(v, visibility) {
632 if (v == "*") {
633 allow_dep = false
634 }
635 }
636 foreach(p, allow_poison + poisonous) {
637 if (p == poison_type) {
638 allow_dep = true
639 }
640 }
641 if (!allow_dep) {
642 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
643 }
644 }
645 }
646
Mirko Bonadei96ede162018-09-06 13:45:44 +0200647 if (!defined(testonly) || !testonly) {
648 configs += rtc_prod_configs
649 }
650
mbonadei9aa3f0a2017-01-24 06:58:22 -0800651 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200652 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800653 configs -= rtc_remove_configs
654 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000655 public_configs = [
656 rtc_common_inherited_config,
657 absl_include_config,
658 absl_define_config,
659 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200660 if (defined(testonly) && testonly) {
661 public_configs += [ absl_flags_config ]
662 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800663 if (defined(invoker.public_configs)) {
664 public_configs += invoker.public_configs
665 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200666
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200667 # If absl_deps is [], no action is needed. If not [], then it needs to be
668 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200669 # otherwise it just needs to be added to deps.
670 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200671 if (!defined(deps)) {
672 deps = []
673 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200674 if (build_with_chromium) {
675 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200676 } else {
677 deps += absl_deps
678 }
679 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800680 }
681}
682
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200683# This template automatically switches the target type between source_set
684# and static_library.
685#
686# This should be the default target type for all the WebRTC targets with
687# one exception. Do not use this template for header only targets, in that case
688# rtc_source_set must be used in order to avoid build errors (e.g. libtool
689# complains if the output .a file is empty).
690#
691# How does it work:
692# Since all files in a source_set are linked into a final binary, while files
693# in a static library are only linked in if at least one symbol in them is
694# referenced, in component builds source_sets are easy to deal with because
695# all their object files are passed to the linker to create a shared library.
696# In release builds instead, static_libraries are preferred since they allow
697# the linker to discard dead code.
698# For the same reason, testonly targets will always be expanded to
699# source_set in order to be sure that tests are present in the test binary.
700template("rtc_library") {
701 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
702 target_type = "source_set"
703 } else {
704 target_type = "static_library"
705 }
706 target(target_type, target_name) {
707 forward_variables_from(invoker,
708 "*",
709 [
710 "configs",
711 "public_configs",
712 "suppressed_configs",
713 "visibility",
714 ])
715 forward_variables_from(invoker, [ "visibility" ])
716 if (!defined(visibility)) {
717 visibility = webrtc_default_visibility
718 }
719
720 # What's your poison?
721 if (defined(testonly) && testonly) {
722 assert(!defined(poisonous))
723 assert(!defined(allow_poison))
724 } else {
725 if (!defined(poisonous)) {
726 poisonous = []
727 }
728 if (!defined(allow_poison)) {
729 allow_poison = []
730 }
731 if (!defined(assert_no_deps)) {
732 assert_no_deps = []
733 }
734 if (!defined(deps)) {
735 deps = []
736 }
737 foreach(p, poisonous) {
738 deps += [ webrtc_root + ":poison_" + p ]
739 }
740 foreach(poison_type, all_poison_types) {
741 allow_dep = true
742 foreach(v, visibility) {
743 if (v == "*") {
744 allow_dep = false
745 }
746 }
747 foreach(p, allow_poison + poisonous) {
748 if (p == poison_type) {
749 allow_dep = true
750 }
751 }
752 if (!allow_dep) {
753 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
754 }
755 }
756 }
757
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100758 # Chromium should only depend on the WebRTC component in order to
759 # avoid to statically link WebRTC in a component build.
760 if (build_with_chromium) {
761 publicly_visible = false
762 foreach(v, visibility) {
763 if (v == "*") {
764 publicly_visible = true
765 }
766 }
767 if (publicly_visible) {
768 visibility = []
769 visibility = webrtc_default_visibility
770 }
771 }
772
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200773 if (!defined(testonly) || !testonly) {
774 configs += rtc_prod_configs
775 }
776
777 configs += invoker.configs
778 configs += rtc_library_impl_config
779 configs -= rtc_remove_configs
780 configs -= invoker.suppressed_configs
781 public_configs = [
782 rtc_common_inherited_config,
783 absl_include_config,
784 absl_define_config,
785 ]
786 if (defined(testonly) && testonly) {
787 public_configs += [ absl_flags_config ]
788 }
789 if (defined(invoker.public_configs)) {
790 public_configs += invoker.public_configs
791 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200792
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200793 # If absl_deps is [], no action is needed. If not [], then it needs to be
794 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200795 # otherwise it just needs to be added to deps.
796 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200797 if (!defined(deps)) {
798 deps = []
799 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200800 if (build_with_chromium) {
801 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200802 } else {
803 deps += absl_deps
804 }
805 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200806 }
807}
808
809template("rtc_executable") {
810 executable(target_name) {
811 forward_variables_from(invoker,
812 "*",
813 [
814 "deps",
815 "configs",
816 "public_configs",
817 "suppressed_configs",
818 "visibility",
819 ])
820 forward_variables_from(invoker, [ "visibility" ])
821 if (!defined(visibility)) {
822 visibility = webrtc_default_visibility
823 }
824 configs += invoker.configs
825 configs -= rtc_remove_configs
826 configs -= invoker.suppressed_configs
827 deps = invoker.deps
828
829 public_configs = [
830 rtc_common_inherited_config,
831 absl_include_config,
832 absl_define_config,
833 ]
834 if (defined(testonly) && testonly) {
835 public_configs += [ absl_flags_config ]
836 }
837 if (defined(invoker.public_configs)) {
838 public_configs += invoker.public_configs
839 }
840 if (is_win) {
841 deps += [
842 # Give executables the default manifest on Windows (a no-op elsewhere).
843 "//build/win:default_exe_manifest",
844 ]
845 }
846 }
847}
848
mbonadei9aa3f0a2017-01-24 06:58:22 -0800849template("rtc_shared_library") {
850 shared_library(target_name) {
851 forward_variables_from(invoker,
852 "*",
853 [
854 "configs",
855 "public_configs",
856 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200857 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800858 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200859 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000860 if (!defined(visibility)) {
861 visibility = webrtc_default_visibility
862 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200863
864 # What's your poison?
865 if (defined(testonly) && testonly) {
866 assert(!defined(poisonous))
867 assert(!defined(allow_poison))
868 } else {
869 if (!defined(poisonous)) {
870 poisonous = []
871 }
872 if (!defined(allow_poison)) {
873 allow_poison = []
874 }
875 if (!defined(assert_no_deps)) {
876 assert_no_deps = []
877 }
878 if (!defined(deps)) {
879 deps = []
880 }
881 foreach(p, poisonous) {
882 deps += [ webrtc_root + ":poison_" + p ]
883 }
884 foreach(poison_type, all_poison_types) {
885 allow_dep = true
886 foreach(v, visibility) {
887 if (v == "*") {
888 allow_dep = false
889 }
890 }
891 foreach(p, allow_poison + poisonous) {
892 if (p == poison_type) {
893 allow_dep = true
894 }
895 }
896 if (!allow_dep) {
897 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
898 }
899 }
900 }
901
mbonadei9aa3f0a2017-01-24 06:58:22 -0800902 configs += invoker.configs
903 configs -= rtc_remove_configs
904 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000905 public_configs = [
906 rtc_common_inherited_config,
907 absl_include_config,
908 absl_define_config,
909 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200910 if (defined(testonly) && testonly) {
911 public_configs += [ absl_flags_config ]
912 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800913 if (defined(invoker.public_configs)) {
914 public_configs += invoker.public_configs
915 }
916 }
917}
kthelgason4065a572017-02-14 04:58:56 -0800918
919if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400920 # TODO: Generate module.modulemap file to enable use in Swift
921 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100922 template("ios_framework_bundle_with_umbrella_header") {
923 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900924 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100925 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900926 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
927
928 action_foreach("create_bracket_include_headers_$target_name") {
929 script = "//tools_webrtc/apple/copy_framework_header.py"
930 sources = invoker.sources
931 output_name = invoker.output_name
932 outputs = [
933 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
934 ]
935 args = [
936 "--input",
937 "{{source}}",
938 "--output",
939 rebase_path(target_gen_dir, root_build_dir) +
940 "/$output_name.framework/WebRTC/{{source_file_part}}",
941 ]
942 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100943
944 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900945 forward_variables_from(invoker, "*", [ "public_headers" ])
946 public_headers = get_target_outputs(
947 ":create_bracket_include_headers_$this_target_name")
948 deps += [
949 ":copy_umbrella_header_$target_name",
950 ":create_bracket_include_headers_$target_name",
951 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100952 }
953
954 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900955 public_headers = get_target_outputs(
956 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100957
958 script = "//tools_webrtc/ios/generate_umbrella_header.py"
959
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100960 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100961 args = [
962 "--out",
963 rebase_path(umbrella_header_path, root_build_dir),
964 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200965 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900966 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100967 }
968
969 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100970 sources = [ umbrella_header_path ]
971 outputs =
972 [ "$root_out_dir/$output_name.framework/Headers/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100973
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100974 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100975 }
976 }
977
978 set_defaults("ios_framework_bundle_with_umbrella_header") {
979 configs = default_shared_library_configs
980 }
kthelgason4065a572017-02-14 04:58:56 -0800981}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000982
Anders Carlsson37bbf792018-09-05 16:29:27 +0200983if (is_mac) {
984 template("mac_framework_bundle_with_umbrella_header") {
985 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200986 this_target_name = target_name
987 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400988 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200989
990 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -0800991 forward_variables_from(invoker, "*", [ "configs" ])
992 if (defined(invoker.configs)) {
993 configs += invoker.configs
994 }
Anders Carlsson37bbf792018-09-05 16:29:27 +0200995
996 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400997 framework_contents = [
998 "Headers",
999 "Modules",
1000 "Resources",
1001 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001002
1003 ldflags = [
1004 "-all_load",
1005 "-install_name",
1006 "@rpath/$output_name.framework/$output_name",
1007 ]
1008
1009 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001010 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001011 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001012 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001013 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001014 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001015 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001016 ]
1017 }
1018
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001019 action_foreach("create_bracket_include_headers_$this_target_name") {
1020 script = "//tools_webrtc/apple/copy_framework_header.py"
1021 sources = invoker.sources
1022 output_name = invoker.output_name
1023 outputs = [
1024 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1025 ]
1026 args = [
1027 "--input",
1028 "{{source}}",
1029 "--output",
1030 rebase_path(target_gen_dir, root_build_dir) +
1031 "/$output_name.framework/WebRTC/{{source_file_part}}",
1032 ]
1033 }
1034
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001035 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001036 sources = get_target_outputs(
1037 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001038
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001039 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001040 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001041 }
1042
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001043 action("modulemap_$this_target_name") {
1044 script = "//tools_webrtc/ios/generate_modulemap.py"
1045 args = [
1046 "--out",
1047 rebase_path(modulemap_path, root_build_dir),
1048 "--name",
1049 output_name,
1050 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001051 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001052 }
1053
1054 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001055 sources = [ modulemap_path ]
1056 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1057 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001058 }
1059
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001060 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001061 sources = get_target_outputs(
1062 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001063
1064 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1065
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001066 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001067 args = [
1068 "--out",
1069 rebase_path(umbrella_header_path, root_build_dir),
1070 "--sources",
1071 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001072 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001073 }
1074
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001075 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001076 sources = [ umbrella_header_path ]
1077 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001078
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001079 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001080 }
1081 }
1082}
1083
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001084if (is_android) {
1085 template("rtc_android_library") {
1086 android_library(target_name) {
1087 forward_variables_from(invoker,
1088 "*",
1089 [
1090 "configs",
1091 "public_configs",
1092 "suppressed_configs",
1093 "visibility",
1094 ])
1095
Oleh Prypin05aee742018-11-23 17:29:44 +01001096 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001097
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001098 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001099 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001100
1101 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001102 if (defined(invoker.errorprone_args)) {
1103 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001104 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001105
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001106 if (!defined(deps)) {
1107 deps = []
1108 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001109
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001110 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001111 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001112 }
1113 }
1114
1115 template("rtc_android_apk") {
1116 android_apk(target_name) {
1117 forward_variables_from(invoker,
1118 "*",
1119 [
1120 "configs",
1121 "public_configs",
1122 "suppressed_configs",
1123 "visibility",
1124 ])
1125
1126 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001127 errorprone_args = []
1128 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001129
1130 if (!defined(deps)) {
1131 deps = []
1132 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001133
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001134 no_build_hooks = true
1135 }
1136 }
1137
1138 template("rtc_instrumentation_test_apk") {
1139 instrumentation_test_apk(target_name) {
1140 forward_variables_from(invoker,
1141 "*",
1142 [
1143 "configs",
1144 "public_configs",
1145 "suppressed_configs",
1146 "visibility",
1147 ])
1148
1149 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001150 errorprone_args = []
1151 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001152
1153 if (!defined(deps)) {
1154 deps = []
1155 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001156
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001157 no_build_hooks = true
1158 }
1159 }
1160}