blob: 6c80d721f469ad92ed7d8abd79328afffbcd0e8b [file] [log] [blame]
mbonadei9aa3f0a2017-01-24 06:58:22 -08001# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS. All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
mbonadei9aa3f0a2017-01-24 06:58:22 -08008import("//build/config/arm.gni")
9import("//build/config/features.gni")
10import("//build/config/mips.gni")
11import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 06:32:23 +010012import("//build/config/sysroot.gni")
ehmaldonado0d729b32017-02-10 01:38:23 -080013import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080014import("//build_overrides/build.gni")
mbonadei96606272017-03-03 19:41:59 -080015
16if (!build_with_chromium && is_component_build) {
17 print("The Gn argument `is_component_build` is currently " +
18 "ignored for WebRTC builds.")
19 print("Component builds are supported by Chromium and the argument " +
20 "`is_component_build` makes it possible to create shared libraries " +
21 "instead of static libraries.")
22 print("If an app depends on WebRTC it makes sense to just depend on the " +
23 "WebRTC static library, so there is no difference between " +
24 "`is_component_build=true` and `is_component_build=false`.")
25 print(
26 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md")
27 assert(!is_component_build, "Component builds are not supported in WebRTC.")
28}
29
kthelgason4065a572017-02-14 04:58:56 -080030if (is_ios) {
31 import("//build/config/ios/rules.gni")
32}
mbonadei9aa3f0a2017-01-24 06:58:22 -080033
Anders Carlsson37bbf792018-09-05 16:29:27 +020034if (is_mac) {
35 import("//build/config/mac/rules.gni")
36}
37
mbonadei9aa3f0a2017-01-24 06:58:22 -080038declare_args() {
Mirko Bonadei028248c2018-10-10 12:19:02 +020039 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
40 # expand to code that will manage symbols visibility.
41 rtc_enable_symbol_export = false
42
Mirko Bonadei31b0b452018-08-22 10:37:11 +020043 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020044 # will tell the pre-processor to remove the default definition of symbols
45 # needed to use field_trial. In that case a new implementation needs to be
46 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020047 if (build_with_chromium) {
48 # When WebRTC is built as part of Chromium it should exclude the default
49 # implementation of field_trial unless it is building for NACL or
50 # Chromecast.
51 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
52 } else {
53 rtc_exclude_field_trial_default = false
54 }
Mirko Bonadei70400902018-08-21 15:44:28 +020055
Mirko Bonadei906add42018-09-05 16:03:16 +020056 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
57 # will tell the pre-processor to remove the default definition of symbols
58 # needed to use metrics. In that case a new implementation needs to be
59 # provided.
60 rtc_exclude_metrics_default = build_with_chromium
61
Johannes Kronda20c732021-02-19 16:39:41 +010062 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which
63 # will tell the pre-processor to remove the default definition of the
64 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
65 # that case a new implementation needs to be provided.
Johannes Kronbb52bdf2021-02-25 10:10:08 +010066 rtc_exclude_system_time = build_with_chromium
Johannes Kronda20c732021-02-19 16:39:41 +010067
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070068 # Setting this to false will require the API user to pass in their own
69 # SSLCertificateVerifier to verify the certificates presented from a
70 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
71 rtc_builtin_ssl_root_certificates = true
72
Karl Wibergeb254b42017-11-01 15:08:12 +010073 # Include the iLBC audio codec?
Olga Sharonova5fbd7582020-07-09 09:50:42 +000074 rtc_include_ilbc = true
Karl Wibergeb254b42017-11-01 15:08:12 +010075
mbonadei9aa3f0a2017-01-24 06:58:22 -080076 # Disable this to avoid building the Opus audio codec.
77 rtc_include_opus = true
78
minyue2e03c662017-02-01 17:31:11 -080079 # Enable this if the Opus version upon which WebRTC is built supports direct
80 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020081 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080082
mbonadei9aa3f0a2017-01-24 06:58:22 -080083 # Enable this to let the Opus audio codec change complexity on the fly.
84 rtc_opus_variable_complexity = false
85
mbonadei9aa3f0a2017-01-24 06:58:22 -080086 # Used to specify an external Jsoncpp include path when not compiling the
87 # library that comes with WebRTC (i.e. rtc_build_json == 0).
88 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
89
90 # Used to specify an external OpenSSL include path when not compiling the
91 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
92 rtc_ssl_root = ""
93
mbonadei9aa3f0a2017-01-24 06:58:22 -080094 # Enable when an external authentication mechanism is used for performing
95 # packet authentication for RTP packets instead of libsrtp.
96 rtc_enable_external_auth = build_with_chromium
97
98 # Selects whether debug dumps for the audio processing module
99 # should be generated.
100 apm_debug_dump = false
101
Per Åhgrencc73ed32020-04-26 23:56:17 +0200102 # Selects whether the audio processing module should be excluded.
103 rtc_exclude_audio_processing_module = false
104
mbonadei9aa3f0a2017-01-24 06:58:22 -0800105 # Set this to true to enable BWE test logging.
106 rtc_enable_bwe_test_logging = false
107
Joachim Bauch93e91342017-12-07 01:25:53 +0100108 # Set this to false to skip building examples.
109 rtc_build_examples = true
110
111 # Set this to false to skip building tools.
112 rtc_build_tools = true
113
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100114 # Set this to false to skip building code that requires X11.
115 rtc_use_x11 = use_x11
116
Tomas Popela318da512018-11-13 06:32:23 +0100117 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 14:37:51 +0100118 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
119 # only when using the sysroot as PipeWire is not available in older and
120 # supported Ubuntu and Debian distributions.
Xiaohan Wang9f32f3b2020-10-01 14:46:54 -0700121 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 14:37:51 +0100122
123 # Set this to link PipeWire directly instead of using the dlopen.
124 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 06:32:23 +0100125
Jan Grulichc3c81292020-12-02 09:03:34 +0100126 # Set this to use certain PipeWire version
Jan Grulich14b036d2021-02-04 09:53:20 +0100127 # Currently WebRTC supports PipeWire 0.2 and PipeWire 0.3 (default)
128 rtc_pipewire_version = "0.3"
Jan Grulichc3c81292020-12-02 09:03:34 +0100129
mbonadei9aa3f0a2017-01-24 06:58:22 -0800130 # Enable to use the Mozilla internal settings.
131 build_with_mozilla = false
132
Philipp Hanckee95ebda2020-09-17 16:13:20 +0200133 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
134 # and NDK r16 or above.
henrika883d00f2018-03-16 10:09:49 +0100135 rtc_enable_android_aaudio = false
136
mbonadei9aa3f0a2017-01-24 06:58:22 -0800137 # Set to "func", "block", "edge" for coverage generation.
138 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
139 # It is recommend to set include_examples=0.
140 # Use llvm's sancov -html-report for human readable reports.
141 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
142 rtc_sanitize_coverage = ""
143
Philipp Hanckeaeac9f82020-09-11 11:58:18 +0200144 # Selects fixed-point code where possible.
145 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800146 if (current_cpu == "arm" || current_cpu == "arm64") {
147 rtc_prefer_fixed_point = true
148 }
149
mbonadei9aa3f0a2017-01-24 06:58:22 -0800150 # Determines whether NEON code will be built.
151 rtc_build_with_neon =
152 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
153
154 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
155 # all platforms except Android and iOS. Because FFmpeg can be built
156 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
157 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200158 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800159 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
160 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100161 #
162 # Enabling H264 when building with MSVC is currently not supported, see
163 # bugs.webrtc.org/9213#c13 for more info.
164 rtc_use_h264 =
165 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800166
Markus Handell8e75bd42020-06-05 11:47:40 +0200167 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
168 rtc_use_absl_mutex = false
169
mbonadei9aa3f0a2017-01-24 06:58:22 -0800170 # By default, use normal platform audio support or dummy audio, but don't
171 # use file-based audio playout and record.
172 rtc_use_dummy_audio_file_devices = false
173
henrika7be78832017-06-13 17:34:16 +0200174 # When set to true, replace the audio output with a sinus tone at 440Hz.
175 # The ADM will ask for audio data from WebRTC but instead of reading real
176 # audio samples from NetEQ, a sinus tone will be generated and replace the
177 # real audio samples.
178 rtc_audio_device_plays_sinus_tone = false
179
Anders Carlsson358f2e02018-06-04 10:24:37 +0200180 if (is_ios) {
181 # Build broadcast extension in AppRTCMobile for iOS. This results in the
182 # binary only running on iOS 11+, which is why it is disabled by default.
183 rtc_apprtcmobile_broadcast_extension = false
184 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200185
186 # Determines whether Metal is available on iOS/macOS.
187 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Jiawei Ou08745302019-02-12 11:36:13 -0800188
189 # When set to false, builtin audio encoder/decoder factories and all the
190 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
191 # (they will still be included in libjingle_peerconnection_so.so and
192 # WebRTC.framework)
193 rtc_include_builtin_audio_codecs = true
194
195 # When set to false, builtin video encoder/decoder factories and all the
196 # video codecs they depends on will not be included in libwebrtc.{a|lib}
197 # (they will still be included in libjingle_peerconnection_so.so and
198 # WebRTC.framework)
199 rtc_include_builtin_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100200
201 # When set to true and in a standalone build, it will undefine UNICODE and
202 # _UNICODE (which are always defined globally by the Chromium Windows
203 # toolchain).
204 # This is only needed for testing purposes, WebRTC wants to be sure it
205 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
206 # wide character functions.
207 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 13:47:54 -0700208
209 # When set to true, a capturer implementation that uses the
210 # Windows.Graphics.Capture APIs will be available for use. These APIs are
211 # available in the Win 10 SDK v10.0.19041.
212 rtc_enable_win_wgc = false
Dan Minor9c686132018-01-15 10:20:00 -0500213}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800214
Dan Minor9c686132018-01-15 10:20:00 -0500215if (!build_with_mozilla) {
216 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800217}
218
219# A second declare_args block, so that declarations within it can
220# depend on the possibly overridden variables in the first
221# declare_args block.
222declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500223 # Enables the use of protocol buffers for debug recordings.
224 rtc_enable_protobuf = !build_with_mozilla
225
226 # Set this to disable building with support for SCTP data channels.
227 rtc_enable_sctp = !build_with_mozilla
228
229 # Disable these to not build components which can be externally provided.
230 rtc_build_json = !build_with_mozilla
231 rtc_build_libsrtp = !build_with_mozilla
232 rtc_build_libvpx = !build_with_mozilla
233 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500234 rtc_build_opus = !build_with_mozilla
235 rtc_build_ssl = !build_with_mozilla
236 rtc_build_usrsctp = !build_with_mozilla
237
238 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200239 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
240 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500241 rtc_enable_libevent = false
242 rtc_build_libevent = false
243 } else {
244 rtc_enable_libevent = true
245 rtc_build_libevent = !build_with_mozilla
246 }
247
Dan Minor9c686132018-01-15 10:20:00 -0500248 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
249 # build environments, even if available for Chromium builds.
250 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
251
mbonadei9aa3f0a2017-01-24 06:58:22 -0800252 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
253 rtc_include_pulse_audio = !build_with_chromium
254
255 # Chromium uses its own IO handling, so the internal ADM is only built for
256 # standalone WebRTC.
257 rtc_include_internal_audio_device = !build_with_chromium
258
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800259 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 12:02:32 +0200260 # TODO: Make sure that AVX2 works also for non-clang compilers.
261 if (is_clang == true) {
262 rtc_enable_avx2 = true
263 } else {
264 rtc_enable_avx2 = false
265 }
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800266
Philipp Hancke1a89bc82021-03-02 21:23:24 +0100267 # Set this to true to build the unit tests.
268 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 10:20:00 -0500269 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200270
271 # Set this to false to skip building code that also requires X11 extensions
272 # such as Xdamage, Xfixes.
273 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100274
275 # Set this to true to fully remove logging from WebRTC.
276 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100277
278 # Set this to true to disable trace events.
279 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100280
281 # Set this to true to disable detailed error message and logging for
282 # RTC_CHECKs.
283 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100284
285 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100286 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200287
288 # Set this to true to exclude the transient suppressor in the audio processing
289 # module from the build.
290 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800291}
292
293# Make it possible to provide custom locations for some libraries (move these
294# up into declare_args should we need to actually use them for the GN build).
295rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800296rtc_opus_dir = "//third_party/opus"
297
298# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200299rtc_desktop_capture_supported =
300 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900301 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800302
303###############################################################################
304# Templates
305#
306
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200307# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800308# chromium.
309# We need absolute paths for all configs in templates as they are shared in
310# different subdirectories.
311webrtc_root = get_path_info(".", "abspath")
312
313# Global configuration that should be applied to all WebRTC targets.
314# You normally shouldn't need to include this in your target as it's
315# automatically included when using the rtc_* templates.
316# It sets defines, include paths and compilation warnings accordingly,
317# both for WebRTC stand-alone builds and for the scenario when WebRTC
318# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700319rtc_common_configs = [
320 webrtc_root + ":common_config",
321 "//build/config/compiler:no_size_t_to_int_warning",
322]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800323
kthelgasonc0977102017-04-24 00:57:16 -0700324if (is_mac || is_ios) {
325 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
326}
327
mbonadei9aa3f0a2017-01-24 06:58:22 -0800328# Global public configuration that should be applied to all WebRTC targets. You
329# normally shouldn't need to include this in your target as it's automatically
330# included when using the rtc_* templates. It set the defines, include paths and
331# compilation warnings that should be propagated to dependents of the targets
332# depending on the target having this config.
333rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
334
335# Common configs to remove or add in all rtc targets.
336rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100337if (!build_with_chromium && is_clang) {
338 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
339}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800340rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200341rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200342rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800343
344set_defaults("rtc_test") {
345 configs = rtc_add_configs
346 suppressed_configs = []
347}
348
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200349set_defaults("rtc_library") {
350 configs = rtc_add_configs
351 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200352 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200353}
354
mbonadei9aa3f0a2017-01-24 06:58:22 -0800355set_defaults("rtc_source_set") {
356 configs = rtc_add_configs
357 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200358 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800359}
360
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200361set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800362 configs = rtc_add_configs
363 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200364 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800365}
366
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200367set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800368 configs = rtc_add_configs
369 suppressed_configs = []
370}
371
372set_defaults("rtc_shared_library") {
373 configs = rtc_add_configs
374 suppressed_configs = []
375}
376
Per Kjellandera7f2d842018-01-10 15:54:53 +0000377webrtc_default_visibility = [ webrtc_root + "/*" ]
378if (build_with_chromium) {
379 # Allow Chromium's WebRTC overrides targets to bypass the regular
380 # visibility restrictions.
381 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
382}
383
Karl Wibergbb23c832018-04-22 19:55:00 +0200384# ---- Poisons ----
385#
386# The general idea is that some targets declare that they contain some
387# kind of poison, which makes it impossible for other targets to
388# depend on them (even transitively) unless they declare themselves
389# immune to that particular type of poison.
390#
391# Targets that *contain* poison of type foo should contain the line
392#
393# poisonous = [ "foo" ]
394#
395# and targets that *are immune but arent't themselves poisonous*
396# should contain
397#
398# allow_poison = [ "foo" ]
399#
400# This useful in cases where we have some large target or set of
401# targets and want to ensure that most other targets do not
402# transitively depend on them. For example, almost no high-level
403# target should depend on the audio codecs, since we want WebRTC users
404# to be able to inject any subset of them and actually end up with a
405# binary that doesn't include the codecs they didn't inject.
406#
407# Test-only targets (`testonly` set to true) and non-public targets
408# (`visibility` not containing "*") are automatically immune to all
409# types of poison.
410#
411# Here's the complete list of all types of poison. It must be kept in
412# 1:1 correspondence with the set of //:poison_* targets.
413#
414all_poison_types = [
415 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
416 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200417
Danil Chapovalov41300af2019-07-10 12:44:43 +0200418 # Default task queue implementation.
419 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200420
421 # JSON parsing should not be needed in the "slim and modular" WebRTC.
422 "rtc_json",
423
424 # Software video codecs (VP8 and VP9 through libvpx).
425 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200426]
427
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000428absl_include_config = "//third_party/abseil-cpp:absl_include_config"
429absl_define_config = "//third_party/abseil-cpp:absl_define_config"
430
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200431# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
432# that are testonly.
433absl_flags_config = webrtc_root + ":absl_flags_configs"
434
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100435# WebRTC wrapper of Chromium's test() template. This template just adds some
436# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
437# target.
438# The parameter `is_xctest` is different from the one in the Chromium's test()
439# template (and it is not forwarded to it). In rtc_test(), the argument
440# `is_xctest` is used to avoid to take dependencies that are not needed
441# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800442template("rtc_test") {
443 test(target_name) {
444 forward_variables_from(invoker,
445 "*",
446 [
447 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100448 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800449 "public_configs",
450 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200451 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800452 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100453
454 # Always override to public because when target_os is Android the `test`
455 # template can override it to [ "*" ] and we want to avoid conditional
456 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100457 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800458 configs += invoker.configs
459 configs -= rtc_remove_configs
460 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000461 public_configs = [
462 rtc_common_inherited_config,
463 absl_include_config,
464 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200465 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000466 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800467 if (defined(invoker.public_configs)) {
468 public_configs += invoker.public_configs
469 }
sakald7fdb802017-05-26 01:51:53 -0700470 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800471 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200472 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200473 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 19:03:37 +0200474 deps += [
475 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
476 webrtc_root + "test:native_test_java",
477 ]
sakald7fdb802017-05-26 01:51:53 -0700478 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100479
480 # When not targeting a simulator, building //base/test:google_test_runner
481 # fails, so it is added only when the test is not a real XCTest and when
482 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100483 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100484 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
485 xctest_module_target = "//base/test:google_test_runner"
486 }
487 }
Andrey Logvin78646002021-01-29 10:50:19 +0000488
489 # If absl_deps is [], no action is needed. If not [], then it needs to be
490 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
491 # otherwise it just needs to be added to deps.
492 if (defined(absl_deps) && absl_deps != []) {
493 if (!defined(deps)) {
494 deps = []
495 }
496 if (build_with_chromium) {
497 deps += [ "//third_party/abseil-cpp:absl" ]
498 } else {
499 deps += absl_deps
500 }
501 }
502
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100503 if (using_sanitizer) {
504 if (is_linux) {
505 if (!defined(invoker.data)) {
506 data = []
507 }
508 data +=
509 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
510 }
511 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800512 }
513}
514
515template("rtc_source_set") {
516 source_set(target_name) {
517 forward_variables_from(invoker,
518 "*",
519 [
520 "configs",
521 "public_configs",
522 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200523 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800524 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200525 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000526 if (!defined(visibility)) {
527 visibility = webrtc_default_visibility
528 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200529
530 # What's your poison?
531 if (defined(testonly) && testonly) {
532 assert(!defined(poisonous))
533 assert(!defined(allow_poison))
534 } else {
535 if (!defined(poisonous)) {
536 poisonous = []
537 }
538 if (!defined(allow_poison)) {
539 allow_poison = []
540 }
541 if (!defined(assert_no_deps)) {
542 assert_no_deps = []
543 }
544 if (!defined(deps)) {
545 deps = []
546 }
547 foreach(p, poisonous) {
548 deps += [ webrtc_root + ":poison_" + p ]
549 }
550 foreach(poison_type, all_poison_types) {
551 allow_dep = true
552 foreach(v, visibility) {
553 if (v == "*") {
554 allow_dep = false
555 }
556 }
557 foreach(p, allow_poison + poisonous) {
558 if (p == poison_type) {
559 allow_dep = true
560 }
561 }
562 if (!allow_dep) {
563 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
564 }
565 }
566 }
567
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100568 # Chromium should only depend on the WebRTC component in order to
569 # avoid to statically link WebRTC in a component build.
570 if (build_with_chromium) {
571 publicly_visible = false
572 foreach(v, visibility) {
573 if (v == "*") {
574 publicly_visible = true
575 }
576 }
577 if (publicly_visible) {
578 visibility = []
579 visibility = webrtc_default_visibility
580 }
581 }
582
Mirko Bonadei96ede162018-09-06 13:45:44 +0200583 if (!defined(testonly) || !testonly) {
584 configs += rtc_prod_configs
585 }
586
mbonadei9aa3f0a2017-01-24 06:58:22 -0800587 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200588 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800589 configs -= rtc_remove_configs
590 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000591 public_configs = [
592 rtc_common_inherited_config,
593 absl_include_config,
594 absl_define_config,
595 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200596 if (defined(testonly) && testonly) {
597 public_configs += [ absl_flags_config ]
598 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800599 if (defined(invoker.public_configs)) {
600 public_configs += invoker.public_configs
601 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200602
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200603 # If absl_deps is [], no action is needed. If not [], then it needs to be
604 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200605 # otherwise it just needs to be added to deps.
606 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200607 if (!defined(deps)) {
608 deps = []
609 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200610 if (build_with_chromium) {
611 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200612 } else {
613 deps += absl_deps
614 }
615 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800616 }
617}
618
mbonadei9aa3f0a2017-01-24 06:58:22 -0800619template("rtc_static_library") {
620 static_library(target_name) {
621 forward_variables_from(invoker,
622 "*",
623 [
624 "configs",
625 "public_configs",
626 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200627 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800628 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200629 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000630 if (!defined(visibility)) {
631 visibility = webrtc_default_visibility
632 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200633
634 # What's your poison?
635 if (defined(testonly) && testonly) {
636 assert(!defined(poisonous))
637 assert(!defined(allow_poison))
638 } else {
639 if (!defined(poisonous)) {
640 poisonous = []
641 }
642 if (!defined(allow_poison)) {
643 allow_poison = []
644 }
645 if (!defined(assert_no_deps)) {
646 assert_no_deps = []
647 }
648 if (!defined(deps)) {
649 deps = []
650 }
651 foreach(p, poisonous) {
652 deps += [ webrtc_root + ":poison_" + p ]
653 }
654 foreach(poison_type, all_poison_types) {
655 allow_dep = true
656 foreach(v, visibility) {
657 if (v == "*") {
658 allow_dep = false
659 }
660 }
661 foreach(p, allow_poison + poisonous) {
662 if (p == poison_type) {
663 allow_dep = true
664 }
665 }
666 if (!allow_dep) {
667 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
668 }
669 }
670 }
671
Mirko Bonadei96ede162018-09-06 13:45:44 +0200672 if (!defined(testonly) || !testonly) {
673 configs += rtc_prod_configs
674 }
675
mbonadei9aa3f0a2017-01-24 06:58:22 -0800676 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200677 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800678 configs -= rtc_remove_configs
679 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000680 public_configs = [
681 rtc_common_inherited_config,
682 absl_include_config,
683 absl_define_config,
684 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200685 if (defined(testonly) && testonly) {
686 public_configs += [ absl_flags_config ]
687 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800688 if (defined(invoker.public_configs)) {
689 public_configs += invoker.public_configs
690 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200691
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200692 # If absl_deps is [], no action is needed. If not [], then it needs to be
693 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200694 # otherwise it just needs to be added to deps.
695 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200696 if (!defined(deps)) {
697 deps = []
698 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200699 if (build_with_chromium) {
700 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200701 } else {
702 deps += absl_deps
703 }
704 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800705 }
706}
707
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200708# This template automatically switches the target type between source_set
709# and static_library.
710#
711# This should be the default target type for all the WebRTC targets with
712# one exception. Do not use this template for header only targets, in that case
713# rtc_source_set must be used in order to avoid build errors (e.g. libtool
714# complains if the output .a file is empty).
715#
716# How does it work:
717# Since all files in a source_set are linked into a final binary, while files
718# in a static library are only linked in if at least one symbol in them is
719# referenced, in component builds source_sets are easy to deal with because
720# all their object files are passed to the linker to create a shared library.
721# In release builds instead, static_libraries are preferred since they allow
722# the linker to discard dead code.
723# For the same reason, testonly targets will always be expanded to
724# source_set in order to be sure that tests are present in the test binary.
725template("rtc_library") {
726 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
727 target_type = "source_set"
728 } else {
729 target_type = "static_library"
730 }
731 target(target_type, target_name) {
732 forward_variables_from(invoker,
733 "*",
734 [
735 "configs",
736 "public_configs",
737 "suppressed_configs",
738 "visibility",
739 ])
740 forward_variables_from(invoker, [ "visibility" ])
741 if (!defined(visibility)) {
742 visibility = webrtc_default_visibility
743 }
744
745 # What's your poison?
746 if (defined(testonly) && testonly) {
747 assert(!defined(poisonous))
748 assert(!defined(allow_poison))
749 } else {
750 if (!defined(poisonous)) {
751 poisonous = []
752 }
753 if (!defined(allow_poison)) {
754 allow_poison = []
755 }
756 if (!defined(assert_no_deps)) {
757 assert_no_deps = []
758 }
759 if (!defined(deps)) {
760 deps = []
761 }
762 foreach(p, poisonous) {
763 deps += [ webrtc_root + ":poison_" + p ]
764 }
765 foreach(poison_type, all_poison_types) {
766 allow_dep = true
767 foreach(v, visibility) {
768 if (v == "*") {
769 allow_dep = false
770 }
771 }
772 foreach(p, allow_poison + poisonous) {
773 if (p == poison_type) {
774 allow_dep = true
775 }
776 }
777 if (!allow_dep) {
778 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
779 }
780 }
781 }
782
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100783 # Chromium should only depend on the WebRTC component in order to
784 # avoid to statically link WebRTC in a component build.
785 if (build_with_chromium) {
786 publicly_visible = false
787 foreach(v, visibility) {
788 if (v == "*") {
789 publicly_visible = true
790 }
791 }
792 if (publicly_visible) {
793 visibility = []
794 visibility = webrtc_default_visibility
795 }
796 }
797
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200798 if (!defined(testonly) || !testonly) {
799 configs += rtc_prod_configs
800 }
801
802 configs += invoker.configs
803 configs += rtc_library_impl_config
804 configs -= rtc_remove_configs
805 configs -= invoker.suppressed_configs
806 public_configs = [
807 rtc_common_inherited_config,
808 absl_include_config,
809 absl_define_config,
810 ]
811 if (defined(testonly) && testonly) {
812 public_configs += [ absl_flags_config ]
813 }
814 if (defined(invoker.public_configs)) {
815 public_configs += invoker.public_configs
816 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200817
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200818 # If absl_deps is [], no action is needed. If not [], then it needs to be
819 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200820 # otherwise it just needs to be added to deps.
821 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200822 if (!defined(deps)) {
823 deps = []
824 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200825 if (build_with_chromium) {
826 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200827 } else {
828 deps += absl_deps
829 }
830 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200831 }
832}
833
834template("rtc_executable") {
835 executable(target_name) {
836 forward_variables_from(invoker,
837 "*",
838 [
839 "deps",
840 "configs",
841 "public_configs",
842 "suppressed_configs",
843 "visibility",
844 ])
845 forward_variables_from(invoker, [ "visibility" ])
846 if (!defined(visibility)) {
847 visibility = webrtc_default_visibility
848 }
849 configs += invoker.configs
850 configs -= rtc_remove_configs
851 configs -= invoker.suppressed_configs
852 deps = invoker.deps
853
854 public_configs = [
855 rtc_common_inherited_config,
856 absl_include_config,
857 absl_define_config,
858 ]
859 if (defined(testonly) && testonly) {
860 public_configs += [ absl_flags_config ]
861 }
862 if (defined(invoker.public_configs)) {
863 public_configs += invoker.public_configs
864 }
865 if (is_win) {
866 deps += [
867 # Give executables the default manifest on Windows (a no-op elsewhere).
868 "//build/win:default_exe_manifest",
869 ]
870 }
871 }
872}
873
mbonadei9aa3f0a2017-01-24 06:58:22 -0800874template("rtc_shared_library") {
875 shared_library(target_name) {
876 forward_variables_from(invoker,
877 "*",
878 [
879 "configs",
880 "public_configs",
881 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200882 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800883 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200884 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000885 if (!defined(visibility)) {
886 visibility = webrtc_default_visibility
887 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200888
889 # What's your poison?
890 if (defined(testonly) && testonly) {
891 assert(!defined(poisonous))
892 assert(!defined(allow_poison))
893 } else {
894 if (!defined(poisonous)) {
895 poisonous = []
896 }
897 if (!defined(allow_poison)) {
898 allow_poison = []
899 }
900 if (!defined(assert_no_deps)) {
901 assert_no_deps = []
902 }
903 if (!defined(deps)) {
904 deps = []
905 }
906 foreach(p, poisonous) {
907 deps += [ webrtc_root + ":poison_" + p ]
908 }
909 foreach(poison_type, all_poison_types) {
910 allow_dep = true
911 foreach(v, visibility) {
912 if (v == "*") {
913 allow_dep = false
914 }
915 }
916 foreach(p, allow_poison + poisonous) {
917 if (p == poison_type) {
918 allow_dep = true
919 }
920 }
921 if (!allow_dep) {
922 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
923 }
924 }
925 }
926
mbonadei9aa3f0a2017-01-24 06:58:22 -0800927 configs += invoker.configs
928 configs -= rtc_remove_configs
929 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000930 public_configs = [
931 rtc_common_inherited_config,
932 absl_include_config,
933 absl_define_config,
934 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200935 if (defined(testonly) && testonly) {
936 public_configs += [ absl_flags_config ]
937 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800938 if (defined(invoker.public_configs)) {
939 public_configs += invoker.public_configs
940 }
941 }
942}
kthelgason4065a572017-02-14 04:58:56 -0800943
944if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400945 # TODO: Generate module.modulemap file to enable use in Swift
946 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100947 template("ios_framework_bundle_with_umbrella_header") {
948 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900949 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100950 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900951 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
952
953 action_foreach("create_bracket_include_headers_$target_name") {
954 script = "//tools_webrtc/apple/copy_framework_header.py"
955 sources = invoker.sources
956 output_name = invoker.output_name
957 outputs = [
958 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
959 ]
960 args = [
961 "--input",
962 "{{source}}",
963 "--output",
964 rebase_path(target_gen_dir, root_build_dir) +
965 "/$output_name.framework/WebRTC/{{source_file_part}}",
966 ]
967 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100968
969 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900970 forward_variables_from(invoker, "*", [ "public_headers" ])
971 public_headers = get_target_outputs(
972 ":create_bracket_include_headers_$this_target_name")
973 deps += [
974 ":copy_umbrella_header_$target_name",
975 ":create_bracket_include_headers_$target_name",
976 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100977 }
978
979 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900980 public_headers = get_target_outputs(
981 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100982
983 script = "//tools_webrtc/ios/generate_umbrella_header.py"
984
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100985 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100986 args = [
987 "--out",
988 rebase_path(umbrella_header_path, root_build_dir),
989 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200990 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900991 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100992 }
993
994 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100995 sources = [ umbrella_header_path ]
996 outputs =
997 [ "$root_out_dir/$output_name.framework/Headers/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100998
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100999 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001000 }
1001 }
1002
1003 set_defaults("ios_framework_bundle_with_umbrella_header") {
1004 configs = default_shared_library_configs
1005 }
kthelgason4065a572017-02-14 04:58:56 -08001006}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001007
Anders Carlsson37bbf792018-09-05 16:29:27 +02001008if (is_mac) {
1009 template("mac_framework_bundle_with_umbrella_header") {
1010 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001011 this_target_name = target_name
1012 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001013 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +02001014
1015 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -08001016 forward_variables_from(invoker, "*", [ "configs" ])
1017 if (defined(invoker.configs)) {
1018 configs += invoker.configs
1019 }
Anders Carlsson37bbf792018-09-05 16:29:27 +02001020
1021 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001022 framework_contents = [
1023 "Headers",
1024 "Modules",
1025 "Resources",
1026 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001027
1028 ldflags = [
1029 "-all_load",
1030 "-install_name",
1031 "@rpath/$output_name.framework/$output_name",
1032 ]
1033
1034 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001035 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001036 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001037 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001038 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001039 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001040 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001041 ]
1042 }
1043
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001044 action_foreach("create_bracket_include_headers_$this_target_name") {
1045 script = "//tools_webrtc/apple/copy_framework_header.py"
1046 sources = invoker.sources
1047 output_name = invoker.output_name
1048 outputs = [
1049 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1050 ]
1051 args = [
1052 "--input",
1053 "{{source}}",
1054 "--output",
1055 rebase_path(target_gen_dir, root_build_dir) +
1056 "/$output_name.framework/WebRTC/{{source_file_part}}",
1057 ]
1058 }
1059
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001060 bundle_data("copy_framework_headers_$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
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001064 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001065 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001066 }
1067
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001068 action("modulemap_$this_target_name") {
1069 script = "//tools_webrtc/ios/generate_modulemap.py"
1070 args = [
1071 "--out",
1072 rebase_path(modulemap_path, root_build_dir),
1073 "--name",
1074 output_name,
1075 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001076 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001077 }
1078
1079 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001080 sources = [ modulemap_path ]
1081 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1082 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001083 }
1084
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001085 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001086 sources = get_target_outputs(
1087 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001088
1089 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1090
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001091 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001092 args = [
1093 "--out",
1094 rebase_path(umbrella_header_path, root_build_dir),
1095 "--sources",
1096 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001097 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001098 }
1099
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001100 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001101 sources = [ umbrella_header_path ]
1102 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001103
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001104 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001105 }
1106 }
1107}
1108
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001109if (is_android) {
1110 template("rtc_android_library") {
1111 android_library(target_name) {
1112 forward_variables_from(invoker,
1113 "*",
1114 [
1115 "configs",
1116 "public_configs",
1117 "suppressed_configs",
1118 "visibility",
1119 ])
1120
Oleh Prypin05aee742018-11-23 17:29:44 +01001121 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001122
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001123 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001124 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001125
1126 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001127 if (defined(invoker.errorprone_args)) {
1128 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001129 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001130
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001131 if (!defined(deps)) {
1132 deps = []
1133 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001134
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001135 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001136 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001137 }
1138 }
1139
1140 template("rtc_android_apk") {
1141 android_apk(target_name) {
1142 forward_variables_from(invoker,
1143 "*",
1144 [
1145 "configs",
1146 "public_configs",
1147 "suppressed_configs",
1148 "visibility",
1149 ])
1150
1151 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001152 errorprone_args = []
1153 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001154
1155 if (!defined(deps)) {
1156 deps = []
1157 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001158
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001159 no_build_hooks = true
1160 }
1161 }
1162
1163 template("rtc_instrumentation_test_apk") {
1164 instrumentation_test_apk(target_name) {
1165 forward_variables_from(invoker,
1166 "*",
1167 [
1168 "configs",
1169 "public_configs",
1170 "suppressed_configs",
1171 "visibility",
1172 ])
1173
1174 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001175 errorprone_args = []
1176 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001177
1178 if (!defined(deps)) {
1179 deps = []
1180 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001181
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001182 no_build_hooks = true
1183 }
1184 }
1185}