webrtc.gni (46223B)
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. 8 import("//chromium/build/config/arm.gni") 9 import("//chromium/build/config/features.gni") 10 import("//chromium/build/config/mips.gni") 11 import("//chromium/build/config/ozone.gni") 12 import("//chromium/build/config/sanitizers/sanitizers.gni") 13 import("//chromium/build/config/sysroot.gni") 14 import("//build_overrides/build.gni") 15 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`.") 25 print( 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.") 28 } 29 30 if (is_ios) { 31 import("//chromium/build/config/ios/rules.gni") 32 } 33 34 if (is_mac) { 35 import("//chromium/build/config/mac/rules.gni") 36 } 37 38 if (is_android) { 39 import("//chromium/build/config/android/config.gni") 40 import("//chromium/build/config/android/rules.gni") 41 } 42 43 if (is_fuchsia) { 44 import("//chromium/build/config/fuchsia/config.gni") 45 } 46 47 if (build_with_chromium) { 48 import("//media/media_options.gni") 49 } 50 51 # This declare_args is separated from the next one because args declared 52 # in this one, can be read from the next one (args defined in the same 53 # declare_args cannot be referenced in that scope). 54 declare_args() { 55 # Enable to use the Mozilla internal settings. 56 build_with_mozilla = true 57 } 58 59 declare_args() { 60 # Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h) 61 # expand to code that will manage symbols visibility. 62 rtc_enable_symbol_export = false 63 } 64 65 declare_args() { 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 70 71 # Enables additional build targets that rely on 72 # //third_party/google_benchmarks. 73 rtc_enable_google_benchmarks = true 74 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 79 # annotated symbols. 80 rtc_enable_objc_symbol_export = rtc_enable_symbol_export 81 82 # Setting this to true will define WEBRTC_EXCLUDE_METRICS_DEFAULT which 83 # will tell the pre-processor to remove the default definition of symbols 84 # needed to use metrics. In that case a new implementation needs to be 85 # provided. 86 rtc_exclude_metrics_default = build_with_chromium 87 88 # Setting this to true will define WEBRTC_EXCLUDE_SYSTEM_TIME which 89 # will tell the pre-processor to remove the default definition of the 90 # SystemTimeNanos() which is defined in rtc_base/system_time.cc. In 91 # that case a new implementation needs to be provided. 92 rtc_exclude_system_time = build_with_chromium || build_with_mozilla 93 94 # Setting this to false will require the API user to pass in their own 95 # SSLCertificateVerifier to verify the certificates presented from a 96 # TLS-TURN server. In return disabling this saves around 100kb in the binary. 97 rtc_builtin_ssl_root_certificates = true 98 99 # Disable this to avoid building the Opus audio codec. 100 rtc_include_opus = true 101 102 # Enable this if the Opus version upon which WebRTC is built supports direct 103 # encoding of 120 ms packets. 104 rtc_opus_support_120ms_ptime = true 105 106 # Enable this to let the Opus audio codec change complexity on the fly. 107 rtc_opus_variable_complexity = false 108 109 # Used to specify an external Jsoncpp include path when not compiling the 110 # library that comes with WebRTC (i.e. rtc_build_json == 0). 111 rtc_jsoncpp_root = "//third_party/jsoncpp/source/include" 112 113 # Used to specify an external OpenSSL include path when not compiling the 114 # library that comes with WebRTC (i.e. rtc_build_ssl == 0). 115 rtc_ssl_root = "" 116 117 # Enable when an external authentication mechanism is used for performing 118 # packet authentication for RTP packets instead of libsrtp. 119 rtc_enable_external_auth = build_with_chromium 120 121 # Selects whether debug dumps for the audio processing module 122 # should be generated. 123 apm_debug_dump = build_with_mozilla 124 125 # Selects whether the audio processing module should be excluded. 126 rtc_exclude_audio_processing_module = false 127 128 # Set this to false to skip building examples. 129 rtc_build_examples = false 130 131 # Set this to false to skip building tools. 132 rtc_build_tools = false 133 134 # Set this to false to skip building code that requires X11. 135 rtc_use_x11 = ozone_platform_x11 136 137 # Set this to use PipeWire on the Wayland display server. 138 # By default it's only enabled on desktop Linux (excludes ChromeOS) and 139 # only when using the sysroot as PipeWire is not available in older and 140 # supported Ubuntu and Debian distributions. 141 rtc_use_pipewire = is_linux && use_sysroot 142 143 # Set this to link PipeWire and required libraries directly instead of using the dlopen. 144 rtc_link_pipewire = false 145 146 # Experimental: enable use of Android AAudio which requires Android SDK 26 or above 147 # and NDK r16 or above. 148 rtc_enable_android_aaudio = false 149 150 # Set to "func", "block", "edge" for coverage generation. 151 # At unit test runtime set UBSAN_OPTIONS="coverage=1". 152 # It is recommend to set include_examples=0. 153 # Use llvm's sancov -html-report for human readable reports. 154 # See http://clang.llvm.org/docs/SanitizerCoverage.html . 155 rtc_sanitize_coverage = "" 156 157 # Selects fixed-point code where possible. 158 rtc_prefer_fixed_point = false 159 if (target_cpu == "arm" || target_cpu == "arm64") { 160 rtc_prefer_fixed_point = true 161 } 162 163 # Determines whether NEON code will be built. 164 rtc_build_with_neon = 165 (target_cpu == "arm" && arm_use_neon) || target_cpu == "arm64" 166 167 # Enable this to build OpenH264 encoder/FFmpeg decoder. When building WebRTC 168 # as part of Chromium, this is delegated to `media_use_openh264`. When 169 # building WebRTC as a standalone library, this is supported on all platforms 170 # except Android and iOS. Because FFmpeg can be built with/without H.264 171 # support, `ffmpeg_branding` has to separately be set to a value that 172 # includes H.264, for example "Chrome". If FFmpeg is built without H.264, 173 # compilation succeeds but `H264DecoderImpl` fails to initialize. 174 # CHECK THE OPENH264, FFMPEG AND H.264 LICENSES/PATENTS BEFORE BUILDING. 175 # http://www.openh264.org, https://www.ffmpeg.org/ 176 # 177 # Enabling H264 when building with MSVC is currently not supported, see 178 # bugs.webrtc.org/9213#c13 for more info. 179 if (build_with_chromium) { 180 rtc_use_h264 = media_use_openh264 181 } else { 182 rtc_use_h264 = 183 proprietary_codecs && !is_android && !is_ios && !(is_win && !is_clang) 184 } 185 186 # Use system OpenH264 187 rtc_system_openh264 = false 188 189 # Enable to use H265 190 if (build_with_chromium) { 191 rtc_use_h265 = enable_hevc_parser_and_hw_decoder 192 } else { 193 rtc_use_h265 = proprietary_codecs 194 } 195 196 # Enable this flag to make webrtc::Mutex be implemented by absl::Mutex. 197 rtc_use_absl_mutex = false 198 199 # By default, use normal platform audio support or dummy audio, but don't 200 # use file-based audio playout and record. 201 rtc_use_dummy_audio_file_devices = false 202 203 # When set to true, replace the audio output with a sinus tone at 440Hz. 204 # The ADM will ask for audio data from WebRTC but instead of reading real 205 # audio samples from NetEQ, a sinus tone will be generated and replace the 206 # real audio samples. 207 rtc_audio_device_plays_sinus_tone = false 208 209 if (is_ios) { 210 # Build broadcast extension in AppRTCMobile for iOS. This results in the 211 # binary only running on iOS 11+, which is why it is disabled by default. 212 rtc_apprtcmobile_broadcast_extension = false 213 } 214 215 # Determines whether OpenGL is available on iOS. 216 rtc_ios_use_opengl_rendering = is_ios && target_environment != "catalyst" 217 218 # When set to false, builtin audio encoder/decoder factories and all the 219 # audio codecs they depend on will not be included in libwebrtc.{a|lib} 220 # (they will still be included in libjingle_peerconnection_so.so and 221 # WebRTC.framework) 222 rtc_include_builtin_audio_codecs = true 223 224 # When set to true and in a standalone build, it will undefine UNICODE and 225 # _UNICODE (which are always defined globally by the Chromium Windows 226 # toolchain). 227 # This is only needed for testing purposes, WebRTC wants to be sure it 228 # doesn't assume /DUNICODE and /D_UNICODE but that it explicitly uses 229 # wide character functions. 230 rtc_win_undef_unicode = false 231 232 # When set to true, a capturer implementation that uses the 233 # Windows.Graphics.Capture APIs will be available for use. This introduces a 234 # dependency on the Win 10 SDK v10.0.17763.0. 235 rtc_enable_win_wgc = is_win 236 237 # Includes the dav1d decoder in the internal decoder factory when set to true. 238 rtc_include_dav1d_in_internal_decoder_factory = true 239 240 # When enabled, a run-time check will make sure that all field trial keys have 241 # been registered in accordance with the field trial policy, see 242 # g3doc/field-trials.md. The value can be set to the following: 243 # 244 # "dcheck": RTC_DCHECKs that the field trial has been registered. RTC_DCHECK 245 # must be enabled separately. 246 # 247 # "warn": RTC_LOGs a message with LS_WARNING severity if the field trial 248 # hasn't been registered. 249 rtc_strict_field_trials = "" 250 251 # If different from "", symbols exported with RTC_OBJC_EXPORT will be prefixed 252 # with this string. 253 # See the definition of RTC_OBJC_TYPE_PREFIX in the code. 254 rtc_objc_prefix = "" 255 256 # Embedders can define dependencies needed by WebRTC. Dependencies can be 257 # configs or targets. This can be defined in their `.gn` file. 258 # 259 # In practise, this is use by Chromium: Targets from 260 # `//third_party/webrtc_overrides` are depending on Chrome's `//base`, but 261 # WebRTC does not declare its public dependencies. See webrtc:8603. Instead 262 # WebRTC is using a global common dependencies. 263 rtc_common_public_deps = [] # no-presubmit-check TODO(webrtc:8603) 264 265 # When true, include the Perfetto library. 266 rtc_use_perfetto = false 267 } 268 269 if (!build_with_mozilla) { 270 import("//testing/test.gni") 271 } 272 273 # A second declare_args block, so that declarations within it can 274 # depend on the possibly overridden variables in the first 275 # declare_args block. 276 declare_args() { 277 # Enables the use of protocol buffers for debug recordings. 278 rtc_enable_protobuf = !build_with_mozilla 279 280 # Set this to disable building with support for SCTP data channels. 281 rtc_enable_sctp = !build_with_mozilla 282 283 # Disable these to not build components which can be externally provided. 284 rtc_build_json = !build_with_mozilla 285 rtc_build_libsrtp = !build_with_mozilla 286 rtc_build_libvpx = !build_with_mozilla 287 rtc_libvpx_build_vp9 = true 288 rtc_build_opus = !build_with_mozilla 289 rtc_build_ssl = !build_with_mozilla 290 291 # Excluded in Chromium since its prerequisites don't require Pulse Audio. 292 rtc_include_pulse_audio = !build_with_chromium 293 294 # Chromium uses its own IO handling, so the internal ADM is only built for 295 # standalone WebRTC. 296 rtc_include_internal_audio_device = !build_with_chromium && !build_with_mozilla 297 298 # Set this to true to enable the avx2 support in webrtc. 299 # TODO: Make sure that AVX2 works also for non-clang compilers. 300 if (is_clang == true && (target_cpu == "x86" || target_cpu == "x64")) { 301 rtc_enable_avx2 = true 302 } else { 303 rtc_enable_avx2 = false 304 } 305 306 # Set this to true to build the unit tests. 307 # Disabled when building with Chromium or Mozilla. 308 rtc_include_tests = !build_with_chromium && !build_with_mozilla 309 310 # Set this to false to skip building code that also requires X11 extensions 311 # such as Xdamage, Xfixes. 312 rtc_use_x11_extensions = rtc_use_x11 313 314 # Set this to true to fully remove logging from WebRTC. 315 rtc_disable_logging = false 316 317 # Set this to true to disable trace events. 318 rtc_disable_trace_events = false 319 320 # Set this to true to disable detailed error message and logging for 321 # RTC_CHECKs. 322 rtc_disable_check_msg = false 323 324 # Set this to true to disable webrtc metrics. 325 rtc_disable_metrics = false 326 327 # Enables an experimental rust version of base64 for building and testing. 328 rtc_rusty_base64 = false 329 330 # Enables PSNR calculation for video getStats. 331 rtc_video_psnr = true 332 } 333 334 declare_args() { 335 # Enable the dcsctp backend for DataChannels and related unittests 336 rtc_build_dcsctp = !build_with_mozilla && rtc_enable_sctp 337 338 # Enable gRPC used for negotiation in multiprocess tests 339 rtc_enable_grpc = rtc_enable_protobuf && (is_linux || is_mac) 340 } 341 342 # Enable liboam only on non-mozilla builds. 343 enable_libaom = true 344 345 # Make it possible to provide custom locations for some libraries (move these 346 # up into declare_args should we need to actually use them for the GN build). 347 rtc_libvpx_dir = "//third_party/libvpx" 348 rtc_opus_dir = "//third_party/opus" 349 350 # Desktop capturer is supported only on Windows, OSX and Linux. 351 rtc_desktop_capture_supported = 352 (is_win && current_os != "winuwp") || is_mac || is_bsd || 353 ((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire)) 354 355 ############################################################################### 356 # Templates 357 # 358 359 # Points to // in webrtc stand-alone or to //third_party/webrtc/ in 360 # chromium. 361 # We need absolute paths for all configs in templates as they are shared in 362 # different subdirectories. 363 webrtc_root = get_path_info(".", "abspath") 364 365 # Global configuration that should be applied to all WebRTC targets. 366 # You normally shouldn't need to include this in your target as it's 367 # automatically included when using the rtc_* templates. 368 # It sets defines, include paths and compilation warnings accordingly, 369 # both for WebRTC stand-alone builds and for the scenario when WebRTC 370 # native code is built as part of Chromium. 371 rtc_common_configs = [ webrtc_root + ":common_config" ] 372 373 if (is_mac || is_ios) { 374 if (filter_include(default_compiler_configs, 375 [ "//chromium/build/config/compiler:enable_arc" ]) == []) { 376 rtc_common_configs += [ "//chromium/build/config/compiler:enable_arc" ] 377 } 378 } 379 380 if (build_with_chromium) { 381 rtc_use_perfetto = true 382 } 383 384 # Global public configuration that should be applied to all WebRTC targets. You 385 # normally shouldn't need to include this in your target as it's automatically 386 # included when using the rtc_* templates. It set the defines, include paths and 387 # compilation warnings that should be propagated to dependents of the targets 388 # depending on the target having this config. 389 rtc_common_inherited_config = webrtc_root + ":common_inherited_config" 390 391 # Common configs to remove or add in all rtc targets. 392 rtc_remove_configs = [] 393 if (!build_with_chromium && is_clang) { 394 rtc_remove_configs += [ "//chromium/build/config/clang:find_bad_constructs" ] 395 } 396 rtc_add_configs = rtc_common_configs 397 rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ] 398 rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ] 399 400 set_defaults("rtc_test") { 401 configs = rtc_add_configs 402 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) 403 suppressed_configs = [] 404 } 405 406 set_defaults("rtc_library") { 407 configs = rtc_add_configs 408 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) 409 suppressed_configs = [] 410 } 411 412 set_defaults("rtc_source_set") { 413 configs = rtc_add_configs 414 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) 415 suppressed_configs = [] 416 } 417 418 set_defaults("rtc_static_library") { 419 configs = rtc_add_configs 420 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) 421 suppressed_configs = [] 422 } 423 424 set_defaults("rtc_executable") { 425 configs = rtc_add_configs 426 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) 427 suppressed_configs = [] 428 } 429 430 set_defaults("rtc_shared_library") { 431 configs = rtc_add_configs 432 public_deps = rtc_common_public_deps # no-presubmit-check TODO(webrtc:8603) 433 suppressed_configs = [] 434 } 435 436 webrtc_default_visibility = [ webrtc_root + "/*" ] 437 if (build_with_chromium) { 438 # Allow Chromium's WebRTC overrides targets to bypass the regular 439 # visibility restrictions. 440 webrtc_default_visibility += [ webrtc_root + "/../webrtc_overrides/*" ] 441 } 442 443 # ---- Poisons ---- 444 # 445 # The general idea is that some targets declare that they contain some 446 # kind of poison, which makes it impossible for other targets to 447 # depend on them (even transitively) unless they declare themselves 448 # immune to that particular type of poison. 449 # 450 # Targets that *contain* poison of type foo should contain the line 451 # 452 # poisonous = [ "foo" ] 453 # 454 # and targets that *are immune but arent't themselves poisonous* 455 # should contain 456 # 457 # allow_poison = [ "foo" ] 458 # 459 # This useful in cases where we have some large target or set of 460 # targets and want to ensure that most other targets do not 461 # transitively depend on them. For example, almost no high-level 462 # target should depend on the audio codecs, since we want WebRTC users 463 # to be able to inject any subset of them and actually end up with a 464 # binary that doesn't include the codecs they didn't inject. 465 # 466 # Test-only targets (`testonly` set to true) and non-public targets 467 # (`visibility` not containing "*") are automatically immune to all 468 # types of poison. 469 # 470 # Here's the complete list of all types of poison. It must be kept in 471 # 1:1 correspondence with the set of //:poison_* targets. 472 # 473 all_poison_types = [ 474 # Encoders and decoders for specific audio codecs such as Opus and iSAC. 475 "audio_codecs", 476 477 # Default echo detector implementation. 478 "default_echo_detector", 479 480 # Implementations of the utilities exposed through `Environment`. 481 # Most webrtc classes must use propagated `Environment`. Only few top-level 482 # classes are allowed to create `Environment` from individual utilities. 483 "environment_construction", 484 485 # Software video codecs (VP8 and VP9 through libvpx). 486 "software_video_codecs", 487 488 # Residual echo estimator based that runs inferences using the tflite library. 489 "default_neural_residual_echo_estimator", 490 ] 491 492 absl_include_config = "//libwebrtc/third_party/abseil-cpp:absl_include_config" 493 absl_define_config = "//libwebrtc/third_party/abseil-cpp:absl_define_config" 494 495 # Abseil Flags are testonly, so this config will only be applied to WebRTC targets 496 # that are testonly. 497 absl_flags_config = webrtc_root + ":absl_flags_configs" 498 499 # WebRTC wrapper of Chromium's test() template. This template just adds some 500 # WebRTC only configuration in order to avoid to duplicate it for every WebRTC 501 # target. 502 # The parameter `is_xctest` is different from the one in the Chromium's test() 503 # template (and it is not forwarded to it). In rtc_test(), the argument 504 # `is_xctest` is used to avoid to take dependencies that are not needed 505 # in case the test is a real XCTest (using the XCTest framework). 506 template("rtc_test") { 507 test(target_name) { 508 forward_variables_from(invoker, 509 "*", 510 [ 511 "configs", 512 "is_xctest", 513 "public_configs", 514 "suppressed_configs", 515 "visibility", 516 ]) 517 518 # Always override to public because when target_os is Android the `test` 519 # template can override it to [ "*" ] and we want to avoid conditional 520 # visibility. 521 visibility = [ "*" ] 522 configs += invoker.configs 523 configs -= rtc_remove_configs 524 configs -= invoker.suppressed_configs 525 public_configs = [ 526 rtc_common_inherited_config, 527 absl_include_config, 528 absl_define_config, 529 absl_flags_config, 530 ] 531 if (defined(invoker.public_configs)) { 532 public_configs += invoker.public_configs 533 } 534 if (!build_with_chromium && is_android) { 535 use_default_launcher = false 536 android_manifest = webrtc_root + "test/android/AndroidManifest.xml" 537 use_raw_android_executable = false 538 min_sdk_version = 23 539 target_sdk_version = 24 540 deps += [ 541 "//chromium/build/android/gtest_apk:native_test_instrumentation_test_runner_java", 542 webrtc_root + "sdk/android:native_test_jni_onload", 543 webrtc_root + "sdk/android:base_java", 544 webrtc_root + "test:native_test_java", 545 webrtc_root + "test:native_test_support", 546 "//third_party/jni_zero:jni_zero_java", 547 ] 548 } 549 550 # Build //test:google_test_runner_objc when the test is not a real XCTest. 551 if (is_ios && rtc_include_tests) { 552 if (!defined(invoker.is_xctest) || !invoker.is_xctest) { 553 xctest_module_target = "//test:google_test_runner_objc" 554 } 555 } 556 557 assert( 558 !defined(absl_deps), 559 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.") 560 561 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true 562 if (build_with_chromium && defined(deps)) { 563 absl_dependencies = 564 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ]) 565 if (absl_dependencies != []) { 566 filtered_deps = 567 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ]) 568 deps = [] 569 deps = filtered_deps 570 deps += [ "//third_party/abseil-cpp:absl" ] 571 } 572 } 573 574 # TODO(crbug.com/webrtc/13556): Adding the .app folder in the runtime_deps 575 # shoulnd't be necessary. this code should be removed and the same solution 576 # as Chromium should be used. 577 if (is_ios) { 578 if (!defined(invoker.data)) { 579 data = [] 580 } 581 data += [ "${root_out_dir}/${target_name}.app" ] 582 } 583 } 584 } 585 586 template("rtc_source_set") { 587 source_set(target_name) { 588 forward_variables_from(invoker, 589 "*", 590 [ 591 "configs", 592 "public_configs", 593 "suppressed_configs", 594 "visibility", 595 ]) 596 forward_variables_from(invoker, [ "visibility" ]) 597 if (!defined(visibility)) { 598 visibility = webrtc_default_visibility 599 } 600 601 if (defined(invoker.sources)) { 602 nonheader_sources = filter_include(invoker.sources, [ "*.cc" ]) 603 assert(nonheader_sources == [], 604 "rtc_source_set shall not contain cc files") 605 } 606 607 # What's your poison? 608 if (defined(testonly) && testonly) { 609 assert(!defined(poisonous)) 610 assert(!defined(allow_poison)) 611 } else { 612 if (!defined(poisonous)) { 613 poisonous = [] 614 } 615 if (!defined(allow_poison)) { 616 allow_poison = [] 617 } 618 if (!defined(assert_no_deps)) { 619 assert_no_deps = [] 620 } 621 if (!defined(deps)) { 622 deps = [] 623 } 624 foreach(p, poisonous) { 625 deps += [ webrtc_root + ":poison_" + p ] 626 } 627 foreach(poison_type, all_poison_types) { 628 allow_dep = true 629 foreach(v, visibility) { 630 if (v == "*") { 631 allow_dep = false 632 } 633 } 634 foreach(p, allow_poison + poisonous) { 635 if (p == poison_type) { 636 allow_dep = true 637 } 638 } 639 if (!allow_dep) { 640 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] 641 } 642 } 643 } 644 645 # Chromium should only depend on the WebRTC component in order to 646 # avoid to statically link WebRTC in a component build. 647 if (build_with_chromium) { 648 publicly_visible = false 649 foreach(v, visibility) { 650 if (v == "*") { 651 publicly_visible = true 652 } 653 } 654 if (publicly_visible) { 655 visibility = [] 656 visibility = webrtc_default_visibility 657 } 658 } 659 660 if (!defined(testonly) || !testonly) { 661 configs += rtc_prod_configs 662 } 663 664 configs += invoker.configs 665 configs += rtc_library_impl_config 666 configs -= rtc_remove_configs 667 configs -= invoker.suppressed_configs 668 public_configs = [ 669 rtc_common_inherited_config, 670 absl_include_config, 671 absl_define_config, 672 ] 673 if (defined(testonly) && testonly) { 674 public_configs += [ absl_flags_config ] 675 } 676 if (defined(invoker.public_configs)) { 677 public_configs += invoker.public_configs 678 } 679 680 assert( 681 !defined(absl_deps), 682 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.") 683 684 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true 685 if (build_with_chromium && defined(deps)) { 686 absl_dependencies = 687 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ]) 688 if (absl_dependencies != []) { 689 filtered_deps = 690 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ]) 691 deps = [] 692 deps = filtered_deps 693 deps += [ "//third_party/abseil-cpp:absl" ] 694 } 695 } 696 697 # Rather than widespread changes to most, if not all, BUILD.gn files 698 # we'll do some filtering on dependencies here. 699 if (build_with_mozilla && defined(deps)) { 700 # Now that abseil-cpp is moved to Mozilla's third_party directory 701 # we remove all the abseil-cpp dependency listings so moz.build 702 # generation succeed. 703 filtered_deps = [] 704 foreach (dep, deps) { 705 newdep = string_replace(dep, "//third_party/abseil-cpp/", "") 706 if (newdep == dep) { 707 filtered_deps += [ dep ] 708 } 709 } 710 deps = [] 711 deps = filtered_deps 712 713 # We don't build any of the test code, but many of the test 714 # targets list gtest/gmock as a dependency. We can simply 715 # filter them out here. 716 filtered_deps = [] 717 foreach (dep, deps) { 718 newdep = string_replace(dep, "//testing/g", "") 719 if (newdep == dep) { 720 filtered_deps += [ dep ] 721 } 722 } 723 deps = [] 724 deps = filtered_deps 725 } 726 } 727 } 728 729 template("rtc_static_library") { 730 static_library(target_name) { 731 forward_variables_from(invoker, 732 "*", 733 [ 734 "configs", 735 "public_configs", 736 "suppressed_configs", 737 "visibility", 738 ]) 739 forward_variables_from(invoker, [ "visibility" ]) 740 if (!defined(visibility)) { 741 visibility = webrtc_default_visibility 742 } 743 744 # What's your poison? 745 if (defined(testonly) && testonly) { 746 assert(!defined(poisonous)) 747 assert(!defined(allow_poison)) 748 } else { 749 if (!defined(poisonous)) { 750 poisonous = [] 751 } 752 if (!defined(allow_poison)) { 753 allow_poison = [] 754 } 755 if (!defined(assert_no_deps)) { 756 assert_no_deps = [] 757 } 758 if (!defined(deps)) { 759 deps = [] 760 } 761 foreach(p, poisonous) { 762 deps += [ webrtc_root + ":poison_" + p ] 763 } 764 foreach(poison_type, all_poison_types) { 765 allow_dep = true 766 foreach(v, visibility) { 767 if (v == "*") { 768 allow_dep = false 769 } 770 } 771 foreach(p, allow_poison + poisonous) { 772 if (p == poison_type) { 773 allow_dep = true 774 } 775 } 776 if (!allow_dep) { 777 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] 778 } 779 } 780 } 781 782 if (!defined(testonly) || !testonly) { 783 configs += rtc_prod_configs 784 } 785 786 configs += invoker.configs 787 configs += rtc_library_impl_config 788 configs -= rtc_remove_configs 789 configs -= invoker.suppressed_configs 790 public_configs = [ 791 rtc_common_inherited_config, 792 absl_include_config, 793 absl_define_config, 794 ] 795 if (defined(testonly) && testonly) { 796 public_configs += [ absl_flags_config ] 797 } 798 if (defined(invoker.public_configs)) { 799 public_configs += invoker.public_configs 800 } 801 802 assert( 803 !defined(absl_deps), 804 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.") 805 806 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true 807 if (build_with_chromium && defined(deps)) { 808 absl_dependencies = 809 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ]) 810 if (absl_dependencies != []) { 811 filtered_deps = 812 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ]) 813 deps = [] 814 deps = filtered_deps 815 deps += [ "//third_party/abseil-cpp:absl" ] 816 } 817 } 818 } 819 } 820 821 # This template automatically switches the target type between source_set 822 # and static_library. 823 # 824 # This should be the default target type for all the WebRTC targets. 825 # 826 # How does it work: 827 # Since all files in a source_set are linked into a final binary, while files 828 # in a static library are only linked in if at least one symbol in them is 829 # referenced, in component builds source_sets are easy to deal with because 830 # all their object files are passed to the linker to create a shared library. 831 # In release builds instead, static_libraries are preferred since they allow 832 # the linker to discard dead code. 833 # For the same reason, testonly targets will always be expanded to 834 # source_set in order to be sure that tests are present in the test binary. 835 template("rtc_library") { 836 header_only = true 837 if (defined(invoker.sources)) { 838 non_header_sources = filter_exclude(invoker.sources, 839 [ 840 "*.h", 841 "*.hh", 842 "*.inc", 843 ]) 844 if (non_header_sources != []) { 845 header_only = false 846 } 847 } 848 849 # Header only libraries should use source_set as a static_library with no 850 # source files will cause issues with macOS libtool. 851 if (header_only || is_component_build || 852 (defined(invoker.testonly) && invoker.testonly)) { 853 target_type = "source_set" 854 } else { 855 target_type = "static_library" 856 } 857 target(target_type, target_name) { 858 forward_variables_from(invoker, 859 "*", 860 [ 861 "configs", 862 "public_configs", 863 "suppressed_configs", 864 "visibility", 865 ]) 866 forward_variables_from(invoker, [ "visibility" ]) 867 if (!defined(visibility)) { 868 visibility = webrtc_default_visibility 869 } 870 871 # What's your poison? 872 if (defined(testonly) && testonly) { 873 assert(!defined(poisonous)) 874 assert(!defined(allow_poison)) 875 } else { 876 if (!defined(poisonous)) { 877 poisonous = [] 878 } 879 if (!defined(allow_poison)) { 880 allow_poison = [] 881 } 882 if (!defined(assert_no_deps)) { 883 assert_no_deps = [] 884 } 885 if (!defined(deps)) { 886 deps = [] 887 } 888 foreach(p, poisonous) { 889 deps += [ webrtc_root + ":poison_" + p ] 890 } 891 foreach(poison_type, all_poison_types) { 892 allow_dep = true 893 foreach(v, visibility) { 894 if (v == "*") { 895 allow_dep = false 896 } 897 } 898 foreach(p, allow_poison + poisonous) { 899 if (p == poison_type) { 900 allow_dep = true 901 } 902 } 903 if (!allow_dep) { 904 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] 905 } 906 } 907 } 908 909 # Chromium should only depend on the WebRTC component in order to 910 # avoid to statically link WebRTC in a component build. 911 if (build_with_chromium) { 912 publicly_visible = false 913 foreach(v, visibility) { 914 if (v == "*") { 915 publicly_visible = true 916 } 917 } 918 if (publicly_visible) { 919 visibility = [] 920 visibility = webrtc_default_visibility 921 } 922 } 923 924 if (!defined(testonly) || !testonly) { 925 configs += rtc_prod_configs 926 } 927 928 configs += invoker.configs 929 configs += rtc_library_impl_config 930 configs -= rtc_remove_configs 931 configs -= invoker.suppressed_configs 932 public_configs = [ 933 rtc_common_inherited_config, 934 absl_include_config, 935 absl_define_config, 936 ] 937 if (defined(testonly) && testonly) { 938 public_configs += [ absl_flags_config ] 939 } 940 if (defined(invoker.public_configs)) { 941 public_configs += invoker.public_configs 942 } 943 944 assert( 945 !defined(absl_deps), 946 "`absl_deps` has been deprecated, add your Abseil dependencies to the `deps` variable.") 947 948 # Abseil dependencies need to be converted to //third_party/abseil-cpp:absl when build_with_chromium=true 949 if (build_with_chromium && defined(deps)) { 950 absl_dependencies = 951 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ]) 952 if (absl_dependencies != []) { 953 filtered_deps = 954 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ]) 955 deps = [] 956 deps = filtered_deps 957 deps += [ "//third_party/abseil-cpp:absl" ] 958 } 959 } 960 961 # Rather than widespread changes to most, if not all, BUILD.gn files 962 # we'll do some filtering on dependencies here. 963 if (build_with_mozilla && defined(deps)) { 964 # Now that abseil-cpp is moved to Mozilla's third_party directory 965 # we remove all the abseil-cpp dependency listings so moz.build 966 # generation succeed. 967 filtered_deps = [] 968 foreach (dep, deps) { 969 newdep = string_replace(dep, "//third_party/abseil-cpp/", "") 970 if (newdep == dep) { 971 filtered_deps += [ dep ] 972 } 973 } 974 deps = [] 975 deps = filtered_deps 976 977 # We don't build any of the test code, but many of the test 978 # targets list gtest/gmock as a dependency. We can simply 979 # filter them out here. 980 filtered_deps = [] 981 foreach (dep, deps) { 982 newdep = string_replace(dep, "//testing/g", "") 983 if (newdep == dep) { 984 filtered_deps += [ dep ] 985 } 986 } 987 deps = [] 988 deps = filtered_deps 989 990 # Moving the google build directory requires looking for libwebrtc's 991 # third_party dependencies under libwebrtc/third_party instead of 992 # simply third_party. 993 modified_deps = [] 994 foreach (dep, deps) { 995 newdep = string_replace(dep, "//third_party/", "//libwebrtc/third_party/") 996 newdep = string_replace(newdep, "//build", "//chromium/build") 997 modified_deps += [ newdep ] 998 } 999 deps = [] 1000 deps = modified_deps 1001 } 1002 if (build_with_mozilla && defined(data_deps)) { 1003 modified_deps = [] 1004 foreach (dep, data_deps) { 1005 newdep = string_replace(dep, "//build/", "//chromium/build/") 1006 modified_deps += [ newdep ] 1007 } 1008 data_deps = [] 1009 data_deps = modified_deps 1010 } 1011 } 1012 } 1013 1014 template("rtc_executable") { 1015 executable(target_name) { 1016 forward_variables_from(invoker, 1017 "*", 1018 [ 1019 "deps", 1020 "configs", 1021 "public_configs", 1022 "suppressed_configs", 1023 "visibility", 1024 ]) 1025 forward_variables_from(invoker, [ "visibility" ]) 1026 if (!defined(visibility)) { 1027 visibility = webrtc_default_visibility 1028 } 1029 configs += invoker.configs 1030 configs -= rtc_remove_configs 1031 configs -= invoker.suppressed_configs 1032 deps = invoker.deps 1033 1034 public_configs = [ 1035 rtc_common_inherited_config, 1036 absl_include_config, 1037 absl_define_config, 1038 ] 1039 if (defined(testonly) && testonly) { 1040 public_configs += [ absl_flags_config ] 1041 } 1042 if (defined(invoker.public_configs)) { 1043 public_configs += invoker.public_configs 1044 } 1045 if (is_win) { 1046 deps += [ 1047 # Give executables the default manifest on Windows (a no-op elsewhere). 1048 "//chromium/build/win:default_exe_manifest", 1049 ] 1050 } 1051 1052 # Convert abseil dependencies to //third_party/abseil-cpp:absl_full when 1053 # build_with_chromium=true so that webrtc targets won't need exceptions to 1054 # depend on individual absl targets. 1055 # Note that //third_party/abseil-cpp:absl_full build target includes flags, 1056 # but //third_party/abseil-cpp:absl target - doesn't. That allows webrtc 1057 # executables, but not libraries to use absl flags. 1058 if (build_with_chromium && defined(deps)) { 1059 absl_dependencies = 1060 filter_labels_include(deps, [ "//third_party/abseil-cpp/*" ]) 1061 if (absl_dependencies != []) { 1062 filtered_deps = 1063 filter_labels_exclude(deps, [ "//third_party/abseil-cpp/*" ]) 1064 deps = [] 1065 deps = filtered_deps 1066 deps += [ "//third_party/abseil-cpp:absl_full" ] 1067 } 1068 } 1069 } 1070 } 1071 1072 template("rtc_shared_library") { 1073 shared_library(target_name) { 1074 forward_variables_from(invoker, 1075 "*", 1076 [ 1077 "configs", 1078 "public_configs", 1079 "suppressed_configs", 1080 "visibility", 1081 ]) 1082 forward_variables_from(invoker, [ "visibility" ]) 1083 if (!defined(visibility)) { 1084 visibility = webrtc_default_visibility 1085 } 1086 1087 # What's your poison? 1088 if (defined(testonly) && testonly) { 1089 assert(!defined(poisonous)) 1090 assert(!defined(allow_poison)) 1091 } else { 1092 if (!defined(poisonous)) { 1093 poisonous = [] 1094 } 1095 if (!defined(allow_poison)) { 1096 allow_poison = [] 1097 } 1098 if (!defined(assert_no_deps)) { 1099 assert_no_deps = [] 1100 } 1101 if (!defined(deps)) { 1102 deps = [] 1103 } 1104 foreach(p, poisonous) { 1105 deps += [ webrtc_root + ":poison_" + p ] 1106 } 1107 foreach(poison_type, all_poison_types) { 1108 allow_dep = true 1109 foreach(v, visibility) { 1110 if (v == "*") { 1111 allow_dep = false 1112 } 1113 } 1114 foreach(p, allow_poison + poisonous) { 1115 if (p == poison_type) { 1116 allow_dep = true 1117 } 1118 } 1119 if (!allow_dep) { 1120 assert_no_deps += [ webrtc_root + ":poison_" + poison_type ] 1121 } 1122 } 1123 } 1124 1125 configs += invoker.configs 1126 configs -= rtc_remove_configs 1127 configs -= invoker.suppressed_configs 1128 public_configs = [ 1129 rtc_common_inherited_config, 1130 absl_include_config, 1131 absl_define_config, 1132 ] 1133 if (defined(testonly) && testonly) { 1134 public_configs += [ absl_flags_config ] 1135 } 1136 if (defined(invoker.public_configs)) { 1137 public_configs += invoker.public_configs 1138 } 1139 } 1140 } 1141 1142 if (is_mac || is_ios) { 1143 template("apple_framework_bundle_with_umbrella_header") { 1144 forward_variables_from(invoker, [ "output_name" ]) 1145 this_target_name = target_name 1146 umbrella_header_path = 1147 "$target_gen_dir/$output_name.framework/Headers/$output_name.h" 1148 modulemap_path = "$target_gen_dir/Modules/module.modulemap" 1149 privacy_manifest_path = 1150 "$target_gen_dir/$this_target_name/PrivacyInfo.xcprivacy" 1151 1152 action("umbrella_header_$this_target_name") { 1153 script = "//tools_webrtc/ios/generate_umbrella_header.py" 1154 sources = invoker.sources 1155 outputs = [ umbrella_header_path ] 1156 args = [ 1157 "--out", 1158 rebase_path(umbrella_header_path, root_build_dir), 1159 "--sources", 1160 ] + rebase_path(sources, root_build_dir) 1161 } 1162 1163 action("create_privacy_manifest_$this_target_name") { 1164 script = "//tools_webrtc/apple/generate_privacy_manifest.py" 1165 args = [ 1166 "--output", 1167 rebase_path(privacy_manifest_path), 1168 ] 1169 outputs = [ privacy_manifest_path ] 1170 } 1171 1172 bundle_data("privacy_manifest_bundle_data_$this_target_name") { 1173 deps = [ ":create_privacy_manifest_$this_target_name" ] 1174 sources = get_target_outputs(":create_privacy_manifest_$this_target_name") 1175 if (is_mac || target_environment == "catalyst") { 1176 privacy_manifest_out_path = "Versions/A/Resources/PrivacyInfo.xcprivacy" 1177 } else { 1178 privacy_manifest_out_path = "PrivacyInfo.xcprivacy" 1179 } 1180 outputs = [ "{{bundle_contents_dir}}/$privacy_manifest_out_path" ] 1181 } 1182 1183 if (is_mac) { 1184 mac_framework_bundle(target_name) { 1185 forward_variables_from(invoker, "*", [ "configs" ]) 1186 if (defined(invoker.configs)) { 1187 configs += invoker.configs 1188 } 1189 framework_version = "A" 1190 framework_contents = [ 1191 "Headers", 1192 "Modules", 1193 "Resources", 1194 ] 1195 ldflags = [ 1196 "-all_load", 1197 "-install_name", 1198 "@rpath/$output_name.framework/$output_name", 1199 ] 1200 1201 # This is the fix. The mac framework now has a direct dependency on 1202 # the creation of the privacy manifest, just like the iOS version. 1203 deps += [ 1204 ":copy_modulemap_$this_target_name", 1205 ":copy_umbrella_header_$this_target_name", 1206 ":create_privacy_manifest_$this_target_name", 1207 ":modulemap_$this_target_name", 1208 ":privacy_manifest_bundle_data_$this_target_name", 1209 ] 1210 } 1211 } 1212 if (is_ios) { 1213 ios_framework_bundle(target_name) { 1214 if (defined(invoker.testonly)) { 1215 testonly = invoker.testonly 1216 } 1217 if (defined(invoker.visibility)) { 1218 visibility = invoker.visibility 1219 } 1220 if (defined(invoker.sources)) { 1221 sources = invoker.sources 1222 } 1223 if (defined(invoker.deps)) { 1224 deps = invoker.deps 1225 } 1226 if (defined(invoker.defines)) { 1227 defines = invoker.defines 1228 } 1229 if (defined(invoker.include_dirs)) { 1230 include_dirs = invoker.include_dirs 1231 } 1232 if (defined(invoker.public_configs)) { 1233 public_configs = invoker.public_configs 1234 } 1235 if (defined(invoker.all_dependent_configs)) { 1236 all_dependent_configs = invoker.all_dependent_configs 1237 } 1238 if (defined(invoker.ldflags)) { 1239 ldflags = invoker.ldflags 1240 } 1241 if (defined(invoker.libs)) { 1242 libs = invoker.libs 1243 } 1244 if (defined(invoker.frameworks)) { 1245 frameworks = invoker.frameworks 1246 } 1247 if (defined(invoker.info_plist)) { 1248 info_plist = invoker.info_plist 1249 } 1250 if (defined(invoker.configs)) { 1251 configs += invoker.configs 1252 } 1253 1254 if (defined(invoker.public_headers)) { 1255 public_headers = invoker.public_headers 1256 } else { 1257 public_headers = [] 1258 } 1259 public_headers += 1260 get_target_outputs(":umbrella_header_$this_target_name") 1261 1262 deps += [ 1263 ":create_privacy_manifest_$this_target_name", 1264 ":umbrella_header_$this_target_name", 1265 ] 1266 1267 if (defined(invoker.bundle_deps)) { 1268 bundle_deps = invoker.bundle_deps 1269 } else { 1270 bundle_deps = [] 1271 } 1272 bundle_deps += [ ":privacy_manifest_bundle_data_$this_target_name" ] 1273 } 1274 } 1275 1276 action("modulemap_$this_target_name") { 1277 script = "//tools_webrtc/ios/generate_modulemap.py" 1278 args = [ 1279 "--out", 1280 rebase_path(modulemap_path, root_build_dir), 1281 "--name", 1282 output_name, 1283 ] 1284 outputs = [ modulemap_path ] 1285 } 1286 1287 bundle_data("copy_modulemap_$this_target_name") { 1288 sources = [ modulemap_path ] 1289 outputs = [ "{{bundle_contents_dir}}/Modules/module.modulemap" ] 1290 deps = [ ":modulemap_$this_target_name" ] 1291 } 1292 1293 if (is_mac) { 1294 headers_dir = "Versions/A/Headers" 1295 copy("copy_umbrella_header_$this_target_name") { 1296 sources = [ umbrella_header_path ] 1297 outputs = [ 1298 "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h", 1299 ] 1300 deps = [ ":umbrella_header_$this_target_name" ] 1301 } 1302 } 1303 } 1304 } 1305 1306 if (is_android && !build_with_mozilla) { 1307 template("rtc_android_library") { 1308 android_library(target_name) { 1309 forward_variables_from(invoker, 1310 "*", 1311 [ 1312 "configs", 1313 "public_configs", 1314 "suppressed_configs", 1315 "visibility", 1316 ]) 1317 1318 # Add any arguments defined by the invoker. 1319 if (defined(invoker.errorprone_args)) { 1320 errorprone_args = invoker.errorprone_args 1321 } 1322 1323 not_needed([ "android_manifest" ]) 1324 } 1325 } 1326 1327 template("rtc_android_apk") { 1328 android_apk(target_name) { 1329 forward_variables_from(invoker, 1330 "*", 1331 [ 1332 "configs", 1333 "public_configs", 1334 "suppressed_configs", 1335 "visibility", 1336 ]) 1337 } 1338 } 1339 1340 template("rtc_instrumentation_test_apk") { 1341 instrumentation_test_apk(target_name) { 1342 forward_variables_from(invoker, 1343 "*", 1344 [ 1345 "configs", 1346 "public_configs", 1347 "suppressed_configs", 1348 "visibility", 1349 ]) 1350 deps += [ "//third_party/jni_zero:jni_zero_java" ] 1351 } 1352 } 1353 }