blob: 6baf175fea45c6b2fc2a13bf9d3f0c493653860b [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
Dan Minor9c686132018-01-15 10:20:00 -0500227}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800228
Dan Minor9c686132018-01-15 10:20:00 -0500229if (!build_with_mozilla) {
230 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800231}
232
233# A second declare_args block, so that declarations within it can
234# depend on the possibly overridden variables in the first
235# declare_args block.
236declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500237 # Enables the use of protocol buffers for debug recordings.
238 rtc_enable_protobuf = !build_with_mozilla
239
240 # Set this to disable building with support for SCTP data channels.
241 rtc_enable_sctp = !build_with_mozilla
242
243 # Disable these to not build components which can be externally provided.
244 rtc_build_json = !build_with_mozilla
245 rtc_build_libsrtp = !build_with_mozilla
246 rtc_build_libvpx = !build_with_mozilla
247 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500248 rtc_build_opus = !build_with_mozilla
249 rtc_build_ssl = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500250
251 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200252 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
253 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500254 rtc_enable_libevent = false
255 rtc_build_libevent = false
256 } else {
257 rtc_enable_libevent = true
258 rtc_build_libevent = !build_with_mozilla
259 }
260
mbonadei9aa3f0a2017-01-24 06:58:22 -0800261 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
262 rtc_include_pulse_audio = !build_with_chromium
263
264 # Chromium uses its own IO handling, so the internal ADM is only built for
265 # standalone WebRTC.
266 rtc_include_internal_audio_device = !build_with_chromium
267
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800268 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 12:02:32 +0200269 # TODO: Make sure that AVX2 works also for non-clang compilers.
270 if (is_clang == true) {
271 rtc_enable_avx2 = true
272 } else {
273 rtc_enable_avx2 = false
274 }
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800275
Philipp Hancke1a89bc82021-03-02 21:23:24 +0100276 # Set this to true to build the unit tests.
277 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 10:20:00 -0500278 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200279
280 # Set this to false to skip building code that also requires X11 extensions
281 # such as Xdamage, Xfixes.
282 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100283
284 # Set this to true to fully remove logging from WebRTC.
285 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100286
287 # Set this to true to disable trace events.
288 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100289
290 # Set this to true to disable detailed error message and logging for
291 # RTC_CHECKs.
292 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100293
294 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100295 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200296
297 # Set this to true to exclude the transient suppressor in the audio processing
298 # module from the build.
299 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800300}
301
Florent Castellia80c3e52021-04-15 15:02:56 +0200302declare_args() {
Florent Castellia6983c62021-05-06 10:50:07 +0200303 # Enable the dcsctp backend for DataChannels and related unittests
304 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
305
Florent Castellia80c3e52021-04-15 15:02:56 +0200306 # Enable the usrsctp backend for DataChannels and related unittests
307 rtc_build_usrsctp = !build_with_mozilla && rtc_enable_sctp
308}
309
mbonadei9aa3f0a2017-01-24 06:58:22 -0800310# Make it possible to provide custom locations for some libraries (move these
311# up into declare_args should we need to actually use them for the GN build).
312rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800313rtc_opus_dir = "//third_party/opus"
314
315# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200316rtc_desktop_capture_supported =
317 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900318 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800319
320###############################################################################
321# Templates
322#
323
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200324# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800325# chromium.
326# We need absolute paths for all configs in templates as they are shared in
327# different subdirectories.
328webrtc_root = get_path_info(".", "abspath")
329
330# Global configuration that should be applied to all WebRTC targets.
331# You normally shouldn't need to include this in your target as it's
332# automatically included when using the rtc_* templates.
333# It sets defines, include paths and compilation warnings accordingly,
334# both for WebRTC stand-alone builds and for the scenario when WebRTC
335# native code is built as part of Chromium.
Mirko Bonadei5f078452021-07-30 22:32:55 +0200336rtc_common_configs = [ webrtc_root + ":common_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800337
kthelgasonc0977102017-04-24 00:57:16 -0700338if (is_mac || is_ios) {
339 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
340}
341
mbonadei9aa3f0a2017-01-24 06:58:22 -0800342# Global public configuration that should be applied to all WebRTC targets. You
343# normally shouldn't need to include this in your target as it's automatically
344# included when using the rtc_* templates. It set the defines, include paths and
345# compilation warnings that should be propagated to dependents of the targets
346# depending on the target having this config.
347rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
348
349# Common configs to remove or add in all rtc targets.
350rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100351if (!build_with_chromium && is_clang) {
352 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
353}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800354rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200355rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200356rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800357
358set_defaults("rtc_test") {
359 configs = rtc_add_configs
360 suppressed_configs = []
361}
362
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200363set_defaults("rtc_library") {
364 configs = rtc_add_configs
365 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200366 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200367}
368
mbonadei9aa3f0a2017-01-24 06:58:22 -0800369set_defaults("rtc_source_set") {
370 configs = rtc_add_configs
371 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200372 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800373}
374
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200375set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800376 configs = rtc_add_configs
377 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200378 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800379}
380
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200381set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800382 configs = rtc_add_configs
383 suppressed_configs = []
384}
385
386set_defaults("rtc_shared_library") {
387 configs = rtc_add_configs
388 suppressed_configs = []
389}
390
Per Kjellandera7f2d842018-01-10 15:54:53 +0000391webrtc_default_visibility = [ webrtc_root + "/*" ]
392if (build_with_chromium) {
393 # Allow Chromium's WebRTC overrides targets to bypass the regular
394 # visibility restrictions.
395 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
396}
397
Karl Wibergbb23c832018-04-22 19:55:00 +0200398# ---- Poisons ----
399#
400# The general idea is that some targets declare that they contain some
401# kind of poison, which makes it impossible for other targets to
402# depend on them (even transitively) unless they declare themselves
403# immune to that particular type of poison.
404#
405# Targets that *contain* poison of type foo should contain the line
406#
407# poisonous = [ "foo" ]
408#
409# and targets that *are immune but arent't themselves poisonous*
410# should contain
411#
412# allow_poison = [ "foo" ]
413#
414# This useful in cases where we have some large target or set of
415# targets and want to ensure that most other targets do not
416# transitively depend on them. For example, almost no high-level
417# target should depend on the audio codecs, since we want WebRTC users
418# to be able to inject any subset of them and actually end up with a
419# binary that doesn't include the codecs they didn't inject.
420#
421# Test-only targets (`testonly` set to true) and non-public targets
422# (`visibility` not containing "*") are automatically immune to all
423# types of poison.
424#
425# Here's the complete list of all types of poison. It must be kept in
426# 1:1 correspondence with the set of //:poison_* targets.
427#
428all_poison_types = [
429 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
430 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200431
Danil Chapovalov41300af2019-07-10 12:44:43 +0200432 # Default task queue implementation.
433 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200434
435 # JSON parsing should not be needed in the "slim and modular" WebRTC.
436 "rtc_json",
437
438 # Software video codecs (VP8 and VP9 through libvpx).
439 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200440]
441
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000442absl_include_config = "//third_party/abseil-cpp:absl_include_config"
443absl_define_config = "//third_party/abseil-cpp:absl_define_config"
444
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200445# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
446# that are testonly.
447absl_flags_config = webrtc_root + ":absl_flags_configs"
448
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100449# WebRTC wrapper of Chromium's test() template. This template just adds some
450# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
451# target.
452# The parameter `is_xctest` is different from the one in the Chromium's test()
453# template (and it is not forwarded to it). In rtc_test(), the argument
454# `is_xctest` is used to avoid to take dependencies that are not needed
455# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800456template("rtc_test") {
457 test(target_name) {
458 forward_variables_from(invoker,
459 "*",
460 [
461 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100462 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800463 "public_configs",
464 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200465 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800466 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100467
468 # Always override to public because when target_os is Android the `test`
469 # template can override it to [ "*" ] and we want to avoid conditional
470 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100471 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800472 configs += invoker.configs
473 configs -= rtc_remove_configs
474 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000475 public_configs = [
476 rtc_common_inherited_config,
477 absl_include_config,
478 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200479 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000480 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800481 if (defined(invoker.public_configs)) {
482 public_configs += invoker.public_configs
483 }
sakald7fdb802017-05-26 01:51:53 -0700484 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800485 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 18:53:11 -0400486 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200487 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200488 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 19:03:37 +0200489 deps += [
490 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
491 webrtc_root + "test:native_test_java",
492 ]
sakald7fdb802017-05-26 01:51:53 -0700493 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100494
495 # When not targeting a simulator, building //base/test:google_test_runner
496 # fails, so it is added only when the test is not a real XCTest and when
497 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100498 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100499 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
500 xctest_module_target = "//base/test:google_test_runner"
501 }
502 }
Andrey Logvin78646002021-01-29 10:50:19 +0000503
504 # If absl_deps is [], no action is needed. If not [], then it needs to be
505 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
506 # otherwise it just needs to be added to deps.
507 if (defined(absl_deps) && absl_deps != []) {
508 if (!defined(deps)) {
509 deps = []
510 }
511 if (build_with_chromium) {
512 deps += [ "//third_party/abseil-cpp:absl" ]
513 } else {
514 deps += absl_deps
515 }
516 }
517
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100518 if (using_sanitizer) {
519 if (is_linux) {
520 if (!defined(invoker.data)) {
521 data = []
522 }
523 data +=
524 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
525 }
526 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800527 }
528}
529
530template("rtc_source_set") {
531 source_set(target_name) {
532 forward_variables_from(invoker,
533 "*",
534 [
535 "configs",
536 "public_configs",
537 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200538 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800539 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200540 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000541 if (!defined(visibility)) {
542 visibility = webrtc_default_visibility
543 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200544
545 # What's your poison?
546 if (defined(testonly) && testonly) {
547 assert(!defined(poisonous))
548 assert(!defined(allow_poison))
549 } else {
550 if (!defined(poisonous)) {
551 poisonous = []
552 }
553 if (!defined(allow_poison)) {
554 allow_poison = []
555 }
556 if (!defined(assert_no_deps)) {
557 assert_no_deps = []
558 }
559 if (!defined(deps)) {
560 deps = []
561 }
562 foreach(p, poisonous) {
563 deps += [ webrtc_root + ":poison_" + p ]
564 }
565 foreach(poison_type, all_poison_types) {
566 allow_dep = true
567 foreach(v, visibility) {
568 if (v == "*") {
569 allow_dep = false
570 }
571 }
572 foreach(p, allow_poison + poisonous) {
573 if (p == poison_type) {
574 allow_dep = true
575 }
576 }
577 if (!allow_dep) {
578 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
579 }
580 }
581 }
582
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100583 # Chromium should only depend on the WebRTC component in order to
584 # avoid to statically link WebRTC in a component build.
585 if (build_with_chromium) {
586 publicly_visible = false
587 foreach(v, visibility) {
588 if (v == "*") {
589 publicly_visible = true
590 }
591 }
592 if (publicly_visible) {
593 visibility = []
594 visibility = webrtc_default_visibility
595 }
596 }
597
Mirko Bonadei96ede162018-09-06 13:45:44 +0200598 if (!defined(testonly) || !testonly) {
599 configs += rtc_prod_configs
600 }
601
mbonadei9aa3f0a2017-01-24 06:58:22 -0800602 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200603 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800604 configs -= rtc_remove_configs
605 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000606 public_configs = [
607 rtc_common_inherited_config,
608 absl_include_config,
609 absl_define_config,
610 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200611 if (defined(testonly) && testonly) {
612 public_configs += [ absl_flags_config ]
613 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800614 if (defined(invoker.public_configs)) {
615 public_configs += invoker.public_configs
616 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200617
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200618 # If absl_deps is [], no action is needed. If not [], then it needs to be
619 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200620 # otherwise it just needs to be added to deps.
621 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200622 if (!defined(deps)) {
623 deps = []
624 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200625 if (build_with_chromium) {
626 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200627 } else {
628 deps += absl_deps
629 }
630 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800631 }
632}
633
mbonadei9aa3f0a2017-01-24 06:58:22 -0800634template("rtc_static_library") {
635 static_library(target_name) {
636 forward_variables_from(invoker,
637 "*",
638 [
639 "configs",
640 "public_configs",
641 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200642 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800643 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200644 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000645 if (!defined(visibility)) {
646 visibility = webrtc_default_visibility
647 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200648
649 # What's your poison?
650 if (defined(testonly) && testonly) {
651 assert(!defined(poisonous))
652 assert(!defined(allow_poison))
653 } else {
654 if (!defined(poisonous)) {
655 poisonous = []
656 }
657 if (!defined(allow_poison)) {
658 allow_poison = []
659 }
660 if (!defined(assert_no_deps)) {
661 assert_no_deps = []
662 }
663 if (!defined(deps)) {
664 deps = []
665 }
666 foreach(p, poisonous) {
667 deps += [ webrtc_root + ":poison_" + p ]
668 }
669 foreach(poison_type, all_poison_types) {
670 allow_dep = true
671 foreach(v, visibility) {
672 if (v == "*") {
673 allow_dep = false
674 }
675 }
676 foreach(p, allow_poison + poisonous) {
677 if (p == poison_type) {
678 allow_dep = true
679 }
680 }
681 if (!allow_dep) {
682 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
683 }
684 }
685 }
686
Mirko Bonadei96ede162018-09-06 13:45:44 +0200687 if (!defined(testonly) || !testonly) {
688 configs += rtc_prod_configs
689 }
690
mbonadei9aa3f0a2017-01-24 06:58:22 -0800691 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200692 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800693 configs -= rtc_remove_configs
694 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000695 public_configs = [
696 rtc_common_inherited_config,
697 absl_include_config,
698 absl_define_config,
699 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200700 if (defined(testonly) && testonly) {
701 public_configs += [ absl_flags_config ]
702 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800703 if (defined(invoker.public_configs)) {
704 public_configs += invoker.public_configs
705 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200706
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200707 # If absl_deps is [], no action is needed. If not [], then it needs to be
708 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200709 # otherwise it just needs to be added to deps.
710 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200711 if (!defined(deps)) {
712 deps = []
713 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200714 if (build_with_chromium) {
715 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200716 } else {
717 deps += absl_deps
718 }
719 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800720 }
721}
722
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200723# This template automatically switches the target type between source_set
724# and static_library.
725#
726# This should be the default target type for all the WebRTC targets with
727# one exception. Do not use this template for header only targets, in that case
728# rtc_source_set must be used in order to avoid build errors (e.g. libtool
729# complains if the output .a file is empty).
730#
731# How does it work:
732# Since all files in a source_set are linked into a final binary, while files
733# in a static library are only linked in if at least one symbol in them is
734# referenced, in component builds source_sets are easy to deal with because
735# all their object files are passed to the linker to create a shared library.
736# In release builds instead, static_libraries are preferred since they allow
737# the linker to discard dead code.
738# For the same reason, testonly targets will always be expanded to
739# source_set in order to be sure that tests are present in the test binary.
740template("rtc_library") {
741 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
742 target_type = "source_set"
743 } else {
744 target_type = "static_library"
745 }
746 target(target_type, target_name) {
747 forward_variables_from(invoker,
748 "*",
749 [
750 "configs",
751 "public_configs",
752 "suppressed_configs",
753 "visibility",
754 ])
755 forward_variables_from(invoker, [ "visibility" ])
756 if (!defined(visibility)) {
757 visibility = webrtc_default_visibility
758 }
759
760 # What's your poison?
761 if (defined(testonly) && testonly) {
762 assert(!defined(poisonous))
763 assert(!defined(allow_poison))
764 } else {
765 if (!defined(poisonous)) {
766 poisonous = []
767 }
768 if (!defined(allow_poison)) {
769 allow_poison = []
770 }
771 if (!defined(assert_no_deps)) {
772 assert_no_deps = []
773 }
774 if (!defined(deps)) {
775 deps = []
776 }
777 foreach(p, poisonous) {
778 deps += [ webrtc_root + ":poison_" + p ]
779 }
780 foreach(poison_type, all_poison_types) {
781 allow_dep = true
782 foreach(v, visibility) {
783 if (v == "*") {
784 allow_dep = false
785 }
786 }
787 foreach(p, allow_poison + poisonous) {
788 if (p == poison_type) {
789 allow_dep = true
790 }
791 }
792 if (!allow_dep) {
793 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
794 }
795 }
796 }
797
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100798 # Chromium should only depend on the WebRTC component in order to
799 # avoid to statically link WebRTC in a component build.
800 if (build_with_chromium) {
801 publicly_visible = false
802 foreach(v, visibility) {
803 if (v == "*") {
804 publicly_visible = true
805 }
806 }
807 if (publicly_visible) {
808 visibility = []
809 visibility = webrtc_default_visibility
810 }
811 }
812
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200813 if (!defined(testonly) || !testonly) {
814 configs += rtc_prod_configs
815 }
816
817 configs += invoker.configs
818 configs += rtc_library_impl_config
819 configs -= rtc_remove_configs
820 configs -= invoker.suppressed_configs
821 public_configs = [
822 rtc_common_inherited_config,
823 absl_include_config,
824 absl_define_config,
825 ]
826 if (defined(testonly) && testonly) {
827 public_configs += [ absl_flags_config ]
828 }
829 if (defined(invoker.public_configs)) {
830 public_configs += invoker.public_configs
831 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200832
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200833 # If absl_deps is [], no action is needed. If not [], then it needs to be
834 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200835 # otherwise it just needs to be added to deps.
836 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200837 if (!defined(deps)) {
838 deps = []
839 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200840 if (build_with_chromium) {
841 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200842 } else {
843 deps += absl_deps
844 }
845 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200846 }
847}
848
849template("rtc_executable") {
850 executable(target_name) {
851 forward_variables_from(invoker,
852 "*",
853 [
854 "deps",
855 "configs",
856 "public_configs",
857 "suppressed_configs",
858 "visibility",
859 ])
860 forward_variables_from(invoker, [ "visibility" ])
861 if (!defined(visibility)) {
862 visibility = webrtc_default_visibility
863 }
864 configs += invoker.configs
865 configs -= rtc_remove_configs
866 configs -= invoker.suppressed_configs
867 deps = invoker.deps
868
869 public_configs = [
870 rtc_common_inherited_config,
871 absl_include_config,
872 absl_define_config,
873 ]
874 if (defined(testonly) && testonly) {
875 public_configs += [ absl_flags_config ]
876 }
877 if (defined(invoker.public_configs)) {
878 public_configs += invoker.public_configs
879 }
880 if (is_win) {
881 deps += [
882 # Give executables the default manifest on Windows (a no-op elsewhere).
883 "//build/win:default_exe_manifest",
884 ]
885 }
886 }
887}
888
mbonadei9aa3f0a2017-01-24 06:58:22 -0800889template("rtc_shared_library") {
890 shared_library(target_name) {
891 forward_variables_from(invoker,
892 "*",
893 [
894 "configs",
895 "public_configs",
896 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200897 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800898 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200899 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000900 if (!defined(visibility)) {
901 visibility = webrtc_default_visibility
902 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200903
904 # What's your poison?
905 if (defined(testonly) && testonly) {
906 assert(!defined(poisonous))
907 assert(!defined(allow_poison))
908 } else {
909 if (!defined(poisonous)) {
910 poisonous = []
911 }
912 if (!defined(allow_poison)) {
913 allow_poison = []
914 }
915 if (!defined(assert_no_deps)) {
916 assert_no_deps = []
917 }
918 if (!defined(deps)) {
919 deps = []
920 }
921 foreach(p, poisonous) {
922 deps += [ webrtc_root + ":poison_" + p ]
923 }
924 foreach(poison_type, all_poison_types) {
925 allow_dep = true
926 foreach(v, visibility) {
927 if (v == "*") {
928 allow_dep = false
929 }
930 }
931 foreach(p, allow_poison + poisonous) {
932 if (p == poison_type) {
933 allow_dep = true
934 }
935 }
936 if (!allow_dep) {
937 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
938 }
939 }
940 }
941
mbonadei9aa3f0a2017-01-24 06:58:22 -0800942 configs += invoker.configs
943 configs -= rtc_remove_configs
944 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000945 public_configs = [
946 rtc_common_inherited_config,
947 absl_include_config,
948 absl_define_config,
949 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200950 if (defined(testonly) && testonly) {
951 public_configs += [ absl_flags_config ]
952 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800953 if (defined(invoker.public_configs)) {
954 public_configs += invoker.public_configs
955 }
956 }
957}
kthelgason4065a572017-02-14 04:58:56 -0800958
959if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400960 # TODO: Generate module.modulemap file to enable use in Swift
961 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100962 template("ios_framework_bundle_with_umbrella_header") {
963 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900964 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100965 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900966 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
967
968 action_foreach("create_bracket_include_headers_$target_name") {
969 script = "//tools_webrtc/apple/copy_framework_header.py"
970 sources = invoker.sources
971 output_name = invoker.output_name
972 outputs = [
973 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
974 ]
975 args = [
976 "--input",
977 "{{source}}",
978 "--output",
979 rebase_path(target_gen_dir, root_build_dir) +
980 "/$output_name.framework/WebRTC/{{source_file_part}}",
981 ]
982 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100983
984 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900985 forward_variables_from(invoker, "*", [ "public_headers" ])
986 public_headers = get_target_outputs(
987 ":create_bracket_include_headers_$this_target_name")
988 deps += [
989 ":copy_umbrella_header_$target_name",
990 ":create_bracket_include_headers_$target_name",
991 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100992 }
993
994 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900995 public_headers = get_target_outputs(
996 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100997
998 script = "//tools_webrtc/ios/generate_umbrella_header.py"
999
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001000 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001001 args = [
1002 "--out",
1003 rebase_path(umbrella_header_path, root_build_dir),
1004 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +02001005 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001006 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001007 }
1008
Jordan Rose53d3fc92021-07-06 12:16:41 -07001009 if (target_environment == "catalyst") {
1010 # Catalyst frameworks use the same layout as regular Mac frameworks.
1011 headers_dir = "Versions/A/Headers"
1012 } else {
1013 headers_dir = "Headers"
1014 }
Anders Carlssondc6b4772018-01-15 13:31:03 +01001015 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001016 sources = [ umbrella_header_path ]
1017 outputs =
Jordan Rose53d3fc92021-07-06 12:16:41 -07001018 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001019
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001020 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001021 }
1022 }
1023
1024 set_defaults("ios_framework_bundle_with_umbrella_header") {
1025 configs = default_shared_library_configs
1026 }
kthelgason4065a572017-02-14 04:58:56 -08001027}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001028
Anders Carlsson37bbf792018-09-05 16:29:27 +02001029if (is_mac) {
1030 template("mac_framework_bundle_with_umbrella_header") {
1031 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001032 this_target_name = target_name
1033 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001034 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +02001035
1036 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -08001037 forward_variables_from(invoker, "*", [ "configs" ])
1038 if (defined(invoker.configs)) {
1039 configs += invoker.configs
1040 }
Anders Carlsson37bbf792018-09-05 16:29:27 +02001041
1042 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001043 framework_contents = [
1044 "Headers",
1045 "Modules",
1046 "Resources",
1047 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001048
1049 ldflags = [
1050 "-all_load",
1051 "-install_name",
1052 "@rpath/$output_name.framework/$output_name",
1053 ]
1054
1055 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001056 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001057 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001058 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001059 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001060 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001061 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001062 ]
1063 }
1064
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001065 action_foreach("create_bracket_include_headers_$this_target_name") {
1066 script = "//tools_webrtc/apple/copy_framework_header.py"
1067 sources = invoker.sources
1068 output_name = invoker.output_name
1069 outputs = [
1070 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1071 ]
1072 args = [
1073 "--input",
1074 "{{source}}",
1075 "--output",
1076 rebase_path(target_gen_dir, root_build_dir) +
1077 "/$output_name.framework/WebRTC/{{source_file_part}}",
1078 ]
1079 }
1080
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001081 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001082 sources = get_target_outputs(
1083 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001084
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001085 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001086 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001087 }
1088
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001089 action("modulemap_$this_target_name") {
1090 script = "//tools_webrtc/ios/generate_modulemap.py"
1091 args = [
1092 "--out",
1093 rebase_path(modulemap_path, root_build_dir),
1094 "--name",
1095 output_name,
1096 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001097 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001098 }
1099
1100 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001101 sources = [ modulemap_path ]
1102 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1103 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001104 }
1105
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001106 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001107 sources = get_target_outputs(
1108 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001109
1110 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1111
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001112 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001113 args = [
1114 "--out",
1115 rebase_path(umbrella_header_path, root_build_dir),
1116 "--sources",
1117 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001118 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001119 }
1120
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001121 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001122 sources = [ umbrella_header_path ]
1123 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001124
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001125 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001126 }
1127 }
1128}
1129
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001130if (is_android) {
1131 template("rtc_android_library") {
1132 android_library(target_name) {
1133 forward_variables_from(invoker,
1134 "*",
1135 [
1136 "configs",
1137 "public_configs",
1138 "suppressed_configs",
1139 "visibility",
1140 ])
1141
Oleh Prypin05aee742018-11-23 17:29:44 +01001142 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001143
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001144 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001145 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001146
1147 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001148 if (defined(invoker.errorprone_args)) {
1149 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001150 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001151
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001152 if (!defined(deps)) {
1153 deps = []
1154 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001155
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001156 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001157 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001158 }
1159 }
1160
1161 template("rtc_android_apk") {
1162 android_apk(target_name) {
1163 forward_variables_from(invoker,
1164 "*",
1165 [
1166 "configs",
1167 "public_configs",
1168 "suppressed_configs",
1169 "visibility",
1170 ])
1171
1172 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001173 errorprone_args = []
1174 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001175
1176 if (!defined(deps)) {
1177 deps = []
1178 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001179
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001180 no_build_hooks = true
1181 }
1182 }
1183
1184 template("rtc_instrumentation_test_apk") {
1185 instrumentation_test_apk(target_name) {
1186 forward_variables_from(invoker,
1187 "*",
1188 [
1189 "configs",
1190 "public_configs",
1191 "suppressed_configs",
1192 "visibility",
1193 ])
1194
1195 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001196 errorprone_args = []
1197 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001198
1199 if (!defined(deps)) {
1200 deps = []
1201 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001202
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001203 no_build_hooks = true
1204 }
1205 }
1206}