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