blob: 05a230c4f15c0a301f9e05998cb72a738fe007a4 [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 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800478 }
479}
480
481template("rtc_source_set") {
482 source_set(target_name) {
483 forward_variables_from(invoker,
484 "*",
485 [
486 "configs",
487 "public_configs",
488 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200489 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800490 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200491 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000492 if (!defined(visibility)) {
493 visibility = webrtc_default_visibility
494 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200495
496 # What's your poison?
497 if (defined(testonly) && testonly) {
498 assert(!defined(poisonous))
499 assert(!defined(allow_poison))
500 } else {
501 if (!defined(poisonous)) {
502 poisonous = []
503 }
504 if (!defined(allow_poison)) {
505 allow_poison = []
506 }
507 if (!defined(assert_no_deps)) {
508 assert_no_deps = []
509 }
510 if (!defined(deps)) {
511 deps = []
512 }
513 foreach(p, poisonous) {
514 deps += [ webrtc_root + ":poison_" + p ]
515 }
516 foreach(poison_type, all_poison_types) {
517 allow_dep = true
518 foreach(v, visibility) {
519 if (v == "*") {
520 allow_dep = false
521 }
522 }
523 foreach(p, allow_poison + poisonous) {
524 if (p == poison_type) {
525 allow_dep = true
526 }
527 }
528 if (!allow_dep) {
529 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
530 }
531 }
532 }
533
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100534 # Chromium should only depend on the WebRTC component in order to
535 # avoid to statically link WebRTC in a component build.
536 if (build_with_chromium) {
537 publicly_visible = false
538 foreach(v, visibility) {
539 if (v == "*") {
540 publicly_visible = true
541 }
542 }
543 if (publicly_visible) {
544 visibility = []
545 visibility = webrtc_default_visibility
546 }
547 }
548
Mirko Bonadei96ede162018-09-06 13:45:44 +0200549 if (!defined(testonly) || !testonly) {
550 configs += rtc_prod_configs
551 }
552
mbonadei9aa3f0a2017-01-24 06:58:22 -0800553 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200554 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800555 configs -= rtc_remove_configs
556 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000557 public_configs = [
558 rtc_common_inherited_config,
559 absl_include_config,
560 absl_define_config,
561 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200562 if (defined(testonly) && testonly) {
563 public_configs += [ absl_flags_config ]
564 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800565 if (defined(invoker.public_configs)) {
566 public_configs += invoker.public_configs
567 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200568
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200569 # If absl_deps is [], no action is needed. If not [], then it needs to be
570 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200571 # otherwise it just needs to be added to deps.
572 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200573 if (!defined(deps)) {
574 deps = []
575 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200576 if (build_with_chromium) {
577 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200578 } else {
579 deps += absl_deps
580 }
581 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800582 }
583}
584
mbonadei9aa3f0a2017-01-24 06:58:22 -0800585template("rtc_static_library") {
586 static_library(target_name) {
587 forward_variables_from(invoker,
588 "*",
589 [
590 "configs",
591 "public_configs",
592 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200593 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800594 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200595 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000596 if (!defined(visibility)) {
597 visibility = webrtc_default_visibility
598 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200599
600 # What's your poison?
601 if (defined(testonly) && testonly) {
602 assert(!defined(poisonous))
603 assert(!defined(allow_poison))
604 } else {
605 if (!defined(poisonous)) {
606 poisonous = []
607 }
608 if (!defined(allow_poison)) {
609 allow_poison = []
610 }
611 if (!defined(assert_no_deps)) {
612 assert_no_deps = []
613 }
614 if (!defined(deps)) {
615 deps = []
616 }
617 foreach(p, poisonous) {
618 deps += [ webrtc_root + ":poison_" + p ]
619 }
620 foreach(poison_type, all_poison_types) {
621 allow_dep = true
622 foreach(v, visibility) {
623 if (v == "*") {
624 allow_dep = false
625 }
626 }
627 foreach(p, allow_poison + poisonous) {
628 if (p == poison_type) {
629 allow_dep = true
630 }
631 }
632 if (!allow_dep) {
633 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
634 }
635 }
636 }
637
Mirko Bonadei96ede162018-09-06 13:45:44 +0200638 if (!defined(testonly) || !testonly) {
639 configs += rtc_prod_configs
640 }
641
mbonadei9aa3f0a2017-01-24 06:58:22 -0800642 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200643 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800644 configs -= rtc_remove_configs
645 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000646 public_configs = [
647 rtc_common_inherited_config,
648 absl_include_config,
649 absl_define_config,
650 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200651 if (defined(testonly) && testonly) {
652 public_configs += [ absl_flags_config ]
653 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800654 if (defined(invoker.public_configs)) {
655 public_configs += invoker.public_configs
656 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200657
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200658 # If absl_deps is [], no action is needed. If not [], then it needs to be
659 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200660 # otherwise it just needs to be added to deps.
661 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200662 if (!defined(deps)) {
663 deps = []
664 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200665 if (build_with_chromium) {
666 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200667 } else {
668 deps += absl_deps
669 }
670 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800671 }
672}
673
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200674# This template automatically switches the target type between source_set
675# and static_library.
676#
677# This should be the default target type for all the WebRTC targets with
678# one exception. Do not use this template for header only targets, in that case
679# rtc_source_set must be used in order to avoid build errors (e.g. libtool
680# complains if the output .a file is empty).
681#
682# How does it work:
683# Since all files in a source_set are linked into a final binary, while files
684# in a static library are only linked in if at least one symbol in them is
685# referenced, in component builds source_sets are easy to deal with because
686# all their object files are passed to the linker to create a shared library.
687# In release builds instead, static_libraries are preferred since they allow
688# the linker to discard dead code.
689# For the same reason, testonly targets will always be expanded to
690# source_set in order to be sure that tests are present in the test binary.
691template("rtc_library") {
692 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
693 target_type = "source_set"
694 } else {
695 target_type = "static_library"
696 }
697 target(target_type, target_name) {
698 forward_variables_from(invoker,
699 "*",
700 [
701 "configs",
702 "public_configs",
703 "suppressed_configs",
704 "visibility",
705 ])
706 forward_variables_from(invoker, [ "visibility" ])
707 if (!defined(visibility)) {
708 visibility = webrtc_default_visibility
709 }
710
711 # What's your poison?
712 if (defined(testonly) && testonly) {
713 assert(!defined(poisonous))
714 assert(!defined(allow_poison))
715 } else {
716 if (!defined(poisonous)) {
717 poisonous = []
718 }
719 if (!defined(allow_poison)) {
720 allow_poison = []
721 }
722 if (!defined(assert_no_deps)) {
723 assert_no_deps = []
724 }
725 if (!defined(deps)) {
726 deps = []
727 }
728 foreach(p, poisonous) {
729 deps += [ webrtc_root + ":poison_" + p ]
730 }
731 foreach(poison_type, all_poison_types) {
732 allow_dep = true
733 foreach(v, visibility) {
734 if (v == "*") {
735 allow_dep = false
736 }
737 }
738 foreach(p, allow_poison + poisonous) {
739 if (p == poison_type) {
740 allow_dep = true
741 }
742 }
743 if (!allow_dep) {
744 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
745 }
746 }
747 }
748
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100749 # Chromium should only depend on the WebRTC component in order to
750 # avoid to statically link WebRTC in a component build.
751 if (build_with_chromium) {
752 publicly_visible = false
753 foreach(v, visibility) {
754 if (v == "*") {
755 publicly_visible = true
756 }
757 }
758 if (publicly_visible) {
759 visibility = []
760 visibility = webrtc_default_visibility
761 }
762 }
763
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200764 if (!defined(testonly) || !testonly) {
765 configs += rtc_prod_configs
766 }
767
768 configs += invoker.configs
769 configs += rtc_library_impl_config
770 configs -= rtc_remove_configs
771 configs -= invoker.suppressed_configs
772 public_configs = [
773 rtc_common_inherited_config,
774 absl_include_config,
775 absl_define_config,
776 ]
777 if (defined(testonly) && testonly) {
778 public_configs += [ absl_flags_config ]
779 }
780 if (defined(invoker.public_configs)) {
781 public_configs += invoker.public_configs
782 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200783
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200784 # If absl_deps is [], no action is needed. If not [], then it needs to be
785 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200786 # otherwise it just needs to be added to deps.
787 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200788 if (!defined(deps)) {
789 deps = []
790 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200791 if (build_with_chromium) {
792 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200793 } else {
794 deps += absl_deps
795 }
796 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200797 }
798}
799
800template("rtc_executable") {
801 executable(target_name) {
802 forward_variables_from(invoker,
803 "*",
804 [
805 "deps",
806 "configs",
807 "public_configs",
808 "suppressed_configs",
809 "visibility",
810 ])
811 forward_variables_from(invoker, [ "visibility" ])
812 if (!defined(visibility)) {
813 visibility = webrtc_default_visibility
814 }
815 configs += invoker.configs
816 configs -= rtc_remove_configs
817 configs -= invoker.suppressed_configs
818 deps = invoker.deps
819
820 public_configs = [
821 rtc_common_inherited_config,
822 absl_include_config,
823 absl_define_config,
824 ]
825 if (defined(testonly) && testonly) {
826 public_configs += [ absl_flags_config ]
827 }
828 if (defined(invoker.public_configs)) {
829 public_configs += invoker.public_configs
830 }
831 if (is_win) {
832 deps += [
833 # Give executables the default manifest on Windows (a no-op elsewhere).
834 "//build/win:default_exe_manifest",
835 ]
836 }
837 }
838}
839
mbonadei9aa3f0a2017-01-24 06:58:22 -0800840template("rtc_shared_library") {
841 shared_library(target_name) {
842 forward_variables_from(invoker,
843 "*",
844 [
845 "configs",
846 "public_configs",
847 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200848 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800849 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200850 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000851 if (!defined(visibility)) {
852 visibility = webrtc_default_visibility
853 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200854
855 # What's your poison?
856 if (defined(testonly) && testonly) {
857 assert(!defined(poisonous))
858 assert(!defined(allow_poison))
859 } else {
860 if (!defined(poisonous)) {
861 poisonous = []
862 }
863 if (!defined(allow_poison)) {
864 allow_poison = []
865 }
866 if (!defined(assert_no_deps)) {
867 assert_no_deps = []
868 }
869 if (!defined(deps)) {
870 deps = []
871 }
872 foreach(p, poisonous) {
873 deps += [ webrtc_root + ":poison_" + p ]
874 }
875 foreach(poison_type, all_poison_types) {
876 allow_dep = true
877 foreach(v, visibility) {
878 if (v == "*") {
879 allow_dep = false
880 }
881 }
882 foreach(p, allow_poison + poisonous) {
883 if (p == poison_type) {
884 allow_dep = true
885 }
886 }
887 if (!allow_dep) {
888 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
889 }
890 }
891 }
892
mbonadei9aa3f0a2017-01-24 06:58:22 -0800893 configs += invoker.configs
894 configs -= rtc_remove_configs
895 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000896 public_configs = [
897 rtc_common_inherited_config,
898 absl_include_config,
899 absl_define_config,
900 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200901 if (defined(testonly) && testonly) {
902 public_configs += [ absl_flags_config ]
903 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800904 if (defined(invoker.public_configs)) {
905 public_configs += invoker.public_configs
906 }
907 }
908}
kthelgason4065a572017-02-14 04:58:56 -0800909
910if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400911 # TODO: Generate module.modulemap file to enable use in Swift
912 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100913 template("ios_framework_bundle_with_umbrella_header") {
914 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900915 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100916 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900917 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
918
919 action_foreach("create_bracket_include_headers_$target_name") {
920 script = "//tools_webrtc/apple/copy_framework_header.py"
921 sources = invoker.sources
922 output_name = invoker.output_name
923 outputs = [
924 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
925 ]
926 args = [
927 "--input",
928 "{{source}}",
929 "--output",
930 rebase_path(target_gen_dir, root_build_dir) +
931 "/$output_name.framework/WebRTC/{{source_file_part}}",
932 ]
933 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100934
935 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900936 forward_variables_from(invoker, "*", [ "public_headers" ])
937 public_headers = get_target_outputs(
938 ":create_bracket_include_headers_$this_target_name")
939 deps += [
940 ":copy_umbrella_header_$target_name",
941 ":create_bracket_include_headers_$target_name",
942 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100943 }
944
945 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900946 public_headers = get_target_outputs(
947 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100948
949 script = "//tools_webrtc/ios/generate_umbrella_header.py"
950
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100951 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100952 args = [
953 "--out",
954 rebase_path(umbrella_header_path, root_build_dir),
955 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200956 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900957 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100958 }
959
960 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100961 sources = [ umbrella_header_path ]
962 outputs =
963 [ "$root_out_dir/$output_name.framework/Headers/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100964
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100965 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100966 }
967 }
968
969 set_defaults("ios_framework_bundle_with_umbrella_header") {
970 configs = default_shared_library_configs
971 }
kthelgason4065a572017-02-14 04:58:56 -0800972}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000973
Anders Carlsson37bbf792018-09-05 16:29:27 +0200974if (is_mac) {
975 template("mac_framework_bundle_with_umbrella_header") {
976 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200977 this_target_name = target_name
978 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400979 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200980
981 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -0800982 forward_variables_from(invoker, "*", [ "configs" ])
983 if (defined(invoker.configs)) {
984 configs += invoker.configs
985 }
Anders Carlsson37bbf792018-09-05 16:29:27 +0200986
987 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400988 framework_contents = [
989 "Headers",
990 "Modules",
991 "Resources",
992 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200993
994 ldflags = [
995 "-all_load",
996 "-install_name",
997 "@rpath/$output_name.framework/$output_name",
998 ]
999
1000 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001001 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001002 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001003 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001004 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001005 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001006 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001007 ]
1008 }
1009
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001010 action_foreach("create_bracket_include_headers_$this_target_name") {
1011 script = "//tools_webrtc/apple/copy_framework_header.py"
1012 sources = invoker.sources
1013 output_name = invoker.output_name
1014 outputs = [
1015 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1016 ]
1017 args = [
1018 "--input",
1019 "{{source}}",
1020 "--output",
1021 rebase_path(target_gen_dir, root_build_dir) +
1022 "/$output_name.framework/WebRTC/{{source_file_part}}",
1023 ]
1024 }
1025
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001026 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001027 sources = get_target_outputs(
1028 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001029
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001030 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001031 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001032 }
1033
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001034 action("modulemap_$this_target_name") {
1035 script = "//tools_webrtc/ios/generate_modulemap.py"
1036 args = [
1037 "--out",
1038 rebase_path(modulemap_path, root_build_dir),
1039 "--name",
1040 output_name,
1041 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001042 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001043 }
1044
1045 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001046 sources = [ modulemap_path ]
1047 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1048 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001049 }
1050
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001051 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001052 sources = get_target_outputs(
1053 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001054
1055 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1056
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001057 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001058 args = [
1059 "--out",
1060 rebase_path(umbrella_header_path, root_build_dir),
1061 "--sources",
1062 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001063 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001064 }
1065
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001066 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001067 sources = [ umbrella_header_path ]
1068 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001069
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001070 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001071 }
1072 }
1073}
1074
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001075if (is_android) {
1076 template("rtc_android_library") {
1077 android_library(target_name) {
1078 forward_variables_from(invoker,
1079 "*",
1080 [
1081 "configs",
1082 "public_configs",
1083 "suppressed_configs",
1084 "visibility",
1085 ])
1086
Oleh Prypin05aee742018-11-23 17:29:44 +01001087 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001088
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001089 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001090 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001091
1092 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001093 if (defined(invoker.errorprone_args)) {
1094 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001095 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001096
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001097 if (!defined(deps)) {
1098 deps = []
1099 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001100
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001101 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001102 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001103 }
1104 }
1105
1106 template("rtc_android_apk") {
1107 android_apk(target_name) {
1108 forward_variables_from(invoker,
1109 "*",
1110 [
1111 "configs",
1112 "public_configs",
1113 "suppressed_configs",
1114 "visibility",
1115 ])
1116
1117 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001118 errorprone_args = []
1119 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001120
1121 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
1126 }
1127 }
1128
1129 template("rtc_instrumentation_test_apk") {
1130 instrumentation_test_apk(target_name) {
1131 forward_variables_from(invoker,
1132 "*",
1133 [
1134 "configs",
1135 "public_configs",
1136 "suppressed_configs",
1137 "visibility",
1138 ])
1139
1140 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001141 errorprone_args = []
1142 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001143
1144 if (!defined(deps)) {
1145 deps = []
1146 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001147
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001148 no_build_hooks = true
1149 }
1150 }
1151}