1 # Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 # Use of this source code is governed by a BSD-style license
4 # that can be found in the LICENSE file in the root of the source
5 # tree. An additional intellectual property rights grant can be found
6 # in the file PATENTS. All contributing project authors may
7 # be found in the AUTHORS file in the root of the source tree.
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.
15 # Use of visibility = clauses:
16 # The default visibility for all rtc_ targets is equivalent to "//*", or
17 # "all targets in webrtc can depend on this, nothing outside can".
19 # When overriding, the choices are:
20 # - visibility = [ "*" ] - public. Stuff outside webrtc can use this.
21 # - visibility = [ ":*" ] - directory private.
22 # As a general guideline, only targets in api/ should have public visibility.
24 import("//build/config/linux/pkg_config.gni")
25 import("//build/config/sanitizers/sanitizers.gni")
27 if (rtc_enable_protobuf) {
28 import("//third_party/protobuf/proto_library.gni")
31 import("//build/config/android/config.gni")
32 import("//build/config/android/rules.gni")
35 if (!build_with_chromium && !build_with_mozilla) {
36 # This target should (transitively) cause everything to be built; if you run
37 # 'ninja default' and then 'ninja all', the second build should do no work.
41 if (rtc_build_examples) {
42 deps += [ "examples" ]
44 if (rtc_build_tools) {
45 deps += [ "rtc_tools" ]
47 if (rtc_include_tests) {
50 ":video_engine_tests",
52 ":webrtc_nonparallel_tests",
54 "common_audio:common_audio_unittests",
55 "common_video:common_video_unittests",
56 "examples:examples_unittests",
57 "media:rtc_media_unittests",
58 "modules:modules_tests",
59 "modules:modules_unittests",
60 "modules/audio_coding:audio_coding_tests",
61 "modules/audio_processing:audio_processing_tests",
62 "modules/remote_bitrate_estimator:rtp_to_text",
63 "modules/rtp_rtcp:test_packet_masks_metrics",
64 "modules/video_capture:video_capture_internal_impl",
65 "modules/video_coding:video_codec_perf_tests",
66 "net/dcsctp:dcsctp_unittests",
67 "pc:peerconnection_unittests",
68 "pc:rtc_pc_unittests",
69 "pc:slow_peer_connection_unittests",
71 "rtc_tools:rtp_generator",
72 "rtc_tools:video_encoder",
73 "rtc_tools:video_replay",
74 "stats:rtc_stats_unittests",
75 "system_wrappers:system_wrappers_unittests",
77 "video:screenshare_loopback",
79 "video:video_loopback",
82 # Do not build :webrtc_lib_link_test because lld complains on some OS
83 # (e.g. when target_os = "mac") when is_asan=true. For more details,
84 # see bugs.webrtc.org/11027#c5.
85 deps += [ ":webrtc_lib_link_test" ]
89 "examples:apprtcmobile_tests",
90 "sdk:sdk_framework_unittests",
96 "examples:android_examples_junit_tests",
97 "sdk/android:android_instrumentation_test_apk",
98 "sdk/android:android_sdk_junit_tests",
101 deps += [ "modules/video_capture:video_capture_tests" ]
103 if (rtc_enable_protobuf) {
105 "logging:rtc_event_log_rtp_dump",
106 "tools_webrtc/perf:webrtc_dashboard_upload",
109 if ((is_linux || is_chromeos) && rtc_use_pipewire) {
110 deps += [ "modules/desktop_capture:shared_screencast_stream_test" ]
113 if (target_os == "android") {
114 deps += [ "tools_webrtc:binary_version_check" ]
119 # Abseil Flags by default doesn't register command line flags on mobile
120 # platforms, WebRTC tests requires them (e.g. on simualtors) so this
121 # config will be applied to testonly targets globally (see webrtc.gni).
122 config("absl_flags_configs") {
123 defines = [ "ABSL_FLAGS_STRIP_NAMES=0" ]
126 config("library_impl_config") {
127 # Build targets that contain WebRTC implementation need this macro to
128 # be defined in order to correctly export symbols when is_component_build
130 # For more info see: rtc_base/build/rtc_export.h.
131 defines = [ "WEBRTC_LIBRARY_IMPL" ]
134 # Contains the defines and includes in common.gypi that are duplicated both as
135 # target_defaults and direct_dependent_settings.
136 config("common_inherited_config") {
141 if (rtc_jni_generator_legacy_symbols) {
142 defines += [ "RTC_JNI_GENERATOR_LEGACY_SYMBOLS" ]
145 if (rtc_objc_prefix != "") {
146 defines += [ "RTC_OBJC_TYPE_PREFIX=${rtc_objc_prefix}" ]
149 if (rtc_dlog_always_on) {
150 defines += [ "DLOG_ALWAYS_ON" ]
153 if (rtc_enable_symbol_export || is_component_build) {
154 defines += [ "WEBRTC_ENABLE_SYMBOL_EXPORT" ]
156 if (rtc_enable_objc_symbol_export) {
157 defines += [ "WEBRTC_ENABLE_OBJC_SYMBOL_EXPORT" ]
160 if (build_with_mozilla) {
161 defines += [ "WEBRTC_MOZILLA_BUILD" ]
164 if (!rtc_builtin_ssl_root_certificates) {
165 defines += [ "WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS" ]
168 if (rtc_disable_check_msg) {
169 defines += [ "RTC_DISABLE_CHECK_MSG" ]
172 if (rtc_enable_avx2) {
173 defines += [ "WEBRTC_ENABLE_AVX2" ]
176 if (rtc_enable_win_wgc) {
177 defines += [ "RTC_ENABLE_WIN_WGC" ]
180 # Some tests need to declare their own trace event handlers. If this define is
181 # not set, the first time TRACE_EVENT_* is called it will store the return
182 # value for the current handler in an static variable, so that subsequent
183 # changes to the handler for that TRACE_EVENT_* will be ignored.
184 # So when tests are included, we set this define, making it possible to use
185 # different event handlers in different tests.
186 if (rtc_include_tests) {
187 defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1" ]
189 defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0" ]
191 if (build_with_chromium) {
192 defines += [ "WEBRTC_CHROMIUM_BUILD" ]
194 # The overrides must be included first as that is the mechanism for
195 # selecting the override headers in Chromium.
196 "../webrtc_overrides",
198 # Allow includes to be prefixed with webrtc/ in case it is not an
199 # immediate subdirectory of the top-level.
202 # Just like the root WebRTC directory is added to include path, the
203 # corresponding directory tree with generated files needs to be added too.
204 # Note: this path does not change depending on the current target, e.g.
205 # it is always "//gen/third_party/webrtc" when building with Chromium.
206 # See also: http://cs.chromium.org/?q=%5C"default_include_dirs
207 # https://gn.googlesource.com/gn/+/master/docs/reference.md#target_gen_dir
211 if (is_posix || is_fuchsia) {
212 defines += [ "WEBRTC_POSIX" ]
220 if (is_linux || is_chromeos) {
221 defines += [ "WEBRTC_LINUX" ]
224 defines += [ "WEBRTC_BSD" ]
227 defines += [ "WEBRTC_MAC" ]
230 defines += [ "WEBRTC_FUCHSIA" ]
233 defines += [ "WEBRTC_WIN" ]
241 if (build_with_mozilla) {
242 defines += [ "WEBRTC_ANDROID_OPENSLES" ]
246 defines += [ "CHROMEOS" ]
249 if (rtc_sanitize_coverage != "") {
250 assert(is_clang, "sanitizer coverage requires clang")
251 cflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
252 ldflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
256 cflags += [ "-fsanitize=float-cast-overflow" ]
260 # TODO(bugs.webrtc.org/9693): Remove the possibility to suppress this warning
261 # as soon as WebRTC compiles without it.
262 config("no_global_constructors") {
264 cflags = [ "-Wno-global-constructors" ]
268 config("rtc_prod_config") {
269 # Ideally, WebRTC production code (but not test code) should have these flags.
272 "-Wexit-time-destructors",
273 "-Wglobal-constructors",
278 config("common_config") {
285 if (rtc_enable_protobuf) {
286 defines += [ "WEBRTC_ENABLE_PROTOBUF=1" ]
288 defines += [ "WEBRTC_ENABLE_PROTOBUF=0" ]
291 if (rtc_strict_field_trials == "") {
292 defines += [ "WEBRTC_STRICT_FIELD_TRIALS=0" ]
293 } else if (rtc_strict_field_trials == "dcheck") {
294 defines += [ "WEBRTC_STRICT_FIELD_TRIALS=1" ]
295 } else if (rtc_strict_field_trials == "warn") {
296 defines += [ "WEBRTC_STRICT_FIELD_TRIALS=2" ]
299 "Unsupported value for rtc_strict_field_trials: " +
300 "$rtc_strict_field_trials")
303 if (rtc_include_internal_audio_device) {
304 defines += [ "WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE" ]
307 if (rtc_libvpx_build_vp9) {
308 defines += [ "RTC_ENABLE_VP9" ]
311 if (rtc_include_dav1d_in_internal_decoder_factory) {
312 defines += [ "RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY" ]
315 if (rtc_enable_sctp) {
316 defines += [ "WEBRTC_HAVE_SCTP" ]
319 if (rtc_enable_external_auth) {
320 defines += [ "ENABLE_EXTERNAL_AUTH" ]
324 defines += [ "WEBRTC_USE_H264" ]
327 if (rtc_use_absl_mutex) {
328 defines += [ "WEBRTC_ABSL_MUTEX" ]
331 if (rtc_disable_logging) {
332 defines += [ "RTC_DISABLE_LOGGING" ]
335 if (rtc_disable_trace_events) {
336 defines += [ "RTC_DISABLE_TRACE_EVENTS" ]
339 if (rtc_disable_metrics) {
340 defines += [ "RTC_DISABLE_METRICS" ]
343 if (rtc_exclude_transient_suppressor) {
344 defines += [ "WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR" ]
347 if (rtc_exclude_audio_processing_module) {
348 defines += [ "WEBRTC_EXCLUDE_AUDIO_PROCESSING_MODULE" ]
353 # TODO(webrtc:13219): Fix -Wshadow instances and enable.
356 # See https://reviews.llvm.org/D56731 for details about this
358 "-Wctad-maybe-unsupported",
362 if (build_with_chromium) {
364 # NOTICE: Since common_inherited_config is used in public_configs for our
365 # targets, there's no point including the defines in that config here.
366 # TODO(kjellander): Cleanup unused ones and move defines closer to the
367 # source when webrtc:4256 is completed.
369 "LOGGING_INSIDE_WEBRTC",
372 if (is_posix || is_fuchsia) {
374 # TODO(bugs.webrtc.org/9029): enable commented compiler flags.
375 # Some of these flags should also be added to cflags_objc.
377 # "-Wextra", (used when building C++ but not when building C)
378 # "-Wmissing-prototypes", (C/Obj-C only)
379 # "-Wmissing-declarations", (ensure this is always used C/C++, etc..)
380 "-Wstrict-prototypes",
382 # "-Wpointer-arith", (ensure this is always used C/C++, etc..)
383 # "-Wbad-function-cast", (C/Obj-C only)
384 # "-Wnested-externs", (C/Obj-C only)
386 cflags_objc += [ "-Wstrict-prototypes" ]
388 "-Wnon-virtual-dtor",
390 # This is enabled for clang; enable for gcc as well.
391 "-Woverloaded-virtual",
396 cflags += [ "-Wc++11-narrowing" ]
399 # Compiling with the Fuchsia SDK results in Wundef errors
400 # TODO(bugs.fuchsia.dev/100722): Remove from (!is_fuchsia) branch when
401 # Fuchsia build errors are fixed.
402 cflags += [ "-Wundef" ]
406 # Flags NaCl (Clang 3.7) do not recognize.
407 cflags += [ "-Wunused-lambda-capture" ]
411 if (is_win && !is_clang) {
412 # MSVC warning suppressions (needed to use Abseil).
413 # TODO(bugs.webrtc.org/9274): Remove these warnings as soon as MSVC allows
414 # external headers warning suppression (or fix them upstream).
415 cflags += [ "/wd4702" ] # unreachable code
417 # MSVC 2019 warning suppressions for C++17 compiling
419 [ "/wd5041" ] # out-of-line definition for constexpr static data
420 # member is not needed and is deprecated in C++17
424 if (target_cpu == "arm64") {
425 defines += [ "WEBRTC_ARCH_ARM64" ]
426 defines += [ "WEBRTC_HAS_NEON" ]
429 if (target_cpu == "arm") {
430 defines += [ "WEBRTC_ARCH_ARM" ]
431 if (arm_version >= 7) {
432 defines += [ "WEBRTC_ARCH_ARM_V7" ]
434 defines += [ "WEBRTC_HAS_NEON" ]
439 if (target_cpu == "mipsel") {
440 defines += [ "MIPS32_LE" ]
441 if (mips_float_abi == "hard") {
442 defines += [ "MIPS_FPU_LE" ]
444 if (mips_arch_variant == "r2") {
445 defines += [ "MIPS32_R2_LE" ]
447 if (mips_dsp_rev == 1) {
448 defines += [ "MIPS_DSP_R1_LE" ]
449 } else if (mips_dsp_rev == 2) {
457 if (is_android && !is_clang) {
458 # The Android NDK doesn"t provide optimized versions of these
459 # functions. Ensure they are disabled for all compilers.
468 if (use_fuzzing_engine && optimize_for_fuzzing) {
469 # Used in Chromium's overrides to disable logging
470 defines += [ "WEBRTC_UNSAFE_FUZZER_MODE" ]
473 if (!build_with_chromium && rtc_win_undef_unicode) {
482 config("common_objc") {
483 frameworks = [ "Foundation.framework" ]
487 if (!build_with_chromium) {
488 # Target to build all the WebRTC production code.
489 rtc_static_library("webrtc") {
490 # Only the root target and the test should depend on this.
493 "//:webrtc_lib_link_test",
497 complete_static_lib = true
498 suppressed_configs += [ "//build/config/compiler:thin_archive" ]
502 "api:create_peerconnection_factory",
503 "api:libjingle_peerconnection_api",
507 "api/rtc_event_log:rtc_event_log_factory",
509 "api/task_queue:default_task_queue_factory",
511 "api/video_codecs:video_decoder_factory_template",
512 "api/video_codecs:video_decoder_factory_template_dav1d_adapter",
513 "api/video_codecs:video_decoder_factory_template_libvpx_vp8_adapter",
514 "api/video_codecs:video_decoder_factory_template_libvpx_vp9_adapter",
515 "api/video_codecs:video_decoder_factory_template_open_h264_adapter",
516 "api/video_codecs:video_encoder_factory_template",
517 "api/video_codecs:video_encoder_factory_template_libaom_av1_adapter",
518 "api/video_codecs:video_encoder_factory_template_libvpx_vp8_adapter",
519 "api/video_codecs:video_encoder_factory_template_libvpx_vp9_adapter",
520 "api/video_codecs:video_encoder_factory_template_open_h264_adapter",
525 "logging:rtc_event_log_api",
528 "modules/video_capture:video_capture_internal_impl",
530 "pc:libjingle_peerconnection",
535 if (build_with_mozilla) {
537 "api:create_peerconnection_factory",
541 "api/rtc_event_log:rtc_event_log_factory",
543 "api/task_queue:default_task_queue_factory",
545 "api/video_codecs:video_decoder_factory_template",
546 "api/video_codecs:video_decoder_factory_template_dav1d_adapter",
547 "api/video_codecs:video_decoder_factory_template_libvpx_vp8_adapter",
548 "api/video_codecs:video_decoder_factory_template_libvpx_vp9_adapter",
549 "api/video_codecs:video_decoder_factory_template_open_h264_adapter",
550 "api/video_codecs:video_encoder_factory_template",
551 "api/video_codecs:video_encoder_factory_template_libaom_av1_adapter",
552 "api/video_codecs:video_encoder_factory_template_libvpx_vp8_adapter",
553 "api/video_codecs:video_encoder_factory_template_libvpx_vp9_adapter",
554 "api/video_codecs:video_encoder_factory_template_open_h264_adapter",
555 "logging:rtc_event_log_api",
557 "pc:libjingle_peerconnection",
563 if (rtc_include_builtin_audio_codecs) {
565 "api/audio_codecs:builtin_audio_decoder_factory",
566 "api/audio_codecs:builtin_audio_encoder_factory",
570 if (build_with_mozilla) {
572 "api/video:video_frame",
573 "api/video:video_rtp_headers",
574 "test:rtp_test_utils",
576 # Added when we removed deps in other places to avoid building
577 # unreachable sources. See Bug 1820869.
579 "api/video_codecs:video_codecs_api",
580 "api/video_codecs:rtc_software_fallback_wrappers",
581 "media:rtc_simulcast_encoder_adapter",
582 "modules/video_coding:webrtc_vp8",
583 "modules/video_coding:webrtc_vp9",
595 if (build_with_mozilla && is_mac) {
596 deps += [ "sdk:videocapture_objc" ]
599 if (rtc_enable_protobuf) {
600 deps += [ "logging:rtc_event_log_proto" ]
604 if (rtc_include_tests && !is_asan) {
605 rtc_executable("webrtc_lib_link_test") {
608 # This target is used for checking to link, so do not check dependencies
610 check_includes = false # no-presubmit-check TODO(bugs.webrtc.org/12785)
612 sources = [ "webrtc_lib_link_test.cc" ]
614 # NOTE: Don't add deps here. If this test fails to link, it means you
615 # need to add stuff to the webrtc static lib target above.
622 if (use_libfuzzer || use_afl) {
623 # This target is only here for gn to discover fuzzer build targets under
624 # webrtc/test/fuzzers/.
625 group("webrtc_fuzzers_dummy") {
627 deps = [ "test/fuzzers:webrtc_fuzzer_main" ]
631 if (rtc_include_tests && !build_with_chromium) {
632 rtc_test("rtc_unittests") {
636 "api:compile_all_headers",
637 "api:rtc_api_unittests",
638 "api/audio/test:audio_api_unittests",
639 "api/audio_codecs/test:audio_codecs_api_unittests",
640 "api/numerics:numerics_unittests",
641 "api/task_queue:pending_task_safety_flag_unittests",
642 "api/test/metrics:metrics_unittests",
643 "api/transport:stun_unittest",
644 "api/video/test:rtc_api_video_unittests",
645 "api/video_codecs/test:video_codecs_api_unittests",
646 "api/voip:compile_all_headers",
647 "call:fake_network_pipe_unittests",
648 "p2p:libstunprober_unittests",
649 "p2p:rtc_p2p_unittests",
650 "rtc_base:callback_list_unittests",
651 "rtc_base:rtc_base_approved_unittests",
652 "rtc_base:rtc_base_unittests",
653 "rtc_base:rtc_json_unittests",
654 "rtc_base:rtc_numerics_unittests",
655 "rtc_base:rtc_operations_chain_unittests",
656 "rtc_base:rtc_task_queue_unittests",
657 "rtc_base:sigslot_unittest",
658 "rtc_base:task_queue_stdlib_unittest",
659 "rtc_base:untyped_function_unittest",
660 "rtc_base:weak_ptr_unittests",
661 "rtc_base/experiments:experiments_unittests",
662 "rtc_base/system:file_wrapper_unittests",
663 "rtc_base/task_utils:repeating_task_unittests",
664 "rtc_base/units:units_unittests",
666 "test:rtp_test_utils",
668 "test/network:network_emulation_unittests",
671 if (rtc_enable_protobuf) {
672 deps += [ "logging:rtc_event_log_tests" ]
676 # Do not use Chromium's launcher. native_unittests defines its own JNI_OnLoad.
677 use_default_launcher = false
680 "sdk/android:native_unittests",
681 "sdk/android:native_unittests_java",
682 "//testing/android/native_test:native_test_support",
688 if (rtc_enable_google_benchmarks) {
689 rtc_test("benchmarks") {
692 "rtc_base/synchronization:mutex_benchmark",
693 "test:benchmark_main",
698 # TODO(pbos): Rename test suite, this is no longer "just" for video targets.
699 video_engine_tests_resources = [
700 "resources/foreman_cif_short.yuv",
701 "resources/voice_engine/audio_long16.pcm",
705 bundle_data("video_engine_tests_bundle_data") {
707 sources = video_engine_tests_resources
708 outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
712 rtc_test("video_engine_tests") {
717 # TODO(eladalon): call_tests aren't actually video-specific, so we
718 # should move them to a more appropriate test suite.
720 "call/adaptation:resource_adaptation_tests",
723 "test:video_test_common",
725 "video/adaptation:video_adaptation_tests",
727 data = video_engine_tests_resources
729 use_default_launcher = false
731 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
732 "//testing/android/native_test:native_test_java",
733 "//testing/android/native_test:native_test_support",
738 deps += [ ":video_engine_tests_bundle_data" ]
742 webrtc_perf_tests_resources = [
743 "resources/ConferenceMotion_1280_720_50.yuv",
744 "resources/audio_coding/speech_mono_16kHz.pcm",
745 "resources/audio_coding/speech_mono_32_48kHz.pcm",
746 "resources/audio_coding/testfile32kHz.pcm",
747 "resources/difficult_photo_1850_1110.yuv",
748 "resources/foreman_cif.yuv",
749 "resources/paris_qcif.yuv",
750 "resources/photo_1850_1110.yuv",
751 "resources/presentation_1850_1110.yuv",
752 "resources/voice_engine/audio_long16.pcm",
753 "resources/web_screenshot_1850_1110.yuv",
757 bundle_data("webrtc_perf_tests_bundle_data") {
759 sources = webrtc_perf_tests_resources
760 outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
764 rtc_test("webrtc_perf_tests") {
767 "call:call_perf_tests",
768 "modules/audio_coding:audio_coding_perf_tests",
769 "modules/audio_processing:audio_processing_perf_tests",
770 "pc:peerconnection_perf_tests",
772 "video:video_full_stack_tests",
773 "video:video_pc_full_stack_tests",
776 data = webrtc_perf_tests_resources
778 use_default_launcher = false
780 "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
781 "//testing/android/native_test:native_test_java",
782 "//testing/android/native_test:native_test_support",
787 deps += [ ":webrtc_perf_tests_bundle_data" ]
791 rtc_test("webrtc_nonparallel_tests") {
793 deps = [ "rtc_base:rtc_base_nonparallel_tests" ]
795 deps += [ "//testing/android/native_test:native_test_support" ]
800 rtc_test("voip_unittests") {
803 "api/voip:compile_all_headers",
804 "api/voip:voip_engine_factory_unittests",
805 "audio/voip/test:audio_channel_unittests",
806 "audio/voip/test:audio_egress_unittests",
807 "audio/voip/test:audio_ingress_unittests",
808 "audio/voip/test:voip_core_unittests",
814 # Build target for standalone dcsctp
815 rtc_static_library("dcsctp") {
816 # Only the root target should depend on this.
817 visibility = [ "//:default" ]
819 complete_static_lib = true
820 suppressed_configs += [ "//build/config/compiler:thin_archive" ]
823 "net/dcsctp/public:factory",
824 "net/dcsctp/public:socket",
825 "net/dcsctp/public:types",
826 "net/dcsctp/socket:dcsctp_socket",
827 "net/dcsctp/timer:task_queue_timeout",
833 # Here is one empty dummy target for each poison type (needed because
834 # "being poisonous with poison type foo" is implemented as "depends on
837 # The set of poison_* targets needs to be kept in sync with the
838 # `all_poison_types` list in webrtc.gni.
840 group("poison_audio_codecs") {
843 group("poison_default_task_queue") {
846 group("poison_default_echo_detector") {
849 group("poison_rtc_json") {
852 group("poison_software_video_codecs") {