blob: c4530dd684393e5d988aead96ec37039e0054f35 [file] [log] [blame]
mbonadei9aa3f0a2017-01-24 06:58:22 -08001# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS. All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
mbonadei9aa3f0a2017-01-24 06:58:22 -08008import("//build/config/arm.gni")
9import("//build/config/features.gni")
10import("//build/config/mips.gni")
11import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 06:32:23 +010012import("//build/config/sysroot.gni")
ehmaldonado0d729b32017-02-10 01:38:23 -080013import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080014import("//build_overrides/build.gni")
mbonadei96606272017-03-03 19:41:59 -080015
16if (!build_with_chromium && is_component_build) {
17 print("The Gn argument `is_component_build` is currently " +
18 "ignored for WebRTC builds.")
19 print("Component builds are supported by Chromium and the argument " +
20 "`is_component_build` makes it possible to create shared libraries " +
21 "instead of static libraries.")
22 print("If an app depends on WebRTC it makes sense to just depend on the " +
23 "WebRTC static library, so there is no difference between " +
24 "`is_component_build=true` and `is_component_build=false`.")
25 print(
26 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md")
27 assert(!is_component_build, "Component builds are not supported in WebRTC.")
28}
29
kthelgason4065a572017-02-14 04:58:56 -080030if (is_ios) {
31 import("//build/config/ios/rules.gni")
32}
mbonadei9aa3f0a2017-01-24 06:58:22 -080033
Anders Carlsson37bbf792018-09-05 16:29:27 +020034if (is_mac) {
35 import("//build/config/mac/rules.gni")
36}
37
mbonadei9aa3f0a2017-01-24 06:58:22 -080038declare_args() {
Mirko Bonadei028248c2018-10-10 12:19:02 +020039 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
40 # expand to code that will manage symbols visibility.
41 rtc_enable_symbol_export = false
42
Mirko Bonadei31b0b452018-08-22 10:37:11 +020043 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020044 # will tell the pre-processor to remove the default definition of symbols
45 # needed to use field_trial. In that case a new implementation needs to be
46 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020047 if (build_with_chromium) {
48 # When WebRTC is built as part of Chromium it should exclude the default
49 # implementation of field_trial unless it is building for NACL or
50 # Chromecast.
51 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
52 } else {
53 rtc_exclude_field_trial_default = false
54 }
Mirko Bonadei70400902018-08-21 15:44:28 +020055
Mirko Bonadei906add42018-09-05 16:03:16 +020056 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
57 # will tell the pre-processor to remove the default definition of symbols
58 # needed to use metrics. In that case a new implementation needs to be
59 # provided.
60 rtc_exclude_metrics_default = build_with_chromium
61
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070062 # Setting this to false will require the API user to pass in their own
63 # SSLCertificateVerifier to verify the certificates presented from a
64 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
65 rtc_builtin_ssl_root_certificates = true
66
Karl Wibergeb254b42017-11-01 15:08:12 +010067 # Include the iLBC audio codec?
Olga Sharonova5fbd7582020-07-09 09:50:42 +000068 rtc_include_ilbc = true
Karl Wibergeb254b42017-11-01 15:08:12 +010069
mbonadei9aa3f0a2017-01-24 06:58:22 -080070 # Disable this to avoid building the Opus audio codec.
71 rtc_include_opus = true
72
minyue2e03c662017-02-01 17:31:11 -080073 # Enable this if the Opus version upon which WebRTC is built supports direct
74 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020075 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080076
mbonadei9aa3f0a2017-01-24 06:58:22 -080077 # Enable this to let the Opus audio codec change complexity on the fly.
78 rtc_opus_variable_complexity = false
79
mbonadei9aa3f0a2017-01-24 06:58:22 -080080 # Used to specify an external Jsoncpp include path when not compiling the
81 # library that comes with WebRTC (i.e. rtc_build_json == 0).
82 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
83
84 # Used to specify an external OpenSSL include path when not compiling the
85 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
86 rtc_ssl_root = ""
87
mbonadei9aa3f0a2017-01-24 06:58:22 -080088 # Enable when an external authentication mechanism is used for performing
89 # packet authentication for RTP packets instead of libsrtp.
90 rtc_enable_external_auth = build_with_chromium
91
92 # Selects whether debug dumps for the audio processing module
93 # should be generated.
94 apm_debug_dump = false
95
Per Åhgrencc73ed32020-04-26 23:56:17 +020096 # Selects whether the audio processing module should be excluded.
97 rtc_exclude_audio_processing_module = false
98
mbonadei9aa3f0a2017-01-24 06:58:22 -080099 # Set this to true to enable BWE test logging.
100 rtc_enable_bwe_test_logging = false
101
Joachim Bauch93e91342017-12-07 01:25:53 +0100102 # Set this to false to skip building examples.
103 rtc_build_examples = true
104
105 # Set this to false to skip building tools.
106 rtc_build_tools = true
107
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100108 # Set this to false to skip building code that requires X11.
109 rtc_use_x11 = use_x11
110
Tomas Popela318da512018-11-13 06:32:23 +0100111 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 14:37:51 +0100112 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
113 # only when using the sysroot as PipeWire is not available in older and
114 # supported Ubuntu and Debian distributions.
Xiaohan Wang9f32f3b2020-10-01 14:46:54 -0700115 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 14:37:51 +0100116
117 # Set this to link PipeWire directly instead of using the dlopen.
118 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 06:32:23 +0100119
mbonadei9aa3f0a2017-01-24 06:58:22 -0800120 # Enable to use the Mozilla internal settings.
121 build_with_mozilla = false
122
Philipp Hanckee95ebda2020-09-17 16:13:20 +0200123 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
124 # and NDK r16 or above.
henrika883d00f2018-03-16 10:09:49 +0100125 rtc_enable_android_aaudio = false
126
mbonadei9aa3f0a2017-01-24 06:58:22 -0800127 # Set to "func", "block", "edge" for coverage generation.
128 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
129 # It is recommend to set include_examples=0.
130 # Use llvm's sancov -html-report for human readable reports.
131 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
132 rtc_sanitize_coverage = ""
133
Philipp Hanckeaeac9f82020-09-11 11:58:18 +0200134 # Selects fixed-point code where possible.
135 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800136 if (current_cpu == "arm" || current_cpu == "arm64") {
137 rtc_prefer_fixed_point = true
138 }
139
mbonadei9aa3f0a2017-01-24 06:58:22 -0800140 # Determines whether NEON code will be built.
141 rtc_build_with_neon =
142 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
143
144 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
145 # all platforms except Android and iOS. Because FFmpeg can be built
146 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a
147 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Sergey Silkinfe288eb2018-06-25 16:22:38 +0200148 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800149 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
150 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100151 #
152 # Enabling H264 when building with MSVC is currently not supported, see
153 # bugs.webrtc.org/9213#c13 for more info.
154 rtc_use_h264 =
155 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800156
Markus Handell8e75bd42020-06-05 11:47:40 +0200157 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
158 rtc_use_absl_mutex = false
159
mbonadei9aa3f0a2017-01-24 06:58:22 -0800160 # By default, use normal platform audio support or dummy audio, but don't
161 # use file-based audio playout and record.
162 rtc_use_dummy_audio_file_devices = false
163
henrika7be78832017-06-13 17:34:16 +0200164 # When set to true, replace the audio output with a sinus tone at 440Hz.
165 # The ADM will ask for audio data from WebRTC but instead of reading real
166 # audio samples from NetEQ, a sinus tone will be generated and replace the
167 # real audio samples.
168 rtc_audio_device_plays_sinus_tone = false
169
Anders Carlsson358f2e02018-06-04 10:24:37 +0200170 if (is_ios) {
171 # Build broadcast extension in AppRTCMobile for iOS. This results in the
172 # binary only running on iOS 11+, which is why it is disabled by default.
173 rtc_apprtcmobile_broadcast_extension = false
174 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200175
176 # Determines whether Metal is available on iOS/macOS.
177 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64")
Jiawei Ou08745302019-02-12 11:36:13 -0800178
179 # When set to false, builtin audio encoder/decoder factories and all the
180 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
181 # (they will still be included in libjingle_peerconnection_so.so and
182 # WebRTC.framework)
183 rtc_include_builtin_audio_codecs = true
184
185 # When set to false, builtin video encoder/decoder factories and all the
186 # video codecs they depends on will not be included in libwebrtc.{a|lib}
187 # (they will still be included in libjingle_peerconnection_so.so and
188 # WebRTC.framework)
189 rtc_include_builtin_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100190
191 # When set to true and in a standalone build, it will undefine UNICODE and
192 # _UNICODE (which are always defined globally by the Chromium Windows
193 # toolchain).
194 # This is only needed for testing purposes, WebRTC wants to be sure it
195 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
196 # wide character functions.
197 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 13:47:54 -0700198
199 # When set to true, a capturer implementation that uses the
200 # Windows.Graphics.Capture APIs will be available for use. These APIs are
201 # available in the Win 10 SDK v10.0.19041.
202 rtc_enable_win_wgc = false
Dan Minor9c686132018-01-15 10:20:00 -0500203}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800204
Dan Minor9c686132018-01-15 10:20:00 -0500205if (!build_with_mozilla) {
206 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800207}
208
209# A second declare_args block, so that declarations within it can
210# depend on the possibly overridden variables in the first
211# declare_args block.
212declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500213 # Enables the use of protocol buffers for debug recordings.
214 rtc_enable_protobuf = !build_with_mozilla
215
216 # Set this to disable building with support for SCTP data channels.
217 rtc_enable_sctp = !build_with_mozilla
218
219 # Disable these to not build components which can be externally provided.
220 rtc_build_json = !build_with_mozilla
221 rtc_build_libsrtp = !build_with_mozilla
222 rtc_build_libvpx = !build_with_mozilla
223 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500224 rtc_build_opus = !build_with_mozilla
225 rtc_build_ssl = !build_with_mozilla
226 rtc_build_usrsctp = !build_with_mozilla
227
228 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200229 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
230 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500231 rtc_enable_libevent = false
232 rtc_build_libevent = false
233 } else {
234 rtc_enable_libevent = true
235 rtc_build_libevent = !build_with_mozilla
236 }
237
Dan Minor9c686132018-01-15 10:20:00 -0500238 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS
239 # build environments, even if available for Chromium builds.
240 rtc_use_gtk = !build_with_chromium && !build_with_mozilla
241
mbonadei9aa3f0a2017-01-24 06:58:22 -0800242 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
243 rtc_include_pulse_audio = !build_with_chromium
244
245 # Chromium uses its own IO handling, so the internal ADM is only built for
246 # standalone WebRTC.
247 rtc_include_internal_audio_device = !build_with_chromium
248
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800249 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 12:02:32 +0200250 # TODO: Make sure that AVX2 works also for non-clang compilers.
251 if (is_clang == true) {
252 rtc_enable_avx2 = true
253 } else {
254 rtc_enable_avx2 = false
255 }
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800256
mbonadei9aa3f0a2017-01-24 06:58:22 -0800257 # Include tests in standalone checkout.
Dan Minor9c686132018-01-15 10:20:00 -0500258 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200259
260 # Set this to false to skip building code that also requires X11 extensions
261 # such as Xdamage, Xfixes.
262 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100263
264 # Set this to true to fully remove logging from WebRTC.
265 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100266
267 # Set this to true to disable trace events.
268 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100269
270 # Set this to true to disable detailed error message and logging for
271 # RTC_CHECKs.
272 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100273
274 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100275 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200276
277 # Set this to true to exclude the transient suppressor in the audio processing
278 # module from the build.
279 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800280}
281
282# Make it possible to provide custom locations for some libraries (move these
283# up into declare_args should we need to actually use them for the GN build).
284rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800285rtc_opus_dir = "//third_party/opus"
286
287# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200288rtc_desktop_capture_supported =
289 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900290 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800291
292###############################################################################
293# Templates
294#
295
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200296# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800297# chromium.
298# We need absolute paths for all configs in templates as they are shared in
299# different subdirectories.
300webrtc_root = get_path_info(".", "abspath")
301
302# Global configuration that should be applied to all WebRTC targets.
303# You normally shouldn't need to include this in your target as it's
304# automatically included when using the rtc_* templates.
305# It sets defines, include paths and compilation warnings accordingly,
306# both for WebRTC stand-alone builds and for the scenario when WebRTC
307# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700308rtc_common_configs = [
309 webrtc_root + ":common_config",
310 "//build/config/compiler:no_size_t_to_int_warning",
311]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800312
kthelgasonc0977102017-04-24 00:57:16 -0700313if (is_mac || is_ios) {
314 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
315}
316
mbonadei9aa3f0a2017-01-24 06:58:22 -0800317# Global public configuration that should be applied to all WebRTC targets. You
318# normally shouldn't need to include this in your target as it's automatically
319# included when using the rtc_* templates. It set the defines, include paths and
320# compilation warnings that should be propagated to dependents of the targets
321# depending on the target having this config.
322rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
323
324# Common configs to remove or add in all rtc targets.
325rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100326if (!build_with_chromium && is_clang) {
327 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
328}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800329rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200330rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200331rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800332
333set_defaults("rtc_test") {
334 configs = rtc_add_configs
335 suppressed_configs = []
336}
337
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200338set_defaults("rtc_library") {
339 configs = rtc_add_configs
340 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200341 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200342}
343
mbonadei9aa3f0a2017-01-24 06:58:22 -0800344set_defaults("rtc_source_set") {
345 configs = rtc_add_configs
346 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200347 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800348}
349
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200350set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800351 configs = rtc_add_configs
352 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200353 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800354}
355
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200356set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800357 configs = rtc_add_configs
358 suppressed_configs = []
359}
360
361set_defaults("rtc_shared_library") {
362 configs = rtc_add_configs
363 suppressed_configs = []
364}
365
Per Kjellandera7f2d842018-01-10 15:54:53 +0000366webrtc_default_visibility = [ webrtc_root + "/*" ]
367if (build_with_chromium) {
368 # Allow Chromium's WebRTC overrides targets to bypass the regular
369 # visibility restrictions.
370 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
371}
372
Karl Wibergbb23c832018-04-22 19:55:00 +0200373# ---- Poisons ----
374#
375# The general idea is that some targets declare that they contain some
376# kind of poison, which makes it impossible for other targets to
377# depend on them (even transitively) unless they declare themselves
378# immune to that particular type of poison.
379#
380# Targets that *contain* poison of type foo should contain the line
381#
382# poisonous = [ "foo" ]
383#
384# and targets that *are immune but arent't themselves poisonous*
385# should contain
386#
387# allow_poison = [ "foo" ]
388#
389# This useful in cases where we have some large target or set of
390# targets and want to ensure that most other targets do not
391# transitively depend on them. For example, almost no high-level
392# target should depend on the audio codecs, since we want WebRTC users
393# to be able to inject any subset of them and actually end up with a
394# binary that doesn't include the codecs they didn't inject.
395#
396# Test-only targets (`testonly` set to true) and non-public targets
397# (`visibility` not containing "*") are automatically immune to all
398# types of poison.
399#
400# Here's the complete list of all types of poison. It must be kept in
401# 1:1 correspondence with the set of //:poison_* targets.
402#
403all_poison_types = [
404 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
405 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200406
Danil Chapovalov41300af2019-07-10 12:44:43 +0200407 # Default task queue implementation.
408 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200409
410 # JSON parsing should not be needed in the "slim and modular" WebRTC.
411 "rtc_json",
412
413 # Software video codecs (VP8 and VP9 through libvpx).
414 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200415]
416
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000417absl_include_config = "//third_party/abseil-cpp:absl_include_config"
418absl_define_config = "//third_party/abseil-cpp:absl_define_config"
419
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200420# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
421# that are testonly.
422absl_flags_config = webrtc_root + ":absl_flags_configs"
423
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100424# WebRTC wrapper of Chromium's test() template. This template just adds some
425# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
426# target.
427# The parameter `is_xctest` is different from the one in the Chromium's test()
428# template (and it is not forwarded to it). In rtc_test(), the argument
429# `is_xctest` is used to avoid to take dependencies that are not needed
430# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800431template("rtc_test") {
432 test(target_name) {
433 forward_variables_from(invoker,
434 "*",
435 [
436 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100437 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800438 "public_configs",
439 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200440 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800441 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100442
443 # Always override to public because when target_os is Android the `test`
444 # template can override it to [ "*" ] and we want to avoid conditional
445 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100446 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800447 configs += invoker.configs
448 configs -= rtc_remove_configs
449 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000450 public_configs = [
451 rtc_common_inherited_config,
452 absl_include_config,
453 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200454 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000455 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800456 if (defined(invoker.public_configs)) {
457 public_configs += invoker.public_configs
458 }
sakald7fdb802017-05-26 01:51:53 -0700459 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800460 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200461 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200462 target_sdk_version = 23
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800463 deps += [ webrtc_root + "test:native_test_java" ]
sakald7fdb802017-05-26 01:51:53 -0700464 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100465
466 # When not targeting a simulator, building //base/test:google_test_runner
467 # fails, so it is added only when the test is not a real XCTest and when
468 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100469 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100470 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
471 xctest_module_target = "//base/test:google_test_runner"
472 }
473 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800474 }
475}
476
477template("rtc_source_set") {
478 source_set(target_name) {
479 forward_variables_from(invoker,
480 "*",
481 [
482 "configs",
483 "public_configs",
484 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200485 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800486 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200487 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000488 if (!defined(visibility)) {
489 visibility = webrtc_default_visibility
490 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200491
492 # What's your poison?
493 if (defined(testonly) && testonly) {
494 assert(!defined(poisonous))
495 assert(!defined(allow_poison))
496 } else {
497 if (!defined(poisonous)) {
498 poisonous = []
499 }
500 if (!defined(allow_poison)) {
501 allow_poison = []
502 }
503 if (!defined(assert_no_deps)) {
504 assert_no_deps = []
505 }
506 if (!defined(deps)) {
507 deps = []
508 }
509 foreach(p, poisonous) {
510 deps += [ webrtc_root + ":poison_" + p ]
511 }
512 foreach(poison_type, all_poison_types) {
513 allow_dep = true
514 foreach(v, visibility) {
515 if (v == "*") {
516 allow_dep = false
517 }
518 }
519 foreach(p, allow_poison + poisonous) {
520 if (p == poison_type) {
521 allow_dep = true
522 }
523 }
524 if (!allow_dep) {
525 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
526 }
527 }
528 }
529
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100530 # Chromium should only depend on the WebRTC component in order to
531 # avoid to statically link WebRTC in a component build.
532 if (build_with_chromium) {
533 publicly_visible = false
534 foreach(v, visibility) {
535 if (v == "*") {
536 publicly_visible = true
537 }
538 }
539 if (publicly_visible) {
540 visibility = []
541 visibility = webrtc_default_visibility
542 }
543 }
544
Mirko Bonadei96ede162018-09-06 13:45:44 +0200545 if (!defined(testonly) || !testonly) {
546 configs += rtc_prod_configs
547 }
548
mbonadei9aa3f0a2017-01-24 06:58:22 -0800549 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200550 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800551 configs -= rtc_remove_configs
552 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000553 public_configs = [
554 rtc_common_inherited_config,
555 absl_include_config,
556 absl_define_config,
557 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200558 if (defined(testonly) && testonly) {
559 public_configs += [ absl_flags_config ]
560 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800561 if (defined(invoker.public_configs)) {
562 public_configs += invoker.public_configs
563 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200564
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200565 # If absl_deps is [], no action is needed. If not [], then it needs to be
566 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200567 # otherwise it just needs to be added to deps.
568 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200569 if (!defined(deps)) {
570 deps = []
571 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200572 if (build_with_chromium) {
573 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200574 } else {
575 deps += absl_deps
576 }
577 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800578 }
579}
580
mbonadei9aa3f0a2017-01-24 06:58:22 -0800581template("rtc_static_library") {
582 static_library(target_name) {
583 forward_variables_from(invoker,
584 "*",
585 [
586 "configs",
587 "public_configs",
588 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200589 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800590 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200591 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000592 if (!defined(visibility)) {
593 visibility = webrtc_default_visibility
594 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200595
596 # What's your poison?
597 if (defined(testonly) && testonly) {
598 assert(!defined(poisonous))
599 assert(!defined(allow_poison))
600 } else {
601 if (!defined(poisonous)) {
602 poisonous = []
603 }
604 if (!defined(allow_poison)) {
605 allow_poison = []
606 }
607 if (!defined(assert_no_deps)) {
608 assert_no_deps = []
609 }
610 if (!defined(deps)) {
611 deps = []
612 }
613 foreach(p, poisonous) {
614 deps += [ webrtc_root + ":poison_" + p ]
615 }
616 foreach(poison_type, all_poison_types) {
617 allow_dep = true
618 foreach(v, visibility) {
619 if (v == "*") {
620 allow_dep = false
621 }
622 }
623 foreach(p, allow_poison + poisonous) {
624 if (p == poison_type) {
625 allow_dep = true
626 }
627 }
628 if (!allow_dep) {
629 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
630 }
631 }
632 }
633
Mirko Bonadei96ede162018-09-06 13:45:44 +0200634 if (!defined(testonly) || !testonly) {
635 configs += rtc_prod_configs
636 }
637
mbonadei9aa3f0a2017-01-24 06:58:22 -0800638 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200639 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800640 configs -= rtc_remove_configs
641 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000642 public_configs = [
643 rtc_common_inherited_config,
644 absl_include_config,
645 absl_define_config,
646 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200647 if (defined(testonly) && testonly) {
648 public_configs += [ absl_flags_config ]
649 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800650 if (defined(invoker.public_configs)) {
651 public_configs += invoker.public_configs
652 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200653
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200654 # If absl_deps is [], no action is needed. If not [], then it needs to be
655 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200656 # otherwise it just needs to be added to deps.
657 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200658 if (!defined(deps)) {
659 deps = []
660 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200661 if (build_with_chromium) {
662 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200663 } else {
664 deps += absl_deps
665 }
666 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800667 }
668}
669
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200670# This template automatically switches the target type between source_set
671# and static_library.
672#
673# This should be the default target type for all the WebRTC targets with
674# one exception. Do not use this template for header only targets, in that case
675# rtc_source_set must be used in order to avoid build errors (e.g. libtool
676# complains if the output .a file is empty).
677#
678# How does it work:
679# Since all files in a source_set are linked into a final binary, while files
680# in a static library are only linked in if at least one symbol in them is
681# referenced, in component builds source_sets are easy to deal with because
682# all their object files are passed to the linker to create a shared library.
683# In release builds instead, static_libraries are preferred since they allow
684# the linker to discard dead code.
685# For the same reason, testonly targets will always be expanded to
686# source_set in order to be sure that tests are present in the test binary.
687template("rtc_library") {
688 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
689 target_type = "source_set"
690 } else {
691 target_type = "static_library"
692 }
693 target(target_type, target_name) {
694 forward_variables_from(invoker,
695 "*",
696 [
697 "configs",
698 "public_configs",
699 "suppressed_configs",
700 "visibility",
701 ])
702 forward_variables_from(invoker, [ "visibility" ])
703 if (!defined(visibility)) {
704 visibility = webrtc_default_visibility
705 }
706
707 # What's your poison?
708 if (defined(testonly) && testonly) {
709 assert(!defined(poisonous))
710 assert(!defined(allow_poison))
711 } else {
712 if (!defined(poisonous)) {
713 poisonous = []
714 }
715 if (!defined(allow_poison)) {
716 allow_poison = []
717 }
718 if (!defined(assert_no_deps)) {
719 assert_no_deps = []
720 }
721 if (!defined(deps)) {
722 deps = []
723 }
724 foreach(p, poisonous) {
725 deps += [ webrtc_root + ":poison_" + p ]
726 }
727 foreach(poison_type, all_poison_types) {
728 allow_dep = true
729 foreach(v, visibility) {
730 if (v == "*") {
731 allow_dep = false
732 }
733 }
734 foreach(p, allow_poison + poisonous) {
735 if (p == poison_type) {
736 allow_dep = true
737 }
738 }
739 if (!allow_dep) {
740 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
741 }
742 }
743 }
744
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100745 # Chromium should only depend on the WebRTC component in order to
746 # avoid to statically link WebRTC in a component build.
747 if (build_with_chromium) {
748 publicly_visible = false
749 foreach(v, visibility) {
750 if (v == "*") {
751 publicly_visible = true
752 }
753 }
754 if (publicly_visible) {
755 visibility = []
756 visibility = webrtc_default_visibility
757 }
758 }
759
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200760 if (!defined(testonly) || !testonly) {
761 configs += rtc_prod_configs
762 }
763
764 configs += invoker.configs
765 configs += rtc_library_impl_config
766 configs -= rtc_remove_configs
767 configs -= invoker.suppressed_configs
768 public_configs = [
769 rtc_common_inherited_config,
770 absl_include_config,
771 absl_define_config,
772 ]
773 if (defined(testonly) && testonly) {
774 public_configs += [ absl_flags_config ]
775 }
776 if (defined(invoker.public_configs)) {
777 public_configs += invoker.public_configs
778 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200779
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200780 # If absl_deps is [], no action is needed. If not [], then it needs to be
781 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200782 # otherwise it just needs to be added to deps.
783 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200784 if (!defined(deps)) {
785 deps = []
786 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200787 if (build_with_chromium) {
788 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200789 } else {
790 deps += absl_deps
791 }
792 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200793 }
794}
795
796template("rtc_executable") {
797 executable(target_name) {
798 forward_variables_from(invoker,
799 "*",
800 [
801 "deps",
802 "configs",
803 "public_configs",
804 "suppressed_configs",
805 "visibility",
806 ])
807 forward_variables_from(invoker, [ "visibility" ])
808 if (!defined(visibility)) {
809 visibility = webrtc_default_visibility
810 }
811 configs += invoker.configs
812 configs -= rtc_remove_configs
813 configs -= invoker.suppressed_configs
814 deps = invoker.deps
815
816 public_configs = [
817 rtc_common_inherited_config,
818 absl_include_config,
819 absl_define_config,
820 ]
821 if (defined(testonly) && testonly) {
822 public_configs += [ absl_flags_config ]
823 }
824 if (defined(invoker.public_configs)) {
825 public_configs += invoker.public_configs
826 }
827 if (is_win) {
828 deps += [
829 # Give executables the default manifest on Windows (a no-op elsewhere).
830 "//build/win:default_exe_manifest",
831 ]
832 }
833 }
834}
835
mbonadei9aa3f0a2017-01-24 06:58:22 -0800836template("rtc_shared_library") {
837 shared_library(target_name) {
838 forward_variables_from(invoker,
839 "*",
840 [
841 "configs",
842 "public_configs",
843 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200844 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800845 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200846 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000847 if (!defined(visibility)) {
848 visibility = webrtc_default_visibility
849 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200850
851 # What's your poison?
852 if (defined(testonly) && testonly) {
853 assert(!defined(poisonous))
854 assert(!defined(allow_poison))
855 } else {
856 if (!defined(poisonous)) {
857 poisonous = []
858 }
859 if (!defined(allow_poison)) {
860 allow_poison = []
861 }
862 if (!defined(assert_no_deps)) {
863 assert_no_deps = []
864 }
865 if (!defined(deps)) {
866 deps = []
867 }
868 foreach(p, poisonous) {
869 deps += [ webrtc_root + ":poison_" + p ]
870 }
871 foreach(poison_type, all_poison_types) {
872 allow_dep = true
873 foreach(v, visibility) {
874 if (v == "*") {
875 allow_dep = false
876 }
877 }
878 foreach(p, allow_poison + poisonous) {
879 if (p == poison_type) {
880 allow_dep = true
881 }
882 }
883 if (!allow_dep) {
884 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
885 }
886 }
887 }
888
mbonadei9aa3f0a2017-01-24 06:58:22 -0800889 configs += invoker.configs
890 configs -= rtc_remove_configs
891 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000892 public_configs = [
893 rtc_common_inherited_config,
894 absl_include_config,
895 absl_define_config,
896 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200897 if (defined(testonly) && testonly) {
898 public_configs += [ absl_flags_config ]
899 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800900 if (defined(invoker.public_configs)) {
901 public_configs += invoker.public_configs
902 }
903 }
904}
kthelgason4065a572017-02-14 04:58:56 -0800905
906if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400907 # TODO: Generate module.modulemap file to enable use in Swift
908 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100909 template("ios_framework_bundle_with_umbrella_header") {
910 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900911 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100912 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900913 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
914
915 action_foreach("create_bracket_include_headers_$target_name") {
916 script = "//tools_webrtc/apple/copy_framework_header.py"
917 sources = invoker.sources
918 output_name = invoker.output_name
919 outputs = [
920 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
921 ]
922 args = [
923 "--input",
924 "{{source}}",
925 "--output",
926 rebase_path(target_gen_dir, root_build_dir) +
927 "/$output_name.framework/WebRTC/{{source_file_part}}",
928 ]
929 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100930
931 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900932 forward_variables_from(invoker, "*", [ "public_headers" ])
933 public_headers = get_target_outputs(
934 ":create_bracket_include_headers_$this_target_name")
935 deps += [
936 ":copy_umbrella_header_$target_name",
937 ":create_bracket_include_headers_$target_name",
938 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100939 }
940
941 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900942 public_headers = get_target_outputs(
943 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100944
945 script = "//tools_webrtc/ios/generate_umbrella_header.py"
946
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100947 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100948 args = [
949 "--out",
950 rebase_path(umbrella_header_path, root_build_dir),
951 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200952 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900953 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100954 }
955
956 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100957 sources = [ umbrella_header_path ]
958 outputs =
959 [ "$root_out_dir/$output_name.framework/Headers/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100960
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100961 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100962 }
963 }
964
965 set_defaults("ios_framework_bundle_with_umbrella_header") {
966 configs = default_shared_library_configs
967 }
kthelgason4065a572017-02-14 04:58:56 -0800968}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +0000969
Anders Carlsson37bbf792018-09-05 16:29:27 +0200970if (is_mac) {
971 template("mac_framework_bundle_with_umbrella_header") {
972 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200973 this_target_name = target_name
974 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400975 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +0200976
977 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -0800978 forward_variables_from(invoker, "*", [ "configs" ])
979 if (defined(invoker.configs)) {
980 configs += invoker.configs
981 }
Anders Carlsson37bbf792018-09-05 16:29:27 +0200982
983 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400984 framework_contents = [
985 "Headers",
986 "Modules",
987 "Resources",
988 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +0200989
990 ldflags = [
991 "-all_load",
992 "-install_name",
993 "@rpath/$output_name.framework/$output_name",
994 ]
995
996 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200997 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400998 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +0200999 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001000 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001001 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001002 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001003 ]
1004 }
1005
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001006 action_foreach("create_bracket_include_headers_$this_target_name") {
1007 script = "//tools_webrtc/apple/copy_framework_header.py"
1008 sources = invoker.sources
1009 output_name = invoker.output_name
1010 outputs = [
1011 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1012 ]
1013 args = [
1014 "--input",
1015 "{{source}}",
1016 "--output",
1017 rebase_path(target_gen_dir, root_build_dir) +
1018 "/$output_name.framework/WebRTC/{{source_file_part}}",
1019 ]
1020 }
1021
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001022 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001023 sources = get_target_outputs(
1024 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001025
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001026 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001027 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001028 }
1029
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001030 action("modulemap_$this_target_name") {
1031 script = "//tools_webrtc/ios/generate_modulemap.py"
1032 args = [
1033 "--out",
1034 rebase_path(modulemap_path, root_build_dir),
1035 "--name",
1036 output_name,
1037 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001038 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001039 }
1040
1041 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001042 sources = [ modulemap_path ]
1043 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1044 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001045 }
1046
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001047 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001048 sources = get_target_outputs(
1049 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001050
1051 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1052
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001053 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001054 args = [
1055 "--out",
1056 rebase_path(umbrella_header_path, root_build_dir),
1057 "--sources",
1058 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001059 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001060 }
1061
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001062 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001063 sources = [ umbrella_header_path ]
1064 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001065
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001066 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001067 }
1068 }
1069}
1070
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001071if (is_android) {
1072 template("rtc_android_library") {
1073 android_library(target_name) {
1074 forward_variables_from(invoker,
1075 "*",
1076 [
1077 "configs",
1078 "public_configs",
1079 "suppressed_configs",
1080 "visibility",
1081 ])
1082
Oleh Prypin05aee742018-11-23 17:29:44 +01001083 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001084
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001085 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001086 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001087
1088 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001089 if (defined(invoker.errorprone_args)) {
1090 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001091 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001092
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001093 if (!defined(deps)) {
1094 deps = []
1095 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001096
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001097 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001098 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001099 }
1100 }
1101
1102 template("rtc_android_apk") {
1103 android_apk(target_name) {
1104 forward_variables_from(invoker,
1105 "*",
1106 [
1107 "configs",
1108 "public_configs",
1109 "suppressed_configs",
1110 "visibility",
1111 ])
1112
1113 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001114 errorprone_args = []
1115 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001116
1117 if (!defined(deps)) {
1118 deps = []
1119 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001120
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001121 no_build_hooks = true
1122 }
1123 }
1124
1125 template("rtc_instrumentation_test_apk") {
1126 instrumentation_test_apk(target_name) {
1127 forward_variables_from(invoker,
1128 "*",
1129 [
1130 "configs",
1131 "public_configs",
1132 "suppressed_configs",
1133 "visibility",
1134 ])
1135
1136 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001137 errorprone_args = []
1138 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001139
1140 if (!defined(deps)) {
1141 deps = []
1142 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001143
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001144 no_build_hooks = true
1145 }
1146 }
1147}