1# 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. 8import("//build/config/arm.gni") 9import("//build/config/features.gni") 10import("//build/config/mips.gni") 11import("//build/config/sanitizers/sanitizers.gni") 12import("//build/config/sysroot.gni") 13import("//build/config/ui.gni") 14import("//build_overrides/build.gni") 15 16if (!build_with_chromium && is_component_build) { 17 print("The Gn argument `is_component_build` is currently " + 18 "ignored for WebRTC builds.") 19 print("Component builds are supported by Chromium and the argument " + 20 "`is_component_build` makes it possible to create shared libraries " + 21 "instead of static libraries.") 22 print("If an app depends on WebRTC it makes sense to just depend on the " + 23 "WebRTC static library, so there is no difference between " + 24 "`is_component_build=true` and `is_component_build=false`.") 25 print( 26 "More info about component builds at: " + "https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md") 27 assert(!is_component_build, "Component builds are not supported in WebRTC.") 28} 29 30if (is_ios) { 31 import("//build/config/ios/rules.gni") 32} 33 34if (is_mac) { 35 import("//build/config/mac/rules.gni") 36} 37 38declare_args() { 39 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h) 40 # expand to code that will manage symbols visibility. 41 rtc_enable_symbol_export = false 42 43 # Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which 44 # will tell the pre-processor to remove the default definition of symbols 45 # needed to use field_trial. In that case a new implementation needs to be 46 # provided. 47 if (build_with_chromium) { 48 # When WebRTC is built as part of Chromium it should exclude the default 49 # implementation of field_trial unless it is building for NACL or 50 # Chromecast. 51 rtc_exclude_field_trial_default = !is_nacl && !is_chromecast 52 } else { 53 rtc_exclude_field_trial_default = false 54 } 55 56 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which 57 # will tell the pre-processor to remove the default definition of symbols 58 # needed to use metrics. In that case a new implementation needs to be 59 # provided. 60 rtc_exclude_metrics_default = build_with_chromium 61 62 # Setting this to false will require the API user to pass in their own 63 # SSLCertificateVerifier to verify the certificates presented from a 64 # TLS-TURN server. In return disabling this saves around 100kb in the binary. 65 rtc_builtin_ssl_root_certificates = true 66 67 # Include the iLBC audio codec? 68 rtc_include_ilbc = true 69 70 # Disable this to avoid building the Opus audio codec. 71 rtc_include_opus = true 72 73 # Enable this if the Opus version upon which WebRTC is built supports direct 74 # encoding of 120 ms packets. 75 rtc_opus_support_120ms_ptime = true 76 77 # Enable this to let the Opus audio codec change complexity on the fly. 78 rtc_opus_variable_complexity = false 79 80 # Used to specify an external Jsoncpp include path when not compiling the 81 # library that comes with WebRTC (i.e. rtc_build_json == 0). 82 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include" 83 84 # Used to specify an external OpenSSL include path when not compiling the 85 # library that comes with WebRTC (i.e. rtc_build_ssl == 0). 86 rtc_ssl_root = "" 87 88 # Selects fixed-point code where possible. 89 rtc_prefer_fixed_point = false 90 91 # Enable when an external authentication mechanism is used for performing 92 # packet authentication for RTP packets instead of libsrtp. 93 rtc_enable_external_auth = build_with_chromium 94 95 # Selects whether debug dumps for the audio processing module 96 # should be generated. 97 apm_debug_dump = false 98 99 # Selects whether the audio processing module should be excluded. 100 rtc_exclude_audio_processing_module = false 101 102 # Set this to true to enable BWE test logging. 103 rtc_enable_bwe_test_logging = false 104 105 # Set this to false to skip building examples. 106 rtc_build_examples = true 107 108 # Set this to false to skip building tools. 109 rtc_build_tools = true 110 111 # Set this to false to skip building code that requires X11. 112 rtc_use_x11 = use_x11 113 114 # Set this to use PipeWire on the Wayland display server. 115 # By default it's only enabled on desktop Linux (excludes ChromeOS) and 116 # only when using the sysroot as PipeWire is not available in older and 117 # supported Ubuntu and Debian distributions. 118 rtc_use_pipewire = is_desktop_linux && use_sysroot 119 120 # Set this to link PipeWire directly instead of using the dlopen. 121 rtc_link_pipewire = false 122 123 # Enable to use the Mozilla internal settings. 124 build_with_mozilla = false 125 126 # Enable use of Android AAudio which requires Android SDK 26 or above and 127 # NDK r16 or above. 128 rtc_enable_android_aaudio = false 129 130 # Set to "func", "block", "edge" for coverage generation. 131 # At unit test runtime set UBSAN_OPTIONS="coverage=1". 132 # It is recommend to set include_examples=0. 133 # Use llvm's sancov -html-report for human readable reports. 134 # See http://clang.llvm.org/docs/SanitizerCoverage.html . 135 rtc_sanitize_coverage = "" 136 137 if (current_cpu == "arm" || current_cpu == "arm64") { 138 rtc_prefer_fixed_point = true 139 } 140 141 # Determines whether NEON code will be built. 142 rtc_build_with_neon = 143 (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64" 144 145 # Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on 146 # all platforms except Android and iOS. Because FFmpeg can be built 147 # with/without H.264 support, |ffmpeg_branding| has to separately be set to a 148 # value that includes H.264, for example "Chrome". If FFmpeg is built without 149 # H.264, compilation succeeds but |H264DecoderImpl| fails to initialize. 150 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING. 151 # http://www.openh264.org, https://www.ffmpeg.org/ 152 # 153 # Enabling H264 when building with MSVC is currently not supported, see 154 # bugs.webrtc.org/9213#c13 for more info. 155 rtc_use_h264 = 156 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang) 157 158 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex. 159 rtc_use_absl_mutex = false 160 161 # By default, use normal platform audio support or dummy audio, but don't 162 # use file-based audio playout and record. 163 rtc_use_dummy_audio_file_devices = false 164 165 # When set to true, replace the audio output with a sinus tone at 440Hz. 166 # The ADM will ask for audio data from WebRTC but instead of reading real 167 # audio samples from NetEQ, a sinus tone will be generated and replace the 168 # real audio samples. 169 rtc_audio_device_plays_sinus_tone = false 170 171 if (is_ios) { 172 # Build broadcast extension in AppRTCMobile for iOS. This results in the 173 # binary only running on iOS 11+, which is why it is disabled by default. 174 rtc_apprtcmobile_broadcast_extension = false 175 } 176 177 # Determines whether Metal is available on iOS/macOS. 178 rtc_use_metal_rendering = is_mac || (is_ios && current_cpu == "arm64") 179 180 # When set to false, builtin audio encoder/decoder factories and all the 181 # audio codecs they depend on will not be included in libwebrtc.{a|lib} 182 # (they will still be included in libjingle_peerconnection_so.so and 183 # WebRTC.framework) 184 rtc_include_builtin_audio_codecs = true 185 186 # When set to false, builtin video encoder/decoder factories and all the 187 # video codecs they depends on will not be included in libwebrtc.{a|lib} 188 # (they will still be included in libjingle_peerconnection_so.so and 189 # WebRTC.framework) 190 rtc_include_builtin_video_codecs = true 191 192 # When set to true and in a standalone build, it will undefine UNICODE and 193 # _UNICODE (which are always defined globally by the Chromium Windows 194 # toolchain). 195 # This is only needed for testing purposes, WebRTC wants to be sure it 196 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses 197 # wide character functions. 198 rtc_win_undef_unicode = false 199} 200 201if (!build_with_mozilla) { 202 import("//testing/test.gni") 203} 204 205# A second declare_args block, so that declarations within it can 206# depend on the possibly overridden variables in the first 207# declare_args block. 208declare_args() { 209 # Enables the use of protocol buffers for debug recordings. 210 rtc_enable_protobuf = !build_with_mozilla 211 212 # Set this to disable building with support for SCTP data channels. 213 rtc_enable_sctp = !build_with_mozilla 214 215 # Disable these to not build components which can be externally provided. 216 rtc_build_json = !build_with_mozilla 217 rtc_build_libsrtp = !build_with_mozilla 218 rtc_build_libvpx = !build_with_mozilla 219 rtc_libvpx_build_vp9 = !build_with_mozilla 220 rtc_build_opus = !build_with_mozilla 221 rtc_build_ssl = !build_with_mozilla 222 rtc_build_usrsctp = !build_with_mozilla 223 224 # Enable libevent task queues on platforms that support it. 225 if (is_win || is_mac || is_ios || is_nacl || is_fuchsia || 226 target_cpu == "wasm") { 227 rtc_enable_libevent = false 228 rtc_build_libevent = false 229 } else { 230 rtc_enable_libevent = true 231 rtc_build_libevent = !build_with_mozilla 232 } 233 234 # Build sources requiring GTK. NOTICE: This is not present in Chrome OS 235 # build environments, even if available for Chromium builds. 236 rtc_use_gtk = !build_with_chromium && !build_with_mozilla 237 238 # Excluded in Chromium since its prerequisites don't require Pulse Audio. 239 rtc_include_pulse_audio = !build_with_chromium 240 241 # Chromium uses its own IO handling, so the internal ADM is only built for 242 # standalone WebRTC. 243 rtc_include_internal_audio_device = !build_with_chromium 244 245 # Include tests in standalone checkout. 246 rtc_include_tests = !build_with_chromium && !build_with_mozilla 247 248 # Set this to false to skip building code that also requires X11 extensions 249 # such as Xdamage, Xfixes. 250 rtc_use_x11_extensions = rtc_use_x11 251 252 # Set this to true to fully remove logging from WebRTC. 253 rtc_disable_logging = false 254 255 # Set this to true to disable trace events. 256 rtc_disable_trace_events = false 257 258 # Set this to true to disable detailed error message and logging for 259 # RTC_CHECKs. 260 rtc_disable_check_msg = false 261 262 # Set this to true to disable webrtc metrics. 263 rtc_disable_metrics = false 264 265 # Set this to true to exclude the transient suppressor in the audio processing 266 # module from the build. 267 rtc_exclude_transient_suppressor = false 268} 269 270# Make it possible to provide custom locations for some libraries (move these 271# up into declare_args should we need to actually use them for the GN build). 272rtc_libvpx_dir = "//third_party/libvpx" 273rtc_opus_dir = "//third_party/opus" 274 275# Desktop capturer is supported only on Windows, OSX and Linux. 276rtc_desktop_capture_supported = 277 (is_win && current_os != "winuwp") || is_mac || 278 (is_linux && (rtc_use_x11_extensions || rtc_use_pipewire)) 279 280############################################################################### 281# Templates 282# 283 284# Points to // in webrtc stand-alone or to //third_party/webrtc/ in 285# chromium. 286# We need absolute paths for all configs in templates as they are shared in 287# different subdirectories. 288webrtc_root = get_path_info(".", "abspath") 289 290# Global configuration that should be applied to all WebRTC targets. 291# You normally shouldn't need to include this in your target as it's 292# automatically included when using the rtc_* templates. 293# It sets defines, include paths and compilation warnings accordingly, 294# both for WebRTC stand-alone builds and for the scenario when WebRTC 295# native code is built as part of Chromium. 296rtc_common_configs = [ 297 webrtc_root + ":common_config", 298 "//build/config/compiler:no_size_t_to_int_warning", 299] 300 301if (is_mac || is_ios) { 302 rtc_common_configs += [ "//build/config/compiler:enable_arc" ] 303} 304 305# Global public configuration that should be applied to all WebRTC targets. You 306# normally shouldn't need to include this in your target as it's automatically 307# included when using the rtc_* templates. It set the defines, include paths and 308# compilation warnings that should be propagated to dependents of the targets 309# depending on the target having this config. 310rtc_common_inherited_config = webrtc_root + ":common_inherited_config" 311 312# Common configs to remove or add in all rtc targets. 313rtc_remove_configs = [] 314if (!build_with_chromium && is_clang) { 315 rtc_remove_configs += [ "//build/config/clang:find_bad_constructs" ] 316} 317rtc_add_configs = rtc_common_configs 318rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ] 319rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ] 320 321set_defaults("rtc_test") { 322 configs = rtc_add_configs 323 suppressed_configs = [] 324} 325 326set_defaults("rtc_library") { 327 configs = rtc_add_configs 328 suppressed_configs = [] 329 absl_deps = [] 330} 331 332set_defaults("rtc_source_set") { 333 configs = rtc_add_configs 334 suppressed_configs = [] 335 absl_deps = [] 336} 337 338set_defaults("rtc_static_library") { 339 configs = rtc_add_configs 340 suppressed_configs = [] 341 absl_deps = [] 342} 343 344set_defaults("rtc_executable") { 345 configs = rtc_add_configs 346 suppressed_configs = [] 347} 348 349set_defaults("rtc_shared_library") { 350 configs = rtc_add_configs 351 suppressed_configs = [] 352} 353 354webrtc_default_visibility = [ webrtc_root + "/*" ] 355if (build_with_chromium) { 356 # Allow Chromium's WebRTC overrides targets to bypass the regular 357 # visibility restrictions. 358 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ] 359} 360 361# ---- Poisons ---- 362# 363# The general idea is that some targets declare that they contain some 364# kind of poison, which makes it impossible for other targets to 365# depend on them (even transitively) unless they declare themselves 366# immune to that particular type of poison. 367# 368# Targets that *contain* poison of type foo should contain the line 369# 370# poisonous = [ "foo" ] 371# 372# and targets that *are immune but arent't themselves poisonous* 373# should contain 374# 375# allow_poison = [ "foo" ] 376# 377# This useful in cases where we have some large target or set of 378# targets and want to ensure that most other targets do not 379# transitively depend on them. For example, almost no high-level 380# target should depend on the audio codecs, since we want WebRTC users 381# to be able to inject any subset of them and actually end up with a 382# binary that doesn't include the codecs they didn't inject. 383# 384# Test-only targets (`testonly` set to true) and non-public targets 385# (`visibility` not containing "*") are automatically immune to all 386# types of poison. 387# 388# Here's the complete list of all types of poison. It must be kept in 389# 1:1 correspondence with the set of //:poison_* targets. 390# 391all_poison_types = [ 392 # Encoders and decoders for specific audio codecs such as Opus and iSAC. 393 "audio_codecs", 394 395 # Default task queue implementation. 396 "default_task_queue", 397 398 # JSON parsing should not be needed in the "slim and modular" WebRTC. 399 "rtc_json", 400 401 # Software video codecs (VP8 and VP9 through libvpx). 402 "software_video_codecs", 403] 404 405absl_include_config = "//third_party/abseil-cpp:absl_include_config" 406absl_define_config = "//third_party/abseil-cpp:absl_define_config" 407 408# Abseil Flags are testonly, so this config will only be applied to WebRTC targets 409# that are testonly. 410absl_flags_config = webrtc_root + ":absl_flags_configs" 411 412template("rtc_test") { 413 test(target_name) { 414 forward_variables_from(invoker, 415 "*", 416 [ 417 "configs", 418 "public_configs", 419 "suppressed_configs", 420 "visibility", 421 ]) 422 423 # Always override to public because when target_os is Android the `test` 424 # template can override it to [ "*" ] and we want to avoid conditional 425 # visibility. 426 visibility = [ "*" ] 427 configs += invoker.configs 428 configs -= rtc_remove_configs 429 configs -= invoker.suppressed_configs 430 public_configs = [ 431 rtc_common_inherited_config, 432 absl_include_config, 433 absl_define_config, 434 absl_flags_config, 435 ] 436 if (defined(invoker.public_configs)) { 437 public_configs += invoker.public_configs 438 } 439 if (!build_with_chromium && is_android) { 440 android_manifest = webrtc_root + "test/android/AndroidManifest.xml" 441 min_sdk_version = 21 442 target_sdk_version = 23 443 deps += [ webrtc_root + "test:native_test_java" ] 444 } 445 } 446} 447 448template("rtc_source_set") { 449 source_set(target_name) { 450 forward_variables_from(invoker, 451 "*", 452 [ 453 "configs", 454 "public_configs", 455 "suppressed_configs", 456 "visibility", 457 ]) 458 forward_variables_from(invoker, [ "visibility" ]) 459 if (!defined(visibility)) { 460 visibility = webrtc_default_visibility 461 } 462 463 # What's your poison? 464 if (defined(testonly) && testonly) { 465 assert(!defined(poisonous)) 466 assert(!defined(allow_poison)) 467 } else { 468 if (!defined(poisonous)) { 469 poisonous = [] 470 } 471 if (!defined(allow_poison)) { 472 allow_poison = [] 473 } 474 if (!defined(assert_no_deps)) { 475 assert_no_deps = [] 476 } 477 if (!defined(deps)) { 478 deps = [] 479 } 480 foreach(p, poisonous) { 481 deps += [ webrtc_root + ":poison_" + p ] 482 } 483 foreach(poison_type, all_poison_types) { 484 allow_dep = true 485 foreach(v, visibility) { 486 if (v == "*") { 487 allow_dep = false 488 } 489 } 490 foreach(p, allow_poison + poisonous) { 491 if (p == poison_type) { 492 allow_dep = true 493 } 494 } 495 if (!allow_dep) { 496 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] 497 } 498 } 499 } 500 501 # Chromium should only depend on the WebRTC component in order to 502 # avoid to statically link WebRTC in a component build. 503 if (build_with_chromium) { 504 publicly_visible = false 505 foreach(v, visibility) { 506 if (v == "*") { 507 publicly_visible = true 508 } 509 } 510 if (publicly_visible) { 511 visibility = [] 512 visibility = webrtc_default_visibility 513 } 514 } 515 516 if (!defined(testonly) || !testonly) { 517 configs += rtc_prod_configs 518 } 519 520 configs += invoker.configs 521 configs += rtc_library_impl_config 522 configs -= rtc_remove_configs 523 configs -= invoker.suppressed_configs 524 public_configs = [ 525 rtc_common_inherited_config, 526 absl_include_config, 527 absl_define_config, 528 ] 529 if (defined(testonly) && testonly) { 530 public_configs += [ absl_flags_config ] 531 } 532 if (defined(invoker.public_configs)) { 533 public_configs += invoker.public_configs 534 } 535 536 # If absl_deps is [], no action is needed. If not [], then it needs to be 537 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true 538 # otherwise it just needs to be added to deps. 539 if (absl_deps != []) { 540 if (!defined(deps)) { 541 deps = [] 542 } 543 if (build_with_chromium) { 544 deps += [ "//third_party/abseil-cpp:absl" ] 545 } else { 546 deps += absl_deps 547 } 548 } 549 } 550} 551 552template("rtc_static_library") { 553 static_library(target_name) { 554 forward_variables_from(invoker, 555 "*", 556 [ 557 "configs", 558 "public_configs", 559 "suppressed_configs", 560 "visibility", 561 ]) 562 forward_variables_from(invoker, [ "visibility" ]) 563 if (!defined(visibility)) { 564 visibility = webrtc_default_visibility 565 } 566 567 # What's your poison? 568 if (defined(testonly) && testonly) { 569 assert(!defined(poisonous)) 570 assert(!defined(allow_poison)) 571 } else { 572 if (!defined(poisonous)) { 573 poisonous = [] 574 } 575 if (!defined(allow_poison)) { 576 allow_poison = [] 577 } 578 if (!defined(assert_no_deps)) { 579 assert_no_deps = [] 580 } 581 if (!defined(deps)) { 582 deps = [] 583 } 584 foreach(p, poisonous) { 585 deps += [ webrtc_root + ":poison_" + p ] 586 } 587 foreach(poison_type, all_poison_types) { 588 allow_dep = true 589 foreach(v, visibility) { 590 if (v == "*") { 591 allow_dep = false 592 } 593 } 594 foreach(p, allow_poison + poisonous) { 595 if (p == poison_type) { 596 allow_dep = true 597 } 598 } 599 if (!allow_dep) { 600 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] 601 } 602 } 603 } 604 605 if (!defined(testonly) || !testonly) { 606 configs += rtc_prod_configs 607 } 608 609 configs += invoker.configs 610 configs += rtc_library_impl_config 611 configs -= rtc_remove_configs 612 configs -= invoker.suppressed_configs 613 public_configs = [ 614 rtc_common_inherited_config, 615 absl_include_config, 616 absl_define_config, 617 ] 618 if (defined(testonly) && testonly) { 619 public_configs += [ absl_flags_config ] 620 } 621 if (defined(invoker.public_configs)) { 622 public_configs += invoker.public_configs 623 } 624 625 # If absl_deps is [], no action is needed. If not [], then it needs to be 626 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true 627 # otherwise it just needs to be added to deps. 628 if (absl_deps != []) { 629 if (!defined(deps)) { 630 deps = [] 631 } 632 if (build_with_chromium) { 633 deps += [ "//third_party/abseil-cpp:absl" ] 634 } else { 635 deps += absl_deps 636 } 637 } 638 } 639} 640 641# This template automatically switches the target type between source_set 642# and static_library. 643# 644# This should be the default target type for all the WebRTC targets with 645# one exception. Do not use this template for header only targets, in that case 646# rtc_source_set must be used in order to avoid build errors (e.g. libtool 647# complains if the output .a file is empty). 648# 649# How does it work: 650# Since all files in a source_set are linked into a final binary, while files 651# in a static library are only linked in if at least one symbol in them is 652# referenced, in component builds source_sets are easy to deal with because 653# all their object files are passed to the linker to create a shared library. 654# In release builds instead, static_libraries are preferred since they allow 655# the linker to discard dead code. 656# For the same reason, testonly targets will always be expanded to 657# source_set in order to be sure that tests are present in the test binary. 658template("rtc_library") { 659 if (is_component_build || (defined(invoker.testonly) && invoker.testonly)) { 660 target_type = "source_set" 661 } else { 662 target_type = "static_library" 663 } 664 target(target_type, target_name) { 665 forward_variables_from(invoker, 666 "*", 667 [ 668 "configs", 669 "public_configs", 670 "suppressed_configs", 671 "visibility", 672 ]) 673 forward_variables_from(invoker, [ "visibility" ]) 674 if (!defined(visibility)) { 675 visibility = webrtc_default_visibility 676 } 677 678 # What's your poison? 679 if (defined(testonly) && testonly) { 680 assert(!defined(poisonous)) 681 assert(!defined(allow_poison)) 682 } else { 683 if (!defined(poisonous)) { 684 poisonous = [] 685 } 686 if (!defined(allow_poison)) { 687 allow_poison = [] 688 } 689 if (!defined(assert_no_deps)) { 690 assert_no_deps = [] 691 } 692 if (!defined(deps)) { 693 deps = [] 694 } 695 foreach(p, poisonous) { 696 deps += [ webrtc_root + ":poison_" + p ] 697 } 698 foreach(poison_type, all_poison_types) { 699 allow_dep = true 700 foreach(v, visibility) { 701 if (v == "*") { 702 allow_dep = false 703 } 704 } 705 foreach(p, allow_poison + poisonous) { 706 if (p == poison_type) { 707 allow_dep = true 708 } 709 } 710 if (!allow_dep) { 711 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] 712 } 713 } 714 } 715 716 # Chromium should only depend on the WebRTC component in order to 717 # avoid to statically link WebRTC in a component build. 718 if (build_with_chromium) { 719 publicly_visible = false 720 foreach(v, visibility) { 721 if (v == "*") { 722 publicly_visible = true 723 } 724 } 725 if (publicly_visible) { 726 visibility = [] 727 visibility = webrtc_default_visibility 728 } 729 } 730 731 if (!defined(testonly) || !testonly) { 732 configs += rtc_prod_configs 733 } 734 735 configs += invoker.configs 736 configs += rtc_library_impl_config 737 configs -= rtc_remove_configs 738 configs -= invoker.suppressed_configs 739 public_configs = [ 740 rtc_common_inherited_config, 741 absl_include_config, 742 absl_define_config, 743 ] 744 if (defined(testonly) && testonly) { 745 public_configs += [ absl_flags_config ] 746 } 747 if (defined(invoker.public_configs)) { 748 public_configs += invoker.public_configs 749 } 750 751 # If absl_deps is [], no action is needed. If not [], then it needs to be 752 # converted to //third_party/abseil-cpp:absl when build_with_chromium=true 753 # otherwise it just needs to be added to deps. 754 if (absl_deps != []) { 755 if (!defined(deps)) { 756 deps = [] 757 } 758 if (build_with_chromium) { 759 deps += [ "//third_party/abseil-cpp:absl" ] 760 } else { 761 deps += absl_deps 762 } 763 } 764 } 765} 766 767template("rtc_executable") { 768 executable(target_name) { 769 forward_variables_from(invoker, 770 "*", 771 [ 772 "deps", 773 "configs", 774 "public_configs", 775 "suppressed_configs", 776 "visibility", 777 ]) 778 forward_variables_from(invoker, [ "visibility" ]) 779 if (!defined(visibility)) { 780 visibility = webrtc_default_visibility 781 } 782 configs += invoker.configs 783 configs -= rtc_remove_configs 784 configs -= invoker.suppressed_configs 785 deps = invoker.deps 786 787 public_configs = [ 788 rtc_common_inherited_config, 789 absl_include_config, 790 absl_define_config, 791 ] 792 if (defined(testonly) && testonly) { 793 public_configs += [ absl_flags_config ] 794 } 795 if (defined(invoker.public_configs)) { 796 public_configs += invoker.public_configs 797 } 798 if (is_win) { 799 deps += [ 800 # Give executables the default manifest on Windows (a no-op elsewhere). 801 "//build/win:default_exe_manifest", 802 ] 803 } 804 } 805} 806 807template("rtc_shared_library") { 808 shared_library(target_name) { 809 forward_variables_from(invoker, 810 "*", 811 [ 812 "configs", 813 "public_configs", 814 "suppressed_configs", 815 "visibility", 816 ]) 817 forward_variables_from(invoker, [ "visibility" ]) 818 if (!defined(visibility)) { 819 visibility = webrtc_default_visibility 820 } 821 822 # What's your poison? 823 if (defined(testonly) && testonly) { 824 assert(!defined(poisonous)) 825 assert(!defined(allow_poison)) 826 } else { 827 if (!defined(poisonous)) { 828 poisonous = [] 829 } 830 if (!defined(allow_poison)) { 831 allow_poison = [] 832 } 833 if (!defined(assert_no_deps)) { 834 assert_no_deps = [] 835 } 836 if (!defined(deps)) { 837 deps = [] 838 } 839 foreach(p, poisonous) { 840 deps += [ webrtc_root + ":poison_" + p ] 841 } 842 foreach(poison_type, all_poison_types) { 843 allow_dep = true 844 foreach(v, visibility) { 845 if (v == "*") { 846 allow_dep = false 847 } 848 } 849 foreach(p, allow_poison + poisonous) { 850 if (p == poison_type) { 851 allow_dep = true 852 } 853 } 854 if (!allow_dep) { 855 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] 856 } 857 } 858 } 859 860 configs += invoker.configs 861 configs -= rtc_remove_configs 862 configs -= invoker.suppressed_configs 863 public_configs = [ 864 rtc_common_inherited_config, 865 absl_include_config, 866 absl_define_config, 867 ] 868 if (defined(testonly) && testonly) { 869 public_configs += [ absl_flags_config ] 870 } 871 if (defined(invoker.public_configs)) { 872 public_configs += invoker.public_configs 873 } 874 } 875} 876 877if (is_ios) { 878 set_defaults("rtc_ios_xctest_test") { 879 configs = rtc_add_configs 880 suppressed_configs = [] 881 } 882 883 template("rtc_ios_xctest_test") { 884 ios_xctest_test(target_name) { 885 forward_variables_from(invoker, 886 "*", 887 [ 888 "configs", 889 "public_configs", 890 "suppressed_configs", 891 "visibility", 892 ]) 893 forward_variables_from(invoker, [ "visibility" ]) 894 if (!defined(visibility)) { 895 visibility = webrtc_default_visibility 896 } 897 configs += invoker.configs 898 configs -= rtc_remove_configs 899 configs -= invoker.suppressed_configs 900 public_configs = [ rtc_common_inherited_config ] 901 if (defined(invoker.public_configs)) { 902 public_configs += invoker.public_configs 903 } 904 } 905 } 906 907 # TODO: Generate module.modulemap file to enable use in Swift 908 # projects. See "mac_framework_bundle_with_umbrella_header". 909 template("ios_framework_bundle_with_umbrella_header") { 910 forward_variables_from(invoker, [ "output_name" ]) 911 umbrella_header_path = 912 "$target_gen_dir/$output_name.framework/Headers/$output_name.h" 913 914 ios_framework_bundle(target_name) { 915 forward_variables_from(invoker, "*", []) 916 917 deps += [ ":copy_umbrella_header_$target_name" ] 918 } 919 920 action("umbrella_header_$target_name") { 921 forward_variables_from(invoker, [ "public_headers" ]) 922 923 script = "//tools_webrtc/ios/generate_umbrella_header.py" 924 925 outputs = [ umbrella_header_path ] 926 args = [ 927 "--out", 928 rebase_path(umbrella_header_path, root_build_dir), 929 "--sources", 930 ] + public_headers 931 } 932 933 copy("copy_umbrella_header_$target_name") { 934 sources = [ umbrella_header_path ] 935 outputs = 936 [ "$root_out_dir/$output_name.framework/Headers/$output_name.h" ] 937 938 deps = [ ":umbrella_header_$target_name" ] 939 } 940 } 941 942 set_defaults("ios_framework_bundle_with_umbrella_header") { 943 configs = default_shared_library_configs 944 } 945} 946 947if (is_mac) { 948 template("mac_framework_bundle_with_umbrella_header") { 949 forward_variables_from(invoker, [ "output_name" ]) 950 this_target_name = target_name 951 umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h" 952 modulemap_path = "$target_gen_dir/Modules/module.modulemap" 953 954 mac_framework_bundle(target_name) { 955 forward_variables_from(invoker, "*", [ "configs" ]) 956 if (defined(invoker.configs)) { 957 configs += invoker.configs 958 } 959 960 framework_version = "A" 961 framework_contents = [ 962 "Headers", 963 "Modules", 964 "Resources", 965 ] 966 967 ldflags = [ 968 "-all_load", 969 "-install_name", 970 "@rpath/$output_name.framework/$output_name", 971 ] 972 973 deps += [ 974 ":copy_framework_headers_$this_target_name", 975 ":copy_modulemap_$this_target_name", 976 ":copy_umbrella_header_$this_target_name", 977 ":modulemap_$this_target_name", 978 ":umbrella_header_$this_target_name", 979 ] 980 } 981 982 bundle_data("copy_framework_headers_$this_target_name") { 983 forward_variables_from(invoker, [ "sources" ]) 984 985 outputs = [ "{{bundle_contents_dir}}/Headers/{{source_file_part}}" ] 986 } 987 988 action("modulemap_$this_target_name") { 989 script = "//tools_webrtc/ios/generate_modulemap.py" 990 args = [ 991 "--out", 992 rebase_path(modulemap_path, root_build_dir), 993 "--name", 994 output_name, 995 ] 996 outputs = [ modulemap_path ] 997 } 998 999 bundle_data("copy_modulemap_$this_target_name") { 1000 sources = [ modulemap_path ] 1001 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ] 1002 deps = [ ":modulemap_$this_target_name" ] 1003 } 1004 1005 action("umbrella_header_$this_target_name") { 1006 forward_variables_from(invoker, [ "sources" ]) 1007 1008 script = "//tools_webrtc/ios/generate_umbrella_header.py" 1009 1010 outputs = [ umbrella_header_path ] 1011 args = [ 1012 "--out", 1013 rebase_path(umbrella_header_path, root_build_dir), 1014 "--sources", 1015 ] + sources 1016 } 1017 1018 bundle_data("copy_umbrella_header_$this_target_name") { 1019 sources = [ umbrella_header_path ] 1020 outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ] 1021 1022 deps = [ ":umbrella_header_$this_target_name" ] 1023 } 1024 } 1025} 1026 1027if (is_android) { 1028 template("rtc_android_library") { 1029 android_library(target_name) { 1030 forward_variables_from(invoker, 1031 "*", 1032 [ 1033 "configs", 1034 "public_configs", 1035 "suppressed_configs", 1036 "visibility", 1037 ]) 1038 1039 errorprone_args = [] 1040 1041 # Treat warnings as errors. 1042 errorprone_args += [ "-Werror" ] 1043 1044 # Add any arguments defined by the invoker. 1045 if (defined(invoker.errorprone_args)) { 1046 errorprone_args += invoker.errorprone_args 1047 } 1048 1049 if (!defined(deps)) { 1050 deps = [] 1051 } 1052 1053 no_build_hooks = true 1054 not_needed([ "android_manifest" ]) 1055 } 1056 } 1057 1058 template("rtc_android_apk") { 1059 android_apk(target_name) { 1060 forward_variables_from(invoker, 1061 "*", 1062 [ 1063 "configs", 1064 "public_configs", 1065 "suppressed_configs", 1066 "visibility", 1067 ]) 1068 1069 # Treat warnings as errors. 1070 errorprone_args = [] 1071 errorprone_args += [ "-Werror" ] 1072 1073 # Use WebRTC-specific android lint suppressions file. 1074 lint_suppressions_file = "//tools_webrtc/android/suppressions.xml" 1075 1076 if (!defined(deps)) { 1077 deps = [] 1078 } 1079 1080 no_build_hooks = true 1081 } 1082 } 1083 1084 template("rtc_instrumentation_test_apk") { 1085 instrumentation_test_apk(target_name) { 1086 forward_variables_from(invoker, 1087 "*", 1088 [ 1089 "configs", 1090 "public_configs", 1091 "suppressed_configs", 1092 "visibility", 1093 ]) 1094 1095 # Treat warnings as errors. 1096 errorprone_args = [] 1097 errorprone_args += [ "-Werror" ] 1098 1099 if (!defined(deps)) { 1100 deps = [] 1101 } 1102 1103 no_build_hooks = true 1104 } 1105 } 1106} 1107