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 # If set to true, C++ code will refer to the new JNI Generator symbols.
63 # If set to false the old ones will be used (to provide a nice update path).
64 rtc_jni_generator_legacy_symbols = false
66 # Setting this to true, will make RTC_DLOG() expand to log statements instead
67 # of being removed by the preprocessor.
68 # This is useful for example to be able to get RTC_DLOGs on a release build.
69 rtc_dlog_always_on = false
71 # Enables additional build targets that rely on
72 # //third_party/google_benchmarks.
73 rtc_enable_google_benchmarks = true
75 # Setting this to true will make RTC_OBJC_EXPORT expand to code that will
76 # manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported
77 # if C++ symbols are but setting this arg to true while keeping
78 # rtc_enable_symbol_export=false will only export RTC_OBJC_EXPORT
80 rtc_enable_objc_symbol_export = rtc_enable_symbol_export
82 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
83 # will tell the pre-processor to remove the default definition of symbols
84 # needed to use field_trial. In that case a new implementation needs to be
86 if (build_with_chromium) {
87 # When WebRTC is built as part of Chromium it should exclude the default
88 # implementation of field_trial unless it is building for NACL or
90 rtc_exclude_field_trial_default = !is_nacl && !is_castos && !is_cast_android
92 rtc_exclude_field_trial_default = false
95 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which
96 # will tell the pre-processor to remove the default definition of symbols
97 # needed to use metrics. In that case a new implementation needs to be
99 rtc_exclude_metrics_default = build_with_chromium
101 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which
102 # will tell the pre-processor to remove the default definition of the
103 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In
104 # that case a new implementation needs to be provided.
105 rtc_exclude_system_time = build_with_chromium || build_with_mozilla
107 # Setting this to false will require the API user to pass in their own
108 # SSLCertificateVerifier to verify the certificates presented from a
109 # TLS-TURN server. In return disabling this saves around 100kb in the binary.
110 rtc_builtin_ssl_root_certificates = true
112 # Include the iLBC audio codec?
113 rtc_include_ilbc = true
115 # Disable this to avoid building the Opus audio codec.
116 rtc_include_opus = true
118 # Enable this if the Opus version upon which WebRTC is built supports direct
119 # encoding of 120 ms packets.
120 rtc_opus_support_120ms_ptime = true
122 # Enable this to let the Opus audio codec change complexity on the fly.
123 rtc_opus_variable_complexity = false
125 # Used to specify an external Jsoncpp include path when not compiling the
126 # library that comes with WebRTC (i.e. rtc_build_json == 0).
127 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include"
129 # Used to specify an external OpenSSL include path when not compiling the
130 # library that comes with WebRTC (i.e. rtc_build_ssl == 0).
131 rtc_ssl_root = "unused"
133 # Enable when an external authentication mechanism is used for performing
134 # packet authentication for RTP packets instead of libsrtp.
135 rtc_enable_external_auth = build_with_chromium
137 # Selects whether debug dumps for the audio processing module
138 # should be generated.
139 apm_debug_dump = build_with_mozilla
141 # Selects whether the audio processing module should be excluded.
142 rtc_exclude_audio_processing_module = false
144 # Set this to true to enable BWE test logging.
145 rtc_enable_bwe_test_logging = false
147 # Set this to false to skip building examples.
148 rtc_build_examples = false
150 # Set this to false to skip building tools.
151 rtc_build_tools = false
153 # Set this to false to skip building code that requires X11.
154 rtc_use_x11 = use_x11
156 # Set this to use PipeWire on the Wayland display server.
157 # By default it's only enabled on desktop Linux (excludes ChromeOS) and
158 # only when using the sysroot as PipeWire is not available in older and
159 # supported Ubuntu and Debian distributions.
160 rtc_use_pipewire = is_linux && use_sysroot
162 # Set this to link PipeWire and required libraries directly instead of using the dlopen.
163 rtc_link_pipewire = false
165 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above
166 # and NDK r16 or above.
167 rtc_enable_android_aaudio = false
169 # Set to "func", "block", "edge" for coverage generation.
170 # At unit test runtime set UBSAN_OPTIONS="coverage=1".
171 # It is recommend to set include_examples=0.
172 # Use llvm's sancov -html-report for human readable reports.
173 # See http://clang.llvm.org/docs/SanitizerCoverage.html .
174 rtc_sanitize_coverage = ""
176 # Selects fixed-point code where possible.
177 rtc_prefer_fixed_point = false
178 if (target_cpu == "arm" || target_cpu == "arm64") {
179 rtc_prefer_fixed_point = true
182 # Determines whether NEON code will be built.
183 rtc_build_with_neon =
184 (target_cpu == "arm" && arm_use_neon) || target_cpu == "arm64"
186 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
187 # all platforms except Android and iOS. Because FFmpeg can be built
188 # with/without H.264 support, `ffmpeg_branding` has to separately be set to a
189 # value that includes H.264, for example "Chrome". If FFmpeg is built without
190 # H.264, compilation succeeds but `H264DecoderImpl` fails to initialize.
191 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING.
192 # http://www.openh264.org, https://www.ffmpeg.org/
194 # Enabling H264 when building with MSVC is currently not supported, see
195 # bugs.webrtc.org/9213#c13 for more info.
197 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang)
200 rtc_use_h265 = proprietary_codecs
202 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex.
203 rtc_use_absl_mutex = false
205 # By default, use normal platform audio support or dummy audio, but don't
206 # use file-based audio playout and record.
207 rtc_use_dummy_audio_file_devices = false
209 # When set to true, replace the audio output with a sinus tone at 440Hz.
210 # The ADM will ask for audio data from WebRTC but instead of reading real
211 # audio samples from NetEQ, a sinus tone will be generated and replace the
212 # real audio samples.
213 rtc_audio_device_plays_sinus_tone = false
216 # Build broadcast extension in AppRTCMobile for iOS. This results in the
217 # binary only running on iOS 11+, which is why it is disabled by default.
218 rtc_apprtcmobile_broadcast_extension = false
221 # Determines whether OpenGL is available on iOS.
222 rtc_ios_use_opengl_rendering = is_ios && target_environment != "catalyst"
224 # When set to false, builtin audio encoder/decoder factories and all the
225 # audio codecs they depend on will not be included in libwebrtc.{a|lib}
226 # (they will still be included in libjingle_peerconnection_so.so and
228 rtc_include_builtin_audio_codecs = true
230 # When set to true and in a standalone build, it will undefine UNICODE and
231 # _UNICODE (which are always defined globally by the Chromium Windows
233 # This is only needed for testing purposes, WebRTC wants to be sure it
234 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses
235 # wide character functions.
236 rtc_win_undef_unicode = false
238 # When set to true, a capturer implementation that uses the
239 # Windows.Graphics.Capture APIs will be available for use. This introduces a
240 # dependency on the Win 10 SDK v10.0.17763.0.
241 rtc_enable_win_wgc = is_win
243 # Includes the dav1d decoder in the internal decoder factory when set to true.
244 rtc_include_dav1d_in_internal_decoder_factory = true
246 # When enabled, a run-time check will make sure that all field trial keys have
247 # been registered in accordance with the field trial policy, see
248 # g3doc/field-trials.md. The value can be set to the following:
250 # "dcheck": RTC_DCHECKs that the field trial has been registered. RTC_DCHECK
251 # must be enabled separately.
253 # "warn": RTC_LOGs a message with LS_WARNING severity if the field trial
254 # hasn't been registered.
255 rtc_strict_field_trials = ""
257 # If different from "", symbols exported with RTC_OBJC_EXPORT will be prefixed
259 # See the definition of RTC_OBJC_TYPE_PREFIX in the code.
262 # Embedders can define dependencies needed by WebRTC. Dependencies can be
263 # configs or targets. This can be defined in their `.gn` file.
265 # In practise, this is use by Chromium: Targets from
266 # `//third_party/webrtc_overrides` are depending on Chrome's `//base`, but
267 # WebRTC does not declare its public dependencies. See webrtc:8603. Instead
268 # WebRTC is using a global common dependencies.
269 rtc_common_public_deps = [] # no-presubmit-check TODO(webrtc:8603)
272 if (!build_with_mozilla) {
273 import("//testing/test.gni")
276 # A second declare_args block, so that declarations within it can
277 # depend on the possibly overridden variables in the first
278 # declare_args block.
280 # Enables the use of protocol buffers for debug recordings.
281 rtc_enable_protobuf = !build_with_mozilla
283 # Set this to disable building with support for SCTP data channels.
284 rtc_enable_sctp = !build_with_mozilla
286 # Disable these to not build components which can be externally provided.
287 rtc_build_json = !build_with_mozilla
288 rtc_build_libsrtp = !build_with_mozilla
289 rtc_build_libvpx = !build_with_mozilla
290 rtc_libvpx_build_vp9 = true
291 rtc_build_opus = !build_with_mozilla
292 rtc_build_ssl = !build_with_mozilla
294 # Enable libevent task queues on platforms that support it.
295 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia ||
296 target_cpu == "wasm") {
297 rtc_enable_libevent = false
298 rtc_build_libevent = false
300 rtc_enable_libevent = true
301 rtc_build_libevent = !build_with_mozilla
304 # Excluded in Chromium since its prerequisites don't require Pulse Audio.
305 rtc_include_pulse_audio = !build_with_chromium
307 # Chromium uses its own IO handling, so the internal ADM is only built for
309 rtc_include_internal_audio_device = !build_with_chromium && !build_with_mozilla
311 # Set this to true to enable the avx2 support in webrtc.
312 # TODO: Make sure that AVX2 works also for non-clang compilers.
313 if (is_clang == true && (target_cpu == "x86" || target_cpu == "x64")) {
314 rtc_enable_avx2 = true
316 rtc_enable_avx2 = false
319 # Set this to true to build the unit tests.
320 # Disabled when building with Chromium or Mozilla.
321 rtc_include_tests = !build_with_chromium && !build_with_mozilla
323 # Set this to false to skip building code that also requires X11 extensions
324 # such as Xdamage, Xfixes.
325 rtc_use_x11_extensions = rtc_use_x11
327 # Set this to true to fully remove logging from WebRTC.
328 rtc_disable_logging = false
330 # Set this to true to disable trace events.
331 rtc_disable_trace_events = false
333 # Set this to true to disable detailed error message and logging for
335 rtc_disable_check_msg = false
337 # Set this to true to disable webrtc metrics.
338 rtc_disable_metrics = false
340 # Set this to true to exclude the transient suppressor in the audio processing
341 # module from the build.
342 rtc_exclude_transient_suppressor = false
346 # Enable the dcsctp backend for DataChannels and related unittests
347 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp
349 # Enable gRPC used for negotiation in multiprocess tests
350 rtc_enable_grpc = rtc_enable_protobuf && (is_linux || is_mac)
353 # Enable liboam only on non-mozilla builds.
354 enable_libaom = !build_with_mozilla
356 # Make it possible to provide custom locations for some libraries (move these
357 # up into declare_args should we need to actually use them for the GN build).
358 rtc_libvpx_dir = "//third_party/libvpx"
359 rtc_opus_dir = "//third_party/opus"
361 # Desktop capturer is supported only on Windows, OSX and Linux.
362 rtc_desktop_capture_supported =
363 (is_win && current_os != "winuwp") || is_mac || is_bsd ||
364 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
366 ###############################################################################
370 # Points to // in webrtc stand-alone or to //third_party/webrtc/ in
372 # We need absolute paths for all configs in templates as they are shared in
373 # different subdirectories.
374 webrtc_root = get_path_info(".", "abspath")
376 # Global configuration that should be applied to all WebRTC targets.
377 # You normally shouldn't need to include this in your target as it's
378 # automatically included when using the rtc_* templates.
379 # It sets defines, include paths and compilation warnings accordingly,
380 # both for WebRTC stand-alone builds and for the scenario when WebRTC
381 # native code is built as part of Chromium.
382 rtc_common_configs = [ webrtc_root + ":common_config" ]
384 if (is_mac || is_ios) {
385 if (filter_include(default_compiler_configs,
386 [ "//build/config/compiler:enable_arc" ]) == []) {
387 rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
391 # Global public configuration that should be applied to all WebRTC targets. You
392 # normally shouldn't need to include this in your target as it's automatically
393 # included when using the rtc_* templates. It set the defines, include paths and
394 # compilation warnings that should be propagated to dependents of the targets
395 # depending on the target having this config.
396 rtc_common_inherited_config = webrtc_root + ":common_inherited_config"
398 # Common configs to remove or add in all rtc targets.
399 rtc_remove_configs = []
400 if (!build_with_chromium && is_clang) {
401 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
403 rtc_add_configs = rtc_common_configs
404 rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ]
405 rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ]
407 set_defaults("rtc_test") {
408 configs = rtc_add_configs
409 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
410 suppressed_configs = []
413 set_defaults("rtc_library") {
414 configs = rtc_add_configs
415 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
416 suppressed_configs = []
420 set_defaults("rtc_source_set") {
421 configs = rtc_add_configs
422 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
423 suppressed_configs = []
427 set_defaults("rtc_static_library") {
428 configs = rtc_add_configs
429 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
430 suppressed_configs = []
434 set_defaults("rtc_executable") {
435 configs = rtc_add_configs
436 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
437 suppressed_configs = []
440 set_defaults("rtc_shared_library") {
441 configs = rtc_add_configs
442 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603)
443 suppressed_configs = []
446 webrtc_default_visibility = [ webrtc_root + "/*" ]
447 if (build_with_chromium) {
448 # Allow Chromium's WebRTC overrides targets to bypass the regular
449 # visibility restrictions.
450 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ]
455 # The general idea is that some targets declare that they contain some
456 # kind of poison, which makes it impossible for other targets to
457 # depend on them (even transitively) unless they declare themselves
458 # immune to that particular type of poison.
460 # Targets that *contain* poison of type foo should contain the line
462 # poisonous = [ "foo" ]
464 # and targets that *are immune but arent't themselves poisonous*
467 # allow_poison = [ "foo" ]
469 # This useful in cases where we have some large target or set of
470 # targets and want to ensure that most other targets do not
471 # transitively depend on them. For example, almost no high-level
472 # target should depend on the audio codecs, since we want WebRTC users
473 # to be able to inject any subset of them and actually end up with a
474 # binary that doesn't include the codecs they didn't inject.
476 # Test-only targets (`testonly` set to true) and non-public targets
477 # (`visibility` not containing "*") are automatically immune to all
480 # Here's the complete list of all types of poison. It must be kept in
481 # 1:1 correspondence with the set of //:poison_* targets.
484 # Encoders and decoders for specific audio codecs such as Opus and iSAC.
487 # Default echo detector implementation.
488 "default_echo_detector",
490 # Implementations of the utilities exposed through `Environment`.
491 # Most webrtc classes must use propagated `Environment`. Only few top-level
492 # classes are allowed to create `Environment` from individual utilities.
493 "environment_construction",
495 # Software video codecs (VP8 and VP9 through libvpx).
496 "software_video_codecs",
499 absl_include_config = "//third_party/abseil-cpp:absl_include_config"
500 absl_define_config = "//third_party/abseil-cpp:absl_define_config"
502 # Abseil Flags are testonly, so this config will only be applied to WebRTC targets
504 absl_flags_config = webrtc_root + ":absl_flags_configs"
506 # WebRTC wrapper of Chromium's test() template. This template just adds some
507 # WebRTC only configuration in order to avoid to duplicate it for every WebRTC
509 # The parameter `is_xctest` is different from the one in the Chromium's test()
510 # template (and it is not forwarded to it). In rtc_test(), the argument
511 # `is_xctest` is used to avoid to take dependencies that are not needed
512 # in case the test is a real XCTest (using the XCTest framework).
513 template("rtc_test") {
515 forward_variables_from(invoker,
521 "suppressed_configs",
525 # Always override to public because when target_os is Android the `test`
526 # template can override it to [ "*" ] and we want to avoid conditional
529 configs += invoker.configs
530 configs -= rtc_remove_configs
531 configs -= invoker.suppressed_configs
533 rtc_common_inherited_config,
538 if (defined(invoker.public_configs)) {
539 public_configs += invoker.public_configs
541 if (!build_with_chromium && is_android) {
542 android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
543 use_raw_android_executable = false
545 target_sdk_version = 23
547 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
548 webrtc_root + "test:native_test_java",
552 # Build //test:google_test_runner_objc when the test is not a real XCTest.
553 if (is_ios && rtc_include_tests) {
554 if (!defined(invoker.is_xctest) || !invoker.is_xctest) {
555 xctest_module_target = "//test:google_test_runner_objc"
559 # If absl_deps is [], no action is needed. If not [], then it needs to be
560 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
561 # otherwise it just needs to be added to deps.
562 if (defined(absl_deps) && absl_deps != []) {
563 if (!defined(deps)) {
566 if (build_with_chromium) {
567 deps += [ "//third_party/abseil-cpp:absl" ]
573 # TODO(crbug.com/webrtc/13556): Adding the .app folder in the runtime_deps
574 # shoulnd't be necessary. this code should be removed and the same solution
575 # as Chromium should be used.
577 if (!defined(invoker.data)) {
580 data += [ "${root_out_dir}/${target_name}.app" ]
585 template("rtc_source_set") {
586 source_set(target_name) {
587 forward_variables_from(invoker,
592 "suppressed_configs",
595 forward_variables_from(invoker, [ "visibility" ])
596 if (!defined(visibility)) {
597 visibility = webrtc_default_visibility
600 # What's your poison?
601 if (defined(testonly) && testonly) {
602 assert(!defined(poisonous))
603 assert(!defined(allow_poison))
605 if (!defined(poisonous)) {
608 if (!defined(allow_poison)) {
611 if (!defined(assert_no_deps)) {
614 if (!defined(deps)) {
617 foreach(p, poisonous) {
618 deps += [ webrtc_root + ":poison_" + p ]
620 foreach(poison_type, all_poison_types) {
622 foreach(v, visibility) {
627 foreach(p, allow_poison + poisonous) {
628 if (p == poison_type) {
633 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
638 # Chromium should only depend on the WebRTC component in order to
639 # avoid to statically link WebRTC in a component build.
640 if (build_with_chromium) {
641 publicly_visible = false
642 foreach(v, visibility) {
644 publicly_visible = true
647 if (publicly_visible) {
649 visibility = webrtc_default_visibility
653 if (!defined(testonly) || !testonly) {
654 configs += rtc_prod_configs
657 configs += invoker.configs
658 configs += rtc_library_impl_config
659 configs -= rtc_remove_configs
660 configs -= invoker.suppressed_configs
662 rtc_common_inherited_config,
666 if (defined(testonly) && testonly) {
667 public_configs += [ absl_flags_config ]
669 if (defined(invoker.public_configs)) {
670 public_configs += invoker.public_configs
673 # If absl_deps is [], no action is needed. If not [], then it needs to be
674 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
675 # otherwise it just needs to be added to deps.
676 if (absl_deps != []) {
677 if (!defined(deps)) {
680 if (build_with_chromium) {
681 deps += [ "//third_party/abseil-cpp:absl" ]
689 template("rtc_static_library") {
690 static_library(target_name) {
691 forward_variables_from(invoker,
696 "suppressed_configs",
699 forward_variables_from(invoker, [ "visibility" ])
700 if (!defined(visibility)) {
701 visibility = webrtc_default_visibility
704 # What's your poison?
705 if (defined(testonly) && testonly) {
706 assert(!defined(poisonous))
707 assert(!defined(allow_poison))
709 if (!defined(poisonous)) {
712 if (!defined(allow_poison)) {
715 if (!defined(assert_no_deps)) {
718 if (!defined(deps)) {
721 foreach(p, poisonous) {
722 deps += [ webrtc_root + ":poison_" + p ]
724 foreach(poison_type, all_poison_types) {
726 foreach(v, visibility) {
731 foreach(p, allow_poison + poisonous) {
732 if (p == poison_type) {
737 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
742 if (!defined(testonly) || !testonly) {
743 configs += rtc_prod_configs
746 configs += invoker.configs
747 configs += rtc_library_impl_config
748 configs -= rtc_remove_configs
749 configs -= invoker.suppressed_configs
751 rtc_common_inherited_config,
755 if (defined(testonly) && testonly) {
756 public_configs += [ absl_flags_config ]
758 if (defined(invoker.public_configs)) {
759 public_configs += invoker.public_configs
762 # If absl_deps is [], no action is needed. If not [], then it needs to be
763 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
764 # otherwise it just needs to be added to deps.
765 if (absl_deps != []) {
766 if (!defined(deps)) {
769 if (build_with_chromium) {
770 deps += [ "//third_party/abseil-cpp:absl" ]
778 # This template automatically switches the target type between source_set
779 # and static_library.
781 # This should be the default target type for all the WebRTC targets.
784 # Since all files in a source_set are linked into a final binary, while files
785 # in a static library are only linked in if at least one symbol in them is
786 # referenced, in component builds source_sets are easy to deal with because
787 # all their object files are passed to the linker to create a shared library.
788 # In release builds instead, static_libraries are preferred since they allow
789 # the linker to discard dead code.
790 # For the same reason, testonly targets will always be expanded to
791 # source_set in order to be sure that tests are present in the test binary.
792 template("rtc_library") {
794 if (defined(invoker.sources)) {
795 non_header_sources = filter_exclude(invoker.sources,
801 if (non_header_sources != []) {
806 # Header only libraries should use source_set as a static_library with no
807 # source files will cause issues with macOS libtool.
808 if (header_only || is_component_build ||
809 (defined(invoker.testonly) && invoker.testonly)) {
810 target_type = "source_set"
812 target_type = "static_library"
814 target(target_type, target_name) {
815 forward_variables_from(invoker,
820 "suppressed_configs",
823 forward_variables_from(invoker, [ "visibility" ])
824 if (!defined(visibility)) {
825 visibility = webrtc_default_visibility
828 # What's your poison?
829 if (defined(testonly) && testonly) {
830 assert(!defined(poisonous))
831 assert(!defined(allow_poison))
833 if (!defined(poisonous)) {
836 if (!defined(allow_poison)) {
839 if (!defined(assert_no_deps)) {
842 if (!defined(deps)) {
845 foreach(p, poisonous) {
846 deps += [ webrtc_root + ":poison_" + p ]
848 foreach(poison_type, all_poison_types) {
850 foreach(v, visibility) {
855 foreach(p, allow_poison + poisonous) {
856 if (p == poison_type) {
861 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
866 # Chromium should only depend on the WebRTC component in order to
867 # avoid to statically link WebRTC in a component build.
868 if (build_with_chromium) {
869 publicly_visible = false
870 foreach(v, visibility) {
872 publicly_visible = true
875 if (publicly_visible) {
877 visibility = webrtc_default_visibility
881 if (!defined(testonly) || !testonly) {
882 configs += rtc_prod_configs
885 configs += invoker.configs
886 configs += rtc_library_impl_config
887 configs -= rtc_remove_configs
888 configs -= invoker.suppressed_configs
890 rtc_common_inherited_config,
894 if (defined(testonly) && testonly) {
895 public_configs += [ absl_flags_config ]
897 if (defined(invoker.public_configs)) {
898 public_configs += invoker.public_configs
901 # If absl_deps is [], no action is needed. If not [], then it needs to be
902 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true
903 # otherwise it just needs to be added to deps.
904 if (absl_deps != []) {
905 if (!defined(deps)) {
908 if (build_with_chromium) {
909 deps += [ "//third_party/abseil-cpp:absl" ]
917 template("rtc_executable") {
918 executable(target_name) {
919 forward_variables_from(invoker,
925 "suppressed_configs",
928 forward_variables_from(invoker, [ "visibility" ])
929 if (!defined(visibility)) {
930 visibility = webrtc_default_visibility
932 configs += invoker.configs
933 configs -= rtc_remove_configs
934 configs -= invoker.suppressed_configs
938 rtc_common_inherited_config,
942 if (defined(testonly) && testonly) {
943 public_configs += [ absl_flags_config ]
945 if (defined(invoker.public_configs)) {
946 public_configs += invoker.public_configs
950 # Give executables the default manifest on Windows (a no-op elsewhere).
951 "//build/win:default_exe_manifest",
957 template("rtc_shared_library") {
958 shared_library(target_name) {
959 forward_variables_from(invoker,
964 "suppressed_configs",
967 forward_variables_from(invoker, [ "visibility" ])
968 if (!defined(visibility)) {
969 visibility = webrtc_default_visibility
972 # What's your poison?
973 if (defined(testonly) && testonly) {
974 assert(!defined(poisonous))
975 assert(!defined(allow_poison))
977 if (!defined(poisonous)) {
980 if (!defined(allow_poison)) {
983 if (!defined(assert_no_deps)) {
986 if (!defined(deps)) {
989 foreach(p, poisonous) {
990 deps += [ webrtc_root + ":poison_" + p ]
992 foreach(poison_type, all_poison_types) {
994 foreach(v, visibility) {
999 foreach(p, allow_poison + poisonous) {
1000 if (p == poison_type) {
1005 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ]
1010 configs += invoker.configs
1011 configs -= rtc_remove_configs
1012 configs -= invoker.suppressed_configs
1014 rtc_common_inherited_config,
1015 absl_include_config,
1018 if (defined(testonly) && testonly) {
1019 public_configs += [ absl_flags_config ]
1021 if (defined(invoker.public_configs)) {
1022 public_configs += invoker.public_configs
1027 if (is_mac || is_ios) {
1028 template("apple_framework_bundle_with_umbrella_header") {
1029 forward_variables_from(invoker, [ "output_name" ])
1030 this_target_name = target_name
1031 umbrella_header_path =
1032 "$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
1033 modulemap_path = "$target_gen_dir/Modules/module.modulemap"
1035 action_foreach("create_bracket_include_headers_$target_name") {
1036 script = "//tools_webrtc/apple/copy_framework_header.py"
1037 sources = invoker.sources
1038 output_name = invoker.output_name
1040 "$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
1046 rebase_path(target_gen_dir, root_build_dir) +
1047 "/$output_name.framework/WebRTC/{{source_file_part}}",
1052 mac_framework_bundle(target_name) {
1053 forward_variables_from(invoker, "*", [ "configs" ])
1054 if (defined(invoker.configs)) {
1055 configs += invoker.configs
1058 framework_version = "A"
1059 framework_contents = [
1068 "@rpath/$output_name.framework/$output_name",
1072 ":copy_framework_headers_$this_target_name",
1073 ":copy_modulemap_$this_target_name",
1074 ":copy_umbrella_header_$this_target_name",
1075 ":create_bracket_include_headers_$this_target_name",
1076 ":modulemap_$this_target_name",
1077 ":umbrella_header_$this_target_name",
1082 ios_framework_bundle(target_name) {
1083 forward_variables_from(invoker,
1089 if (defined(invoker.configs)) {
1090 configs += invoker.configs
1092 public_headers = get_target_outputs(
1093 ":create_bracket_include_headers_$this_target_name")
1096 ":copy_umbrella_header_$this_target_name",
1097 ":create_bracket_include_headers_$this_target_name",
1102 if (is_mac || target_environment == "catalyst") {
1103 # Catalyst frameworks use the same layout as regular Mac frameworks.
1104 headers_dir = "Versions/A/Headers"
1106 headers_dir = "Headers"
1109 bundle_data("copy_framework_headers_$this_target_name") {
1110 sources = get_target_outputs(
1111 ":create_bracket_include_headers_$this_target_name")
1113 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ]
1114 deps = [ ":create_bracket_include_headers_$this_target_name" ]
1117 action("modulemap_$this_target_name") {
1118 script = "//tools_webrtc/ios/generate_modulemap.py"
1121 rebase_path(modulemap_path, root_build_dir),
1125 outputs = [ modulemap_path ]
1128 bundle_data("copy_modulemap_$this_target_name") {
1129 sources = [ modulemap_path ]
1130 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ]
1131 deps = [ ":modulemap_$this_target_name" ]
1134 action("umbrella_header_$this_target_name") {
1135 sources = get_target_outputs(
1136 ":create_bracket_include_headers_$this_target_name")
1138 script = "//tools_webrtc/ios/generate_umbrella_header.py"
1140 outputs = [ umbrella_header_path ]
1143 rebase_path(umbrella_header_path, root_build_dir),
1146 deps = [ ":create_bracket_include_headers_$this_target_name" ]
1149 copy("copy_umbrella_header_$target_name") {
1150 sources = [ umbrella_header_path ]
1152 [ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
1154 deps = [ ":umbrella_header_$target_name" ]
1159 if (is_android && !build_with_mozilla) {
1160 template("rtc_android_library") {
1161 android_library(target_name) {
1162 forward_variables_from(invoker,
1167 "suppressed_configs",
1171 errorprone_args = []
1173 # Treat warnings as errors.
1174 errorprone_args += [ "-Werror" ]
1176 # Add any arguments defined by the invoker.
1177 if (defined(invoker.errorprone_args)) {
1178 errorprone_args += invoker.errorprone_args
1181 if (!defined(deps)) {
1185 no_build_hooks = true
1186 not_needed([ "android_manifest" ])
1190 template("rtc_android_apk") {
1191 android_apk(target_name) {
1192 forward_variables_from(invoker,
1197 "suppressed_configs",
1201 # Treat warnings as errors.
1202 errorprone_args = []
1203 errorprone_args += [ "-Werror" ]
1205 if (!defined(deps)) {
1209 no_build_hooks = true
1213 template("rtc_instrumentation_test_apk") {
1214 instrumentation_test_apk(target_name) {
1215 forward_variables_from(invoker,
1220 "suppressed_configs",
1224 # Treat warnings as errors.
1225 errorprone_args = []
1226 errorprone_args += [ "-Werror" ]
1228 if (!defined(deps)) {
1232 no_build_hooks = true