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 9# This is the root build file for GN. GN will start processing by loading this 10# file, and recursively load all dependencies until all dependencies are either 11# resolved or known not to exist (which will cause the build to fail). So if 12# you add a new build file, there must be some path of dependencies from this 13# file to your new one or GN won't know about it. 14 15import("//build/config/linux/pkg_config.gni") 16import("//build/config/sanitizers/sanitizers.gni") 17import("webrtc.gni") 18if (rtc_enable_protobuf) { 19 import("//third_party/protobuf/proto_library.gni") 20} 21if (is_android) { 22 import("//build/config/android/config.gni") 23 import("//build/config/android/rules.gni") 24} 25 26if (!build_with_chromium) { 27 # This target should (transitively) cause everything to be built; if you run 28 # 'ninja default' and then 'ninja all', the second build should do no work. 29 group("default") { 30 testonly = true 31 deps = [ ":webrtc" ] 32 if (rtc_build_examples) { 33 deps += [ "examples" ] 34 } 35 if (rtc_build_tools) { 36 deps += [ "rtc_tools" ] 37 } 38 if (rtc_include_tests) { 39 deps += [ 40 ":rtc_unittests", 41 ":slow_tests", 42 ":video_engine_tests", 43 ":voip_unittests", 44 ":webrtc_nonparallel_tests", 45 ":webrtc_perf_tests", 46 "common_audio:common_audio_unittests", 47 "common_video:common_video_unittests", 48 "examples:examples_unittests", 49 "media:rtc_media_unittests", 50 "modules:modules_tests", 51 "modules:modules_unittests", 52 "modules/audio_coding:audio_coding_tests", 53 "modules/audio_processing:audio_processing_tests", 54 "modules/remote_bitrate_estimator:rtp_to_text", 55 "modules/rtp_rtcp:test_packet_masks_metrics", 56 "modules/video_capture:video_capture_internal_impl", 57 "pc:peerconnection_unittests", 58 "pc:rtc_pc_unittests", 59 "rtc_tools:rtp_generator", 60 "rtc_tools:video_replay", 61 "stats:rtc_stats_unittests", 62 "system_wrappers:system_wrappers_unittests", 63 "test", 64 "video:screenshare_loopback", 65 "video:sv_loopback", 66 "video:video_loopback", 67 ] 68 if (!is_asan) { 69 # Do not build :webrtc_lib_link_test because lld complains on some OS 70 # (e.g. when target_os = "mac") when is_asan=true. For more details, 71 # see bugs.webrtc.org/11027#c5. 72 deps += [ ":webrtc_lib_link_test" ] 73 } 74 if (is_android) { 75 deps += [ 76 "examples:android_examples_junit_tests", 77 "sdk/android:android_instrumentation_test_apk", 78 "sdk/android:android_sdk_junit_tests", 79 ] 80 } else { 81 deps += [ "modules/video_capture:video_capture_tests" ] 82 } 83 if (rtc_enable_protobuf) { 84 deps += [ 85 "audio:low_bandwidth_audio_test", 86 "logging:rtc_event_log_rtp_dump", 87 "tools_webrtc/perf:webrtc_dashboard_upload", 88 ] 89 } 90 } 91 } 92} 93 94# Abseil Flags by default doesn't register command line flags on mobile 95# platforms, WebRTC tests requires them (e.g. on simualtors) so this 96# config will be applied to testonly targets globally (see webrtc.gni). 97config("absl_flags_configs") { 98 defines = [ "ABSL_FLAGS_STRIP_NAMES=0" ] 99} 100 101config("library_impl_config") { 102 # Build targets that contain WebRTC implementation need this macro to 103 # be defined in order to correctly export symbols when is_component_build 104 # is true. 105 # For more info see: rtc_base/build/rtc_export.h. 106 defines = [ "WEBRTC_LIBRARY_IMPL" ] 107} 108 109# Contains the defines and includes in common.gypi that are duplicated both as 110# target_defaults and direct_dependent_settings. 111config("common_inherited_config") { 112 defines = [] 113 cflags = [] 114 ldflags = [] 115 116 if (rtc_enable_symbol_export || is_component_build) { 117 defines = [ "WEBRTC_ENABLE_SYMBOL_EXPORT" ] 118 } 119 120 if (build_with_mozilla) { 121 defines += [ "WEBRTC_MOZILLA_BUILD" ] 122 } 123 124 if (!rtc_builtin_ssl_root_certificates) { 125 defines += [ "WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS" ] 126 } 127 128 if (rtc_disable_check_msg) { 129 defines += [ "RTC_DISABLE_CHECK_MSG" ] 130 } 131 132 # Some tests need to declare their own trace event handlers. If this define is 133 # not set, the first time TRACE_EVENT_* is called it will store the return 134 # value for the current handler in an static variable, so that subsequent 135 # changes to the handler for that TRACE_EVENT_* will be ignored. 136 # So when tests are included, we set this define, making it possible to use 137 # different event handlers in different tests. 138 if (rtc_include_tests) { 139 defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1" ] 140 } else { 141 defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0" ] 142 } 143 if (build_with_chromium) { 144 defines += [ "WEBRTC_CHROMIUM_BUILD" ] 145 include_dirs = [ 146 # The overrides must be included first as that is the mechanism for 147 # selecting the override headers in Chromium. 148 "../webrtc_overrides", 149 150 # Allow includes to be prefixed with webrtc/ in case it is not an 151 # immediate subdirectory of the top-level. 152 ".", 153 154 # Just like the root WebRTC directory is added to include path, the 155 # corresponding directory tree with generated files needs to be added too. 156 # Note: this path does not change depending on the current target, e.g. 157 # it is always "//gen/third_party/webrtc" when building with Chromium. 158 # See also: http://cs.chromium.org/?q=%5C"default_include_dirs 159 # https://gn.googlesource.com/gn/+/master/docs/reference.md#target_gen_dir 160 target_gen_dir, 161 ] 162 } 163 if (is_posix || is_fuchsia) { 164 defines += [ "WEBRTC_POSIX" ] 165 } 166 if (is_ios) { 167 defines += [ 168 "WEBRTC_MAC", 169 "WEBRTC_IOS", 170 ] 171 } 172 if (is_linux) { 173 defines += [ "WEBRTC_LINUX" ] 174 } 175 if (is_bsd) { 176 defines += [ "WEBRTC_BSD" ] 177 } 178 if (is_mac) { 179 defines += [ "WEBRTC_MAC" ] 180 } 181 if (is_fuchsia) { 182 defines += [ "WEBRTC_FUCHSIA" ] 183 } 184 if (is_win) { 185 defines += [ "WEBRTC_WIN" ] 186 } 187 if (is_android) { 188 defines += [ 189 "WEBRTC_LINUX", 190 "WEBRTC_ANDROID", 191 ] 192 193 if (build_with_mozilla) { 194 defines += [ "WEBRTC_ANDROID_OPENSLES" ] 195 } 196 } 197 if (is_chromeos) { 198 defines += [ "CHROMEOS" ] 199 } 200 201 if (rtc_sanitize_coverage != "") { 202 assert(is_clang, "sanitizer coverage requires clang") 203 cflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ] 204 ldflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ] 205 } 206 207 if (is_ubsan) { 208 cflags += [ "-fsanitize=float-cast-overflow" ] 209 } 210} 211 212# TODO(bugs.webrtc.org/9693): Remove the possibility to suppress this warning 213# as soon as WebRTC compiles without it. 214config("no_exit_time_destructors") { 215 if (is_clang) { 216 cflags = [ "-Wno-exit-time-destructors" ] 217 } 218} 219 220# TODO(bugs.webrtc.org/9693): Remove the possibility to suppress this warning 221# as soon as WebRTC compiles without it. 222config("no_global_constructors") { 223 if (is_clang) { 224 cflags = [ "-Wno-global-constructors" ] 225 } 226} 227 228config("rtc_prod_config") { 229 # Ideally, WebRTC production code (but not test code) should have these flags. 230 if (is_clang) { 231 cflags = [ 232 "-Wexit-time-destructors", 233 "-Wglobal-constructors", 234 ] 235 } 236} 237 238config("common_config") { 239 cflags = [] 240 cflags_c = [] 241 cflags_cc = [] 242 cflags_objc = [] 243 defines = [] 244 245 if (rtc_enable_protobuf) { 246 defines += [ "WEBRTC_ENABLE_PROTOBUF=1" ] 247 } else { 248 defines += [ "WEBRTC_ENABLE_PROTOBUF=0" ] 249 } 250 251 if (rtc_include_internal_audio_device) { 252 defines += [ "WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE" ] 253 } 254 255 if (rtc_libvpx_build_vp9) { 256 defines += [ "RTC_ENABLE_VP9" ] 257 } 258 259 if (rtc_enable_sctp) { 260 defines += [ "HAVE_SCTP" ] 261 } 262 263 if (rtc_enable_external_auth) { 264 defines += [ "ENABLE_EXTERNAL_AUTH" ] 265 } 266 267 if (rtc_use_h264) { 268 defines += [ "WEBRTC_USE_H264" ] 269 } 270 271 if (rtc_disable_logging) { 272 defines += [ "RTC_DISABLE_LOGGING" ] 273 } 274 275 if (rtc_disable_trace_events) { 276 defines += [ "RTC_DISABLE_TRACE_EVENTS" ] 277 } 278 279 if (rtc_disable_metrics) { 280 defines += [ "RTC_DISABLE_METRICS" ] 281 } 282 283 if (rtc_exclude_transient_suppressor) { 284 defines += [ "WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR" ] 285 } 286 287 cflags = [] 288 289 if (build_with_chromium) { 290 defines += [ 291 # NOTICE: Since common_inherited_config is used in public_configs for our 292 # targets, there's no point including the defines in that config here. 293 # TODO(kjellander): Cleanup unused ones and move defines closer to the 294 # source when webrtc:4256 is completed. 295 "HAVE_WEBRTC_VIDEO", 296 "LOGGING_INSIDE_WEBRTC", 297 ] 298 } else { 299 if (is_posix || is_fuchsia) { 300 cflags_c += [ 301 # TODO(bugs.webrtc.org/9029): enable commented compiler flags. 302 # Some of these flags should also be added to cflags_objc. 303 304 # "-Wextra", (used when building C++ but not when building C) 305 # "-Wmissing-prototypes", (C/Obj-C only) 306 # "-Wmissing-declarations", (ensure this is always used C/C++, etc..) 307 "-Wstrict-prototypes", 308 309 # "-Wpointer-arith", (ensure this is always used C/C++, etc..) 310 # "-Wbad-function-cast", (C/Obj-C only) 311 # "-Wnested-externs", (C/Obj-C only) 312 ] 313 cflags_objc += [ "-Wstrict-prototypes" ] 314 cflags_cc = [ 315 "-Wnon-virtual-dtor", 316 317 # This is enabled for clang; enable for gcc as well. 318 "-Woverloaded-virtual", 319 ] 320 } 321 322 if (is_clang) { 323 cflags += [ 324 "-Wc++11-narrowing", 325 "-Wimplicit-fallthrough", 326 "-Wthread-safety", 327 "-Winconsistent-missing-override", 328 "-Wundef", 329 ] 330 331 # use_xcode_clang only refers to the iOS toolchain, host binaries use 332 # chromium's clang always. 333 if (!is_nacl && 334 (!use_xcode_clang || current_toolchain == host_toolchain)) { 335 # Flags NaCl (Clang 3.7) and Xcode 7.3 (Clang clang-703.0.31) do not 336 # recognize. 337 cflags += [ "-Wunused-lambda-capture" ] 338 } 339 } 340 341 if (is_win && !is_clang) { 342 # MSVC warning suppressions (needed to use Abseil). 343 # TODO(bugs.webrtc.org/9274): Remove these warnings as soon as MSVC allows 344 # external headers warning suppression (or fix them upstream). 345 cflags += [ "/wd4702" ] # unreachable code 346 347 # MSVC 2019 warning suppressions for C++17 compiling 348 cflags += 349 [ "/wd5041" ] # out-of-line definition for constexpr static data 350 # member is not needed and is deprecated in C++17 351 } 352 } 353 354 if (current_cpu == "arm64") { 355 defines += [ "WEBRTC_ARCH_ARM64" ] 356 defines += [ "WEBRTC_HAS_NEON" ] 357 } 358 359 if (current_cpu == "arm") { 360 defines += [ "WEBRTC_ARCH_ARM" ] 361 if (arm_version >= 7) { 362 defines += [ "WEBRTC_ARCH_ARM_V7" ] 363 if (arm_use_neon) { 364 defines += [ "WEBRTC_HAS_NEON" ] 365 } 366 } 367 } 368 369 if (current_cpu == "mipsel") { 370 defines += [ "MIPS32_LE" ] 371 if (mips_float_abi == "hard") { 372 defines += [ "MIPS_FPU_LE" ] 373 } 374 if (mips_arch_variant == "r2") { 375 defines += [ "MIPS32_R2_LE" ] 376 } 377 if (mips_dsp_rev == 1) { 378 defines += [ "MIPS_DSP_R1_LE" ] 379 } else if (mips_dsp_rev == 2) { 380 defines += [ 381 "MIPS_DSP_R1_LE", 382 "MIPS_DSP_R2_LE", 383 ] 384 } 385 } 386 387 if (is_android && !is_clang) { 388 # The Android NDK doesn"t provide optimized versions of these 389 # functions. Ensure they are disabled for all compilers. 390 cflags += [ 391 "-fno-builtin-cos", 392 "-fno-builtin-sin", 393 "-fno-builtin-cosf", 394 "-fno-builtin-sinf", 395 ] 396 } 397 398 if (use_fuzzing_engine && optimize_for_fuzzing) { 399 # Used in Chromium's overrides to disable logging 400 defines += [ "WEBRTC_UNSAFE_FUZZER_MODE" ] 401 } 402 403 if (!build_with_chromium && rtc_win_undef_unicode) { 404 cflags += [ 405 "/UUNICODE", 406 "/U_UNICODE", 407 ] 408 } 409} 410 411config("common_objc") { 412 libs = [ "Foundation.framework" ] 413 414 if (rtc_use_metal_rendering) { 415 defines = [ "RTC_SUPPORTS_METAL" ] 416 } 417} 418 419if (!build_with_chromium) { 420 # Target to build all the WebRTC production code. 421 rtc_static_library("webrtc") { 422 # Only the root target and the test should depend on this. 423 visibility = [ 424 "//:default", 425 "//:webrtc_lib_link_test", 426 ] 427 428 sources = [] 429 complete_static_lib = true 430 suppressed_configs += [ "//build/config/compiler:thin_archive" ] 431 defines = [] 432 433 deps = [ 434 ":webrtc_common", 435 "api:create_peerconnection_factory", 436 "api:libjingle_peerconnection_api", 437 "api:rtc_error", 438 "api:transport_api", 439 "api/crypto", 440 "api/rtc_event_log:rtc_event_log_factory", 441 "api/task_queue", 442 "api/task_queue:default_task_queue_factory", 443 "audio", 444 "call", 445 "common_audio", 446 "common_video", 447 "logging:rtc_event_log_api", 448 "media", 449 "modules", 450 "modules/video_capture:video_capture_internal_impl", 451 "p2p:rtc_p2p", 452 "pc:libjingle_peerconnection", 453 "pc:peerconnection", 454 "pc:rtc_pc", 455 "pc:rtc_pc_base", 456 "rtc_base", 457 "sdk", 458 "video", 459 ] 460 461 if (rtc_include_builtin_audio_codecs) { 462 deps += [ 463 "api/audio_codecs:builtin_audio_decoder_factory", 464 "api/audio_codecs:builtin_audio_encoder_factory", 465 ] 466 } 467 468 if (rtc_include_builtin_video_codecs) { 469 deps += [ 470 "api/video_codecs:builtin_video_decoder_factory", 471 "api/video_codecs:builtin_video_encoder_factory", 472 ] 473 } 474 475 if (build_with_mozilla) { 476 deps += [ 477 "api/video:video_frame", 478 "api/video:video_rtp_headers", 479 ] 480 } else { 481 deps += [ 482 "api", 483 "logging", 484 "p2p", 485 "pc", 486 "stats", 487 ] 488 } 489 490 if (rtc_enable_protobuf) { 491 deps += [ "logging:rtc_event_log_proto" ] 492 } 493 } 494 495 if (rtc_include_tests && !is_asan) { 496 rtc_executable("webrtc_lib_link_test") { 497 testonly = true 498 499 sources = [ "webrtc_lib_link_test.cc" ] 500 deps = [ 501 # NOTE: Don't add deps here. If this test fails to link, it means you 502 # need to add stuff to the webrtc static lib target above. 503 ":webrtc", 504 ] 505 } 506 } 507} 508 509rtc_source_set("webrtc_common") { 510 # Client code SHOULD NOT USE THIS TARGET, but for now it needs to be public 511 # because there exists client code that uses it. 512 # TODO(bugs.webrtc.org/9808): Move to private visibility as soon as that 513 # client code gets updated. 514 visibility = [ "*" ] 515 sources = [ "common_types.h" ] 516} 517 518if (use_libfuzzer || use_afl) { 519 # This target is only here for gn to discover fuzzer build targets under 520 # webrtc/test/fuzzers/. 521 group("webrtc_fuzzers_dummy") { 522 testonly = true 523 deps = [ "test/fuzzers:webrtc_fuzzer_main" ] 524 } 525} 526 527if (rtc_include_tests) { 528 rtc_test("rtc_unittests") { 529 testonly = true 530 531 deps = [ 532 ":webrtc_common", 533 "api:compile_all_headers", 534 "api:rtc_api_unittests", 535 "api/audio/test:audio_api_unittests", 536 "api/audio_codecs/test:audio_codecs_api_unittests", 537 "api/transport:stun_unittest", 538 "api/video/test:rtc_api_video_unittests", 539 "api/video_codecs/test:video_codecs_api_unittests", 540 "call:fake_network_pipe_unittests", 541 "p2p:libstunprober_unittests", 542 "p2p:rtc_p2p_unittests", 543 "rtc_base:rtc_base_approved_unittests", 544 "rtc_base:rtc_base_unittests", 545 "rtc_base:rtc_json_unittests", 546 "rtc_base:rtc_numerics_unittests", 547 "rtc_base:rtc_operations_chain_unittests", 548 "rtc_base:rtc_task_queue_unittests", 549 "rtc_base:sigslot_unittest", 550 "rtc_base:weak_ptr_unittests", 551 "rtc_base/experiments:experiments_unittests", 552 "rtc_base/synchronization:sequence_checker_unittests", 553 "rtc_base/task_utils:to_queued_task_unittests", 554 "sdk:sdk_tests", 555 "test:rtp_test_utils", 556 "test:test_main", 557 "test/network:network_emulation_unittests", 558 ] 559 560 if (rtc_enable_protobuf) { 561 deps += [ "logging:rtc_event_log_tests" ] 562 } 563 564 if (is_android) { 565 # Do not use Chromium's launcher. native_unittests defines its own JNI_OnLoad. 566 use_default_launcher = false 567 568 deps += [ 569 "sdk/android:native_unittests", 570 "sdk/android:native_unittests_java", 571 "//testing/android/native_test:native_test_support", 572 ] 573 shard_timeout = 900 574 } 575 576 if (is_ios || is_mac) { 577 deps += [ "sdk:rtc_unittests_objc" ] 578 } 579 } 580 581 # This runs tests that must run in real time and therefore can take some 582 # time to execute. They are in a separate executable to avoid making the 583 # regular unittest suite too slow to run frequently. 584 rtc_test("slow_tests") { 585 testonly = true 586 deps = [ 587 "rtc_base/task_utils:repeating_task_unittests", 588 "test:test_main", 589 ] 590 } 591 592 # TODO(pbos): Rename test suite, this is no longer "just" for video targets. 593 video_engine_tests_resources = [ 594 "resources/foreman_cif_short.yuv", 595 "resources/voice_engine/audio_long16.pcm", 596 ] 597 598 if (is_ios) { 599 bundle_data("video_engine_tests_bundle_data") { 600 testonly = true 601 sources = video_engine_tests_resources 602 outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ] 603 } 604 } 605 606 rtc_test("video_engine_tests") { 607 testonly = true 608 deps = [ 609 "audio:audio_tests", 610 611 # TODO(eladalon): call_tests aren't actually video-specific, so we 612 # should move them to a more appropriate test suite. 613 "call:call_tests", 614 "call/adaptation:resource_adaptation_tests", 615 "test:test_common", 616 "test:test_main", 617 "test:video_test_common", 618 "video:video_tests", 619 "video/adaptation:video_adaptation_tests", 620 ] 621 data = video_engine_tests_resources 622 if (is_android) { 623 deps += [ "//testing/android/native_test:native_test_native_code" ] 624 shard_timeout = 900 625 } 626 if (is_ios) { 627 deps += [ ":video_engine_tests_bundle_data" ] 628 } 629 } 630 631 webrtc_perf_tests_resources = [ 632 "resources/ConferenceMotion_1280_720_50.yuv", 633 "resources/audio_coding/speech_mono_16kHz.pcm", 634 "resources/audio_coding/speech_mono_32_48kHz.pcm", 635 "resources/audio_coding/testfile32kHz.pcm", 636 "resources/difficult_photo_1850_1110.yuv", 637 "resources/foreman_cif.yuv", 638 "resources/paris_qcif.yuv", 639 "resources/photo_1850_1110.yuv", 640 "resources/presentation_1850_1110.yuv", 641 "resources/voice_engine/audio_long16.pcm", 642 "resources/web_screenshot_1850_1110.yuv", 643 ] 644 645 if (is_ios) { 646 bundle_data("webrtc_perf_tests_bundle_data") { 647 testonly = true 648 sources = webrtc_perf_tests_resources 649 outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ] 650 } 651 } 652 653 rtc_test("webrtc_perf_tests") { 654 testonly = true 655 deps = [ 656 "audio:audio_perf_tests", 657 "call:call_perf_tests", 658 "modules/audio_coding:audio_coding_perf_tests", 659 "modules/audio_processing:audio_processing_perf_tests", 660 "pc:peerconnection_perf_tests", 661 "test:test_main", 662 "video:video_full_stack_tests", 663 "video:video_pc_full_stack_tests", 664 ] 665 666 data = webrtc_perf_tests_resources 667 if (is_android) { 668 deps += [ "//testing/android/native_test:native_test_native_code" ] 669 shard_timeout = 4500 670 } 671 if (is_ios) { 672 deps += [ ":webrtc_perf_tests_bundle_data" ] 673 } 674 } 675 676 rtc_test("webrtc_nonparallel_tests") { 677 testonly = true 678 deps = [ "rtc_base:rtc_base_nonparallel_tests" ] 679 if (is_android) { 680 deps += [ "//testing/android/native_test:native_test_support" ] 681 shard_timeout = 900 682 } 683 } 684 685 rtc_test("voip_unittests") { 686 testonly = true 687 deps = [ 688 "audio/voip/test:audio_egress_unittests", 689 "test:test_main", 690 ] 691 } 692} 693 694# ---- Poisons ---- 695# 696# Here is one empty dummy target for each poison type (needed because 697# "being poisonous with poison type foo" is implemented as "depends on 698# //:poison_foo"). 699# 700# The set of poison_* targets needs to be kept in sync with the 701# `all_poison_types` list in webrtc.gni. 702# 703group("poison_audio_codecs") { 704} 705 706group("poison_default_task_queue") { 707} 708 709group("poison_rtc_json") { 710} 711 712group("poison_software_video_codecs") { 713} 714