summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/BUILD.gn
blob: 7feca08e60bcadebf6b15ee175a04d3a7d4eda42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS.  All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.

# This is the root build file for GN. GN will start processing by loading this
# file, and recursively load all dependencies until all dependencies are either
# resolved or known not to exist (which will cause the build to fail). So if
# you add a new build file, there must be some path of dependencies from this
# file to your new one or GN won't know about it.

# Use of visibility = clauses:
# The default visibility for all rtc_ targets is equivalent to "//*", or
# "all targets in webrtc can depend on this, nothing outside can".
#
# When overriding, the choices are:
# - visibility = [ "*" ] - public. Stuff outside webrtc can use this.
# - visibility = [ ":*" ] - directory private.
# As a general guideline, only targets in api/ should have public visibility.

import("//build/config/linux/pkg_config.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("webrtc.gni")
if (rtc_enable_protobuf) {
  import("//third_party/protobuf/proto_library.gni")
}
if (is_android) {
  import("//build/config/android/config.gni")
  import("//build/config/android/rules.gni")
  import("//third_party/jni_zero/jni_zero.gni")
}

if (!build_with_chromium && !build_with_mozilla) {
  # This target should (transitively) cause everything to be built; if you run
  # 'ninja default' and then 'ninja all', the second build should do no work.
  group("default") {
    testonly = true
    deps = [ ":webrtc" ]
    if (rtc_build_examples) {
      deps += [ "examples" ]
    }
    if (rtc_build_tools) {
      deps += [ "rtc_tools" ]
    }
    if (rtc_include_tests) {
      deps += [
        ":rtc_unittests",
        ":video_engine_tests",
        ":voip_unittests",
        ":webrtc_nonparallel_tests",
        ":webrtc_perf_tests",
        "common_audio:common_audio_unittests",
        "common_video:common_video_unittests",
        "examples:examples_unittests",
        "media:rtc_media_unittests",
        "modules:modules_tests",
        "modules:modules_unittests",
        "modules/audio_coding:audio_coding_tests",
        "modules/audio_processing:audio_processing_tests",
        "modules/remote_bitrate_estimator:rtp_to_text",
        "modules/rtp_rtcp:test_packet_masks_metrics",
        "modules/video_capture:video_capture_internal_impl",
        "modules/video_coding:video_codec_perf_tests",
        "net/dcsctp:dcsctp_unittests",
        "pc:peerconnection_unittests",
        "pc:rtc_pc_unittests",
        "pc:slow_peer_connection_unittests",
        "pc:svc_tests",
        "rtc_tools:rtp_generator",
        "rtc_tools:video_encoder",
        "rtc_tools:video_replay",
        "stats:rtc_stats_unittests",
        "system_wrappers:system_wrappers_unittests",
        "test",
        "video:screenshare_loopback",
        "video:sv_loopback",
        "video:video_loopback",
      ]
      if (!is_asan) {
        # Do not build :webrtc_lib_link_test because lld complains on some OS
        # (e.g. when target_os = "mac") when is_asan=true. For more details,
        # see bugs.webrtc.org/11027#c5.
        deps += [ ":webrtc_lib_link_test" ]
      }
      if (is_ios) {
        deps += [
          "examples:apprtcmobile_tests",
          "sdk:sdk_framework_unittests",
          "sdk:sdk_unittests",
        ]
      }
      if (is_android) {
        deps += [
          "examples:android_examples_junit_tests",
          "sdk/android:android_instrumentation_test_apk",
          "sdk/android:android_sdk_junit_tests",
        ]
      } else {
        deps += [ "modules/video_capture:video_capture_tests" ]
      }
      if (rtc_enable_protobuf) {
        deps += [
          "logging:rtc_event_log_rtp_dump",
          "tools_webrtc/perf:webrtc_dashboard_upload",
        ]
      }
      if ((is_linux || is_chromeos) && rtc_use_pipewire) {
        deps += [ "modules/desktop_capture:shared_screencast_stream_test" ]
      }
    }
    if (target_os == "android") {
      deps += [ "tools_webrtc:binary_version_check" ]
    }
  }
}

# Abseil Flags by default doesn't register command line flags on mobile
# platforms, WebRTC tests requires them (e.g. on simualtors) so this
# config will be applied to testonly targets globally (see webrtc.gni).
config("absl_flags_configs") {
  defines = [ "ABSL_FLAGS_STRIP_NAMES=0" ]
}

config("library_impl_config") {
  # Build targets that contain WebRTC implementation need this macro to
  # be defined in order to correctly export symbols when is_component_build
  # is true.
  # For more info see: rtc_base/build/rtc_export.h.
  defines = [ "WEBRTC_LIBRARY_IMPL" ]
}

# Contains the defines and includes in common.gypi that are duplicated both as
# target_defaults and direct_dependent_settings.
config("common_inherited_config") {
  defines = []
  cflags = []
  ldflags = []

  if (rtc_jni_generator_legacy_symbols) {
    defines += [ "RTC_JNI_GENERATOR_LEGACY_SYMBOLS" ]
  }

  if (rtc_objc_prefix != "") {
    defines += [ "RTC_OBJC_TYPE_PREFIX=${rtc_objc_prefix}" ]
  }

  if (rtc_dlog_always_on) {
    defines += [ "DLOG_ALWAYS_ON" ]
  }

  if (rtc_enable_symbol_export || is_component_build) {
    defines += [ "WEBRTC_ENABLE_SYMBOL_EXPORT" ]
  }
  if (rtc_enable_objc_symbol_export) {
    defines += [ "WEBRTC_ENABLE_OBJC_SYMBOL_EXPORT" ]
  }

  if (build_with_mozilla) {
    defines += [ "WEBRTC_MOZILLA_BUILD" ]
  }

  if (!rtc_builtin_ssl_root_certificates) {
    defines += [ "WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS" ]
  }

  if (rtc_disable_check_msg) {
    defines += [ "RTC_DISABLE_CHECK_MSG" ]
  }

  if (rtc_enable_avx2) {
    defines += [ "WEBRTC_ENABLE_AVX2" ]
  }

  if (rtc_enable_win_wgc) {
    defines += [ "RTC_ENABLE_WIN_WGC" ]
  }

  # Some tests need to declare their own trace event handlers. If this define is
  # not set, the first time TRACE_EVENT_* is called it will store the return
  # value for the current handler in an static variable, so that subsequent
  # changes to the handler for that TRACE_EVENT_* will be ignored.
  # So when tests are included, we set this define, making it possible to use
  # different event handlers in different tests.
  if (rtc_include_tests) {
    defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1" ]
  } else {
    defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0" ]
  }
  if (build_with_chromium) {
    defines += [ "WEBRTC_CHROMIUM_BUILD" ]
    include_dirs = [
      # The overrides must be included first as that is the mechanism for
      # selecting the override headers in Chromium.
      "../webrtc_overrides",

      # Allow includes to be prefixed with webrtc/ in case it is not an
      # immediate subdirectory of the top-level.
      ".",

      # Just like the root WebRTC directory is added to include path, the
      # corresponding directory tree with generated files needs to be added too.
      # Note: this path does not change depending on the current target, e.g.
      # it is always "//gen/third_party/webrtc" when building with Chromium.
      # See also: http://cs.chromium.org/?q=%5C"default_include_dirs
      # https://gn.googlesource.com/gn/+/master/docs/reference.md#target_gen_dir
      target_gen_dir,
    ]
  }
  if (is_posix || is_fuchsia) {
    defines += [ "WEBRTC_POSIX" ]
  }
  if (is_ios) {
    defines += [
      "WEBRTC_MAC",
      "WEBRTC_IOS",
    ]
  }
  if (is_linux || is_chromeos) {
    defines += [ "WEBRTC_LINUX" ]
  }
  if (is_bsd) {
    defines += [ "WEBRTC_BSD" ]
  }
  if (is_mac) {
    defines += [ "WEBRTC_MAC" ]
  }
  if (is_fuchsia) {
    defines += [ "WEBRTC_FUCHSIA" ]
  }
  if (is_win) {
    defines += [ "WEBRTC_WIN" ]
  }
  if (is_android) {
    defines += [
      "WEBRTC_LINUX",
      "WEBRTC_ANDROID",
    ]

    if (build_with_mozilla) {
      defines += [ "WEBRTC_ANDROID_OPENSLES" ]
    }
  }
  if (is_chromeos) {
    defines += [ "CHROMEOS" ]
  }

  if (rtc_sanitize_coverage != "") {
    assert(is_clang, "sanitizer coverage requires clang")
    cflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
    ldflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
  }

  if (is_ubsan) {
    cflags += [ "-fsanitize=float-cast-overflow" ]
  }
}

# TODO(bugs.webrtc.org/9693): Remove the possibility to suppress this warning
# as soon as WebRTC compiles without it.
config("no_global_constructors") {
  if (is_clang) {
    cflags = [ "-Wno-global-constructors" ]
  }
}

config("rtc_prod_config") {
  # Ideally, WebRTC production code (but not test code) should have these flags.
  if (is_clang) {
    cflags = [
      "-Wexit-time-destructors",
      "-Wglobal-constructors",
    ]
  }
}

config("common_config") {
  cflags = []
  cflags_c = []
  cflags_cc = []
  cflags_objc = []
  defines = []

  if (rtc_enable_protobuf) {
    defines += [ "WEBRTC_ENABLE_PROTOBUF=1" ]
  } else {
    defines += [ "WEBRTC_ENABLE_PROTOBUF=0" ]
  }

  if (rtc_strict_field_trials == "") {
    defines += [ "WEBRTC_STRICT_FIELD_TRIALS=0" ]
  } else if (rtc_strict_field_trials == "dcheck") {
    defines += [ "WEBRTC_STRICT_FIELD_TRIALS=1" ]
  } else if (rtc_strict_field_trials == "warn") {
    defines += [ "WEBRTC_STRICT_FIELD_TRIALS=2" ]
  } else {
    assert(false,
           "Unsupported value for rtc_strict_field_trials: " +
               "$rtc_strict_field_trials")
  }

  if (rtc_include_internal_audio_device) {
    defines += [ "WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE" ]
  }

  if (rtc_libvpx_build_vp9) {
    defines += [ "RTC_ENABLE_VP9" ]
  }

  if (rtc_use_h265) {
    defines += [ "RTC_ENABLE_H265" ]
  }

  if (rtc_include_dav1d_in_internal_decoder_factory) {
    defines += [ "RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY" ]
  }

  if (rtc_enable_sctp) {
    defines += [ "WEBRTC_HAVE_SCTP" ]
  }

  if (rtc_enable_external_auth) {
    defines += [ "ENABLE_EXTERNAL_AUTH" ]
  }

  if (rtc_use_h264) {
    defines += [ "WEBRTC_USE_H264" ]
  }

  if (rtc_use_absl_mutex) {
    defines += [ "WEBRTC_ABSL_MUTEX" ]
  }

  if (rtc_enable_libevent) {
    defines += [ "WEBRTC_ENABLE_LIBEVENT" ]
  }

  if (rtc_disable_logging) {
    defines += [ "RTC_DISABLE_LOGGING" ]
  }

  if (rtc_disable_trace_events) {
    defines += [ "RTC_DISABLE_TRACE_EVENTS" ]
  }

  if (rtc_disable_metrics) {
    defines += [ "RTC_DISABLE_METRICS" ]
  }

  if (rtc_exclude_transient_suppressor) {
    defines += [ "WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR" ]
  }

  if (rtc_exclude_audio_processing_module) {
    defines += [ "WEBRTC_EXCLUDE_AUDIO_PROCESSING_MODULE" ]
  }

  if (is_clang) {
    cflags += [
      # TODO(webrtc:13219): Fix -Wshadow instances and enable.
      "-Wno-shadow",

      # See https://reviews.llvm.org/D56731 for details about this
      # warning.
      "-Wctad-maybe-unsupported",
    ]
  }

  if (build_with_chromium) {
    defines += [
      # NOTICE: Since common_inherited_config is used in public_configs for our
      # targets, there's no point including the defines in that config here.
      # TODO(kjellander): Cleanup unused ones and move defines closer to the
      # source when webrtc:4256 is completed.
      "HAVE_WEBRTC_VIDEO",
      "LOGGING_INSIDE_WEBRTC",
    ]
  } else {
    if (is_posix || is_fuchsia) {
      cflags_c += [
        # TODO(bugs.webrtc.org/9029): enable commented compiler flags.
        # Some of these flags should also be added to cflags_objc.

        # "-Wextra",  (used when building C++ but not when building C)
        # "-Wmissing-prototypes",  (C/Obj-C only)
        # "-Wmissing-declarations",  (ensure this is always used C/C++, etc..)
        "-Wstrict-prototypes",

        # "-Wpointer-arith",  (ensure this is always used C/C++, etc..)
        # "-Wbad-function-cast",  (C/Obj-C only)
        # "-Wnested-externs",  (C/Obj-C only)
      ]
      cflags_objc += [ "-Wstrict-prototypes" ]
      cflags_cc = [
        "-Wnon-virtual-dtor",

        # This is enabled for clang; enable for gcc as well.
        "-Woverloaded-virtual",
      ]
    }

    if (is_clang) {
      cflags += [ "-Wc++11-narrowing" ]

      if (!is_fuchsia) {
        # Compiling with the Fuchsia SDK results in Wundef errors
        # TODO(bugs.fuchsia.dev/100722): Remove from (!is_fuchsia) branch when
        # Fuchsia build errors are fixed.
        cflags += [ "-Wundef" ]
      }

      if (!is_nacl) {
        # Flags NaCl (Clang 3.7) do not recognize.
        cflags += [ "-Wunused-lambda-capture" ]
      }
    }

    if (is_win && !is_clang) {
      # MSVC warning suppressions (needed to use Abseil).
      # TODO(bugs.webrtc.org/9274): Remove these warnings as soon as MSVC allows
      # external headers warning suppression (or fix them upstream).
      cflags += [ "/wd4702" ]  # unreachable code

      # MSVC 2019 warning suppressions for C++17 compiling
      cflags +=
          [ "/wd5041" ]  # out-of-line definition for constexpr static data
                         # member is not needed and is deprecated in C++17
    }
  }

  if (target_cpu == "arm64") {
    defines += [ "WEBRTC_ARCH_ARM64" ]
    defines += [ "WEBRTC_HAS_NEON" ]
  }

  if (target_cpu == "arm") {
    defines += [ "WEBRTC_ARCH_ARM" ]
    if (arm_version >= 7) {
      defines += [ "WEBRTC_ARCH_ARM_V7" ]
      if (arm_use_neon) {
        defines += [ "WEBRTC_HAS_NEON" ]
      }
    }
  }

  if (target_cpu == "mipsel") {
    defines += [ "MIPS32_LE" ]
    if (mips_float_abi == "hard") {
      defines += [ "MIPS_FPU_LE" ]
    }
    if (mips_arch_variant == "r2") {
      defines += [ "MIPS32_R2_LE" ]
    }
    if (mips_dsp_rev == 1) {
      defines += [ "MIPS_DSP_R1_LE" ]
    } else if (mips_dsp_rev == 2) {
      defines += [
        "MIPS_DSP_R1_LE",
        "MIPS_DSP_R2_LE",
      ]
    }
  }

  if (is_android && !is_clang) {
    # The Android NDK doesn"t provide optimized versions of these
    # functions. Ensure they are disabled for all compilers.
    cflags += [
      "-fno-builtin-cos",
      "-fno-builtin-sin",
      "-fno-builtin-cosf",
      "-fno-builtin-sinf",
    ]
  }

  if (use_fuzzing_engine) {
    # Used in Chromium's overrides to disable logging
    defines += [ "WEBRTC_UNSAFE_FUZZER_MODE" ]
  }

  if (!build_with_chromium && rtc_win_undef_unicode) {
    cflags += [
      "/UUNICODE",
      "/U_UNICODE",
    ]
  }
}

if (is_mac) {
config("common_objc") {
  frameworks = [ "Foundation.framework" ]
}
}

if (!build_with_chromium) {
  # Target to build all the WebRTC production code.
  rtc_static_library("webrtc") {
    # Only the root target and the test should depend on this.
    visibility = [
      "//:default",
      "//:webrtc_lib_link_test",
    ]

    sources = []
    complete_static_lib = true
    suppressed_configs += [ "//build/config/compiler:thin_archive" ]
    defines = []

    deps = [
      "api:create_peerconnection_factory",
      "api:enable_media",
      "api:libjingle_peerconnection_api",
      "api:rtc_error",
      "api:transport_api",
      "api/crypto",
      "api/rtc_event_log:rtc_event_log_factory",
      "api/task_queue",
      "api/task_queue:default_task_queue_factory",
      "api/test/metrics",
      "api/video_codecs:video_decoder_factory_template",
      "api/video_codecs:video_decoder_factory_template_dav1d_adapter",
      "api/video_codecs:video_decoder_factory_template_libvpx_vp8_adapter",
      "api/video_codecs:video_decoder_factory_template_libvpx_vp9_adapter",
      "api/video_codecs:video_decoder_factory_template_open_h264_adapter",
      "api/video_codecs:video_encoder_factory_template",
      "api/video_codecs:video_encoder_factory_template_libaom_av1_adapter",
      "api/video_codecs:video_encoder_factory_template_libvpx_vp8_adapter",
      "api/video_codecs:video_encoder_factory_template_libvpx_vp9_adapter",
      "api/video_codecs:video_encoder_factory_template_open_h264_adapter",
      "audio",
      "call",
      "common_audio",
      "common_video",
      "logging:rtc_event_log_api",
      "media",
      "modules",
      "modules/video_capture:video_capture_internal_impl",
      "p2p:rtc_p2p",
      "pc:libjingle_peerconnection",
      "pc:rtc_pc",
      "sdk",
      "video",
    ]
    if (build_with_mozilla) {
      deps -= [
        "api:create_peerconnection_factory",
        "api:enable_media",
        "api:rtc_error",
        "api:transport_api",
        "api/crypto",
        "api/rtc_event_log:rtc_event_log_factory",
        "api/task_queue",
        "api/task_queue:default_task_queue_factory",
        "api/test/metrics",
        "api/video_codecs:video_decoder_factory_template",
        "api/video_codecs:video_decoder_factory_template_dav1d_adapter",
        "api/video_codecs:video_decoder_factory_template_libvpx_vp8_adapter",
        "api/video_codecs:video_decoder_factory_template_libvpx_vp9_adapter",
        "api/video_codecs:video_decoder_factory_template_open_h264_adapter",
        "api/video_codecs:video_encoder_factory_template",
        "api/video_codecs:video_encoder_factory_template_libaom_av1_adapter",
        "api/video_codecs:video_encoder_factory_template_libvpx_vp8_adapter",
        "api/video_codecs:video_encoder_factory_template_libvpx_vp9_adapter",
        "api/video_codecs:video_encoder_factory_template_open_h264_adapter",
        "logging:rtc_event_log_api",
        "p2p:rtc_p2p",
        "pc:libjingle_peerconnection",
        "pc:rtc_pc",
        "sdk",
      ]
    }

    if (rtc_include_builtin_audio_codecs) {
      deps += [
        "api/audio_codecs:builtin_audio_decoder_factory",
        "api/audio_codecs:builtin_audio_encoder_factory",
      ]
    }

    if (build_with_mozilla) {
      deps += [
        "api/video:video_frame",
        "api/video:video_rtp_headers",
        "test:rtp_test_utils",
      ]
      # Added when we removed deps in other places to avoid building
      # unreachable sources.  See Bug 1820869.
      deps += [
        "api/video_codecs:video_codecs_api",
        "api/video_codecs:rtc_software_fallback_wrappers",
        "media:rtc_simulcast_encoder_adapter",
        "modules/video_coding:webrtc_vp8",
        "modules/video_coding:webrtc_vp9",
      ]
    } else {
      deps += [
        "api",
        "logging",
        "p2p",
        "pc",
        "stats",
      ]
    }

    if (build_with_mozilla && is_mac) {
      deps += [ "sdk:videocapture_objc" ]
    }

    if (rtc_enable_protobuf) {
      deps += [ "logging:rtc_event_log_proto" ]
    }
  }

  if (rtc_include_tests && !is_asan) {
    rtc_executable("webrtc_lib_link_test") {
      testonly = true

      # This target is used for checking to link, so do not check dependencies
      # on gn check.
      check_includes = false  # no-presubmit-check TODO(bugs.webrtc.org/12785)

      sources = [ "webrtc_lib_link_test.cc" ]
      deps = [
        # NOTE: Don't add deps here. If this test fails to link, it means you
        # need to add stuff to the webrtc static lib target above.
        ":webrtc",
      ]
    }
  }
}

if (use_libfuzzer || use_afl) {
  # This target is only here for gn to discover fuzzer build targets under
  # webrtc/test/fuzzers/.
  group("webrtc_fuzzers_dummy") {
    testonly = true
    deps = [ "test/fuzzers:webrtc_fuzzer_main" ]
  }
}

if (rtc_include_tests && !build_with_chromium) {
  rtc_test("rtc_unittests") {
    testonly = true

    deps = [
      "api:compile_all_headers",
      "api:rtc_api_unittests",
      "api/audio/test:audio_api_unittests",
      "api/audio_codecs/test:audio_codecs_api_unittests",
      "api/numerics:numerics_unittests",
      "api/task_queue:pending_task_safety_flag_unittests",
      "api/test/metrics:metrics_unittests",
      "api/transport:stun_unittest",
      "api/video/test:rtc_api_video_unittests",
      "api/video_codecs/test:video_codecs_api_unittests",
      "api/voip:compile_all_headers",
      "call:fake_network_pipe_unittests",
      "p2p:libstunprober_unittests",
      "p2p:rtc_p2p_unittests",
      "rtc_base:async_dns_resolver_unittests",
      "rtc_base:async_packet_socket_unittest",
      "rtc_base:callback_list_unittests",
      "rtc_base:rtc_base_approved_unittests",
      "rtc_base:rtc_base_unittests",
      "rtc_base:rtc_json_unittests",
      "rtc_base:rtc_numerics_unittests",
      "rtc_base:rtc_operations_chain_unittests",
      "rtc_base:rtc_task_queue_unittests",
      "rtc_base:sigslot_unittest",
      "rtc_base:task_queue_stdlib_unittest",
      "rtc_base:untyped_function_unittest",
      "rtc_base:weak_ptr_unittests",
      "rtc_base/experiments:experiments_unittests",
      "rtc_base/system:file_wrapper_unittests",
      "rtc_base/task_utils:repeating_task_unittests",
      "rtc_base/units:units_unittests",
      "sdk:sdk_tests",
      "test:rtp_test_utils",
      "test:test_main",
      "test/network:network_emulation_unittests",
    ]

    if (rtc_enable_protobuf) {
      deps += [ "logging:rtc_event_log_tests" ]
    }

    if (is_android) {
      # Do not use Chromium's launcher. native_unittests defines its own JNI_OnLoad.
      use_default_launcher = false

      deps += [
        "sdk/android:native_unittests",
        "sdk/android:native_unittests_java",
        "//testing/android/native_test:native_test_support",
      ]
      shard_timeout = 900
    }
  }

  if (rtc_enable_google_benchmarks) {
    rtc_test("benchmarks") {
      testonly = true
      deps = [
        "rtc_base/synchronization:mutex_benchmark",
        "test:benchmark_main",
      ]
    }
  }

  # TODO(pbos): Rename test suite, this is no longer "just" for video targets.
  video_engine_tests_resources = [
    "resources/foreman_cif_short.yuv",
    "resources/voice_engine/audio_long16.pcm",
  ]

  if (is_ios) {
    bundle_data("video_engine_tests_bundle_data") {
      testonly = true
      sources = video_engine_tests_resources
      outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
    }
  }

  rtc_test("video_engine_tests") {
    testonly = true
    deps = [
      "audio:audio_tests",

      # TODO(eladalon): call_tests aren't actually video-specific, so we
      # should move them to a more appropriate test suite.
      "call:call_tests",
      "call/adaptation:resource_adaptation_tests",
      "test:test_common",
      "test:test_main",
      "test:video_test_common",
      "video:video_tests",
      "video/adaptation:video_adaptation_tests",
    ]
    data = video_engine_tests_resources
    if (is_android) {
      use_default_launcher = false
      deps += [
        "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
        "//testing/android/native_test:native_test_java",
        "//testing/android/native_test:native_test_support",
      ]
      shard_timeout = 900
    }
    if (is_ios) {
      deps += [ ":video_engine_tests_bundle_data" ]
    }
  }

  webrtc_perf_tests_resources = [
    "resources/ConferenceMotion_1280_720_50.yuv",
    "resources/audio_coding/speech_mono_16kHz.pcm",
    "resources/audio_coding/speech_mono_32_48kHz.pcm",
    "resources/audio_coding/testfile32kHz.pcm",
    "resources/difficult_photo_1850_1110.yuv",
    "resources/foreman_cif.yuv",
    "resources/paris_qcif.yuv",
    "resources/photo_1850_1110.yuv",
    "resources/presentation_1850_1110.yuv",
    "resources/voice_engine/audio_long16.pcm",
    "resources/web_screenshot_1850_1110.yuv",
  ]

  if (is_ios) {
    bundle_data("webrtc_perf_tests_bundle_data") {
      testonly = true
      sources = webrtc_perf_tests_resources
      outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
    }
  }

  rtc_test("webrtc_perf_tests") {
    testonly = true
    deps = [
      "call:call_perf_tests",
      "modules/audio_coding:audio_coding_perf_tests",
      "modules/audio_processing:audio_processing_perf_tests",
      "pc:peerconnection_perf_tests",
      "test:test_main",
      "video:video_full_stack_tests",
      "video:video_pc_full_stack_tests",
    ]

    data = webrtc_perf_tests_resources
    if (is_android) {
      use_default_launcher = false
      deps += [
        "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
        "//testing/android/native_test:native_test_java",
        "//testing/android/native_test:native_test_support",
      ]
      shard_timeout = 4500
    }
    if (is_ios) {
      deps += [ ":webrtc_perf_tests_bundle_data" ]
    }
  }

  rtc_test("webrtc_nonparallel_tests") {
    testonly = true
    deps = [ "rtc_base:rtc_base_nonparallel_tests" ]
    if (is_android) {
      deps += [ "//testing/android/native_test:native_test_support" ]
      shard_timeout = 900
    }
  }

  rtc_test("voip_unittests") {
    testonly = true
    deps = [
      "api/voip:compile_all_headers",
      "api/voip:voip_engine_factory_unittests",
      "audio/voip/test:audio_channel_unittests",
      "audio/voip/test:audio_egress_unittests",
      "audio/voip/test:audio_ingress_unittests",
      "audio/voip/test:voip_core_unittests",
      "test:test_main",
    ]
  }
}

# Build target for standalone dcsctp
rtc_static_library("dcsctp") {
  # Only the root target should depend on this.
  visibility = [ "//:default" ]
  sources = []
  complete_static_lib = true
  suppressed_configs += [ "//build/config/compiler:thin_archive" ]
  defines = []
  deps = [
    "net/dcsctp/public:factory",
    "net/dcsctp/public:socket",
    "net/dcsctp/public:types",
    "net/dcsctp/socket:dcsctp_socket",
    "net/dcsctp/timer:task_queue_timeout",
  ]
}

# ---- Poisons ----
#
# Here is one empty dummy target for each poison type (needed because
# "being poisonous with poison type foo" is implemented as "depends on
# //:poison_foo").
#
# The set of poison_* targets needs to be kept in sync with the
# `all_poison_types` list in webrtc.gni.
#
group("poison_audio_codecs") {
}

group("poison_default_echo_detector") {
}

group("poison_environment_construction") {
}

group("poison_software_video_codecs") {
}