blob: a32e7bfc4423bde1e18cc0f6e0b40c8c177f24d9 [file] [log] [blame]
mbonadei9aa3f0a2017-01-24 06:58:22 -08001# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS. All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
mbonadei9aa3f0a2017-01-24 06:58:22 -08008import("//build/config/arm.gni")
9import("//build/config/features.gni")
10import("//build/config/mips.gni")
11import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 06:32:23 +010012import("//build/config/sysroot.gni")
ehmaldonado0d729b32017-02-10 01:38:23 -080013import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080014import("//build_overrides/build.gni")
mbonadei96606272017-03-03 19:41:59 -080015
16if (!build_with_chromium && is_component_build) {
17 print("The Gn argument `is_component_build` is currently " +
18 "ignored for WebRTC builds.")
19 print("Component builds are supported by Chromium and the argument " +
20 "`is_component_build` makes it possible to create shared libraries " +
21 "instead of static libraries.")
22 print("If an app depends on WebRTC it makes sense to just depend on the " +
23 "WebRTC static library, so there is no difference between " +
24 "`is_component_build=true` and `is_component_build=false`.")
25 print(
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() {
48 # Setting this to true will make RTC_OBJC_EXPORT expand to code that will
49 # manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported
50 # if C++ symbols are but setting this arg to true while keeping
51 # rtc_enable_symbol_export=false will only export RTC_OBJC_EXPORT
52 # annotated symbols.
53 rtc_enable_objc_symbol_export = rtc_enable_symbol_export
Mirko Bonadei028248c2018-10-10 12:19:02 +020054
Mirko Bonadei31b0b452018-08-22 10:37:11 +020055 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020056 # will tell the pre-processor to remove the default definition of symbols
57 # needed to use field_trial. In that case a new implementation needs to be
58 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020059 if (build_with_chromium) {
60 # When WebRTC is built as part of Chromium it should exclude the default
61 # implementation of field_trial unless it is building for NACL or
62 # Chromecast.
63 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
64 } else {
65 rtc_exclude_field_trial_default = false
66 }
Mirko Bonadei70400902018-08-21 15:44:28 +020067
Mirko Bonadei906add42018-09-05 16:03:16 +020068 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
69 # will tell the pre-processor to remove the default definition of symbols
70 # needed to use metrics. In that case a new implementation needs to be
71 # provided.
72 rtc_exclude_metrics_default = build_with_chromium
73
Johannes Kronda20c732021-02-19 16:39:41 +010074 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which
75 # will tell the pre-processor to remove the default definition of the
76 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
77 # that case a new implementation needs to be provided.
Johannes Kronbb52bdf2021-02-25 10:10:08 +010078 rtc_exclude_system_time = build_with_chromium
Johannes Kronda20c732021-02-19 16:39:41 +010079
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070080 # Setting this to false will require the API user to pass in their own
81 # SSLCertificateVerifier to verify the certificates presented from a
82 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
83 rtc_builtin_ssl_root_certificates = true
84
Karl Wibergeb254b42017-11-01 15:08:12 +010085 # Include the iLBC audio codec?
Olga Sharonova5fbd7582020-07-09 09:50:42 +000086 rtc_include_ilbc = true
Karl Wibergeb254b42017-11-01 15:08:12 +010087
mbonadei9aa3f0a2017-01-24 06:58:22 -080088 # Disable this to avoid building the Opus audio codec.
89 rtc_include_opus = true
90
minyue2e03c662017-02-01 17:31:11 -080091 # Enable this if the Opus version upon which WebRTC is built supports direct
92 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020093 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080094
mbonadei9aa3f0a2017-01-24 06:58:22 -080095 # Enable this to let the Opus audio codec change complexity on the fly.
96 rtc_opus_variable_complexity = false
97
mbonadei9aa3f0a2017-01-24 06:58:22 -080098 # Used to specify an external Jsoncpp include path when not compiling the
99 # library that comes with WebRTC (i.e. rtc_build_json == 0).
100 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
101
102 # Used to specify an external OpenSSL include path when not compiling the
103 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
104 rtc_ssl_root = ""
105
mbonadei9aa3f0a2017-01-24 06:58:22 -0800106 # Enable when an external authentication mechanism is used for performing
107 # packet authentication for RTP packets instead of libsrtp.
108 rtc_enable_external_auth = build_with_chromium
109
110 # Selects whether debug dumps for the audio processing module
111 # should be generated.
112 apm_debug_dump = false
113
Per Åhgrencc73ed32020-04-26 23:56:17 +0200114 # Selects whether the audio processing module should be excluded.
115 rtc_exclude_audio_processing_module = false
116
mbonadei9aa3f0a2017-01-24 06:58:22 -0800117 # Set this to true to enable BWE test logging.
118 rtc_enable_bwe_test_logging = false
119
Joachim Bauch93e91342017-12-07 01:25:53 +0100120 # Set this to false to skip building examples.
121 rtc_build_examples = true
122
123 # Set this to false to skip building tools.
124 rtc_build_tools = true
125
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100126 # Set this to false to skip building code that requires X11.
127 rtc_use_x11 = use_x11
128
Tomas Popela318da512018-11-13 06:32:23 +0100129 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 14:37:51 +0100130 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
131 # only when using the sysroot as PipeWire is not available in older and
132 # supported Ubuntu and Debian distributions.
Artem Titov4d6a76d2021-09-03 10:07:20 +0000133 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 14:37:51 +0100134
135 # Set this to link PipeWire directly instead of using the dlopen.
136 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 06:32:23 +0100137
mbonadei9aa3f0a2017-01-24 06:58:22 -0800138 # Enable to use the Mozilla internal settings.
139 build_with_mozilla = false
140
Philipp Hanckee95ebda2020-09-17 16:13:20 +0200141 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
142 # and NDK r16 or above.
henrika883d00f2018-03-16 10:09:49 +0100143 rtc_enable_android_aaudio = false
144
mbonadei9aa3f0a2017-01-24 06:58:22 -0800145 # Set to "func", "block", "edge" for coverage generation.
146 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
147 # It is recommend to set include_examples=0.
148 # Use llvm's sancov -html-report for human readable reports.
149 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
150 rtc_sanitize_coverage = ""
151
Philipp Hanckeaeac9f82020-09-11 11:58:18 +0200152 # Selects fixed-point code where possible.
153 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800154 if (current_cpu == "arm" || current_cpu == "arm64") {
155 rtc_prefer_fixed_point = true
156 }
157
mbonadei9aa3f0a2017-01-24 06:58:22 -0800158 # Determines whether NEON code will be built.
159 rtc_build_with_neon =
160 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
161
162 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
163 # all platforms except Android and iOS. Because FFmpeg can be built
Artem Titov22a6b2d2021-07-27 16:25:56 +0200164 # with/without H.264 support, `ffmpeg_branding` has to separately be set to a
mbonadei9aa3f0a2017-01-24 06:58:22 -0800165 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Artem Titov22a6b2d2021-07-27 16:25:56 +0200166 # H.264, compilation succeeds but `H264DecoderImpl` fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800167 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
168 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100169 #
170 # Enabling H264 when building with MSVC is currently not supported, see
171 # bugs.webrtc.org/9213#c13 for more info.
172 rtc_use_h264 =
173 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800174
Markus Handell8e75bd42020-06-05 11:47:40 +0200175 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
176 rtc_use_absl_mutex = false
177
mbonadei9aa3f0a2017-01-24 06:58:22 -0800178 # By default, use normal platform audio support or dummy audio, but don't
179 # use file-based audio playout and record.
180 rtc_use_dummy_audio_file_devices = false
181
henrika7be78832017-06-13 17:34:16 +0200182 # When set to true, replace the audio output with a sinus tone at 440Hz.
183 # The ADM will ask for audio data from WebRTC but instead of reading real
184 # audio samples from NetEQ, a sinus tone will be generated and replace the
185 # real audio samples.
186 rtc_audio_device_plays_sinus_tone = false
187
Anders Carlsson358f2e02018-06-04 10:24:37 +0200188 if (is_ios) {
189 # Build broadcast extension in AppRTCMobile for iOS. This results in the
190 # binary only running on iOS 11+, which is why it is disabled by default.
191 rtc_apprtcmobile_broadcast_extension = false
192 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200193
Jordan Rose53d3fc92021-07-06 12:16:41 -0700194 # Determines whether OpenGL is available on iOS/macOS.
195 rtc_ios_macos_use_opengl_rendering =
196 !(is_ios && target_environment == "catalyst")
197
Jiawei Ou08745302019-02-12 11:36:13 -0800198 # When set to false, builtin audio encoder/decoder factories and all the
199 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
200 # (they will still be included in libjingle_peerconnection_so.so and
201 # WebRTC.framework)
202 rtc_include_builtin_audio_codecs = true
203
204 # When set to false, builtin video encoder/decoder factories and all the
205 # video codecs they depends on will not be included in libwebrtc.{a|lib}
206 # (they will still be included in libjingle_peerconnection_so.so and
207 # WebRTC.framework)
208 rtc_include_builtin_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100209
210 # When set to true and in a standalone build, it will undefine UNICODE and
211 # _UNICODE (which are always defined globally by the Chromium Windows
212 # toolchain).
213 # This is only needed for testing purposes, WebRTC wants to be sure it
214 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
215 # wide character functions.
216 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 13:47:54 -0700217
218 # When set to true, a capturer implementation that uses the
Austin Orion66241e42021-04-22 13:22:25 -0700219 # Windows.Graphics.Capture APIs will be available for use. This introduces a
220 # dependency on the Win 10 SDK v10.0.17763.0.
Austin Orion78f04d82021-04-23 12:37:26 -0700221 rtc_enable_win_wgc = is_win
Dan Minor9c686132018-01-15 10:20:00 -0500222}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800223
Dan Minor9c686132018-01-15 10:20:00 -0500224if (!build_with_mozilla) {
225 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800226}
227
228# A second declare_args block, so that declarations within it can
229# depend on the possibly overridden variables in the first
230# declare_args block.
231declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500232 # Enables the use of protocol buffers for debug recordings.
233 rtc_enable_protobuf = !build_with_mozilla
234
235 # Set this to disable building with support for SCTP data channels.
236 rtc_enable_sctp = !build_with_mozilla
237
238 # Disable these to not build components which can be externally provided.
239 rtc_build_json = !build_with_mozilla
240 rtc_build_libsrtp = !build_with_mozilla
241 rtc_build_libvpx = !build_with_mozilla
242 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500243 rtc_build_opus = !build_with_mozilla
244 rtc_build_ssl = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500245
246 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200247 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
248 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500249 rtc_enable_libevent = false
250 rtc_build_libevent = false
251 } else {
252 rtc_enable_libevent = true
253 rtc_build_libevent = !build_with_mozilla
254 }
255
mbonadei9aa3f0a2017-01-24 06:58:22 -0800256 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
257 rtc_include_pulse_audio = !build_with_chromium
258
259 # Chromium uses its own IO handling, so the internal ADM is only built for
260 # standalone WebRTC.
261 rtc_include_internal_audio_device = !build_with_chromium
262
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800263 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 12:02:32 +0200264 # TODO: Make sure that AVX2 works also for non-clang compilers.
265 if (is_clang == true) {
266 rtc_enable_avx2 = true
267 } else {
268 rtc_enable_avx2 = false
269 }
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800270
Philipp Hancke1a89bc82021-03-02 21:23:24 +0100271 # Set this to true to build the unit tests.
272 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 10:20:00 -0500273 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200274
275 # Set this to false to skip building code that also requires X11 extensions
276 # such as Xdamage, Xfixes.
277 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100278
279 # Set this to true to fully remove logging from WebRTC.
280 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100281
282 # Set this to true to disable trace events.
283 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100284
285 # Set this to true to disable detailed error message and logging for
286 # RTC_CHECKs.
287 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100288
289 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100290 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200291
292 # Set this to true to exclude the transient suppressor in the audio processing
293 # module from the build.
294 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800295}
296
Florent Castellia80c3e52021-04-15 15:02:56 +0200297declare_args() {
Florent Castellia6983c62021-05-06 10:50:07 +0200298 # Enable the dcsctp backend for DataChannels and related unittests
299 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
300
Florent Castellia80c3e52021-04-15 15:02:56 +0200301 # Enable the usrsctp backend for DataChannels and related unittests
302 rtc_build_usrsctp = !build_with_mozilla && rtc_enable_sctp
303}
304
mbonadei9aa3f0a2017-01-24 06:58:22 -0800305# Make it possible to provide custom locations for some libraries (move these
306# up into declare_args should we need to actually use them for the GN build).
307rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800308rtc_opus_dir = "//third_party/opus"
309
310# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200311rtc_desktop_capture_supported =
312 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900313 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800314
315###############################################################################
316# Templates
317#
318
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200319# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800320# chromium.
321# We need absolute paths for all configs in templates as they are shared in
322# different subdirectories.
323webrtc_root = get_path_info(".", "abspath")
324
325# Global configuration that should be applied to all WebRTC targets.
326# You normally shouldn't need to include this in your target as it's
327# automatically included when using the rtc_* templates.
328# It sets defines, include paths and compilation warnings accordingly,
329# both for WebRTC stand-alone builds and for the scenario when WebRTC
330# native code is built as part of Chromium.
Mirko Bonadei5f078452021-07-30 22:32:55 +0200331rtc_common_configs = [ webrtc_root + ":common_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800332
kthelgasonc0977102017-04-24 00:57:16 -0700333if (is_mac || is_ios) {
334 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
335}
336
mbonadei9aa3f0a2017-01-24 06:58:22 -0800337# Global public configuration that should be applied to all WebRTC targets. You
338# normally shouldn't need to include this in your target as it's automatically
339# included when using the rtc_* templates. It set the defines, include paths and
340# compilation warnings that should be propagated to dependents of the targets
341# depending on the target having this config.
342rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
343
344# Common configs to remove or add in all rtc targets.
345rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100346if (!build_with_chromium && is_clang) {
347 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
348}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800349rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200350rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200351rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800352
353set_defaults("rtc_test") {
354 configs = rtc_add_configs
355 suppressed_configs = []
356}
357
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200358set_defaults("rtc_library") {
359 configs = rtc_add_configs
360 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200361 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200362}
363
mbonadei9aa3f0a2017-01-24 06:58:22 -0800364set_defaults("rtc_source_set") {
365 configs = rtc_add_configs
366 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200367 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800368}
369
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200370set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800371 configs = rtc_add_configs
372 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200373 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800374}
375
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200376set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800377 configs = rtc_add_configs
378 suppressed_configs = []
379}
380
381set_defaults("rtc_shared_library") {
382 configs = rtc_add_configs
383 suppressed_configs = []
384}
385
Per Kjellandera7f2d842018-01-10 15:54:53 +0000386webrtc_default_visibility = [ webrtc_root + "/*" ]
387if (build_with_chromium) {
388 # Allow Chromium's WebRTC overrides targets to bypass the regular
389 # visibility restrictions.
390 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
391}
392
Karl Wibergbb23c832018-04-22 19:55:00 +0200393# ---- Poisons ----
394#
395# The general idea is that some targets declare that they contain some
396# kind of poison, which makes it impossible for other targets to
397# depend on them (even transitively) unless they declare themselves
398# immune to that particular type of poison.
399#
400# Targets that *contain* poison of type foo should contain the line
401#
402# poisonous = [ "foo" ]
403#
404# and targets that *are immune but arent't themselves poisonous*
405# should contain
406#
407# allow_poison = [ "foo" ]
408#
409# This useful in cases where we have some large target or set of
410# targets and want to ensure that most other targets do not
411# transitively depend on them. For example, almost no high-level
412# target should depend on the audio codecs, since we want WebRTC users
413# to be able to inject any subset of them and actually end up with a
414# binary that doesn't include the codecs they didn't inject.
415#
416# Test-only targets (`testonly` set to true) and non-public targets
417# (`visibility` not containing "*") are automatically immune to all
418# types of poison.
419#
420# Here's the complete list of all types of poison. It must be kept in
421# 1:1 correspondence with the set of //:poison_* targets.
422#
423all_poison_types = [
424 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
425 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200426
Danil Chapovalov41300af2019-07-10 12:44:43 +0200427 # Default task queue implementation.
428 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200429
430 # JSON parsing should not be needed in the "slim and modular" WebRTC.
431 "rtc_json",
432
433 # Software video codecs (VP8 and VP9 through libvpx).
434 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200435]
436
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000437absl_include_config = "//third_party/abseil-cpp:absl_include_config"
438absl_define_config = "//third_party/abseil-cpp:absl_define_config"
439
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200440# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
441# that are testonly.
442absl_flags_config = webrtc_root + ":absl_flags_configs"
443
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100444# WebRTC wrapper of Chromium's test() template. This template just adds some
445# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
446# target.
447# The parameter `is_xctest` is different from the one in the Chromium's test()
448# template (and it is not forwarded to it). In rtc_test(), the argument
449# `is_xctest` is used to avoid to take dependencies that are not needed
450# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800451template("rtc_test") {
452 test(target_name) {
453 forward_variables_from(invoker,
454 "*",
455 [
456 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100457 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800458 "public_configs",
459 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200460 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800461 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100462
463 # Always override to public because when target_os is Android the `test`
464 # template can override it to [ "*" ] and we want to avoid conditional
465 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100466 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800467 configs += invoker.configs
468 configs -= rtc_remove_configs
469 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000470 public_configs = [
471 rtc_common_inherited_config,
472 absl_include_config,
473 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200474 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000475 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800476 if (defined(invoker.public_configs)) {
477 public_configs += invoker.public_configs
478 }
sakald7fdb802017-05-26 01:51:53 -0700479 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800480 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 18:53:11 -0400481 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200482 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200483 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 19:03:37 +0200484 deps += [
485 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
486 webrtc_root + "test:native_test_java",
487 ]
sakald7fdb802017-05-26 01:51:53 -0700488 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100489
490 # When not targeting a simulator, building //base/test:google_test_runner
491 # fails, so it is added only when the test is not a real XCTest and when
492 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100493 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100494 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
495 xctest_module_target = "//base/test:google_test_runner"
496 }
497 }
Andrey Logvin78646002021-01-29 10:50:19 +0000498
499 # If absl_deps is [], no action is needed. If not [], then it needs to be
500 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
501 # otherwise it just needs to be added to deps.
502 if (defined(absl_deps) && absl_deps != []) {
503 if (!defined(deps)) {
504 deps = []
505 }
506 if (build_with_chromium) {
507 deps += [ "//third_party/abseil-cpp:absl" ]
508 } else {
509 deps += absl_deps
510 }
511 }
512
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100513 if (using_sanitizer) {
514 if (is_linux) {
515 if (!defined(invoker.data)) {
516 data = []
517 }
518 data +=
519 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
520 }
521 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800522 }
523}
524
525template("rtc_source_set") {
526 source_set(target_name) {
527 forward_variables_from(invoker,
528 "*",
529 [
530 "configs",
531 "public_configs",
532 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200533 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800534 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200535 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000536 if (!defined(visibility)) {
537 visibility = webrtc_default_visibility
538 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200539
540 # What's your poison?
541 if (defined(testonly) && testonly) {
542 assert(!defined(poisonous))
543 assert(!defined(allow_poison))
544 } else {
545 if (!defined(poisonous)) {
546 poisonous = []
547 }
548 if (!defined(allow_poison)) {
549 allow_poison = []
550 }
551 if (!defined(assert_no_deps)) {
552 assert_no_deps = []
553 }
554 if (!defined(deps)) {
555 deps = []
556 }
557 foreach(p, poisonous) {
558 deps += [ webrtc_root + ":poison_" + p ]
559 }
560 foreach(poison_type, all_poison_types) {
561 allow_dep = true
562 foreach(v, visibility) {
563 if (v == "*") {
564 allow_dep = false
565 }
566 }
567 foreach(p, allow_poison + poisonous) {
568 if (p == poison_type) {
569 allow_dep = true
570 }
571 }
572 if (!allow_dep) {
573 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
574 }
575 }
576 }
577
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100578 # Chromium should only depend on the WebRTC component in order to
579 # avoid to statically link WebRTC in a component build.
580 if (build_with_chromium) {
581 publicly_visible = false
582 foreach(v, visibility) {
583 if (v == "*") {
584 publicly_visible = true
585 }
586 }
587 if (publicly_visible) {
588 visibility = []
589 visibility = webrtc_default_visibility
590 }
591 }
592
Mirko Bonadei96ede162018-09-06 13:45:44 +0200593 if (!defined(testonly) || !testonly) {
594 configs += rtc_prod_configs
595 }
596
mbonadei9aa3f0a2017-01-24 06:58:22 -0800597 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200598 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800599 configs -= rtc_remove_configs
600 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000601 public_configs = [
602 rtc_common_inherited_config,
603 absl_include_config,
604 absl_define_config,
605 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200606 if (defined(testonly) && testonly) {
607 public_configs += [ absl_flags_config ]
608 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800609 if (defined(invoker.public_configs)) {
610 public_configs += invoker.public_configs
611 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200612
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200613 # If absl_deps is [], no action is needed. If not [], then it needs to be
614 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200615 # otherwise it just needs to be added to deps.
616 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200617 if (!defined(deps)) {
618 deps = []
619 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200620 if (build_with_chromium) {
621 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200622 } else {
623 deps += absl_deps
624 }
625 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800626 }
627}
628
mbonadei9aa3f0a2017-01-24 06:58:22 -0800629template("rtc_static_library") {
630 static_library(target_name) {
631 forward_variables_from(invoker,
632 "*",
633 [
634 "configs",
635 "public_configs",
636 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200637 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800638 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200639 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000640 if (!defined(visibility)) {
641 visibility = webrtc_default_visibility
642 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200643
644 # What's your poison?
645 if (defined(testonly) && testonly) {
646 assert(!defined(poisonous))
647 assert(!defined(allow_poison))
648 } else {
649 if (!defined(poisonous)) {
650 poisonous = []
651 }
652 if (!defined(allow_poison)) {
653 allow_poison = []
654 }
655 if (!defined(assert_no_deps)) {
656 assert_no_deps = []
657 }
658 if (!defined(deps)) {
659 deps = []
660 }
661 foreach(p, poisonous) {
662 deps += [ webrtc_root + ":poison_" + p ]
663 }
664 foreach(poison_type, all_poison_types) {
665 allow_dep = true
666 foreach(v, visibility) {
667 if (v == "*") {
668 allow_dep = false
669 }
670 }
671 foreach(p, allow_poison + poisonous) {
672 if (p == poison_type) {
673 allow_dep = true
674 }
675 }
676 if (!allow_dep) {
677 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
678 }
679 }
680 }
681
Mirko Bonadei96ede162018-09-06 13:45:44 +0200682 if (!defined(testonly) || !testonly) {
683 configs += rtc_prod_configs
684 }
685
mbonadei9aa3f0a2017-01-24 06:58:22 -0800686 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200687 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800688 configs -= rtc_remove_configs
689 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000690 public_configs = [
691 rtc_common_inherited_config,
692 absl_include_config,
693 absl_define_config,
694 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200695 if (defined(testonly) && testonly) {
696 public_configs += [ absl_flags_config ]
697 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800698 if (defined(invoker.public_configs)) {
699 public_configs += invoker.public_configs
700 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200701
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200702 # If absl_deps is [], no action is needed. If not [], then it needs to be
703 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200704 # otherwise it just needs to be added to deps.
705 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200706 if (!defined(deps)) {
707 deps = []
708 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200709 if (build_with_chromium) {
710 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200711 } else {
712 deps += absl_deps
713 }
714 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800715 }
716}
717
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200718# This template automatically switches the target type between source_set
719# and static_library.
720#
721# This should be the default target type for all the WebRTC targets with
722# one exception. Do not use this template for header only targets, in that case
723# rtc_source_set must be used in order to avoid build errors (e.g. libtool
724# complains if the output .a file is empty).
725#
726# How does it work:
727# Since all files in a source_set are linked into a final binary, while files
728# in a static library are only linked in if at least one symbol in them is
729# referenced, in component builds source_sets are easy to deal with because
730# all their object files are passed to the linker to create a shared library.
731# In release builds instead, static_libraries are preferred since they allow
732# the linker to discard dead code.
733# For the same reason, testonly targets will always be expanded to
734# source_set in order to be sure that tests are present in the test binary.
735template("rtc_library") {
736 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
737 target_type = "source_set"
738 } else {
739 target_type = "static_library"
740 }
741 target(target_type, target_name) {
742 forward_variables_from(invoker,
743 "*",
744 [
745 "configs",
746 "public_configs",
747 "suppressed_configs",
748 "visibility",
749 ])
750 forward_variables_from(invoker, [ "visibility" ])
751 if (!defined(visibility)) {
752 visibility = webrtc_default_visibility
753 }
754
755 # What's your poison?
756 if (defined(testonly) && testonly) {
757 assert(!defined(poisonous))
758 assert(!defined(allow_poison))
759 } else {
760 if (!defined(poisonous)) {
761 poisonous = []
762 }
763 if (!defined(allow_poison)) {
764 allow_poison = []
765 }
766 if (!defined(assert_no_deps)) {
767 assert_no_deps = []
768 }
769 if (!defined(deps)) {
770 deps = []
771 }
772 foreach(p, poisonous) {
773 deps += [ webrtc_root + ":poison_" + p ]
774 }
775 foreach(poison_type, all_poison_types) {
776 allow_dep = true
777 foreach(v, visibility) {
778 if (v == "*") {
779 allow_dep = false
780 }
781 }
782 foreach(p, allow_poison + poisonous) {
783 if (p == poison_type) {
784 allow_dep = true
785 }
786 }
787 if (!allow_dep) {
788 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
789 }
790 }
791 }
792
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100793 # Chromium should only depend on the WebRTC component in order to
794 # avoid to statically link WebRTC in a component build.
795 if (build_with_chromium) {
796 publicly_visible = false
797 foreach(v, visibility) {
798 if (v == "*") {
799 publicly_visible = true
800 }
801 }
802 if (publicly_visible) {
803 visibility = []
804 visibility = webrtc_default_visibility
805 }
806 }
807
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200808 if (!defined(testonly) || !testonly) {
809 configs += rtc_prod_configs
810 }
811
812 configs += invoker.configs
813 configs += rtc_library_impl_config
814 configs -= rtc_remove_configs
815 configs -= invoker.suppressed_configs
816 public_configs = [
817 rtc_common_inherited_config,
818 absl_include_config,
819 absl_define_config,
820 ]
821 if (defined(testonly) && testonly) {
822 public_configs += [ absl_flags_config ]
823 }
824 if (defined(invoker.public_configs)) {
825 public_configs += invoker.public_configs
826 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200827
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200828 # If absl_deps is [], no action is needed. If not [], then it needs to be
829 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200830 # otherwise it just needs to be added to deps.
831 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200832 if (!defined(deps)) {
833 deps = []
834 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200835 if (build_with_chromium) {
836 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200837 } else {
838 deps += absl_deps
839 }
840 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200841 }
842}
843
844template("rtc_executable") {
845 executable(target_name) {
846 forward_variables_from(invoker,
847 "*",
848 [
849 "deps",
850 "configs",
851 "public_configs",
852 "suppressed_configs",
853 "visibility",
854 ])
855 forward_variables_from(invoker, [ "visibility" ])
856 if (!defined(visibility)) {
857 visibility = webrtc_default_visibility
858 }
859 configs += invoker.configs
860 configs -= rtc_remove_configs
861 configs -= invoker.suppressed_configs
862 deps = invoker.deps
863
864 public_configs = [
865 rtc_common_inherited_config,
866 absl_include_config,
867 absl_define_config,
868 ]
869 if (defined(testonly) && testonly) {
870 public_configs += [ absl_flags_config ]
871 }
872 if (defined(invoker.public_configs)) {
873 public_configs += invoker.public_configs
874 }
875 if (is_win) {
876 deps += [
877 # Give executables the default manifest on Windows (a no-op elsewhere).
878 "//build/win:default_exe_manifest",
879 ]
880 }
881 }
882}
883
mbonadei9aa3f0a2017-01-24 06:58:22 -0800884template("rtc_shared_library") {
885 shared_library(target_name) {
886 forward_variables_from(invoker,
887 "*",
888 [
889 "configs",
890 "public_configs",
891 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200892 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800893 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200894 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000895 if (!defined(visibility)) {
896 visibility = webrtc_default_visibility
897 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200898
899 # What's your poison?
900 if (defined(testonly) && testonly) {
901 assert(!defined(poisonous))
902 assert(!defined(allow_poison))
903 } else {
904 if (!defined(poisonous)) {
905 poisonous = []
906 }
907 if (!defined(allow_poison)) {
908 allow_poison = []
909 }
910 if (!defined(assert_no_deps)) {
911 assert_no_deps = []
912 }
913 if (!defined(deps)) {
914 deps = []
915 }
916 foreach(p, poisonous) {
917 deps += [ webrtc_root + ":poison_" + p ]
918 }
919 foreach(poison_type, all_poison_types) {
920 allow_dep = true
921 foreach(v, visibility) {
922 if (v == "*") {
923 allow_dep = false
924 }
925 }
926 foreach(p, allow_poison + poisonous) {
927 if (p == poison_type) {
928 allow_dep = true
929 }
930 }
931 if (!allow_dep) {
932 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
933 }
934 }
935 }
936
mbonadei9aa3f0a2017-01-24 06:58:22 -0800937 configs += invoker.configs
938 configs -= rtc_remove_configs
939 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000940 public_configs = [
941 rtc_common_inherited_config,
942 absl_include_config,
943 absl_define_config,
944 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200945 if (defined(testonly) && testonly) {
946 public_configs += [ absl_flags_config ]
947 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800948 if (defined(invoker.public_configs)) {
949 public_configs += invoker.public_configs
950 }
951 }
952}
kthelgason4065a572017-02-14 04:58:56 -0800953
954if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400955 # TODO: Generate module.modulemap file to enable use in Swift
956 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100957 template("ios_framework_bundle_with_umbrella_header") {
958 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900959 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100960 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900961 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
962
963 action_foreach("create_bracket_include_headers_$target_name") {
964 script = "//tools_webrtc/apple/copy_framework_header.py"
965 sources = invoker.sources
966 output_name = invoker.output_name
967 outputs = [
968 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
969 ]
970 args = [
971 "--input",
972 "{{source}}",
973 "--output",
974 rebase_path(target_gen_dir, root_build_dir) +
975 "/$output_name.framework/WebRTC/{{source_file_part}}",
976 ]
977 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100978
979 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900980 forward_variables_from(invoker, "*", [ "public_headers" ])
981 public_headers = get_target_outputs(
982 ":create_bracket_include_headers_$this_target_name")
983 deps += [
984 ":copy_umbrella_header_$target_name",
985 ":create_bracket_include_headers_$target_name",
986 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100987 }
988
989 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900990 public_headers = get_target_outputs(
991 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100992
993 script = "//tools_webrtc/ios/generate_umbrella_header.py"
994
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100995 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100996 args = [
997 "--out",
998 rebase_path(umbrella_header_path, root_build_dir),
999 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +02001000 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001001 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001002 }
1003
Jordan Rose53d3fc92021-07-06 12:16:41 -07001004 if (target_environment == "catalyst") {
1005 # Catalyst frameworks use the same layout as regular Mac frameworks.
1006 headers_dir = "Versions/A/Headers"
1007 } else {
1008 headers_dir = "Headers"
1009 }
Anders Carlssondc6b4772018-01-15 13:31:03 +01001010 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001011 sources = [ umbrella_header_path ]
1012 outputs =
Jordan Rose53d3fc92021-07-06 12:16:41 -07001013 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001014
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001015 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001016 }
1017 }
1018
1019 set_defaults("ios_framework_bundle_with_umbrella_header") {
1020 configs = default_shared_library_configs
1021 }
kthelgason4065a572017-02-14 04:58:56 -08001022}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001023
Anders Carlsson37bbf792018-09-05 16:29:27 +02001024if (is_mac) {
1025 template("mac_framework_bundle_with_umbrella_header") {
1026 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001027 this_target_name = target_name
1028 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001029 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +02001030
1031 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -08001032 forward_variables_from(invoker, "*", [ "configs" ])
1033 if (defined(invoker.configs)) {
1034 configs += invoker.configs
1035 }
Anders Carlsson37bbf792018-09-05 16:29:27 +02001036
1037 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001038 framework_contents = [
1039 "Headers",
1040 "Modules",
1041 "Resources",
1042 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001043
1044 ldflags = [
1045 "-all_load",
1046 "-install_name",
1047 "@rpath/$output_name.framework/$output_name",
1048 ]
1049
1050 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001051 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001052 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001053 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001054 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001055 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001056 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001057 ]
1058 }
1059
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001060 action_foreach("create_bracket_include_headers_$this_target_name") {
1061 script = "//tools_webrtc/apple/copy_framework_header.py"
1062 sources = invoker.sources
1063 output_name = invoker.output_name
1064 outputs = [
1065 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1066 ]
1067 args = [
1068 "--input",
1069 "{{source}}",
1070 "--output",
1071 rebase_path(target_gen_dir, root_build_dir) +
1072 "/$output_name.framework/WebRTC/{{source_file_part}}",
1073 ]
1074 }
1075
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001076 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001077 sources = get_target_outputs(
1078 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001079
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001080 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001081 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001082 }
1083
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001084 action("modulemap_$this_target_name") {
1085 script = "//tools_webrtc/ios/generate_modulemap.py"
1086 args = [
1087 "--out",
1088 rebase_path(modulemap_path, root_build_dir),
1089 "--name",
1090 output_name,
1091 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001092 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001093 }
1094
1095 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001096 sources = [ modulemap_path ]
1097 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1098 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001099 }
1100
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001101 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001102 sources = get_target_outputs(
1103 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001104
1105 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1106
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001107 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001108 args = [
1109 "--out",
1110 rebase_path(umbrella_header_path, root_build_dir),
1111 "--sources",
1112 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001113 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001114 }
1115
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001116 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001117 sources = [ umbrella_header_path ]
1118 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001119
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001120 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001121 }
1122 }
1123}
1124
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001125if (is_android) {
1126 template("rtc_android_library") {
1127 android_library(target_name) {
1128 forward_variables_from(invoker,
1129 "*",
1130 [
1131 "configs",
1132 "public_configs",
1133 "suppressed_configs",
1134 "visibility",
1135 ])
1136
Oleh Prypin05aee742018-11-23 17:29:44 +01001137 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001138
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001139 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001140 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001141
1142 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001143 if (defined(invoker.errorprone_args)) {
1144 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001145 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001146
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001147 if (!defined(deps)) {
1148 deps = []
1149 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001150
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001151 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001152 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001153 }
1154 }
1155
1156 template("rtc_android_apk") {
1157 android_apk(target_name) {
1158 forward_variables_from(invoker,
1159 "*",
1160 [
1161 "configs",
1162 "public_configs",
1163 "suppressed_configs",
1164 "visibility",
1165 ])
1166
1167 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001168 errorprone_args = []
1169 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001170
1171 if (!defined(deps)) {
1172 deps = []
1173 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001174
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001175 no_build_hooks = true
1176 }
1177 }
1178
1179 template("rtc_instrumentation_test_apk") {
1180 instrumentation_test_apk(target_name) {
1181 forward_variables_from(invoker,
1182 "*",
1183 [
1184 "configs",
1185 "public_configs",
1186 "suppressed_configs",
1187 "visibility",
1188 ])
1189
1190 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001191 errorprone_args = []
1192 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001193
1194 if (!defined(deps)) {
1195 deps = []
1196 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001197
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001198 no_build_hooks = true
1199 }
1200 }
1201}