blob: a63f1dd70b883f213f4d470c0b78d82888fc78f9 [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")
Mirko Bonadei8c185fc2021-07-21 13:12:38 +02009import("//build/config/dcheck_always_on.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080010import("//build/config/features.gni")
11import("//build/config/mips.gni")
12import("//build/config/sanitizers/sanitizers.gni")
Tomas Popela318da512018-11-13 06:32:23 +010013import("//build/config/sysroot.gni")
ehmaldonado0d729b32017-02-10 01:38:23 -080014import("//build/config/ui.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -080015import("//build_overrides/build.gni")
mbonadei96606272017-03-03 19:41:59 -080016
17if (!build_with_chromium && is_component_build) {
18 print("The Gn argument `is_component_build` is currently " +
19 "ignored for WebRTC builds.")
20 print("Component builds are supported by Chromium and the argument " +
21 "`is_component_build` makes it possible to create shared libraries " +
22 "instead of static libraries.")
23 print("If an app depends on WebRTC it makes sense to just depend on the " +
24 "WebRTC static library, so there is no difference between " +
25 "`is_component_build=true` and `is_component_build=false`.")
26 print(
Fanny Linderborg0d2dc1f2021-07-14 14:02:11 +000027 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/main/docs/component_build.md")
mbonadei96606272017-03-03 19:41:59 -080028 assert(!is_component_build, "Component builds are not supported in WebRTC.")
29}
30
kthelgason4065a572017-02-14 04:58:56 -080031if (is_ios) {
32 import("//build/config/ios/rules.gni")
33}
mbonadei9aa3f0a2017-01-24 06:58:22 -080034
Anders Carlsson37bbf792018-09-05 16:29:27 +020035if (is_mac) {
36 import("//build/config/mac/rules.gni")
37}
38
mbonadei9aa3f0a2017-01-24 06:58:22 -080039declare_args() {
Mirko Bonadei8c185fc2021-07-21 13:12:38 +020040 # Separate control for dchecks in WebRTC. Defaults to Chromium's behavior if
41 # built with Chromium.
42 # When set to true, it will enable RTC_DCHECK() also in Release builds.
43 rtc_dcheck_always_on = build_with_chromium && dcheck_always_on
44
Mirko Bonadei028248c2018-10-10 12:19:02 +020045 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
46 # expand to code that will manage symbols visibility.
47 rtc_enable_symbol_export = false
48
Mirko Bonadei31b0b452018-08-22 10:37:11 +020049 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
Mirko Bonadei70400902018-08-21 15:44:28 +020050 # will tell the pre-processor to remove the default definition of symbols
51 # needed to use field_trial. In that case a new implementation needs to be
52 # provided.
Mirko Bonadei31b0b452018-08-22 10:37:11 +020053 if (build_with_chromium) {
54 # When WebRTC is built as part of Chromium it should exclude the default
55 # implementation of field_trial unless it is building for NACL or
56 # Chromecast.
57 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast
58 } else {
59 rtc_exclude_field_trial_default = false
60 }
Mirko Bonadei70400902018-08-21 15:44:28 +020061
Mirko Bonadei906add42018-09-05 16:03:16 +020062 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
63 # will tell the pre-processor to remove the default definition of symbols
64 # needed to use metrics. In that case a new implementation needs to be
65 # provided.
66 rtc_exclude_metrics_default = build_with_chromium
67
Johannes Kronda20c732021-02-19 16:39:41 +010068 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which
69 # will tell the pre-processor to remove the default definition of the
70 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
71 # that case a new implementation needs to be provided.
Johannes Kronbb52bdf2021-02-25 10:10:08 +010072 rtc_exclude_system_time = build_with_chromium
Johannes Kronda20c732021-02-19 16:39:41 +010073
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070074 # Setting this to false will require the API user to pass in their own
75 # SSLCertificateVerifier to verify the certificates presented from a
76 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
77 rtc_builtin_ssl_root_certificates = true
78
Karl Wibergeb254b42017-11-01 15:08:12 +010079 # Include the iLBC audio codec?
Olga Sharonova5fbd7582020-07-09 09:50:42 +000080 rtc_include_ilbc = true
Karl Wibergeb254b42017-11-01 15:08:12 +010081
mbonadei9aa3f0a2017-01-24 06:58:22 -080082 # Disable this to avoid building the Opus audio codec.
83 rtc_include_opus = true
84
minyue2e03c662017-02-01 17:31:11 -080085 # Enable this if the Opus version upon which WebRTC is built supports direct
86 # encoding of 120 ms packets.
minyue-webrtc516711c2017-07-27 17:45:49 +020087 rtc_opus_support_120ms_ptime = true
minyue2e03c662017-02-01 17:31:11 -080088
mbonadei9aa3f0a2017-01-24 06:58:22 -080089 # Enable this to let the Opus audio codec change complexity on the fly.
90 rtc_opus_variable_complexity = false
91
mbonadei9aa3f0a2017-01-24 06:58:22 -080092 # Used to specify an external Jsoncpp include path when not compiling the
93 # library that comes with WebRTC (i.e. rtc_build_json == 0).
94 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
95
96 # Used to specify an external OpenSSL include path when not compiling the
97 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
98 rtc_ssl_root = ""
99
mbonadei9aa3f0a2017-01-24 06:58:22 -0800100 # Enable when an external authentication mechanism is used for performing
101 # packet authentication for RTP packets instead of libsrtp.
102 rtc_enable_external_auth = build_with_chromium
103
104 # Selects whether debug dumps for the audio processing module
105 # should be generated.
106 apm_debug_dump = false
107
Per Åhgrencc73ed32020-04-26 23:56:17 +0200108 # Selects whether the audio processing module should be excluded.
109 rtc_exclude_audio_processing_module = false
110
mbonadei9aa3f0a2017-01-24 06:58:22 -0800111 # Set this to true to enable BWE test logging.
112 rtc_enable_bwe_test_logging = false
113
Joachim Bauch93e91342017-12-07 01:25:53 +0100114 # Set this to false to skip building examples.
115 rtc_build_examples = true
116
117 # Set this to false to skip building tools.
118 rtc_build_tools = true
119
Joachim Bauch75f18fc2017-12-20 21:25:47 +0100120 # Set this to false to skip building code that requires X11.
121 rtc_use_x11 = use_x11
122
Tomas Popela318da512018-11-13 06:32:23 +0100123 # Set this to use PipeWire on the Wayland display server.
Tomas Popela762543f2018-12-12 14:37:51 +0100124 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
125 # only when using the sysroot as PipeWire is not available in older and
126 # supported Ubuntu and Debian distributions.
Xiaohan Wang9f32f3b2020-10-01 14:46:54 -0700127 rtc_use_pipewire = is_linux && use_sysroot
Tomas Popela762543f2018-12-12 14:37:51 +0100128
129 # Set this to link PipeWire directly instead of using the dlopen.
130 rtc_link_pipewire = false
Tomas Popela318da512018-11-13 06:32:23 +0100131
Jan Grulichc3c81292020-12-02 09:03:34 +0100132 # Set this to use certain PipeWire version
Jan Grulich14b036d2021-02-04 09:53:20 +0100133 # Currently WebRTC supports PipeWire 0.2 and PipeWire 0.3 (default)
134 rtc_pipewire_version = "0.3"
Jan Grulichc3c81292020-12-02 09:03:34 +0100135
mbonadei9aa3f0a2017-01-24 06:58:22 -0800136 # Enable to use the Mozilla internal settings.
137 build_with_mozilla = false
138
Philipp Hanckee95ebda2020-09-17 16:13:20 +0200139 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
140 # and NDK r16 or above.
henrika883d00f2018-03-16 10:09:49 +0100141 rtc_enable_android_aaudio = false
142
mbonadei9aa3f0a2017-01-24 06:58:22 -0800143 # Set to "func", "block", "edge" for coverage generation.
144 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
145 # It is recommend to set include_examples=0.
146 # Use llvm's sancov -html-report for human readable reports.
147 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
148 rtc_sanitize_coverage = ""
149
Philipp Hanckeaeac9f82020-09-11 11:58:18 +0200150 # Selects fixed-point code where possible.
151 rtc_prefer_fixed_point = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800152 if (current_cpu == "arm" || current_cpu == "arm64") {
153 rtc_prefer_fixed_point = true
154 }
155
mbonadei9aa3f0a2017-01-24 06:58:22 -0800156 # Determines whether NEON code will be built.
157 rtc_build_with_neon =
158 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
159
160 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
161 # all platforms except Android and iOS. Because FFmpeg can be built
Artem Titov22a6b2d2021-07-27 16:25:56 +0200162 # with/without H.264 support, `ffmpeg_branding` has to separately be set to a
mbonadei9aa3f0a2017-01-24 06:58:22 -0800163 # value that includes H.264, for example "Chrome". If FFmpeg is built without
Artem Titov22a6b2d2021-07-27 16:25:56 +0200164 # H.264, compilation succeeds but `H264DecoderImpl` fails to initialize.
mbonadei9aa3f0a2017-01-24 06:58:22 -0800165 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
166 # http://www.openh264.org, https://www.ffmpeg.org/
Mirko Bonadeiee0a85c2019-01-15 10:47:18 +0100167 #
168 # Enabling H264 when building with MSVC is currently not supported, see
169 # bugs.webrtc.org/9213#c13 for more info.
170 rtc_use_h264 =
171 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
mbonadei9aa3f0a2017-01-24 06:58:22 -0800172
Markus Handell8e75bd42020-06-05 11:47:40 +0200173 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
174 rtc_use_absl_mutex = false
175
mbonadei9aa3f0a2017-01-24 06:58:22 -0800176 # By default, use normal platform audio support or dummy audio, but don't
177 # use file-based audio playout and record.
178 rtc_use_dummy_audio_file_devices = false
179
henrika7be78832017-06-13 17:34:16 +0200180 # When set to true, replace the audio output with a sinus tone at 440Hz.
181 # The ADM will ask for audio data from WebRTC but instead of reading real
182 # audio samples from NetEQ, a sinus tone will be generated and replace the
183 # real audio samples.
184 rtc_audio_device_plays_sinus_tone = false
185
Anders Carlsson358f2e02018-06-04 10:24:37 +0200186 if (is_ios) {
187 # Build broadcast extension in AppRTCMobile for iOS. This results in the
188 # binary only running on iOS 11+, which is why it is disabled by default.
189 rtc_apprtcmobile_broadcast_extension = false
190 }
Anders Carlsson7bca8ca2018-08-30 09:30:29 +0200191
Jordan Rose53d3fc92021-07-06 12:16:41 -0700192 # Determines whether OpenGL is available on iOS/macOS.
193 rtc_ios_macos_use_opengl_rendering =
194 !(is_ios && target_environment == "catalyst")
195
Jiawei Ou08745302019-02-12 11:36:13 -0800196 # When set to false, builtin audio encoder/decoder factories and all the
197 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
198 # (they will still be included in libjingle_peerconnection_so.so and
199 # WebRTC.framework)
200 rtc_include_builtin_audio_codecs = true
201
202 # When set to false, builtin video encoder/decoder factories and all the
203 # video codecs they depends on will not be included in libwebrtc.{a|lib}
204 # (they will still be included in libjingle_peerconnection_so.so and
205 # WebRTC.framework)
206 rtc_include_builtin_video_codecs = true
Mirko Bonadei20574f42019-03-28 07:50:07 +0100207
208 # When set to true and in a standalone build, it will undefine UNICODE and
209 # _UNICODE (which are always defined globally by the Chromium Windows
210 # toolchain).
211 # This is only needed for testing purposes, WebRTC wants to be sure it
212 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
213 # wide character functions.
214 rtc_win_undef_unicode = false
Austin Orion25b0dee2020-10-01 13:47:54 -0700215
216 # When set to true, a capturer implementation that uses the
Austin Orion66241e42021-04-22 13:22:25 -0700217 # Windows.Graphics.Capture APIs will be available for use. This introduces a
218 # dependency on the Win 10 SDK v10.0.17763.0.
Austin Orion78f04d82021-04-23 12:37:26 -0700219 rtc_enable_win_wgc = is_win
Dan Minor9c686132018-01-15 10:20:00 -0500220}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800221
Dan Minor9c686132018-01-15 10:20:00 -0500222if (!build_with_mozilla) {
223 import("//testing/test.gni")
mbonadei9aa3f0a2017-01-24 06:58:22 -0800224}
225
226# A second declare_args block, so that declarations within it can
227# depend on the possibly overridden variables in the first
228# declare_args block.
229declare_args() {
Dan Minor9c686132018-01-15 10:20:00 -0500230 # Enables the use of protocol buffers for debug recordings.
231 rtc_enable_protobuf = !build_with_mozilla
232
233 # Set this to disable building with support for SCTP data channels.
234 rtc_enable_sctp = !build_with_mozilla
235
236 # Disable these to not build components which can be externally provided.
237 rtc_build_json = !build_with_mozilla
238 rtc_build_libsrtp = !build_with_mozilla
239 rtc_build_libvpx = !build_with_mozilla
240 rtc_libvpx_build_vp9 = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500241 rtc_build_opus = !build_with_mozilla
242 rtc_build_ssl = !build_with_mozilla
Dan Minor9c686132018-01-15 10:20:00 -0500243
244 # Enable libevent task queues on platforms that support it.
Mirko Bonadei775c02e2019-06-19 19:05:00 +0200245 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
246 target_cpu == "wasm") {
Dan Minor9c686132018-01-15 10:20:00 -0500247 rtc_enable_libevent = false
248 rtc_build_libevent = false
249 } else {
250 rtc_enable_libevent = true
251 rtc_build_libevent = !build_with_mozilla
252 }
253
mbonadei9aa3f0a2017-01-24 06:58:22 -0800254 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
255 rtc_include_pulse_audio = !build_with_chromium
256
257 # Chromium uses its own IO handling, so the internal ADM is only built for
258 # standalone WebRTC.
259 rtc_include_internal_audio_device = !build_with_chromium
260
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800261 # Set this to true to enable the avx2 support in webrtc.
Per Åhgrena43178c2020-09-25 12:02:32 +0200262 # TODO: Make sure that AVX2 works also for non-clang compilers.
263 if (is_clang == true) {
264 rtc_enable_avx2 = true
265 } else {
266 rtc_enable_avx2 = false
267 }
Zhaoliang Ma72e43212020-08-17 17:13:41 +0800268
Philipp Hancke1a89bc82021-03-02 21:23:24 +0100269 # Set this to true to build the unit tests.
270 # Disabled when building with Chromium or Mozilla.
Dan Minor9c686132018-01-15 10:20:00 -0500271 rtc_include_tests = !build_with_chromium && !build_with_mozilla
Oleh Prypin240b8932019-06-07 13:27:07 +0200272
273 # Set this to false to skip building code that also requires X11 extensions
274 # such as Xdamage, Xfixes.
275 rtc_use_x11_extensions = rtc_use_x11
Artem Titov6a4a1462019-11-26 16:24:46 +0100276
277 # Set this to true to fully remove logging from WebRTC.
278 rtc_disable_logging = false
Doudou Kisabaka2dec4962019-11-28 14:24:31 +0100279
280 # Set this to true to disable trace events.
281 rtc_disable_trace_events = false
Artem Titov9dc209a2019-11-28 17:09:30 +0100282
283 # Set this to true to disable detailed error message and logging for
284 # RTC_CHECKs.
285 rtc_disable_check_msg = false
Ying Wangef3998f2019-12-09 13:06:53 +0100286
287 # Set this to true to disable webrtc metrics.
Mirko Bonadei3c4fda22019-12-10 15:02:53 +0100288 rtc_disable_metrics = false
sazaaa42ecd2020-04-01 15:24:40 +0200289
290 # Set this to true to exclude the transient suppressor in the audio processing
291 # module from the build.
292 rtc_exclude_transient_suppressor = false
mbonadei9aa3f0a2017-01-24 06:58:22 -0800293}
294
Florent Castellia80c3e52021-04-15 15:02:56 +0200295declare_args() {
Florent Castellia6983c62021-05-06 10:50:07 +0200296 # Enable the dcsctp backend for DataChannels and related unittests
297 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
298
Florent Castellia80c3e52021-04-15 15:02:56 +0200299 # Enable the usrsctp backend for DataChannels and related unittests
300 rtc_build_usrsctp = !build_with_mozilla && rtc_enable_sctp
301}
302
mbonadei9aa3f0a2017-01-24 06:58:22 -0800303# Make it possible to provide custom locations for some libraries (move these
304# up into declare_args should we need to actually use them for the GN build).
305rtc_libvpx_dir = "//third_party/libvpx"
mbonadei9aa3f0a2017-01-24 06:58:22 -0800306rtc_opus_dir = "//third_party/opus"
307
308# Desktop capturer is supported only on Windows, OSX and Linux.
Oleh Prypin240b8932019-06-07 13:27:07 +0200309rtc_desktop_capture_supported =
310 (is_win && current_os != "winuwp") || is_mac ||
Hidehiko Abef264e702020-09-10 18:10:11 +0900311 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
mbonadei9aa3f0a2017-01-24 06:58:22 -0800312
313###############################################################################
314# Templates
315#
316
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200317# Points to // in webrtc stand-alone or to //third_party/webrtc/ in
mbonadei9aa3f0a2017-01-24 06:58:22 -0800318# chromium.
319# We need absolute paths for all configs in templates as they are shared in
320# different subdirectories.
321webrtc_root = get_path_info(".", "abspath")
322
323# Global configuration that should be applied to all WebRTC targets.
324# You normally shouldn't need to include this in your target as it's
325# automatically included when using the rtc_* templates.
326# It sets defines, include paths and compilation warnings accordingly,
327# both for WebRTC stand-alone builds and for the scenario when WebRTC
328# native code is built as part of Chromium.
Will Harrisfc173d02018-08-29 13:56:00 -0700329rtc_common_configs = [
330 webrtc_root + ":common_config",
331 "//build/config/compiler:no_size_t_to_int_warning",
332]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800333
kthelgasonc0977102017-04-24 00:57:16 -0700334if (is_mac || is_ios) {
335 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
336}
337
mbonadei9aa3f0a2017-01-24 06:58:22 -0800338# Global public configuration that should be applied to all WebRTC targets. You
339# normally shouldn't need to include this in your target as it's automatically
340# included when using the rtc_* templates. It set the defines, include paths and
341# compilation warnings that should be propagated to dependents of the targets
342# depending on the target having this config.
343rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
344
345# Common configs to remove or add in all rtc targets.
346rtc_remove_configs = []
Mirko Bonadeifc52b912019-03-01 10:32:56 +0100347if (!build_with_chromium && is_clang) {
348 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
349}
mbonadei9aa3f0a2017-01-24 06:58:22 -0800350rtc_add_configs = rtc_common_configs
Mirko Bonadei96ede162018-09-06 13:45:44 +0200351rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200352rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800353
354set_defaults("rtc_test") {
355 configs = rtc_add_configs
356 suppressed_configs = []
357}
358
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200359set_defaults("rtc_library") {
360 configs = rtc_add_configs
361 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200362 absl_deps = []
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200363}
364
mbonadei9aa3f0a2017-01-24 06:58:22 -0800365set_defaults("rtc_source_set") {
366 configs = rtc_add_configs
367 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200368 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800369}
370
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200371set_defaults("rtc_static_library") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800372 configs = rtc_add_configs
373 suppressed_configs = []
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200374 absl_deps = []
mbonadei9aa3f0a2017-01-24 06:58:22 -0800375}
376
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200377set_defaults("rtc_executable") {
mbonadei9aa3f0a2017-01-24 06:58:22 -0800378 configs = rtc_add_configs
379 suppressed_configs = []
380}
381
382set_defaults("rtc_shared_library") {
383 configs = rtc_add_configs
384 suppressed_configs = []
385}
386
Per Kjellandera7f2d842018-01-10 15:54:53 +0000387webrtc_default_visibility = [ webrtc_root + "/*" ]
388if (build_with_chromium) {
389 # Allow Chromium's WebRTC overrides targets to bypass the regular
390 # visibility restrictions.
391 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
392}
393
Karl Wibergbb23c832018-04-22 19:55:00 +0200394# ---- Poisons ----
395#
396# The general idea is that some targets declare that they contain some
397# kind of poison, which makes it impossible for other targets to
398# depend on them (even transitively) unless they declare themselves
399# immune to that particular type of poison.
400#
401# Targets that *contain* poison of type foo should contain the line
402#
403# poisonous = [ "foo" ]
404#
405# and targets that *are immune but arent't themselves poisonous*
406# should contain
407#
408# allow_poison = [ "foo" ]
409#
410# This useful in cases where we have some large target or set of
411# targets and want to ensure that most other targets do not
412# transitively depend on them. For example, almost no high-level
413# target should depend on the audio codecs, since we want WebRTC users
414# to be able to inject any subset of them and actually end up with a
415# binary that doesn't include the codecs they didn't inject.
416#
417# Test-only targets (`testonly` set to true) and non-public targets
418# (`visibility` not containing "*") are automatically immune to all
419# types of poison.
420#
421# Here's the complete list of all types of poison. It must be kept in
422# 1:1 correspondence with the set of //:poison_* targets.
423#
424all_poison_types = [
425 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
426 "audio_codecs",
Anders Carlsson1f433e42018-04-24 16:39:05 +0200427
Danil Chapovalov41300af2019-07-10 12:44:43 +0200428 # Default task queue implementation.
429 "default_task_queue",
Sam Zackrisson492fdf42019-10-25 10:45:58 +0200430
431 # JSON parsing should not be needed in the "slim and modular" WebRTC.
432 "rtc_json",
433
434 # Software video codecs (VP8 and VP9 through libvpx).
435 "software_video_codecs",
Karl Wibergbb23c832018-04-22 19:55:00 +0200436]
437
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000438absl_include_config = "//third_party/abseil-cpp:absl_include_config"
439absl_define_config = "//third_party/abseil-cpp:absl_define_config"
440
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200441# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
442# that are testonly.
443absl_flags_config = webrtc_root + ":absl_flags_configs"
444
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100445# WebRTC wrapper of Chromium's test() template. This template just adds some
446# WebRTC only configuration in order to avoid to duplicate it for every WebRTC
447# target.
448# The parameter `is_xctest` is different from the one in the Chromium's test()
449# template (and it is not forwarded to it). In rtc_test(), the argument
450# `is_xctest` is used to avoid to take dependencies that are not needed
451# in case the test is a real XCTest (using the XCTest framework).
mbonadei9aa3f0a2017-01-24 06:58:22 -0800452template("rtc_test") {
453 test(target_name) {
454 forward_variables_from(invoker,
455 "*",
456 [
457 "configs",
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100458 "is_xctest",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800459 "public_configs",
460 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200461 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800462 ])
Mirko Bonadeidd411942017-11-21 15:35:27 +0100463
464 # Always override to public because when target_os is Android the `test`
465 # template can override it to [ "*" ] and we want to avoid conditional
466 # visibility.
Mirko Bonadei21558812017-11-21 12:47:34 +0100467 visibility = [ "*" ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800468 configs += invoker.configs
469 configs -= rtc_remove_configs
470 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000471 public_configs = [
472 rtc_common_inherited_config,
473 absl_include_config,
474 absl_define_config,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200475 absl_flags_config,
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000476 ]
mbonadei9aa3f0a2017-01-24 06:58:22 -0800477 if (defined(invoker.public_configs)) {
478 public_configs += invoker.public_configs
479 }
sakald7fdb802017-05-26 01:51:53 -0700480 if (!build_with_chromium && is_android) {
Jianjun Zhu037f3e42017-08-15 21:48:37 +0800481 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
Peter Kotwicz3ceb16e2021-04-14 18:53:11 -0400482 use_raw_android_executable = false
Jeremy Leconteb19cfee2020-06-25 22:57:49 +0200483 min_sdk_version = 21
Mirko Bonadeibd393b22020-07-10 23:00:41 +0200484 target_sdk_version = 23
Mirko Bonadei80939352021-04-12 19:03:37 +0200485 deps += [
486 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
487 webrtc_root + "test:native_test_java",
488 ]
sakald7fdb802017-05-26 01:51:53 -0700489 }
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100490
491 # When not targeting a simulator, building //base/test:google_test_runner
492 # fails, so it is added only when the test is not a real XCTest and when
493 # targeting a simulator.
Mirko Bonadei58678a02020-12-01 10:54:40 +0100494 if (is_ios && target_cpu == "x64" && rtc_include_tests) {
Mirko Bonadeie99b6cc2020-11-25 16:41:37 +0100495 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
496 xctest_module_target = "//base/test:google_test_runner"
497 }
498 }
Andrey Logvin78646002021-01-29 10:50:19 +0000499
500 # If absl_deps is [], no action is needed. If not [], then it needs to be
501 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
502 # otherwise it just needs to be added to deps.
503 if (defined(absl_deps) && absl_deps != []) {
504 if (!defined(deps)) {
505 deps = []
506 }
507 if (build_with_chromium) {
508 deps += [ "//third_party/abseil-cpp:absl" ]
509 } else {
510 deps += absl_deps
511 }
512 }
513
Mirko Bonadei1d77c3e2021-01-26 17:10:04 +0100514 if (using_sanitizer) {
515 if (is_linux) {
516 if (!defined(invoker.data)) {
517 data = []
518 }
519 data +=
520 [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ]
521 }
522 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800523 }
524}
525
526template("rtc_source_set") {
527 source_set(target_name) {
528 forward_variables_from(invoker,
529 "*",
530 [
531 "configs",
532 "public_configs",
533 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200534 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800535 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200536 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000537 if (!defined(visibility)) {
538 visibility = webrtc_default_visibility
539 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200540
541 # What's your poison?
542 if (defined(testonly) && testonly) {
543 assert(!defined(poisonous))
544 assert(!defined(allow_poison))
545 } else {
546 if (!defined(poisonous)) {
547 poisonous = []
548 }
549 if (!defined(allow_poison)) {
550 allow_poison = []
551 }
552 if (!defined(assert_no_deps)) {
553 assert_no_deps = []
554 }
555 if (!defined(deps)) {
556 deps = []
557 }
558 foreach(p, poisonous) {
559 deps += [ webrtc_root + ":poison_" + p ]
560 }
561 foreach(poison_type, all_poison_types) {
562 allow_dep = true
563 foreach(v, visibility) {
564 if (v == "*") {
565 allow_dep = false
566 }
567 }
568 foreach(p, allow_poison + poisonous) {
569 if (p == poison_type) {
570 allow_dep = true
571 }
572 }
573 if (!allow_dep) {
574 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
575 }
576 }
577 }
578
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100579 # Chromium should only depend on the WebRTC component in order to
580 # avoid to statically link WebRTC in a component build.
581 if (build_with_chromium) {
582 publicly_visible = false
583 foreach(v, visibility) {
584 if (v == "*") {
585 publicly_visible = true
586 }
587 }
588 if (publicly_visible) {
589 visibility = []
590 visibility = webrtc_default_visibility
591 }
592 }
593
Mirko Bonadei96ede162018-09-06 13:45:44 +0200594 if (!defined(testonly) || !testonly) {
595 configs += rtc_prod_configs
596 }
597
mbonadei9aa3f0a2017-01-24 06:58:22 -0800598 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200599 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800600 configs -= rtc_remove_configs
601 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000602 public_configs = [
603 rtc_common_inherited_config,
604 absl_include_config,
605 absl_define_config,
606 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200607 if (defined(testonly) && testonly) {
608 public_configs += [ absl_flags_config ]
609 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800610 if (defined(invoker.public_configs)) {
611 public_configs += invoker.public_configs
612 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200613
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200614 # If absl_deps is [], no action is needed. If not [], then it needs to be
615 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200616 # otherwise it just needs to be added to deps.
617 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200618 if (!defined(deps)) {
619 deps = []
620 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200621 if (build_with_chromium) {
622 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200623 } else {
624 deps += absl_deps
625 }
626 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800627 }
628}
629
mbonadei9aa3f0a2017-01-24 06:58:22 -0800630template("rtc_static_library") {
631 static_library(target_name) {
632 forward_variables_from(invoker,
633 "*",
634 [
635 "configs",
636 "public_configs",
637 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200638 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800639 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200640 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000641 if (!defined(visibility)) {
642 visibility = webrtc_default_visibility
643 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200644
645 # What's your poison?
646 if (defined(testonly) && testonly) {
647 assert(!defined(poisonous))
648 assert(!defined(allow_poison))
649 } else {
650 if (!defined(poisonous)) {
651 poisonous = []
652 }
653 if (!defined(allow_poison)) {
654 allow_poison = []
655 }
656 if (!defined(assert_no_deps)) {
657 assert_no_deps = []
658 }
659 if (!defined(deps)) {
660 deps = []
661 }
662 foreach(p, poisonous) {
663 deps += [ webrtc_root + ":poison_" + p ]
664 }
665 foreach(poison_type, all_poison_types) {
666 allow_dep = true
667 foreach(v, visibility) {
668 if (v == "*") {
669 allow_dep = false
670 }
671 }
672 foreach(p, allow_poison + poisonous) {
673 if (p == poison_type) {
674 allow_dep = true
675 }
676 }
677 if (!allow_dep) {
678 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
679 }
680 }
681 }
682
Mirko Bonadei96ede162018-09-06 13:45:44 +0200683 if (!defined(testonly) || !testonly) {
684 configs += rtc_prod_configs
685 }
686
mbonadei9aa3f0a2017-01-24 06:58:22 -0800687 configs += invoker.configs
Mirko Bonadei32ce18c2018-09-18 13:15:54 +0200688 configs += rtc_library_impl_config
mbonadei9aa3f0a2017-01-24 06:58:22 -0800689 configs -= rtc_remove_configs
690 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000691 public_configs = [
692 rtc_common_inherited_config,
693 absl_include_config,
694 absl_define_config,
695 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200696 if (defined(testonly) && testonly) {
697 public_configs += [ absl_flags_config ]
698 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800699 if (defined(invoker.public_configs)) {
700 public_configs += invoker.public_configs
701 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200702
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200703 # If absl_deps is [], no action is needed. If not [], then it needs to be
704 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200705 # otherwise it just needs to be added to deps.
706 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200707 if (!defined(deps)) {
708 deps = []
709 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200710 if (build_with_chromium) {
711 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200712 } else {
713 deps += absl_deps
714 }
715 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800716 }
717}
718
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200719# This template automatically switches the target type between source_set
720# and static_library.
721#
722# This should be the default target type for all the WebRTC targets with
723# one exception. Do not use this template for header only targets, in that case
724# rtc_source_set must be used in order to avoid build errors (e.g. libtool
725# complains if the output .a file is empty).
726#
727# How does it work:
728# Since all files in a source_set are linked into a final binary, while files
729# in a static library are only linked in if at least one symbol in them is
730# referenced, in component builds source_sets are easy to deal with because
731# all their object files are passed to the linker to create a shared library.
732# In release builds instead, static_libraries are preferred since they allow
733# the linker to discard dead code.
734# For the same reason, testonly targets will always be expanded to
735# source_set in order to be sure that tests are present in the test binary.
736template("rtc_library") {
737 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) {
738 target_type = "source_set"
739 } else {
740 target_type = "static_library"
741 }
742 target(target_type, target_name) {
743 forward_variables_from(invoker,
744 "*",
745 [
746 "configs",
747 "public_configs",
748 "suppressed_configs",
749 "visibility",
750 ])
751 forward_variables_from(invoker, [ "visibility" ])
752 if (!defined(visibility)) {
753 visibility = webrtc_default_visibility
754 }
755
756 # What's your poison?
757 if (defined(testonly) && testonly) {
758 assert(!defined(poisonous))
759 assert(!defined(allow_poison))
760 } else {
761 if (!defined(poisonous)) {
762 poisonous = []
763 }
764 if (!defined(allow_poison)) {
765 allow_poison = []
766 }
767 if (!defined(assert_no_deps)) {
768 assert_no_deps = []
769 }
770 if (!defined(deps)) {
771 deps = []
772 }
773 foreach(p, poisonous) {
774 deps += [ webrtc_root + ":poison_" + p ]
775 }
776 foreach(poison_type, all_poison_types) {
777 allow_dep = true
778 foreach(v, visibility) {
779 if (v == "*") {
780 allow_dep = false
781 }
782 }
783 foreach(p, allow_poison + poisonous) {
784 if (p == poison_type) {
785 allow_dep = true
786 }
787 }
788 if (!allow_dep) {
789 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
790 }
791 }
792 }
793
Mirko Bonadei92dd35d2019-11-15 16:08:41 +0100794 # Chromium should only depend on the WebRTC component in order to
795 # avoid to statically link WebRTC in a component build.
796 if (build_with_chromium) {
797 publicly_visible = false
798 foreach(v, visibility) {
799 if (v == "*") {
800 publicly_visible = true
801 }
802 }
803 if (publicly_visible) {
804 visibility = []
805 visibility = webrtc_default_visibility
806 }
807 }
808
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200809 if (!defined(testonly) || !testonly) {
810 configs += rtc_prod_configs
811 }
812
813 configs += invoker.configs
814 configs += rtc_library_impl_config
815 configs -= rtc_remove_configs
816 configs -= invoker.suppressed_configs
817 public_configs = [
818 rtc_common_inherited_config,
819 absl_include_config,
820 absl_define_config,
821 ]
822 if (defined(testonly) && testonly) {
823 public_configs += [ absl_flags_config ]
824 }
825 if (defined(invoker.public_configs)) {
826 public_configs += invoker.public_configs
827 }
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200828
Mirko Bonadei96115cf2020-06-23 23:39:56 +0200829 # If absl_deps is [], no action is needed. If not [], then it needs to be
830 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200831 # otherwise it just needs to be added to deps.
832 if (absl_deps != []) {
Mirko Bonadei2dcf3482020-06-05 14:30:41 +0200833 if (!defined(deps)) {
834 deps = []
835 }
Mirko Bonadei08ce9862020-06-11 11:25:32 +0200836 if (build_with_chromium) {
837 deps += [ "//third_party/abseil-cpp:absl" ]
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +0200838 } else {
839 deps += absl_deps
840 }
841 }
Mirko Bonadei86d053c2019-10-17 21:32:04 +0200842 }
843}
844
845template("rtc_executable") {
846 executable(target_name) {
847 forward_variables_from(invoker,
848 "*",
849 [
850 "deps",
851 "configs",
852 "public_configs",
853 "suppressed_configs",
854 "visibility",
855 ])
856 forward_variables_from(invoker, [ "visibility" ])
857 if (!defined(visibility)) {
858 visibility = webrtc_default_visibility
859 }
860 configs += invoker.configs
861 configs -= rtc_remove_configs
862 configs -= invoker.suppressed_configs
863 deps = invoker.deps
864
865 public_configs = [
866 rtc_common_inherited_config,
867 absl_include_config,
868 absl_define_config,
869 ]
870 if (defined(testonly) && testonly) {
871 public_configs += [ absl_flags_config ]
872 }
873 if (defined(invoker.public_configs)) {
874 public_configs += invoker.public_configs
875 }
876 if (is_win) {
877 deps += [
878 # Give executables the default manifest on Windows (a no-op elsewhere).
879 "//build/win:default_exe_manifest",
880 ]
881 }
882 }
883}
884
mbonadei9aa3f0a2017-01-24 06:58:22 -0800885template("rtc_shared_library") {
886 shared_library(target_name) {
887 forward_variables_from(invoker,
888 "*",
889 [
890 "configs",
891 "public_configs",
892 "suppressed_configs",
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200893 "visibility",
mbonadei9aa3f0a2017-01-24 06:58:22 -0800894 ])
Karl Wiberg138d4ac2017-10-16 11:16:19 +0200895 forward_variables_from(invoker, [ "visibility" ])
Per Kjellandera7f2d842018-01-10 15:54:53 +0000896 if (!defined(visibility)) {
897 visibility = webrtc_default_visibility
898 }
Karl Wibergbb23c832018-04-22 19:55:00 +0200899
900 # What's your poison?
901 if (defined(testonly) && testonly) {
902 assert(!defined(poisonous))
903 assert(!defined(allow_poison))
904 } else {
905 if (!defined(poisonous)) {
906 poisonous = []
907 }
908 if (!defined(allow_poison)) {
909 allow_poison = []
910 }
911 if (!defined(assert_no_deps)) {
912 assert_no_deps = []
913 }
914 if (!defined(deps)) {
915 deps = []
916 }
917 foreach(p, poisonous) {
918 deps += [ webrtc_root + ":poison_" + p ]
919 }
920 foreach(poison_type, all_poison_types) {
921 allow_dep = true
922 foreach(v, visibility) {
923 if (v == "*") {
924 allow_dep = false
925 }
926 }
927 foreach(p, allow_poison + poisonous) {
928 if (p == poison_type) {
929 allow_dep = true
930 }
931 }
932 if (!allow_dep) {
933 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
934 }
935 }
936 }
937
mbonadei9aa3f0a2017-01-24 06:58:22 -0800938 configs += invoker.configs
939 configs -= rtc_remove_configs
940 configs -= invoker.suppressed_configs
Mirko Bonadei9a89a492018-05-29 14:22:32 +0000941 public_configs = [
942 rtc_common_inherited_config,
943 absl_include_config,
944 absl_define_config,
945 ]
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200946 if (defined(testonly) && testonly) {
947 public_configs += [ absl_flags_config ]
948 }
mbonadei9aa3f0a2017-01-24 06:58:22 -0800949 if (defined(invoker.public_configs)) {
950 public_configs += invoker.public_configs
951 }
952 }
953}
kthelgason4065a572017-02-14 04:58:56 -0800954
955if (is_ios) {
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -0400956 # TODO: Generate module.modulemap file to enable use in Swift
957 # projects. See "mac_framework_bundle_with_umbrella_header".
Anders Carlssondc6b4772018-01-15 13:31:03 +0100958 template("ios_framework_bundle_with_umbrella_header") {
959 forward_variables_from(invoker, [ "output_name" ])
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900960 this_target_name = target_name
Anders Carlssondc6b4772018-01-15 13:31:03 +0100961 umbrella_header_path =
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900962 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
963
964 action_foreach("create_bracket_include_headers_$target_name") {
965 script = "//tools_webrtc/apple/copy_framework_header.py"
966 sources = invoker.sources
967 output_name = invoker.output_name
968 outputs = [
969 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
970 ]
971 args = [
972 "--input",
973 "{{source}}",
974 "--output",
975 rebase_path(target_gen_dir, root_build_dir) +
976 "/$output_name.framework/WebRTC/{{source_file_part}}",
977 ]
978 }
Anders Carlssondc6b4772018-01-15 13:31:03 +0100979
980 ios_framework_bundle(target_name) {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900981 forward_variables_from(invoker, "*", [ "public_headers" ])
982 public_headers = get_target_outputs(
983 ":create_bracket_include_headers_$this_target_name")
984 deps += [
985 ":copy_umbrella_header_$target_name",
986 ":create_bracket_include_headers_$target_name",
987 ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100988 }
989
990 action("umbrella_header_$target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +0900991 public_headers = get_target_outputs(
992 ":create_bracket_include_headers_$this_target_name")
Anders Carlssondc6b4772018-01-15 13:31:03 +0100993
994 script = "//tools_webrtc/ios/generate_umbrella_header.py"
995
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +0100996 outputs = [ umbrella_header_path ]
Anders Carlssondc6b4772018-01-15 13:31:03 +0100997 args = [
998 "--out",
999 rebase_path(umbrella_header_path, root_build_dir),
1000 "--sources",
Anders Carlsson7bca8ca2018-08-30 09:30:29 +02001001 ] + public_headers
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001002 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001003 }
1004
Jordan Rose53d3fc92021-07-06 12:16:41 -07001005 if (target_environment == "catalyst") {
1006 # Catalyst frameworks use the same layout as regular Mac frameworks.
1007 headers_dir = "Versions/A/Headers"
1008 } else {
1009 headers_dir = "Headers"
1010 }
Anders Carlssondc6b4772018-01-15 13:31:03 +01001011 copy("copy_umbrella_header_$target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001012 sources = [ umbrella_header_path ]
1013 outputs =
Jordan Rose53d3fc92021-07-06 12:16:41 -07001014 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001015
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001016 deps = [ ":umbrella_header_$target_name" ]
Anders Carlssondc6b4772018-01-15 13:31:03 +01001017 }
1018 }
1019
1020 set_defaults("ios_framework_bundle_with_umbrella_header") {
1021 configs = default_shared_library_configs
1022 }
kthelgason4065a572017-02-14 04:58:56 -08001023}
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001024
Anders Carlsson37bbf792018-09-05 16:29:27 +02001025if (is_mac) {
1026 template("mac_framework_bundle_with_umbrella_header") {
1027 forward_variables_from(invoker, [ "output_name" ])
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001028 this_target_name = target_name
1029 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001030 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
Anders Carlsson37bbf792018-09-05 16:29:27 +02001031
1032 mac_framework_bundle(target_name) {
Thomas Anderson6fde78c2019-01-23 10:40:29 -08001033 forward_variables_from(invoker, "*", [ "configs" ])
1034 if (defined(invoker.configs)) {
1035 configs += invoker.configs
1036 }
Anders Carlsson37bbf792018-09-05 16:29:27 +02001037
1038 framework_version = "A"
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001039 framework_contents = [
1040 "Headers",
1041 "Modules",
1042 "Resources",
1043 ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001044
1045 ldflags = [
1046 "-all_load",
1047 "-install_name",
1048 "@rpath/$output_name.framework/$output_name",
1049 ]
1050
1051 deps += [
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001052 ":copy_framework_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001053 ":copy_modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001054 ":copy_umbrella_header_$this_target_name",
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001055 ":create_bracket_include_headers_$this_target_name",
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001056 ":modulemap_$this_target_name",
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001057 ":umbrella_header_$this_target_name",
Anders Carlsson37bbf792018-09-05 16:29:27 +02001058 ]
1059 }
1060
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001061 action_foreach("create_bracket_include_headers_$this_target_name") {
1062 script = "//tools_webrtc/apple/copy_framework_header.py"
1063 sources = invoker.sources
1064 output_name = invoker.output_name
1065 outputs = [
1066 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1067 ]
1068 args = [
1069 "--input",
1070 "{{source}}",
1071 "--output",
1072 rebase_path(target_gen_dir, root_build_dir) +
1073 "/$output_name.framework/WebRTC/{{source_file_part}}",
1074 ]
1075 }
1076
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001077 bundle_data("copy_framework_headers_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001078 sources = get_target_outputs(
1079 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001080
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001081 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001082 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001083 }
1084
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001085 action("modulemap_$this_target_name") {
1086 script = "//tools_webrtc/ios/generate_modulemap.py"
1087 args = [
1088 "--out",
1089 rebase_path(modulemap_path, root_build_dir),
1090 "--name",
1091 output_name,
1092 ]
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001093 outputs = [ modulemap_path ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001094 }
1095
1096 bundle_data("copy_modulemap_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001097 sources = [ modulemap_path ]
1098 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1099 deps = [ ":modulemap_$this_target_name" ]
Joel Sutherlandd2fb1bf2018-10-02 16:08:25 -04001100 }
1101
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001102 action("umbrella_header_$this_target_name") {
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001103 sources = get_target_outputs(
1104 ":create_bracket_include_headers_$this_target_name")
Anders Carlsson37bbf792018-09-05 16:29:27 +02001105
1106 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1107
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001108 outputs = [ umbrella_header_path ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001109 args = [
1110 "--out",
1111 rebase_path(umbrella_header_path, root_build_dir),
1112 "--sources",
1113 ] + sources
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09001114 deps = [ ":create_bracket_include_headers_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001115 }
1116
Anders Carlsson95c56ee2018-09-06 15:48:17 +02001117 bundle_data("copy_umbrella_header_$this_target_name") {
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001118 sources = [ umbrella_header_path ]
1119 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001120
Mirko Bonadeiccbe95f2020-01-21 12:10:10 +01001121 deps = [ ":umbrella_header_$this_target_name" ]
Anders Carlsson37bbf792018-09-05 16:29:27 +02001122 }
1123 }
1124}
1125
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001126if (is_android) {
1127 template("rtc_android_library") {
1128 android_library(target_name) {
1129 forward_variables_from(invoker,
1130 "*",
1131 [
1132 "configs",
1133 "public_configs",
1134 "suppressed_configs",
1135 "visibility",
1136 ])
1137
Oleh Prypin05aee742018-11-23 17:29:44 +01001138 errorprone_args = []
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001139
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001140 # Treat warnings as errors.
Oleh Prypin05aee742018-11-23 17:29:44 +01001141 errorprone_args += [ "-Werror" ]
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001142
1143 # Add any arguments defined by the invoker.
Oleh Prypin05aee742018-11-23 17:29:44 +01001144 if (defined(invoker.errorprone_args)) {
1145 errorprone_args += invoker.errorprone_args
Sami Kalliomäkie7fac682018-03-20 16:32:49 +01001146 }
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001147
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001148 if (!defined(deps)) {
1149 deps = []
1150 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001151
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001152 no_build_hooks = true
Mirko Bonadei8b7cfa12020-06-03 21:23:41 +02001153 not_needed([ "android_manifest" ])
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001154 }
1155 }
1156
1157 template("rtc_android_apk") {
1158 android_apk(target_name) {
1159 forward_variables_from(invoker,
1160 "*",
1161 [
1162 "configs",
1163 "public_configs",
1164 "suppressed_configs",
1165 "visibility",
1166 ])
1167
1168 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001169 errorprone_args = []
1170 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001171
1172 if (!defined(deps)) {
1173 deps = []
1174 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001175
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001176 no_build_hooks = true
1177 }
1178 }
1179
1180 template("rtc_instrumentation_test_apk") {
1181 instrumentation_test_apk(target_name) {
1182 forward_variables_from(invoker,
1183 "*",
1184 [
1185 "configs",
1186 "public_configs",
1187 "suppressed_configs",
1188 "visibility",
1189 ])
1190
1191 # Treat warnings as errors.
Yves Gerey2f385d22019-11-20 12:10:08 +01001192 errorprone_args = []
1193 errorprone_args += [ "-Werror" ]
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001194
1195 if (!defined(deps)) {
1196 deps = []
1197 }
Sami Kalliomäkidc526512018-03-27 17:07:27 +02001198
Mirko Bonadeifbb3b7d2017-11-07 15:36:33 +00001199 no_build_hooks = true
1200 }
1201 }
1202}