1 # Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
8 import("//build/config/arm.gni")
9 import("//build/config/features.gni")
10 import("//build/config/mips.gni")
11 import("//build/config/ozone.gni")
12 import("//build/config/sanitizers/sanitizers.gni")
13 import("//build/config/sysroot.gni")
14 import("//build_overrides/build.gni")
16 if (!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`.")
26 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/main/docs/component_build.md")
27 assert(!is_component_build, "Component builds are not supported in WebRTC.")
31 import("//build/config/ios/rules.gni")
35 import("//build/config/mac/rules.gni")
39 import("//build/config/android/config.gni")
40 import("//build/config/android/rules.gni")
44 import("//build/config/fuchsia/config.gni")
47 # This declare_args is separated from the next one because args declared
48 # in this one, can be read from the next one (args defined in the same
49 # declare_args cannot be referenced in that scope).
51 # Enable to use the Mozilla internal settings.
52 build_with_mozilla = true
56 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
57 # expand to code that will manage symbols visibility.
58 rtc_enable_symbol_export = false
62 # Setting this to true, will make RTC_DLOG() expand to log statements instead
63 # of being removed by the preprocessor.
64 # This is useful for example to be able to get RTC_DLOGs on a release build.
65 rtc_dlog_always_on = false
67 # Enables additional build targets that rely on
68 # //third_party/google_benchmarks.
69 rtc_enable_google_benchmarks = true
71 # Setting this to true will make RTC_OBJC_EXPORT expand to code that will
72 # manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported
73 # if C++ symbols are but setting this arg to true while keeping
74 # rtc_enable_symbol_export=false will only export RTC_OBJC_EXPORT
76 rtc_enable_objc_symbol_export = rtc_enable_symbol_export
78 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
79 # will tell the pre-processor to remove the default definition of symbols
80 # needed to use field_trial. In that case a new implementation needs to be
82 if (build_with_chromium) {
83 # When WebRTC is built as part of Chromium it should exclude the default
84 # implementation of field_trial unless it is building for NACL or
86 rtc_exclude_field_trial_default = !is_nacl && !is_castos && !is_cast_android
88 rtc_exclude_field_trial_default = false
91 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
92 # will tell the pre-processor to remove the default definition of symbols
93 # needed to use metrics. In that case a new implementation needs to be
95 rtc_exclude_metrics_default = build_with_chromium
97 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which
98 # will tell the pre-processor to remove the default definition of the
99 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
100 # that case a new implementation needs to be provided.
101 rtc_exclude_system_time = build_with_chromium || build_with_mozilla
103 # Setting this to false will require the API user to pass in their own
104 # SSLCertificateVerifier to verify the certificates presented from a
105 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
106 rtc_builtin_ssl_root_certificates = true
108 # Include the iLBC audio codec?
109 rtc_include_ilbc = true
111 # Disable this to avoid building the Opus audio codec.
112 rtc_include_opus = true
114 # Enable this if the Opus version upon which WebRTC is built supports direct
115 # encoding of 120 ms packets.
116 rtc_opus_support_120ms_ptime = true
118 # Enable this to let the Opus audio codec change complexity on the fly.
119 rtc_opus_variable_complexity = false
121 # Used to specify an external Jsoncpp include path when not compiling the
122 # library that comes with WebRTC (i.e. rtc_build_json == 0).
123 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
125 # Used to specify an external OpenSSL include path when not compiling the
126 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
127 rtc_ssl_root = "unused"
129 # Enable when an external authentication mechanism is used for performing
130 # packet authentication for RTP packets instead of libsrtp.
131 rtc_enable_external_auth = build_with_chromium
133 # Selects whether debug dumps for the audio processing module
134 # should be generated.
135 apm_debug_dump = build_with_mozilla
137 # Selects whether the audio processing module should be excluded.
138 rtc_exclude_audio_processing_module = false
140 # Set this to true to enable BWE test logging.
141 rtc_enable_bwe_test_logging = false
143 # Set this to false to skip building examples.
144 rtc_build_examples = false
146 # Set this to false to skip building tools.
147 rtc_build_tools = false
149 # Set this to false to skip building code that requires X11.
150 rtc_use_x11 = use_x11
152 # Set this to use PipeWire on the Wayland display server.
153 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
154 # only when using the sysroot as PipeWire is not available in older and
155 # supported Ubuntu and Debian distributions.
156 rtc_use_pipewire = is_linux && use_sysroot
158 # Set this to link PipeWire and required libraries directly instead of using the dlopen.
159 rtc_link_pipewire = false
161 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
162 # and NDK r16 or above.
163 rtc_enable_android_aaudio = false
165 # Set to "func", "block", "edge" for coverage generation.
166 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
167 # It is recommend to set include_examples=0.
168 # Use llvm's sancov -html-report for human readable reports.
169 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
170 rtc_sanitize_coverage = ""
172 # Selects fixed-point code where possible.
173 rtc_prefer_fixed_point = false
174 if (target_cpu == "arm" || target_cpu == "arm64") {
175 rtc_prefer_fixed_point = true
178 # Determines whether NEON code will be built.
179 rtc_build_with_neon =
180 (target_cpu == "arm" && arm_use_neon) || target_cpu == "arm64"
182 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
183 # all platforms except Android and iOS. Because FFmpeg can be built
184 # with/without H.264 support, `ffmpeg_branding` has to separately be set to a
185 # value that includes H.264, for example "Chrome". If FFmpeg is built without
186 # H.264, compilation succeeds but `H264DecoderImpl` fails to initialize.
187 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
188 # http://www.openh264.org, https://www.ffmpeg.org/
190 # Enabling H264 when building with MSVC is currently not supported, see
191 # bugs.webrtc.org/9213#c13 for more info.
193 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
195 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
196 rtc_use_absl_mutex = false
198 # By default, use normal platform audio support or dummy audio, but don't
199 # use file-based audio playout and record.
200 rtc_use_dummy_audio_file_devices = false
202 # When set to true, replace the audio output with a sinus tone at 440Hz.
203 # The ADM will ask for audio data from WebRTC but instead of reading real
204 # audio samples from NetEQ, a sinus tone will be generated and replace the
205 # real audio samples.
206 rtc_audio_device_plays_sinus_tone = false
209 # Build broadcast extension in AppRTCMobile for iOS. This results in the
210 # binary only running on iOS 11+, which is why it is disabled by default.
211 rtc_apprtcmobile_broadcast_extension = false
214 # Determines whether OpenGL is available on iOS/macOS.
215 rtc_ios_macos_use_opengl_rendering =
216 !(is_ios && target_environment == "catalyst")
218 # When set to false, builtin audio encoder/decoder factories and all the
219 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
220 # (they will still be included in libjingle_peerconnection_so.so and
222 rtc_include_builtin_audio_codecs = true
224 # When set to true and in a standalone build, it will undefine UNICODE and
225 # _UNICODE (which are always defined globally by the Chromium Windows
227 # This is only needed for testing purposes, WebRTC wants to be sure it
228 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
229 # wide character functions.
230 rtc_win_undef_unicode = false
232 # When set to true, a capturer implementation that uses the
233 # Windows.Graphics.Capture APIs will be available for use. This introduces a
234 # dependency on the Win 10 SDK v10.0.17763.0.
235 rtc_enable_win_wgc = is_win
237 # Includes the dav1d decoder in the internal decoder factory when set to true.
238 rtc_include_dav1d_in_internal_decoder_factory = true
240 # When enabled, a run-time check will make sure that all field trial keys have
241 # been registered in accordance with the field trial policy, see
242 # g3doc/field-trials.md. The value can be set to the following:
244 # "dcheck": RTC_DCHECKs that the field trial has been registered. RTC_DCHECK
245 # must be enabled separately.
247 # "warn": RTC_LOGs a message with LS_WARNING severity if the field trial
248 # hasn't been registered.
249 rtc_strict_field_trials = ""
252 if (!build_with_mozilla) {
253 import("//testing/test.gni")
256 # A second declare_args block, so that declarations within it can
257 # depend on the possibly overridden variables in the first
258 # declare_args block.
260 # Enables the use of protocol buffers for debug recordings.
261 rtc_enable_protobuf = !build_with_mozilla
263 # Set this to disable building with support for SCTP data channels.
264 rtc_enable_sctp = !build_with_mozilla
266 # Disable these to not build components which can be externally provided.
267 rtc_build_json = !build_with_mozilla
268 rtc_build_libsrtp = !build_with_mozilla
269 rtc_build_libvpx = !build_with_mozilla
270 rtc_libvpx_build_vp9 = true
271 rtc_build_opus = !build_with_mozilla
272 rtc_build_ssl = !build_with_mozilla
274 # Enable libevent task queues on platforms that support it.
275 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
276 target_cpu == "wasm") {
277 rtc_enable_libevent = false
278 rtc_build_libevent = false
280 rtc_enable_libevent = true
281 rtc_build_libevent = !build_with_mozilla
284 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
285 rtc_include_pulse_audio = !build_with_chromium
287 # Chromium uses its own IO handling, so the internal ADM is only built for
289 rtc_include_internal_audio_device = !build_with_chromium && !build_with_mozilla
291 # Set this to true to enable the avx2 support in webrtc.
292 # TODO: Make sure that AVX2 works also for non-clang compilers.
293 if (is_clang == true && (target_cpu == "x86" || target_cpu == "x64")) {
294 rtc_enable_avx2 = true
296 rtc_enable_avx2 = false
299 # Set this to true to build the unit tests.
300 # Disabled when building with Chromium or Mozilla.
301 rtc_include_tests = !build_with_chromium && !build_with_mozilla
303 # Set this to false to skip building code that also requires X11 extensions
304 # such as Xdamage, Xfixes.
305 rtc_use_x11_extensions = rtc_use_x11
307 # Set this to true to fully remove logging from WebRTC.
308 rtc_disable_logging = false
310 # Set this to true to disable trace events.
311 rtc_disable_trace_events = false
313 # Set this to true to disable detailed error message and logging for
315 rtc_disable_check_msg = false
317 # Set this to true to disable webrtc metrics.
318 rtc_disable_metrics = false
320 # Set this to true to exclude the transient suppressor in the audio processing
321 # module from the build.
322 rtc_exclude_transient_suppressor = false
326 # Enable the dcsctp backend for DataChannels and related unittests
327 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
329 # Enable gRPC used for negotiation in multiprocess tests
330 rtc_enable_grpc = rtc_enable_protobuf && (is_linux || is_mac)
333 # Enable liboam only on non-mozilla builds.
334 enable_libaom = !build_with_mozilla
336 # Make it possible to provide custom locations for some libraries (move these
337 # up into declare_args should we need to actually use them for the GN build).
338 rtc_libvpx_dir = "//third_party/libvpx"
339 rtc_opus_dir = "//third_party/opus"
341 # Desktop capturer is supported only on Windows, OSX and Linux.
342 rtc_desktop_capture_supported =
343 (is_win && current_os != "winuwp") || is_mac || is_bsd ||
344 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
346 ###############################################################################
350 # Points to // in webrtc stand-alone or to //third_party/webrtc/ in
352 # We need absolute paths for all configs in templates as they are shared in
353 # different subdirectories.
354 webrtc_root = get_path_info(".", "abspath")
356 # Global configuration that should be applied to all WebRTC targets.
357 # You normally shouldn't need to include this in your target as it's
358 # automatically included when using the rtc_* templates.
359 # It sets defines, include paths and compilation warnings accordingly,
360 # both for WebRTC stand-alone builds and for the scenario when WebRTC
361 # native code is built as part of Chromium.
362 rtc_common_configs = [ webrtc_root + ":common_config" ]
364 if (is_mac || is_ios) {
365 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
368 # Global public configuration that should be applied to all WebRTC targets. You
369 # normally shouldn't need to include this in your target as it's automatically
370 # included when using the rtc_* templates. It set the defines, include paths and
371 # compilation warnings that should be propagated to dependents of the targets
372 # depending on the target having this config.
373 rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
375 # Common configs to remove or add in all rtc targets.
376 rtc_remove_configs = []
377 if (!build_with_chromium && is_clang) {
378 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
380 rtc_add_configs = rtc_common_configs
381 rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
382 rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
384 set_defaults("rtc_test") {
385 configs = rtc_add_configs
386 suppressed_configs = []
389 set_defaults("rtc_library") {
390 configs = rtc_add_configs
391 suppressed_configs = []
395 set_defaults("rtc_source_set") {
396 configs = rtc_add_configs
397 suppressed_configs = []
401 set_defaults("rtc_static_library") {
402 configs = rtc_add_configs
403 suppressed_configs = []
407 set_defaults("rtc_executable") {
408 configs = rtc_add_configs
409 suppressed_configs = []
412 set_defaults("rtc_shared_library") {
413 configs = rtc_add_configs
414 suppressed_configs = []
417 webrtc_default_visibility = [ webrtc_root + "/*" ]
418 if (build_with_chromium) {
419 # Allow Chromium's WebRTC overrides targets to bypass the regular
420 # visibility restrictions.
421 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
426 # The general idea is that some targets declare that they contain some
427 # kind of poison, which makes it impossible for other targets to
428 # depend on them (even transitively) unless they declare themselves
429 # immune to that particular type of poison.
431 # Targets that *contain* poison of type foo should contain the line
433 # poisonous = [ "foo" ]
435 # and targets that *are immune but arent't themselves poisonous*
438 # allow_poison = [ "foo" ]
440 # This useful in cases where we have some large target or set of
441 # targets and want to ensure that most other targets do not
442 # transitively depend on them. For example, almost no high-level
443 # target should depend on the audio codecs, since we want WebRTC users
444 # to be able to inject any subset of them and actually end up with a
445 # binary that doesn't include the codecs they didn't inject.
447 # Test-only targets (`testonly` set to true) and non-public targets
448 # (`visibility` not containing "*") are automatically immune to all
451 # Here's the complete list of all types of poison. It must be kept in
452 # 1:1 correspondence with the set of //:poison_* targets.
455 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
458 # Default task queue implementation.
459 "default_task_queue",
461 # Default echo detector implementation.
462 "default_echo_detector",
464 # JSON parsing should not be needed in the "slim and modular" WebRTC.
467 # Software video codecs (VP8 and VP9 through libvpx).
468 "software_video_codecs",
471 absl_include_config = "//third_party/abseil-cpp:absl_include_config"
472 absl_define_config = "//third_party/abseil-cpp:absl_define_config"
474 # Abseil Flags are testonly, so this config will only be applied to WebRTC targets
476 absl_flags_config = webrtc_root + ":absl_flags_configs"
478 # WebRTC wrapper of Chromium's test() template. This template just adds some
479 # WebRTC only configuration in order to avoid to duplicate it for every WebRTC
481 # The parameter `is_xctest` is different from the one in the Chromium's test()
482 # template (and it is not forwarded to it). In rtc_test(), the argument
483 # `is_xctest` is used to avoid to take dependencies that are not needed
484 # in case the test is a real XCTest (using the XCTest framework).
485 template("rtc_test") {
487 forward_variables_from(invoker,
493 "suppressed_configs",
497 # Always override to public because when target_os is Android the `test`
498 # template can override it to [ "*" ] and we want to avoid conditional
501 configs += invoker.configs
502 configs -= rtc_remove_configs
503 configs -= invoker.suppressed_configs
505 rtc_common_inherited_config,
510 if (defined(invoker.public_configs)) {
511 public_configs += invoker.public_configs
513 if (!build_with_chromium && is_android) {
514 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
515 use_raw_android_executable = false
517 target_sdk_version = 23
519 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
520 webrtc_root + "test:native_test_java",
524 # Build //test:google_test_runner_objc when the test is not a real XCTest.
525 if (is_ios && rtc_include_tests) {
526 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
527 xctest_module_target = "//test:google_test_runner_objc"
531 # If absl_deps is [], no action is needed. If not [], then it needs to be
532 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
533 # otherwise it just needs to be added to deps.
534 if (defined(absl_deps) && absl_deps != []) {
535 if (!defined(deps)) {
538 if (build_with_chromium) {
539 deps += [ "//third_party/abseil-cpp:absl" ]
545 # TODO(crbug.com/webrtc/13556): Adding the .app folder in the runtime_deps
546 # shoulnd't be necessary. this code should be removed and the same solution
547 # as Chromium should be used.
549 if (!defined(invoker.data)) {
552 data += [ "${root_out_dir}/${target_name}.app" ]
557 template("rtc_source_set") {
558 source_set(target_name) {
559 forward_variables_from(invoker,
564 "suppressed_configs",
567 forward_variables_from(invoker, [ "visibility" ])
568 if (!defined(visibility)) {
569 visibility = webrtc_default_visibility
572 # What's your poison?
573 if (defined(testonly) && testonly) {
574 assert(!defined(poisonous))
575 assert(!defined(allow_poison))
577 if (!defined(poisonous)) {
580 if (!defined(allow_poison)) {
583 if (!defined(assert_no_deps)) {
586 if (!defined(deps)) {
589 foreach(p, poisonous) {
590 deps += [ webrtc_root + ":poison_" + p ]
592 foreach(poison_type, all_poison_types) {
594 foreach(v, visibility) {
599 foreach(p, allow_poison + poisonous) {
600 if (p == poison_type) {
605 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
610 # Chromium should only depend on the WebRTC component in order to
611 # avoid to statically link WebRTC in a component build.
612 if (build_with_chromium) {
613 publicly_visible = false
614 foreach(v, visibility) {
616 publicly_visible = true
619 if (publicly_visible) {
621 visibility = webrtc_default_visibility
625 if (!defined(testonly) || !testonly) {
626 configs += rtc_prod_configs
629 configs += invoker.configs
630 configs += rtc_library_impl_config
631 configs -= rtc_remove_configs
632 configs -= invoker.suppressed_configs
634 rtc_common_inherited_config,
638 if (defined(testonly) && testonly) {
639 public_configs += [ absl_flags_config ]
641 if (defined(invoker.public_configs)) {
642 public_configs += invoker.public_configs
645 # If absl_deps is [], no action is needed. If not [], then it needs to be
646 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
647 # otherwise it just needs to be added to deps.
648 if (absl_deps != []) {
649 if (!defined(deps)) {
652 if (build_with_chromium) {
653 deps += [ "//third_party/abseil-cpp:absl" ]
661 template("rtc_static_library") {
662 static_library(target_name) {
663 forward_variables_from(invoker,
668 "suppressed_configs",
671 forward_variables_from(invoker, [ "visibility" ])
672 if (!defined(visibility)) {
673 visibility = webrtc_default_visibility
676 # What's your poison?
677 if (defined(testonly) && testonly) {
678 assert(!defined(poisonous))
679 assert(!defined(allow_poison))
681 if (!defined(poisonous)) {
684 if (!defined(allow_poison)) {
687 if (!defined(assert_no_deps)) {
690 if (!defined(deps)) {
693 foreach(p, poisonous) {
694 deps += [ webrtc_root + ":poison_" + p ]
696 foreach(poison_type, all_poison_types) {
698 foreach(v, visibility) {
703 foreach(p, allow_poison + poisonous) {
704 if (p == poison_type) {
709 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
714 if (!defined(testonly) || !testonly) {
715 configs += rtc_prod_configs
718 configs += invoker.configs
719 configs += rtc_library_impl_config
720 configs -= rtc_remove_configs
721 configs -= invoker.suppressed_configs
723 rtc_common_inherited_config,
727 if (defined(testonly) && testonly) {
728 public_configs += [ absl_flags_config ]
730 if (defined(invoker.public_configs)) {
731 public_configs += invoker.public_configs
734 # If absl_deps is [], no action is needed. If not [], then it needs to be
735 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
736 # otherwise it just needs to be added to deps.
737 if (absl_deps != []) {
738 if (!defined(deps)) {
741 if (build_with_chromium) {
742 deps += [ "//third_party/abseil-cpp:absl" ]
750 # This template automatically switches the target type between source_set
751 # and static_library.
753 # This should be the default target type for all the WebRTC targets.
756 # Since all files in a source_set are linked into a final binary, while files
757 # in a static library are only linked in if at least one symbol in them is
758 # referenced, in component builds source_sets are easy to deal with because
759 # all their object files are passed to the linker to create a shared library.
760 # In release builds instead, static_libraries are preferred since they allow
761 # the linker to discard dead code.
762 # For the same reason, testonly targets will always be expanded to
763 # source_set in order to be sure that tests are present in the test binary.
764 template("rtc_library") {
766 if (defined(invoker.sources)) {
767 non_header_sources = filter_exclude(invoker.sources,
773 if (non_header_sources != []) {
778 # Header only libraries should use source_set as a static_library with no
779 # source files will cause issues with macOS libtool.
780 if (header_only || is_component_build ||
781 (defined(invoker.testonly) && invoker.testonly)) {
782 target_type = "source_set"
784 target_type = "static_library"
786 target(target_type, target_name) {
787 forward_variables_from(invoker,
792 "suppressed_configs",
795 forward_variables_from(invoker, [ "visibility" ])
796 if (!defined(visibility)) {
797 visibility = webrtc_default_visibility
800 # What's your poison?
801 if (defined(testonly) && testonly) {
802 assert(!defined(poisonous))
803 assert(!defined(allow_poison))
805 if (!defined(poisonous)) {
808 if (!defined(allow_poison)) {
811 if (!defined(assert_no_deps)) {
814 if (!defined(deps)) {
817 foreach(p, poisonous) {
818 deps += [ webrtc_root + ":poison_" + p ]
820 foreach(poison_type, all_poison_types) {
822 foreach(v, visibility) {
827 foreach(p, allow_poison + poisonous) {
828 if (p == poison_type) {
833 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
838 # Chromium should only depend on the WebRTC component in order to
839 # avoid to statically link WebRTC in a component build.
840 if (build_with_chromium) {
841 publicly_visible = false
842 foreach(v, visibility) {
844 publicly_visible = true
847 if (publicly_visible) {
849 visibility = webrtc_default_visibility
853 if (!defined(testonly) || !testonly) {
854 configs += rtc_prod_configs
857 configs += invoker.configs
858 configs += rtc_library_impl_config
859 configs -= rtc_remove_configs
860 configs -= invoker.suppressed_configs
862 rtc_common_inherited_config,
866 if (defined(testonly) && testonly) {
867 public_configs += [ absl_flags_config ]
869 if (defined(invoker.public_configs)) {
870 public_configs += invoker.public_configs
873 # If absl_deps is [], no action is needed. If not [], then it needs to be
874 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
875 # otherwise it just needs to be added to deps.
876 if (absl_deps != []) {
877 if (!defined(deps)) {
880 if (build_with_chromium) {
881 deps += [ "//third_party/abseil-cpp:absl" ]
889 template("rtc_executable") {
890 executable(target_name) {
891 forward_variables_from(invoker,
897 "suppressed_configs",
900 forward_variables_from(invoker, [ "visibility" ])
901 if (!defined(visibility)) {
902 visibility = webrtc_default_visibility
904 configs += invoker.configs
905 configs -= rtc_remove_configs
906 configs -= invoker.suppressed_configs
910 rtc_common_inherited_config,
914 if (defined(testonly) && testonly) {
915 public_configs += [ absl_flags_config ]
917 if (defined(invoker.public_configs)) {
918 public_configs += invoker.public_configs
922 # Give executables the default manifest on Windows (a no-op elsewhere).
923 "//build/win:default_exe_manifest",
929 template("rtc_shared_library") {
930 shared_library(target_name) {
931 forward_variables_from(invoker,
936 "suppressed_configs",
939 forward_variables_from(invoker, [ "visibility" ])
940 if (!defined(visibility)) {
941 visibility = webrtc_default_visibility
944 # What's your poison?
945 if (defined(testonly) && testonly) {
946 assert(!defined(poisonous))
947 assert(!defined(allow_poison))
949 if (!defined(poisonous)) {
952 if (!defined(allow_poison)) {
955 if (!defined(assert_no_deps)) {
958 if (!defined(deps)) {
961 foreach(p, poisonous) {
962 deps += [ webrtc_root + ":poison_" + p ]
964 foreach(poison_type, all_poison_types) {
966 foreach(v, visibility) {
971 foreach(p, allow_poison + poisonous) {
972 if (p == poison_type) {
977 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
982 configs += invoker.configs
983 configs -= rtc_remove_configs
984 configs -= invoker.suppressed_configs
986 rtc_common_inherited_config,
990 if (defined(testonly) && testonly) {
991 public_configs += [ absl_flags_config ]
993 if (defined(invoker.public_configs)) {
994 public_configs += invoker.public_configs
999 if (is_mac || is_ios) {
1000 template("apple_framework_bundle_with_umbrella_header") {
1001 forward_variables_from(invoker, [ "output_name" ])
1002 this_target_name = target_name
1003 umbrella_header_path =
1004 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
1005 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
1007 action_foreach("create_bracket_include_headers_$target_name") {
1008 script = "//tools_webrtc/apple/copy_framework_header.py"
1009 sources = invoker.sources
1010 output_name = invoker.output_name
1012 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1018 rebase_path(target_gen_dir, root_build_dir) +
1019 "/$output_name.framework/WebRTC/{{source_file_part}}",
1024 mac_framework_bundle(target_name) {
1025 forward_variables_from(invoker, "*", [ "configs" ])
1026 if (defined(invoker.configs)) {
1027 configs += invoker.configs
1030 framework_version = "A"
1031 framework_contents = [
1040 "@rpath/$output_name.framework/$output_name",
1044 ":copy_framework_headers_$this_target_name",
1045 ":copy_modulemap_$this_target_name",
1046 ":copy_umbrella_header_$this_target_name",
1047 ":create_bracket_include_headers_$this_target_name",
1048 ":modulemap_$this_target_name",
1049 ":umbrella_header_$this_target_name",
1054 ios_framework_bundle(target_name) {
1055 forward_variables_from(invoker,
1061 if (defined(invoker.configs)) {
1062 configs += invoker.configs
1064 public_headers = get_target_outputs(
1065 ":create_bracket_include_headers_$this_target_name")
1068 ":copy_umbrella_header_$this_target_name",
1069 ":create_bracket_include_headers_$this_target_name",
1074 if (is_mac || target_environment == "catalyst") {
1075 # Catalyst frameworks use the same layout as regular Mac frameworks.
1076 headers_dir = "Versions/A/Headers"
1078 headers_dir = "Headers"
1081 bundle_data("copy_framework_headers_$this_target_name") {
1082 sources = get_target_outputs(
1083 ":create_bracket_include_headers_$this_target_name")
1085 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
1086 deps = [ ":create_bracket_include_headers_$this_target_name" ]
1089 action("modulemap_$this_target_name") {
1090 script = "//tools_webrtc/ios/generate_modulemap.py"
1093 rebase_path(modulemap_path, root_build_dir),
1097 outputs = [ modulemap_path ]
1100 bundle_data("copy_modulemap_$this_target_name") {
1101 sources = [ modulemap_path ]
1102 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1103 deps = [ ":modulemap_$this_target_name" ]
1106 action("umbrella_header_$this_target_name") {
1107 sources = get_target_outputs(
1108 ":create_bracket_include_headers_$this_target_name")
1110 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1112 outputs = [ umbrella_header_path ]
1115 rebase_path(umbrella_header_path, root_build_dir),
1118 deps = [ ":create_bracket_include_headers_$this_target_name" ]
1121 copy("copy_umbrella_header_$target_name") {
1122 sources = [ umbrella_header_path ]
1124 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
1126 deps = [ ":umbrella_header_$target_name" ]
1131 if (is_android && !build_with_mozilla) {
1132 template("rtc_android_library") {
1133 android_library(target_name) {
1134 forward_variables_from(invoker,
1139 "suppressed_configs",
1143 errorprone_args = []
1145 # Treat warnings as errors.
1146 errorprone_args += [ "-Werror" ]
1148 # Add any arguments defined by the invoker.
1149 if (defined(invoker.errorprone_args)) {
1150 errorprone_args += invoker.errorprone_args
1153 if (!defined(deps)) {
1157 no_build_hooks = true
1158 not_needed([ "android_manifest" ])
1162 template("rtc_android_apk") {
1163 android_apk(target_name) {
1164 forward_variables_from(invoker,
1169 "suppressed_configs",
1173 # Treat warnings as errors.
1174 errorprone_args = []
1175 errorprone_args += [ "-Werror" ]
1177 if (!defined(deps)) {
1181 no_build_hooks = true
1185 template("rtc_instrumentation_test_apk") {
1186 instrumentation_test_apk(target_name) {
1187 forward_variables_from(invoker,
1192 "suppressed_configs",
1196 # Treat warnings as errors.
1197 errorprone_args = []
1198 errorprone_args += [ "-Werror" ]
1200 if (!defined(deps)) {
1204 no_build_hooks = true