blob: c1227bab9d174140848f8cdbda00aeb6fbd3c5e3 [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
mbonadei9aa3f0a2017-01-24 06:58:22 -0800267 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500268 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200269
270 # Set this to false to skip building code that also requires X11 extensions
271 # such as Xdamage, Xfixes.
272 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100273
274 # Set this to true to fully remove logging from WebRTC.
275 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100276
277 # Set this to true to disable trace events.
278 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100279
280 # Set this to true to disable detailed error message and logging for
281 # RTC_CHECKs.
282 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100283
284 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100285 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200286
287 # Set this to true to exclude the transient suppressor in the audio processing
288 # module from the build.
289 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800290}
291
292# Make it possible to provide custom locations for some libraries (move these
293# up into declare_args should we need to actually use them for the GN build).
294rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800295rtc_opus_dir = "//third_party/opus"
296
297# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200298rtc_desktop_capture_supported =
299 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900300 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800301
302###############################################################################
303# Templates
304#
305
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200306# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800307# chromium.
308# We need absolute paths for all configs in templates as they are shared in
309# different subdirectories.
310webrtc_root = get_path_info(".", "abspath")
311
312# Global configuration that should be applied to all WebRTC targets.
313# You normally shouldn't need to include this in your target as it's
314# automatically included when using the rtc_* templates.
315# It sets defines, include paths and compilation warnings accordingly,
316# both for WebRTC stand-alone builds and for the scenario when WebRTC
317# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700318rtc_common_configs = [
319 webrtc_root + ":common_config",
320 "//build/config/compiler:no_size_t_to_int_warning",
321]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800322
kthelgasonc0977102017-04-24 00:57:16 -0700323if (is_mac || is_ios) {
324 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
325}
326
mbonadei9aa3f0a2017-01-24 06:58:22 -0800327# Global public configuration that should be applied to all WebRTC targets. You
328# normally shouldn't need to include this in your target as it's automatically
329# included when using the rtc_* templates. It set the defines, include paths and
330# compilation warnings that should be propagated to dependents of the targets
331# depending on the target having this config.
332rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
333
334# Common configs to remove or add in all rtc targets.
335rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100336if (!build_with_chromium && is_clang) {
337 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
338}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800339rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200340rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200341rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800342
343set_defaults("rtc_test") {
344 configs = rtc_add_configs
345 suppressed_configs = []
346}
347
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200348set_defaults("rtc_library") {
349 configs = rtc_add_configs
350 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200351 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200352}
353
mbonadei9aa3f0a2017-01-24 06:58:22 -0800354set_defaults("rtc_source_set") {
355 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_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800361 configs = rtc_add_configs
362 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200363 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800364}
365
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200366set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800367 configs = rtc_add_configs
368 suppressed_configs = []
369}
370
371set_defaults("rtc_shared_library") {
372 configs = rtc_add_configs
373 suppressed_configs = []
374}
375
Per Kjellandera7f2d842018-01-10 15:54:53 +0000376webrtc_default_visibility = [ webrtc_root + "/*" ]
377if (build_with_chromium) {
378 # Allow Chromium's WebRTC overrides targets to bypass the regular
379 # visibility restrictions.
380 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
381}
382
Karl Wibergbb23c832018-04-22 19:55:00 +0200383# ---- Poisons ----
384#
385# The general idea is that some targets declare that they contain some
386# kind of poison, which makes it impossible for other targets to
387# depend on them (even transitively) unless they declare themselves
388# immune to that particular type of poison.
389#
390# Targets that *contain* poison of type foo should contain the line
391#
392# poisonous = [ "foo" ]
393#
394# and targets that *are immune but arent't themselves poisonous*
395# should contain
396#
397# allow_poison = [ "foo" ]
398#
399# This useful in cases where we have some large target or set of
400# targets and want to ensure that most other targets do not
401# transitively depend on them. For example, almost no high-level
402# target should depend on the audio codecs, since we want WebRTC users
403# to be able to inject any subset of them and actually end up with a
404# binary that doesn't include the codecs they didn't inject.
405#
406# Test-only targets (`testonly` set to true) and non-public targets
407# (`visibility` not containing "*") are automatically immune to all
408# types of poison.
409#
410# Here's the complete list of all types of poison. It must be kept in
411# 1:1 correspondence with the set of //:poison_* targets.
412#
413all_poison_types = [
414 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
415 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200416
Danil Chapovalov41300af2019-07-10 12:44:43 +0200417 # Default task queue implementation.
418 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200419
420 # JSON parsing should not be needed in the "slim and modular" WebRTC.
421 "rtc_json",
422
423 # Software video codecs (VP8 and VP9 through libvpx).
424 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200425]
426
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000427absl_include_config = "//third_party/abseil-cpp:absl_include_config"
428absl_define_config = "//third_party/abseil-cpp:absl_define_config"
429
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200430# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
431# that are testonly.
432absl_flags_config = webrtc_root + ":absl_flags_configs"
433
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100434# WebRTC wrapper of Chromium's test() template. This template just adds some
435# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
436# target.
437# The parameter `is_xctest` is different from the one in the Chromium's test()
438# template (and it is not forwarded to it). In rtc_test(), the argument
439# `is_xctest` is used to avoid to take dependencies that are not needed
440# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800441template("rtc_test") {
442 test(target_name) {
443 forward_variables_from(invoker,
444 "*",
445 [
446 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100447 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800448 "public_configs",
449 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200450 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800451 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100452
453 # Always override to public because when target_os is Android the `test`
454 # template can override it to [ "*" ] and we want to avoid conditional
455 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100456 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800457 configs += invoker.configs
458 configs -= rtc_remove_configs
459 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000460 public_configs = [
461 rtc_common_inherited_config,
462 absl_include_config,
463 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200464 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000465 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800466 if (defined(invoker.public_configs)) {
467 public_configs += invoker.public_configs
468 }
sakald7fdb802017-05-26 01:51:53 -0700469 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800470 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200471 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200472 target_sdk_version = 23
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800473 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700474 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100475
476 # When not targeting a simulator, building //base/test:google_test_runner
477 # fails, so it is added only when the test is not a real XCTest and when
478 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100479 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100480 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
481 xctest_module_target = "//base/test:google_test_runner"
482 }
483 }
Andrey Logvin78646002021-01-29 10:50:19 +0000484
485 # If absl_deps is [], no action is needed. If not [], then it needs to be
486 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
487 # otherwise it just needs to be added to deps.
488 if (defined(absl_deps) && absl_deps != []) {
489 if (!defined(deps)) {
490 deps = []
491 }
492 if (build_with_chromium) {
493 deps += [ "//third_party/abseil-cpp:absl" ]
494 } else {
495 deps += absl_deps
496 }
497 }
498
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100499 if (using_sanitizer) {
500 if (is_linux) {
501 if (!defined(invoker.data)) {
502 data = []
503 }
504 data +=
505 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
506 }
507 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800508 }
509}
510
511template("rtc_source_set") {
512 source_set(target_name) {
513 forward_variables_from(invoker,
514 "*",
515 [
516 "configs",
517 "public_configs",
518 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200519 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800520 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200521 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000522 if (!defined(visibility)) {
523 visibility = webrtc_default_visibility
524 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200525
526 # What's your poison?
527 if (defined(testonly) && testonly) {
528 assert(!defined(poisonous))
529 assert(!defined(allow_poison))
530 } else {
531 if (!defined(poisonous)) {
532 poisonous = []
533 }
534 if (!defined(allow_poison)) {
535 allow_poison = []
536 }
537 if (!defined(assert_no_deps)) {
538 assert_no_deps = []
539 }
540 if (!defined(deps)) {
541 deps = []
542 }
543 foreach(p, poisonous) {
544 deps += [ webrtc_root + ":poison_" + p ]
545 }
546 foreach(poison_type, all_poison_types) {
547 allow_dep = true
548 foreach(v, visibility) {
549 if (v == "*") {
550 allow_dep = false
551 }
552 }
553 foreach(p, allow_poison + poisonous) {
554 if (p == poison_type) {
555 allow_dep = true
556 }
557 }
558 if (!allow_dep) {
559 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
560 }
561 }
562 }
563
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100564 # Chromium should only depend on the WebRTC component in order to
565 # avoid to statically link WebRTC in a component build.
566 if (build_with_chromium) {
567 publicly_visible = false
568 foreach(v, visibility) {
569 if (v == "*") {
570 publicly_visible = true
571 }
572 }
573 if (publicly_visible) {
574 visibility = []
575 visibility = webrtc_default_visibility
576 }
577 }
578
Mirko Bonadei96ede162018-09-06 13:45:44 +0200579 if (!defined(testonly) || !testonly) {
580 configs += rtc_prod_configs
581 }
582
mbonadei9aa3f0a2017-01-24 06:58:22 -0800583 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200584 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800585 configs -= rtc_remove_configs
586 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000587 public_configs = [
588 rtc_common_inherited_config,
589 absl_include_config,
590 absl_define_config,
591 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200592 if (defined(testonly) && testonly) {
593 public_configs += [ absl_flags_config ]
594 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800595 if (defined(invoker.public_configs)) {
596 public_configs += invoker.public_configs
597 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200598
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200599 # If absl_deps is [], no action is needed. If not [], then it needs to be
600 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200601 # otherwise it just needs to be added to deps.
602 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200603 if (!defined(deps)) {
604 deps = []
605 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200606 if (build_with_chromium) {
607 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200608 } else {
609 deps += absl_deps
610 }
611 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800612 }
613}
614
mbonadei9aa3f0a2017-01-24 06:58:22 -0800615template("rtc_static_library") {
616 static_library(target_name) {
617 forward_variables_from(invoker,
618 "*",
619 [
620 "configs",
621 "public_configs",
622 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200623 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800624 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200625 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000626 if (!defined(visibility)) {
627 visibility = webrtc_default_visibility
628 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200629
630 # What's your poison?
631 if (defined(testonly) && testonly) {
632 assert(!defined(poisonous))
633 assert(!defined(allow_poison))
634 } else {
635 if (!defined(poisonous)) {
636 poisonous = []
637 }
638 if (!defined(allow_poison)) {
639 allow_poison = []
640 }
641 if (!defined(assert_no_deps)) {
642 assert_no_deps = []
643 }
644 if (!defined(deps)) {
645 deps = []
646 }
647 foreach(p, poisonous) {
648 deps += [ webrtc_root + ":poison_" + p ]
649 }
650 foreach(poison_type, all_poison_types) {
651 allow_dep = true
652 foreach(v, visibility) {
653 if (v == "*") {
654 allow_dep = false
655 }
656 }
657 foreach(p, allow_poison + poisonous) {
658 if (p == poison_type) {
659 allow_dep = true
660 }
661 }
662 if (!allow_dep) {
663 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
664 }
665 }
666 }
667
Mirko Bonadei96ede162018-09-06 13:45:44 +0200668 if (!defined(testonly) || !testonly) {
669 configs += rtc_prod_configs
670 }
671
mbonadei9aa3f0a2017-01-24 06:58:22 -0800672 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200673 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800674 configs -= rtc_remove_configs
675 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000676 public_configs = [
677 rtc_common_inherited_config,
678 absl_include_config,
679 absl_define_config,
680 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200681 if (defined(testonly) && testonly) {
682 public_configs += [ absl_flags_config ]
683 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800684 if (defined(invoker.public_configs)) {
685 public_configs += invoker.public_configs
686 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200687
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200688 # If absl_deps is [], no action is needed. If not [], then it needs to be
689 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200690 # otherwise it just needs to be added to deps.
691 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200692 if (!defined(deps)) {
693 deps = []
694 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200695 if (build_with_chromium) {
696 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200697 } else {
698 deps += absl_deps
699 }
700 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800701 }
702}
703
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200704# This template automatically switches the target type between source_set
705# and static_library.
706#
707# This should be the default target type for all the WebRTC targets with
708# one exception. Do not use this template for header only targets, in that case
709# rtc_source_set must be used in order to avoid build errors (e.g. libtool
710# complains if the output .a file is empty).
711#
712# How does it work:
713# Since all files in a source_set are linked into a final binary, while files
714# in a static library are only linked in if at least one symbol in them is
715# referenced, in component builds source_sets are easy to deal with because
716# all their object files are passed to the linker to create a shared library.
717# In release builds instead, static_libraries are preferred since they allow
718# the linker to discard dead code.
719# For the same reason, testonly targets will always be expanded to
720# source_set in order to be sure that tests are present in the test binary.
721template("rtc_library") {
722 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
723 target_type = "source_set"
724 } else {
725 target_type = "static_library"
726 }
727 target(target_type, target_name) {
728 forward_variables_from(invoker,
729 "*",
730 [
731 "configs",
732 "public_configs",
733 "suppressed_configs",
734 "visibility",
735 ])
736 forward_variables_from(invoker, [ "visibility" ])
737 if (!defined(visibility)) {
738 visibility = webrtc_default_visibility
739 }
740
741 # What's your poison?
742 if (defined(testonly) && testonly) {
743 assert(!defined(poisonous))
744 assert(!defined(allow_poison))
745 } else {
746 if (!defined(poisonous)) {
747 poisonous = []
748 }
749 if (!defined(allow_poison)) {
750 allow_poison = []
751 }
752 if (!defined(assert_no_deps)) {
753 assert_no_deps = []
754 }
755 if (!defined(deps)) {
756 deps = []
757 }
758 foreach(p, poisonous) {
759 deps += [ webrtc_root + ":poison_" + p ]
760 }
761 foreach(poison_type, all_poison_types) {
762 allow_dep = true
763 foreach(v, visibility) {
764 if (v == "*") {
765 allow_dep = false
766 }
767 }
768 foreach(p, allow_poison + poisonous) {
769 if (p == poison_type) {
770 allow_dep = true
771 }
772 }
773 if (!allow_dep) {
774 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
775 }
776 }
777 }
778
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100779 # Chromium should only depend on the WebRTC component in order to
780 # avoid to statically link WebRTC in a component build.
781 if (build_with_chromium) {
782 publicly_visible = false
783 foreach(v, visibility) {
784 if (v == "*") {
785 publicly_visible = true
786 }
787 }
788 if (publicly_visible) {
789 visibility = []
790 visibility = webrtc_default_visibility
791 }
792 }
793
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200794 if (!defined(testonly) || !testonly) {
795 configs += rtc_prod_configs
796 }
797
798 configs += invoker.configs
799 configs += rtc_library_impl_config
800 configs -= rtc_remove_configs
801 configs -= invoker.suppressed_configs
802 public_configs = [
803 rtc_common_inherited_config,
804 absl_include_config,
805 absl_define_config,
806 ]
807 if (defined(testonly) && testonly) {
808 public_configs += [ absl_flags_config ]
809 }
810 if (defined(invoker.public_configs)) {
811 public_configs += invoker.public_configs
812 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200813
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200814 # If absl_deps is [], no action is needed. If not [], then it needs to be
815 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200816 # otherwise it just needs to be added to deps.
817 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200818 if (!defined(deps)) {
819 deps = []
820 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200821 if (build_with_chromium) {
822 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200823 } else {
824 deps += absl_deps
825 }
826 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200827 }
828}
829
830template("rtc_executable") {
831 executable(target_name) {
832 forward_variables_from(invoker,
833 "*",
834 [
835 "deps",
836 "configs",
837 "public_configs",
838 "suppressed_configs",
839 "visibility",
840 ])
841 forward_variables_from(invoker, [ "visibility" ])
842 if (!defined(visibility)) {
843 visibility = webrtc_default_visibility
844 }
845 configs += invoker.configs
846 configs -= rtc_remove_configs
847 configs -= invoker.suppressed_configs
848 deps = invoker.deps
849
850 public_configs = [
851 rtc_common_inherited_config,
852 absl_include_config,
853 absl_define_config,
854 ]
855 if (defined(testonly) && testonly) {
856 public_configs += [ absl_flags_config ]
857 }
858 if (defined(invoker.public_configs)) {
859 public_configs += invoker.public_configs
860 }
861 if (is_win) {
862 deps += [
863 # Give executables the default manifest on Windows (a no-op elsewhere).
864 "//build/win:default_exe_manifest",
865 ]
866 }
867 }
868}
869
mbonadei9aa3f0a2017-01-24 06:58:22 -0800870template("rtc_shared_library") {
871 shared_library(target_name) {
872 forward_variables_from(invoker,
873 "*",
874 [
875 "configs",
876 "public_configs",
877 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200878 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800879 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200880 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000881 if (!defined(visibility)) {
882 visibility = webrtc_default_visibility
883 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200884
885 # What's your poison?
886 if (defined(testonly) && testonly) {
887 assert(!defined(poisonous))
888 assert(!defined(allow_poison))
889 } else {
890 if (!defined(poisonous)) {
891 poisonous = []
892 }
893 if (!defined(allow_poison)) {
894 allow_poison = []
895 }
896 if (!defined(assert_no_deps)) {
897 assert_no_deps = []
898 }
899 if (!defined(deps)) {
900 deps = []
901 }
902 foreach(p, poisonous) {
903 deps += [ webrtc_root + ":poison_" + p ]
904 }
905 foreach(poison_type, all_poison_types) {
906 allow_dep = true
907 foreach(v, visibility) {
908 if (v == "*") {
909 allow_dep = false
910 }
911 }
912 foreach(p, allow_poison + poisonous) {
913 if (p == poison_type) {
914 allow_dep = true
915 }
916 }
917 if (!allow_dep) {
918 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
919 }
920 }
921 }
922
mbonadei9aa3f0a2017-01-24 06:58:22 -0800923 configs += invoker.configs
924 configs -= rtc_remove_configs
925 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000926 public_configs = [
927 rtc_common_inherited_config,
928 absl_include_config,
929 absl_define_config,
930 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200931 if (defined(testonly) && testonly) {
932 public_configs += [ absl_flags_config ]
933 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800934 if (defined(invoker.public_configs)) {
935 public_configs += invoker.public_configs
936 }
937 }
938}
kthelgason4065a572017-02-14 04:58:56 -0800939
940if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400941 # TODO: Generate module.modulemap file to enable use in Swift
942 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100943 template("ios_framework_bundle_with_umbrella_header") {
944 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900945 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100946 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900947 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
948
949 action_foreach("create_bracket_include_headers_$target_name") {
950 script = "//tools_webrtc/apple/copy_framework_header.py"
951 sources = invoker.sources
952 output_name = invoker.output_name
953 outputs = [
954 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
955 ]
956 args = [
957 "--input",
958 "{{source}}",
959 "--output",
960 rebase_path(target_gen_dir, root_build_dir) +
961 "/$output_name.framework/WebRTC/{{source_file_part}}",
962 ]
963 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100964
965 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900966 forward_variables_from(invoker, "*", [ "public_headers" ])
967 public_headers = get_target_outputs(
968 ":create_bracket_include_headers_$this_target_name")
969 deps += [
970 ":copy_umbrella_header_$target_name",
971 ":create_bracket_include_headers_$target_name",
972 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100973 }
974
975 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900976 public_headers = get_target_outputs(
977 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100978
979 script = "//tools_webrtc/ios/generate_umbrella_header.py"
980
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100981 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100982 args = [
983 "--out",
984 rebase_path(umbrella_header_path, root_build_dir),
985 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200986 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900987 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100988 }
989
990 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100991 sources = [ umbrella_header_path ]
992 outputs =
993 [ "$root_out_dir/$output_name.framework/Headers/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100994
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100995 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100996 }
997 }
998
999 set_defaults("ios_framework_bundle_with_umbrella_header") {
1000 configs = default_shared_library_configs
1001 }
kthelgason4065a572017-02-14 04:58:56 -08001002}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001003
Anders Carlsson37bbf792018-09-05 16:29:27 +02001004if (is_mac) {
1005 template("mac_framework_bundle_with_umbrella_header") {
1006 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001007 this_target_name = target_name
1008 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001009 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +02001010
1011 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -08001012 forward_variables_from(invoker, "*", [ "configs" ])
1013 if (defined(invoker.configs)) {
1014 configs += invoker.configs
1015 }
Anders Carlsson37bbf792018-09-05 16:29:27 +02001016
1017 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001018 framework_contents = [
1019 "Headers",
1020 "Modules",
1021 "Resources",
1022 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001023
1024 ldflags = [
1025 "-all_load",
1026 "-install_name",
1027 "@rpath/$output_name.framework/$output_name",
1028 ]
1029
1030 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001031 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001032 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001033 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001034 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001035 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001036 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001037 ]
1038 }
1039
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001040 action_foreach("create_bracket_include_headers_$this_target_name") {
1041 script = "//tools_webrtc/apple/copy_framework_header.py"
1042 sources = invoker.sources
1043 output_name = invoker.output_name
1044 outputs = [
1045 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1046 ]
1047 args = [
1048 "--input",
1049 "{{source}}",
1050 "--output",
1051 rebase_path(target_gen_dir, root_build_dir) +
1052 "/$output_name.framework/WebRTC/{{source_file_part}}",
1053 ]
1054 }
1055
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001056 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001057 sources = get_target_outputs(
1058 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001059
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001060 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001061 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001062 }
1063
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001064 action("modulemap_$this_target_name") {
1065 script = "//tools_webrtc/ios/generate_modulemap.py"
1066 args = [
1067 "--out",
1068 rebase_path(modulemap_path, root_build_dir),
1069 "--name",
1070 output_name,
1071 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001072 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001073 }
1074
1075 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001076 sources = [ modulemap_path ]
1077 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1078 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001079 }
1080
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001081 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001082 sources = get_target_outputs(
1083 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001084
1085 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1086
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001087 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001088 args = [
1089 "--out",
1090 rebase_path(umbrella_header_path, root_build_dir),
1091 "--sources",
1092 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001093 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001094 }
1095
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001096 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001097 sources = [ umbrella_header_path ]
1098 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001099
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001100 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001101 }
1102 }
1103}
1104
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001105if (is_android) {
1106 template("rtc_android_library") {
1107 android_library(target_name) {
1108 forward_variables_from(invoker,
1109 "*",
1110 [
1111 "configs",
1112 "public_configs",
1113 "suppressed_configs",
1114 "visibility",
1115 ])
1116
Oleh Prypin05aee742018-11-23 17:29:44 +01001117 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001118
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001119 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001120 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001121
1122 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001123 if (defined(invoker.errorprone_args)) {
1124 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001125 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001126
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001127 if (!defined(deps)) {
1128 deps = []
1129 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001130
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001131 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001132 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001133 }
1134 }
1135
1136 template("rtc_android_apk") {
1137 android_apk(target_name) {
1138 forward_variables_from(invoker,
1139 "*",
1140 [
1141 "configs",
1142 "public_configs",
1143 "suppressed_configs",
1144 "visibility",
1145 ])
1146
1147 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001148 errorprone_args = []
1149 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001150
1151 if (!defined(deps)) {
1152 deps = []
1153 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001154
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001155 no_build_hooks = true
1156 }
1157 }
1158
1159 template("rtc_instrumentation_test_apk") {
1160 instrumentation_test_apk(target_name) {
1161 forward_variables_from(invoker,
1162 "*",
1163 [
1164 "configs",
1165 "public_configs",
1166 "suppressed_configs",
1167 "visibility",
1168 ])
1169
1170 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001171 errorprone_args = []
1172 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001173
1174 if (!defined(deps)) {
1175 deps = []
1176 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001177
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001178 no_build_hooks = true
1179 }
1180 }
1181}