blob: 15ddba0e36b0f9647eabae5a12e4a3301ed0bda2 [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")
Maksim Sisovef4d0b62021-09-20 09:02:01 +030011import("//build/config/ozone.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080012import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 06:32:23 +010013import("//build/config/sysroot.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(
Fanny Linderborg0d2dc1f2021-07-14 14:02:11 +000026 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/main/docs/component_build.md")
mbonadei96606272017-03-03 19:41:59 -080027 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
Mirko Bonadei5f078452021-07-30 22:32:55 +020038# This declare_args is separated from the next one because args declared
39# in this one, can be read from the next one (args defined in the same
40# declare_args cannot be referenced in that scope).
mbonadei9aa3f0a2017-01-24 06:58:22 -080041declare_args() {
Mirko Bonadei028248c2018-10-10 12:19:02 +020042 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
43 # expand to code that will manage symbols visibility.
44 rtc_enable_symbol_export = false
Mirko Bonadei5f078452021-07-30 22:32:55 +020045}
46
47declare_args() {
Mirko Bonadei339965f2021-10-12 13:23:44 +020048 # Setting this to true, will make RTC_DLOG() expand to log statements instead
Mirko Bonadei56ed4682021-10-12 08:55:42 +020049 # of being removed by the preprocessor.
50 # This is useful for example to be able to get RTC_DLOGs on a release build.
51 rtc_dlog_always_on = false
52
Mirko Bonadei5f078452021-07-30 22:32:55 +020053 # Setting this to true will make RTC_OBJC_EXPORT expand to code that will
54 # manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported
55 # if C++ symbols are but setting this arg to true while keeping
56 # rtc_enable_symbol_export=false will only export RTC_OBJC_EXPORT
57 # annotated symbols.
58 rtc_enable_objc_symbol_export = rtc_enable_symbol_export
Mirko Bonadei028248c2018-10-10 12:19:02 +020059
Mirko Bonadei31b0b452018-08-22 10:37:11 +020060 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020061 # will tell the pre-processor to remove the default definition of symbols
62 # needed to use field_trial. In that case a new implementation needs to be
63 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020064 if (build_with_chromium) {
65 # When WebRTC is built as part of Chromium it should exclude the default
66 # implementation of field_trial unless it is building for NACL or
67 # Chromecast.
68 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
69 } else {
70 rtc_exclude_field_trial_default = false
71 }
Mirko Bonadei70400902018-08-21 15:44:28 +020072
Mirko Bonadei906add42018-09-05 16:03:16 +020073 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
74 # will tell the pre-processor to remove the default definition of symbols
75 # needed to use metrics. In that case a new implementation needs to be
76 # provided.
77 rtc_exclude_metrics_default = build_with_chromium
78
Johannes Kronda20c732021-02-19 16:39:41 +010079 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which
80 # will tell the pre-processor to remove the default definition of the
81 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
82 # that case a new implementation needs to be provided.
Johannes Kronbb52bdf2021-02-25 10:10:08 +010083 rtc_exclude_system_time = build_with_chromium
Johannes Kronda20c732021-02-19 16:39:41 +010084
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070085 # Setting this to false will require the API user to pass in their own
86 # SSLCertificateVerifier to verify the certificates presented from a
87 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
88 rtc_builtin_ssl_root_certificates = true
89
Karl Wibergeb254b42017-11-01 15:08:12 +010090 # Include the iLBC audio codec?
Olga Sharonova5fbd7582020-07-09 09:50:42 +000091 rtc_include_ilbc = true
Karl Wibergeb254b42017-11-01 15:08:12 +010092
mbonadei9aa3f0a2017-01-24 06:58:22 -080093 # Disable this to avoid building the Opus audio codec.
94 rtc_include_opus = true
95
minyue2e03c662017-02-01 17:31:11 -080096 # Enable this if the Opus version upon which WebRTC is built supports direct
97 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020098 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080099
mbonadei9aa3f0a2017-01-24 06:58:22 -0800100 # Enable this to let the Opus audio codec change complexity on the fly.
101 rtc_opus_variable_complexity = false
102
mbonadei9aa3f0a2017-01-24 06:58:22 -0800103 # Used to specify an external Jsoncpp include path when not compiling the
104 # library that comes with WebRTC (i.e. rtc_build_json == 0).
105 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
106
107 # Used to specify an external OpenSSL include path when not compiling the
108 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
109 rtc_ssl_root = ""
110
mbonadei9aa3f0a2017-01-24 06:58:22 -0800111 # Enable when an external authentication mechanism is used for performing
112 # packet authentication for RTP packets instead of libsrtp.
113 rtc_enable_external_auth = build_with_chromium
114
115 # Selects whether debug dumps for the audio processing module
116 # should be generated.
117 apm_debug_dump = false
118
Per Åhgrencc73ed32020-04-26 23:56:17 +0200119 # Selects whether the audio processing module should be excluded.
120 rtc_exclude_audio_processing_module = false
121
mbonadei9aa3f0a2017-01-24 06:58:22 -0800122 # Set this to true to enable BWE test logging.
123 rtc_enable_bwe_test_logging = false
124
Joachim Bauch93e91342017-12-07 01:25:53 +0100125 # Set this to false to skip building examples.
126 rtc_build_examples = true
127
128 # Set this to false to skip building tools.
129 rtc_build_tools = true
130
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100131 # Set this to false to skip building code that requires X11.
Maksim Sisovef4d0b62021-09-20 09:02:01 +0300132 rtc_use_x11 = ozone_platform_x11
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100133
Tomas Popela318da512018-11-13 06:32:23 +0100134 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 14:37:51 +0100135 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
136 # only when using the sysroot as PipeWire is not available in older and
137 # supported Ubuntu and Debian distributions.
Artem Titov4d6a76d2021-09-03 10:07:20 +0000138 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 14:37:51 +0100139
Jan Gruliche1e05af2021-09-21 20:36:16 +0200140 # Set this to link PipeWire and required libraries directly instead of using the dlopen.
Tomas Popela762543f2018-12-12 14:37:51 +0100141 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 06:32:23 +0100142
mbonadei9aa3f0a2017-01-24 06:58:22 -0800143 # Enable to use the Mozilla internal settings.
144 build_with_mozilla = false
145
Philipp Hanckee95ebda2020-09-17 16:13:20 +0200146 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
147 # and NDK r16 or above.
henrika883d00f2018-03-16 10:09:49 +0100148 rtc_enable_android_aaudio = false
149
mbonadei9aa3f0a2017-01-24 06:58:22 -0800150 # Set to "func", "block", "edge" for coverage generation.
151 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
152 # It is recommend to set include_examples=0.
153 # Use llvm's sancov -html-report for human readable reports.
154 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
155 rtc_sanitize_coverage = ""
156
Philipp Hanckeaeac9f82020-09-11 11:58:18 +0200157 # Selects fixed-point code where possible.
158 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800159 if (current_cpu == "arm" || current_cpu == "arm64") {
160 rtc_prefer_fixed_point = true
161 }
162
mbonadei9aa3f0a2017-01-24 06:58:22 -0800163 # Determines whether NEON code will be built.
164 rtc_build_with_neon =
165 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
166
167 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
168 # all platforms except Android and iOS. Because FFmpeg can be built
Artem Titov22a6b2d2021-07-27 16:25:56 +0200169 # with/without H.264 support, `ffmpeg_branding` has to separately be set to a
mbonadei9aa3f0a2017-01-24 06:58:22 -0800170 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Artem Titov22a6b2d2021-07-27 16:25:56 +0200171 # H.264, compilation succeeds but `H264DecoderImpl` fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800172 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
173 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100174 #
175 # Enabling H264 when building with MSVC is currently not supported, see
176 # bugs.webrtc.org/9213#c13 for more info.
177 rtc_use_h264 =
178 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800179
Markus Handell8e75bd42020-06-05 11:47:40 +0200180 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
181 rtc_use_absl_mutex = false
182
mbonadei9aa3f0a2017-01-24 06:58:22 -0800183 # By default, use normal platform audio support or dummy audio, but don't
184 # use file-based audio playout and record.
185 rtc_use_dummy_audio_file_devices = false
186
henrika7be78832017-06-13 17:34:16 +0200187 # When set to true, replace the audio output with a sinus tone at 440Hz.
188 # The ADM will ask for audio data from WebRTC but instead of reading real
189 # audio samples from NetEQ, a sinus tone will be generated and replace the
190 # real audio samples.
191 rtc_audio_device_plays_sinus_tone = false
192
Anders Carlsson358f2e02018-06-04 10:24:37 +0200193 if (is_ios) {
194 # Build broadcast extension in AppRTCMobile for iOS. This results in the
195 # binary only running on iOS 11+, which is why it is disabled by default.
196 rtc_apprtcmobile_broadcast_extension = false
197 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200198
Jordan Rose53d3fc92021-07-06 12:16:41 -0700199 # Determines whether OpenGL is available on iOS/macOS.
200 rtc_ios_macos_use_opengl_rendering =
201 !(is_ios && target_environment == "catalyst")
202
Jiawei Ou08745302019-02-12 11:36:13 -0800203 # When set to false, builtin audio encoder/decoder factories and all the
204 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
205 # (they will still be included in libjingle_peerconnection_so.so and
206 # WebRTC.framework)
207 rtc_include_builtin_audio_codecs = true
208
209 # When set to false, builtin video encoder/decoder factories and all the
210 # video codecs they depends on will not be included in libwebrtc.{a|lib}
211 # (they will still be included in libjingle_peerconnection_so.so and
212 # WebRTC.framework)
213 rtc_include_builtin_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100214
215 # When set to true and in a standalone build, it will undefine UNICODE and
216 # _UNICODE (which are always defined globally by the Chromium Windows
217 # toolchain).
218 # This is only needed for testing purposes, WebRTC wants to be sure it
219 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
220 # wide character functions.
221 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 13:47:54 -0700222
223 # When set to true, a capturer implementation that uses the
Austin Orion66241e42021-04-22 13:22:25 -0700224 # Windows.Graphics.Capture APIs will be available for use. This introduces a
225 # dependency on the Win 10 SDK v10.0.17763.0.
Austin Orion78f04d82021-04-23 12:37:26 -0700226 rtc_enable_win_wgc = is_win
philipelb09d8722021-11-23 11:00:24 +0100227
228 # Includes the dav1d decoder in the internal decoder factory when set to true.
229 rtc_include_dav1d_in_internal_decoder_factory = true
Dan Minor9c686132018-01-15 10:20:00 -0500230}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800231
Dan Minor9c686132018-01-15 10:20:00 -0500232if (!build_with_mozilla) {
233 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800234}
235
236# A second declare_args block, so that declarations within it can
237# depend on the possibly overridden variables in the first
238# declare_args block.
239declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500240 # Enables the use of protocol buffers for debug recordings.
241 rtc_enable_protobuf = !build_with_mozilla
242
243 # Set this to disable building with support for SCTP data channels.
244 rtc_enable_sctp = !build_with_mozilla
245
246 # Disable these to not build components which can be externally provided.
247 rtc_build_json = !build_with_mozilla
248 rtc_build_libsrtp = !build_with_mozilla
249 rtc_build_libvpx = !build_with_mozilla
250 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500251 rtc_build_opus = !build_with_mozilla
252 rtc_build_ssl = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500253
254 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200255 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
256 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500257 rtc_enable_libevent = false
258 rtc_build_libevent = false
259 } else {
260 rtc_enable_libevent = true
261 rtc_build_libevent = !build_with_mozilla
262 }
263
mbonadei9aa3f0a2017-01-24 06:58:22 -0800264 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
265 rtc_include_pulse_audio = !build_with_chromium
266
267 # Chromium uses its own IO handling, so the internal ADM is only built for
268 # standalone WebRTC.
269 rtc_include_internal_audio_device = !build_with_chromium
270
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800271 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 12:02:32 +0200272 # TODO: Make sure that AVX2 works also for non-clang compilers.
273 if (is_clang == true) {
274 rtc_enable_avx2 = true
275 } else {
276 rtc_enable_avx2 = false
277 }
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800278
Philipp Hancke1a89bc82021-03-02 21:23:24 +0100279 # Set this to true to build the unit tests.
280 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 10:20:00 -0500281 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200282
283 # Set this to false to skip building code that also requires X11 extensions
284 # such as Xdamage, Xfixes.
285 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100286
287 # Set this to true to fully remove logging from WebRTC.
288 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100289
290 # Set this to true to disable trace events.
291 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100292
293 # Set this to true to disable detailed error message and logging for
294 # RTC_CHECKs.
295 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100296
297 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100298 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200299
300 # Set this to true to exclude the transient suppressor in the audio processing
301 # module from the build.
302 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800303}
304
Florent Castellia80c3e52021-04-15 15:02:56 +0200305declare_args() {
Florent Castellia6983c62021-05-06 10:50:07 +0200306 # Enable the dcsctp backend for DataChannels and related unittests
307 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
308
Florent Castellia80c3e52021-04-15 15:02:56 +0200309 # Enable the usrsctp backend for DataChannels and related unittests
310 rtc_build_usrsctp = !build_with_mozilla && rtc_enable_sctp
311}
312
mbonadei9aa3f0a2017-01-24 06:58:22 -0800313# Make it possible to provide custom locations for some libraries (move these
314# up into declare_args should we need to actually use them for the GN build).
315rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800316rtc_opus_dir = "//third_party/opus"
317
318# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200319rtc_desktop_capture_supported =
320 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900321 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800322
323###############################################################################
324# Templates
325#
326
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200327# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800328# chromium.
329# We need absolute paths for all configs in templates as they are shared in
330# different subdirectories.
331webrtc_root = get_path_info(".", "abspath")
332
333# Global configuration that should be applied to all WebRTC targets.
334# You normally shouldn't need to include this in your target as it's
335# automatically included when using the rtc_* templates.
336# It sets defines, include paths and compilation warnings accordingly,
337# both for WebRTC stand-alone builds and for the scenario when WebRTC
338# native code is built as part of Chromium.
Mirko Bonadei5f078452021-07-30 22:32:55 +0200339rtc_common_configs = [ webrtc_root + ":common_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800340
kthelgasonc0977102017-04-24 00:57:16 -0700341if (is_mac || is_ios) {
342 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
343}
344
mbonadei9aa3f0a2017-01-24 06:58:22 -0800345# Global public configuration that should be applied to all WebRTC targets. You
346# normally shouldn't need to include this in your target as it's automatically
347# included when using the rtc_* templates. It set the defines, include paths and
348# compilation warnings that should be propagated to dependents of the targets
349# depending on the target having this config.
350rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
351
352# Common configs to remove or add in all rtc targets.
353rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100354if (!build_with_chromium && is_clang) {
355 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
356}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800357rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200358rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200359rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800360
361set_defaults("rtc_test") {
362 configs = rtc_add_configs
363 suppressed_configs = []
364}
365
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200366set_defaults("rtc_library") {
367 configs = rtc_add_configs
368 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200369 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200370}
371
mbonadei9aa3f0a2017-01-24 06:58:22 -0800372set_defaults("rtc_source_set") {
373 configs = rtc_add_configs
374 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200375 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800376}
377
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200378set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800379 configs = rtc_add_configs
380 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200381 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800382}
383
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200384set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800385 configs = rtc_add_configs
386 suppressed_configs = []
387}
388
389set_defaults("rtc_shared_library") {
390 configs = rtc_add_configs
391 suppressed_configs = []
392}
393
Per Kjellandera7f2d842018-01-10 15:54:53 +0000394webrtc_default_visibility = [ webrtc_root + "/*" ]
395if (build_with_chromium) {
396 # Allow Chromium's WebRTC overrides targets to bypass the regular
397 # visibility restrictions.
398 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
399}
400
Karl Wibergbb23c832018-04-22 19:55:00 +0200401# ---- Poisons ----
402#
403# The general idea is that some targets declare that they contain some
404# kind of poison, which makes it impossible for other targets to
405# depend on them (even transitively) unless they declare themselves
406# immune to that particular type of poison.
407#
408# Targets that *contain* poison of type foo should contain the line
409#
410# poisonous = [ "foo" ]
411#
412# and targets that *are immune but arent't themselves poisonous*
413# should contain
414#
415# allow_poison = [ "foo" ]
416#
417# This useful in cases where we have some large target or set of
418# targets and want to ensure that most other targets do not
419# transitively depend on them. For example, almost no high-level
420# target should depend on the audio codecs, since we want WebRTC users
421# to be able to inject any subset of them and actually end up with a
422# binary that doesn't include the codecs they didn't inject.
423#
424# Test-only targets (`testonly` set to true) and non-public targets
425# (`visibility` not containing "*") are automatically immune to all
426# types of poison.
427#
428# Here's the complete list of all types of poison. It must be kept in
429# 1:1 correspondence with the set of //:poison_* targets.
430#
431all_poison_types = [
432 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
433 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200434
Danil Chapovalov41300af2019-07-10 12:44:43 +0200435 # Default task queue implementation.
436 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200437
438 # JSON parsing should not be needed in the "slim and modular" WebRTC.
439 "rtc_json",
440
441 # Software video codecs (VP8 and VP9 through libvpx).
442 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200443]
444
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000445absl_include_config = "//third_party/abseil-cpp:absl_include_config"
446absl_define_config = "//third_party/abseil-cpp:absl_define_config"
447
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200448# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
449# that are testonly.
450absl_flags_config = webrtc_root + ":absl_flags_configs"
451
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100452# WebRTC wrapper of Chromium's test() template. This template just adds some
453# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
454# target.
455# The parameter `is_xctest` is different from the one in the Chromium's test()
456# template (and it is not forwarded to it). In rtc_test(), the argument
457# `is_xctest` is used to avoid to take dependencies that are not needed
458# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800459template("rtc_test") {
460 test(target_name) {
461 forward_variables_from(invoker,
462 "*",
463 [
464 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100465 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800466 "public_configs",
467 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200468 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800469 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100470
471 # Always override to public because when target_os is Android the `test`
472 # template can override it to [ "*" ] and we want to avoid conditional
473 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100474 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800475 configs += invoker.configs
476 configs -= rtc_remove_configs
477 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000478 public_configs = [
479 rtc_common_inherited_config,
480 absl_include_config,
481 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200482 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000483 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800484 if (defined(invoker.public_configs)) {
485 public_configs += invoker.public_configs
486 }
sakald7fdb802017-05-26 01:51:53 -0700487 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800488 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 18:53:11 -0400489 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200490 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200491 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 19:03:37 +0200492 deps += [
493 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
494 webrtc_root + "test:native_test_java",
495 ]
sakald7fdb802017-05-26 01:51:53 -0700496 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100497
498 # When not targeting a simulator, building //base/test:google_test_runner
499 # fails, so it is added only when the test is not a real XCTest and when
500 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100501 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100502 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
503 xctest_module_target = "//base/test:google_test_runner"
504 }
505 }
Andrey Logvin78646002021-01-29 10:50:19 +0000506
507 # If absl_deps is [], no action is needed. If not [], then it needs to be
508 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
509 # otherwise it just needs to be added to deps.
510 if (defined(absl_deps) && absl_deps != []) {
511 if (!defined(deps)) {
512 deps = []
513 }
514 if (build_with_chromium) {
515 deps += [ "//third_party/abseil-cpp:absl" ]
516 } else {
517 deps += absl_deps
518 }
519 }
520
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100521 if (using_sanitizer) {
522 if (is_linux) {
523 if (!defined(invoker.data)) {
524 data = []
525 }
526 data +=
527 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
528 }
529 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800530 }
531}
532
533template("rtc_source_set") {
534 source_set(target_name) {
535 forward_variables_from(invoker,
536 "*",
537 [
538 "configs",
539 "public_configs",
540 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200541 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800542 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200543 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000544 if (!defined(visibility)) {
545 visibility = webrtc_default_visibility
546 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200547
548 # What's your poison?
549 if (defined(testonly) && testonly) {
550 assert(!defined(poisonous))
551 assert(!defined(allow_poison))
552 } else {
553 if (!defined(poisonous)) {
554 poisonous = []
555 }
556 if (!defined(allow_poison)) {
557 allow_poison = []
558 }
559 if (!defined(assert_no_deps)) {
560 assert_no_deps = []
561 }
562 if (!defined(deps)) {
563 deps = []
564 }
565 foreach(p, poisonous) {
566 deps += [ webrtc_root + ":poison_" + p ]
567 }
568 foreach(poison_type, all_poison_types) {
569 allow_dep = true
570 foreach(v, visibility) {
571 if (v == "*") {
572 allow_dep = false
573 }
574 }
575 foreach(p, allow_poison + poisonous) {
576 if (p == poison_type) {
577 allow_dep = true
578 }
579 }
580 if (!allow_dep) {
581 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
582 }
583 }
584 }
585
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100586 # Chromium should only depend on the WebRTC component in order to
587 # avoid to statically link WebRTC in a component build.
588 if (build_with_chromium) {
589 publicly_visible = false
590 foreach(v, visibility) {
591 if (v == "*") {
592 publicly_visible = true
593 }
594 }
595 if (publicly_visible) {
596 visibility = []
597 visibility = webrtc_default_visibility
598 }
599 }
600
Mirko Bonadei96ede162018-09-06 13:45:44 +0200601 if (!defined(testonly) || !testonly) {
602 configs += rtc_prod_configs
603 }
604
mbonadei9aa3f0a2017-01-24 06:58:22 -0800605 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200606 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800607 configs -= rtc_remove_configs
608 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000609 public_configs = [
610 rtc_common_inherited_config,
611 absl_include_config,
612 absl_define_config,
613 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200614 if (defined(testonly) && testonly) {
615 public_configs += [ absl_flags_config ]
616 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800617 if (defined(invoker.public_configs)) {
618 public_configs += invoker.public_configs
619 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200620
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200621 # If absl_deps is [], no action is needed. If not [], then it needs to be
622 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200623 # otherwise it just needs to be added to deps.
624 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200625 if (!defined(deps)) {
626 deps = []
627 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200628 if (build_with_chromium) {
629 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200630 } else {
631 deps += absl_deps
632 }
633 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800634 }
635}
636
mbonadei9aa3f0a2017-01-24 06:58:22 -0800637template("rtc_static_library") {
638 static_library(target_name) {
639 forward_variables_from(invoker,
640 "*",
641 [
642 "configs",
643 "public_configs",
644 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200645 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800646 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200647 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000648 if (!defined(visibility)) {
649 visibility = webrtc_default_visibility
650 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200651
652 # What's your poison?
653 if (defined(testonly) && testonly) {
654 assert(!defined(poisonous))
655 assert(!defined(allow_poison))
656 } else {
657 if (!defined(poisonous)) {
658 poisonous = []
659 }
660 if (!defined(allow_poison)) {
661 allow_poison = []
662 }
663 if (!defined(assert_no_deps)) {
664 assert_no_deps = []
665 }
666 if (!defined(deps)) {
667 deps = []
668 }
669 foreach(p, poisonous) {
670 deps += [ webrtc_root + ":poison_" + p ]
671 }
672 foreach(poison_type, all_poison_types) {
673 allow_dep = true
674 foreach(v, visibility) {
675 if (v == "*") {
676 allow_dep = false
677 }
678 }
679 foreach(p, allow_poison + poisonous) {
680 if (p == poison_type) {
681 allow_dep = true
682 }
683 }
684 if (!allow_dep) {
685 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
686 }
687 }
688 }
689
Mirko Bonadei96ede162018-09-06 13:45:44 +0200690 if (!defined(testonly) || !testonly) {
691 configs += rtc_prod_configs
692 }
693
mbonadei9aa3f0a2017-01-24 06:58:22 -0800694 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200695 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800696 configs -= rtc_remove_configs
697 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000698 public_configs = [
699 rtc_common_inherited_config,
700 absl_include_config,
701 absl_define_config,
702 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200703 if (defined(testonly) && testonly) {
704 public_configs += [ absl_flags_config ]
705 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800706 if (defined(invoker.public_configs)) {
707 public_configs += invoker.public_configs
708 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200709
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200710 # If absl_deps is [], no action is needed. If not [], then it needs to be
711 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200712 # otherwise it just needs to be added to deps.
713 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200714 if (!defined(deps)) {
715 deps = []
716 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200717 if (build_with_chromium) {
718 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200719 } else {
720 deps += absl_deps
721 }
722 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800723 }
724}
725
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200726# This template automatically switches the target type between source_set
727# and static_library.
728#
729# This should be the default target type for all the WebRTC targets with
730# one exception. Do not use this template for header only targets, in that case
731# rtc_source_set must be used in order to avoid build errors (e.g. libtool
732# complains if the output .a file is empty).
733#
734# How does it work:
735# Since all files in a source_set are linked into a final binary, while files
736# in a static library are only linked in if at least one symbol in them is
737# referenced, in component builds source_sets are easy to deal with because
738# all their object files are passed to the linker to create a shared library.
739# In release builds instead, static_libraries are preferred since they allow
740# the linker to discard dead code.
741# For the same reason, testonly targets will always be expanded to
742# source_set in order to be sure that tests are present in the test binary.
743template("rtc_library") {
744 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
745 target_type = "source_set"
746 } else {
747 target_type = "static_library"
748 }
749 target(target_type, target_name) {
750 forward_variables_from(invoker,
751 "*",
752 [
753 "configs",
754 "public_configs",
755 "suppressed_configs",
756 "visibility",
757 ])
758 forward_variables_from(invoker, [ "visibility" ])
759 if (!defined(visibility)) {
760 visibility = webrtc_default_visibility
761 }
762
763 # What's your poison?
764 if (defined(testonly) && testonly) {
765 assert(!defined(poisonous))
766 assert(!defined(allow_poison))
767 } else {
768 if (!defined(poisonous)) {
769 poisonous = []
770 }
771 if (!defined(allow_poison)) {
772 allow_poison = []
773 }
774 if (!defined(assert_no_deps)) {
775 assert_no_deps = []
776 }
777 if (!defined(deps)) {
778 deps = []
779 }
780 foreach(p, poisonous) {
781 deps += [ webrtc_root + ":poison_" + p ]
782 }
783 foreach(poison_type, all_poison_types) {
784 allow_dep = true
785 foreach(v, visibility) {
786 if (v == "*") {
787 allow_dep = false
788 }
789 }
790 foreach(p, allow_poison + poisonous) {
791 if (p == poison_type) {
792 allow_dep = true
793 }
794 }
795 if (!allow_dep) {
796 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
797 }
798 }
799 }
800
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100801 # Chromium should only depend on the WebRTC component in order to
802 # avoid to statically link WebRTC in a component build.
803 if (build_with_chromium) {
804 publicly_visible = false
805 foreach(v, visibility) {
806 if (v == "*") {
807 publicly_visible = true
808 }
809 }
810 if (publicly_visible) {
811 visibility = []
812 visibility = webrtc_default_visibility
813 }
814 }
815
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200816 if (!defined(testonly) || !testonly) {
817 configs += rtc_prod_configs
818 }
819
820 configs += invoker.configs
821 configs += rtc_library_impl_config
822 configs -= rtc_remove_configs
823 configs -= invoker.suppressed_configs
824 public_configs = [
825 rtc_common_inherited_config,
826 absl_include_config,
827 absl_define_config,
828 ]
829 if (defined(testonly) && testonly) {
830 public_configs += [ absl_flags_config ]
831 }
832 if (defined(invoker.public_configs)) {
833 public_configs += invoker.public_configs
834 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200835
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200836 # If absl_deps is [], no action is needed. If not [], then it needs to be
837 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200838 # otherwise it just needs to be added to deps.
839 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200840 if (!defined(deps)) {
841 deps = []
842 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200843 if (build_with_chromium) {
844 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200845 } else {
846 deps += absl_deps
847 }
848 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200849 }
850}
851
852template("rtc_executable") {
853 executable(target_name) {
854 forward_variables_from(invoker,
855 "*",
856 [
857 "deps",
858 "configs",
859 "public_configs",
860 "suppressed_configs",
861 "visibility",
862 ])
863 forward_variables_from(invoker, [ "visibility" ])
864 if (!defined(visibility)) {
865 visibility = webrtc_default_visibility
866 }
867 configs += invoker.configs
868 configs -= rtc_remove_configs
869 configs -= invoker.suppressed_configs
870 deps = invoker.deps
871
872 public_configs = [
873 rtc_common_inherited_config,
874 absl_include_config,
875 absl_define_config,
876 ]
877 if (defined(testonly) && testonly) {
878 public_configs += [ absl_flags_config ]
879 }
880 if (defined(invoker.public_configs)) {
881 public_configs += invoker.public_configs
882 }
883 if (is_win) {
884 deps += [
885 # Give executables the default manifest on Windows (a no-op elsewhere).
886 "//build/win:default_exe_manifest",
887 ]
888 }
889 }
890}
891
mbonadei9aa3f0a2017-01-24 06:58:22 -0800892template("rtc_shared_library") {
893 shared_library(target_name) {
894 forward_variables_from(invoker,
895 "*",
896 [
897 "configs",
898 "public_configs",
899 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200900 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800901 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200902 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000903 if (!defined(visibility)) {
904 visibility = webrtc_default_visibility
905 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200906
907 # What's your poison?
908 if (defined(testonly) && testonly) {
909 assert(!defined(poisonous))
910 assert(!defined(allow_poison))
911 } else {
912 if (!defined(poisonous)) {
913 poisonous = []
914 }
915 if (!defined(allow_poison)) {
916 allow_poison = []
917 }
918 if (!defined(assert_no_deps)) {
919 assert_no_deps = []
920 }
921 if (!defined(deps)) {
922 deps = []
923 }
924 foreach(p, poisonous) {
925 deps += [ webrtc_root + ":poison_" + p ]
926 }
927 foreach(poison_type, all_poison_types) {
928 allow_dep = true
929 foreach(v, visibility) {
930 if (v == "*") {
931 allow_dep = false
932 }
933 }
934 foreach(p, allow_poison + poisonous) {
935 if (p == poison_type) {
936 allow_dep = true
937 }
938 }
939 if (!allow_dep) {
940 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
941 }
942 }
943 }
944
mbonadei9aa3f0a2017-01-24 06:58:22 -0800945 configs += invoker.configs
946 configs -= rtc_remove_configs
947 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000948 public_configs = [
949 rtc_common_inherited_config,
950 absl_include_config,
951 absl_define_config,
952 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200953 if (defined(testonly) && testonly) {
954 public_configs += [ absl_flags_config ]
955 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800956 if (defined(invoker.public_configs)) {
957 public_configs += invoker.public_configs
958 }
959 }
960}
kthelgason4065a572017-02-14 04:58:56 -0800961
962if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400963 # TODO: Generate module.modulemap file to enable use in Swift
964 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100965 template("ios_framework_bundle_with_umbrella_header") {
966 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900967 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100968 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900969 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
970
971 action_foreach("create_bracket_include_headers_$target_name") {
972 script = "//tools_webrtc/apple/copy_framework_header.py"
973 sources = invoker.sources
974 output_name = invoker.output_name
975 outputs = [
976 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
977 ]
978 args = [
979 "--input",
980 "{{source}}",
981 "--output",
982 rebase_path(target_gen_dir, root_build_dir) +
983 "/$output_name.framework/WebRTC/{{source_file_part}}",
984 ]
985 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100986
987 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900988 forward_variables_from(invoker, "*", [ "public_headers" ])
989 public_headers = get_target_outputs(
990 ":create_bracket_include_headers_$this_target_name")
991 deps += [
992 ":copy_umbrella_header_$target_name",
993 ":create_bracket_include_headers_$target_name",
994 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100995 }
996
997 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900998 public_headers = get_target_outputs(
999 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +01001000
1001 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1002
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001003 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001004 args = [
1005 "--out",
1006 rebase_path(umbrella_header_path, root_build_dir),
1007 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +02001008 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001009 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001010 }
1011
Jordan Rose53d3fc92021-07-06 12:16:41 -07001012 if (target_environment == "catalyst") {
1013 # Catalyst frameworks use the same layout as regular Mac frameworks.
1014 headers_dir = "Versions/A/Headers"
1015 } else {
1016 headers_dir = "Headers"
1017 }
Anders Carlssondc6b4772018-01-15 13:31:03 +01001018 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001019 sources = [ umbrella_header_path ]
1020 outputs =
Jordan Rose53d3fc92021-07-06 12:16:41 -07001021 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001022
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001023 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001024 }
1025 }
1026
1027 set_defaults("ios_framework_bundle_with_umbrella_header") {
1028 configs = default_shared_library_configs
1029 }
kthelgason4065a572017-02-14 04:58:56 -08001030}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001031
Anders Carlsson37bbf792018-09-05 16:29:27 +02001032if (is_mac) {
1033 template("mac_framework_bundle_with_umbrella_header") {
1034 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001035 this_target_name = target_name
1036 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001037 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +02001038
1039 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -08001040 forward_variables_from(invoker, "*", [ "configs" ])
1041 if (defined(invoker.configs)) {
1042 configs += invoker.configs
1043 }
Anders Carlsson37bbf792018-09-05 16:29:27 +02001044
1045 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001046 framework_contents = [
1047 "Headers",
1048 "Modules",
1049 "Resources",
1050 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001051
1052 ldflags = [
1053 "-all_load",
1054 "-install_name",
1055 "@rpath/$output_name.framework/$output_name",
1056 ]
1057
1058 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001059 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001060 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001061 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001062 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001063 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001064 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001065 ]
1066 }
1067
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001068 action_foreach("create_bracket_include_headers_$this_target_name") {
1069 script = "//tools_webrtc/apple/copy_framework_header.py"
1070 sources = invoker.sources
1071 output_name = invoker.output_name
1072 outputs = [
1073 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1074 ]
1075 args = [
1076 "--input",
1077 "{{source}}",
1078 "--output",
1079 rebase_path(target_gen_dir, root_build_dir) +
1080 "/$output_name.framework/WebRTC/{{source_file_part}}",
1081 ]
1082 }
1083
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001084 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001085 sources = get_target_outputs(
1086 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001087
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001088 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001089 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001090 }
1091
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001092 action("modulemap_$this_target_name") {
1093 script = "//tools_webrtc/ios/generate_modulemap.py"
1094 args = [
1095 "--out",
1096 rebase_path(modulemap_path, root_build_dir),
1097 "--name",
1098 output_name,
1099 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001100 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001101 }
1102
1103 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001104 sources = [ modulemap_path ]
1105 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1106 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001107 }
1108
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001109 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001110 sources = get_target_outputs(
1111 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001112
1113 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1114
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001115 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001116 args = [
1117 "--out",
1118 rebase_path(umbrella_header_path, root_build_dir),
1119 "--sources",
1120 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001121 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001122 }
1123
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001124 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001125 sources = [ umbrella_header_path ]
1126 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001127
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001128 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001129 }
1130 }
1131}
1132
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001133if (is_android) {
1134 template("rtc_android_library") {
1135 android_library(target_name) {
1136 forward_variables_from(invoker,
1137 "*",
1138 [
1139 "configs",
1140 "public_configs",
1141 "suppressed_configs",
1142 "visibility",
1143 ])
1144
Oleh Prypin05aee742018-11-23 17:29:44 +01001145 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001146
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001147 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001148 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001149
1150 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001151 if (defined(invoker.errorprone_args)) {
1152 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001153 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001154
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001155 if (!defined(deps)) {
1156 deps = []
1157 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001158
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001159 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001160 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001161 }
1162 }
1163
1164 template("rtc_android_apk") {
1165 android_apk(target_name) {
1166 forward_variables_from(invoker,
1167 "*",
1168 [
1169 "configs",
1170 "public_configs",
1171 "suppressed_configs",
1172 "visibility",
1173 ])
1174
1175 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001176 errorprone_args = []
1177 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001178
1179 if (!defined(deps)) {
1180 deps = []
1181 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001182
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001183 no_build_hooks = true
1184 }
1185 }
1186
1187 template("rtc_instrumentation_test_apk") {
1188 instrumentation_test_apk(target_name) {
1189 forward_variables_from(invoker,
1190 "*",
1191 [
1192 "configs",
1193 "public_configs",
1194 "suppressed_configs",
1195 "visibility",
1196 ])
1197
1198 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001199 errorprone_args = []
1200 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001201
1202 if (!defined(deps)) {
1203 deps = []
1204 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001205
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001206 no_build_hooks = true
1207 }
1208 }
1209}