blob: 209a3fb4b1e5cdbf2e51cfe05256194c744d787a [file] [log] [blame]
wjia@webrtc.org03cfde22014-01-14 17:48:34 +00001# 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
Mirko Bonadeibb547202017-09-15 06:15:48 +02009import("//build/config/linux/pkg_config.gni")
10import("//build/config/sanitizers/sanitizers.gni")
11import("webrtc.gni")
12import("//third_party/protobuf/proto_library.gni")
13if (is_android) {
14 import("//build/config/android/config.gni")
15 import("//build/config/android/rules.gni")
16}
ehmaldonado37d7a222016-11-08 06:34:20 -080017
Mirko Bonadeibb547202017-09-15 06:15:48 +020018if (!build_with_chromium) {
19 group("default") {
20 testonly = true
21 deps = [
22 ":webrtc",
23 "examples",
24 "rtc_tools",
25 ]
26 if (rtc_include_tests) {
27 deps += [ ":webrtc_tests" ]
28 }
29 }
30}
31
32# Contains the defines and includes in common.gypi that are duplicated both as
33# target_defaults and direct_dependent_settings.
34config("common_inherited_config") {
35 defines = []
36 cflags = []
37 ldflags = []
38 if (build_with_mozilla) {
39 defines += [ "WEBRTC_MOZILLA_BUILD" ]
40 }
41
42 # Some tests need to declare their own trace event handlers. If this define is
43 # not set, the first time TRACE_EVENT_* is called it will store the return
44 # value for the current handler in an static variable, so that subsequent
45 # changes to the handler for that TRACE_EVENT_* will be ignored.
46 # So when tests are included, we set this define, making it possible to use
47 # different event handlers in different tests.
ehmaldonado37d7a222016-11-08 06:34:20 -080048 if (rtc_include_tests) {
Mirko Bonadeibb547202017-09-15 06:15:48 +020049 defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1" ]
50 } else {
51 defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0" ]
52 }
53 if (build_with_chromium) {
54 defines += [
55 # TODO(kjellander): Cleanup unused ones and move defines closer to
56 # the source when webrtc:4256 is completed.
57 "FEATURE_ENABLE_VOICEMAIL",
58 "GTEST_RELATIVE_PATH",
59 "WEBRTC_CHROMIUM_BUILD",
60 ]
61 include_dirs = [
62 # The overrides must be included first as that is the mechanism for
63 # selecting the override headers in Chromium.
64 "../webrtc_overrides",
65
66 # Allow includes to be prefixed with webrtc/ in case it is not an
67 # immediate subdirectory of the top-level.
68 ".",
69 ]
70 }
71 if (is_posix) {
72 defines += [ "WEBRTC_POSIX" ]
73 }
74 if (is_ios) {
75 defines += [
76 "WEBRTC_MAC",
77 "WEBRTC_IOS",
78 ]
79 }
80 if (is_linux) {
81 defines += [ "WEBRTC_LINUX" ]
82 }
83 if (is_mac) {
84 defines += [ "WEBRTC_MAC" ]
85 }
86 if (is_win) {
87 defines += [
88 "WEBRTC_WIN",
89 "_CRT_SECURE_NO_WARNINGS", # Suppress warnings about _vsnprinf
90 ]
91 }
92 if (is_android) {
93 defines += [
94 "WEBRTC_LINUX",
95 "WEBRTC_ANDROID",
96 ]
97 }
98 if (is_chromeos) {
99 defines += [ "CHROMEOS" ]
100 }
101
102 if (rtc_sanitize_coverage != "") {
103 assert(is_clang, "sanitizer coverage requires clang")
104 cflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
105 ldflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
106 }
107
108 if (is_ubsan) {
109 cflags += [ "-fsanitize=float-cast-overflow" ]
110 }
111
112 # TODO(GYP): Support these in GN.
113 # if (is_bsd) {
114 # defines += [ "BSD" ]
115 # }
116 # if (is_openbsd) {
117 # defines += [ "OPENBSD" ]
118 # }
119 # if (is_freebsd) {
120 # defines += [ "FREEBSD" ]
121 # }
122}
123
124config("common_config") {
125 cflags = []
126 cflags_cc = []
127 defines = []
128
129 if (rtc_enable_protobuf) {
130 defines += [ "WEBRTC_ENABLE_PROTOBUF=1" ]
131 } else {
132 defines += [ "WEBRTC_ENABLE_PROTOBUF=0" ]
133 }
134
135 if (rtc_restrict_logging) {
136 defines += [ "WEBRTC_RESTRICT_LOGGING" ]
137 }
138
139 if (rtc_include_internal_audio_device) {
140 defines += [ "WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE" ]
141 }
142
143 if (!rtc_libvpx_build_vp9) {
144 defines += [ "RTC_DISABLE_VP9" ]
145 }
146
147 if (rtc_enable_sctp) {
148 defines += [ "HAVE_SCTP" ]
149 }
150
151 if (rtc_enable_external_auth) {
152 defines += [ "ENABLE_EXTERNAL_AUTH" ]
153 }
154
155 if (build_with_chromium) {
156 defines += [
157 # NOTICE: Since common_inherited_config is used in public_configs for our
158 # targets, there's no point including the defines in that config here.
159 # TODO(kjellander): Cleanup unused ones and move defines closer to the
160 # source when webrtc:4256 is completed.
161 "HAVE_WEBRTC_VIDEO",
162 "HAVE_WEBRTC_VOICE",
163 "LOGGING_INSIDE_WEBRTC",
164 "USE_WEBRTC_DEV_BRANCH",
165 ]
166 } else {
167 if (is_posix) {
168 # Enable more warnings: -Wextra is currently disabled in Chromium.
169 cflags = [
170 "-Wextra",
171
172 # Repeat some flags that get overridden by -Wextra.
173 "-Wno-unused-parameter",
174 "-Wno-missing-field-initializers",
175 "-Wno-strict-overflow",
176 ]
177 cflags_cc = [
178 "-Wnon-virtual-dtor",
179
180 # This is enabled for clang; enable for gcc as well.
181 "-Woverloaded-virtual",
182 ]
183 }
184
185 if (is_clang) {
186 cflags += [
187 "-Wc++11-narrowing",
188 "-Wimplicit-fallthrough",
189 "-Wthread-safety",
190 "-Winconsistent-missing-override",
191 "-Wundef",
192 ]
193
194 # use_xcode_clang only refers to the iOS toolchain, host binaries use
195 # chromium's clang always.
196 if (!is_nacl &&
197 (!use_xcode_clang || current_toolchain == host_toolchain)) {
198 # Flags NaCl (Clang 3.7) and Xcode 7.3 (Clang clang-703.0.31) do not
199 # recognize.
200 cflags += [ "-Wunused-lambda-capture" ]
201 }
202 }
203 }
204
205 if (current_cpu == "arm64") {
206 defines += [ "WEBRTC_ARCH_ARM64" ]
207 defines += [ "WEBRTC_HAS_NEON" ]
208 }
209
210 if (current_cpu == "arm") {
211 defines += [ "WEBRTC_ARCH_ARM" ]
212 if (arm_version >= 7) {
213 defines += [ "WEBRTC_ARCH_ARM_V7" ]
214 if (arm_use_neon) {
215 defines += [ "WEBRTC_HAS_NEON" ]
216 }
217 }
218 }
219
220 if (current_cpu == "mipsel") {
221 defines += [ "MIPS32_LE" ]
222 if (mips_float_abi == "hard") {
223 defines += [ "MIPS_FPU_LE" ]
224 }
225 if (mips_arch_variant == "r2") {
226 defines += [ "MIPS32_R2_LE" ]
227 }
228 if (mips_dsp_rev == 1) {
229 defines += [ "MIPS_DSP_R1_LE" ]
230 } else if (mips_dsp_rev == 2) {
231 defines += [
232 "MIPS_DSP_R1_LE",
233 "MIPS_DSP_R2_LE",
234 ]
235 }
236 }
237
238 if (is_android && !is_clang) {
239 # The Android NDK doesn"t provide optimized versions of these
240 # functions. Ensure they are disabled for all compilers.
241 cflags += [
242 "-fno-builtin-cos",
243 "-fno-builtin-sin",
244 "-fno-builtin-cosf",
245 "-fno-builtin-sinf",
246 ]
247 }
248
249 if (use_libfuzzer || use_drfuzz || use_afl) {
250 # Used in Chromium's overrides to disable logging
251 defines += [ "WEBRTC_UNSAFE_FUZZER_MODE" ]
252 }
253}
254
255config("common_objc") {
256 libs = [ "Foundation.framework" ]
257}
258
259if (!build_with_chromium) {
260 # Target to build all the WebRTC production code.
261 rtc_static_library("webrtc") {
262 # Only the root target should depend on this.
263 visibility = [ "//:default" ]
264
265 sources = []
266 complete_static_lib = true
267 defines = []
268
269 deps = [
270 ":webrtc_common",
271 "api",
272 "api:transport_api",
273 "audio",
274 "call",
275 "common_audio",
276 "common_video",
277 "logging",
278 "media",
279 "modules",
280 "modules/video_capture:video_capture_internal_impl",
281 "ortc",
282 "p2p",
283 "pc",
284 "rtc_base",
285 "sdk",
286 "stats",
287 "system_wrappers:system_wrappers_default",
288 "video",
289 "voice_engine",
290 ]
291
292 if (rtc_enable_protobuf) {
293 defines += [ "ENABLE_RTC_EVENT_LOG" ]
294 deps += [ "logging:rtc_event_log_proto" ]
295 }
296 }
297
298 if (rtc_include_tests) {
299 # Target to build all the WebRTC tests (but not examples or tools).
300 # Executable in order to get a target that links all WebRTC code.
301 rtc_executable("webrtc_tests") {
302 testonly = true
303
304 # Only the root target should depend on this.
305 visibility = [ "//:default" ]
306
307 deps = [
308 ":rtc_unittests",
309 ":video_engine_tests",
310 ":webrtc_nonparallel_tests",
311 ":webrtc_perf_tests",
312 "common_audio:common_audio_unittests",
313 "common_video:common_video_unittests",
314 "media:rtc_media_unittests",
315 "modules:modules_tests",
316 "modules:modules_unittests",
317 "modules/audio_coding:audio_coding_tests",
318 "modules/audio_processing:audio_processing_tests",
319 "modules/remote_bitrate_estimator:bwe_simulations_tests",
320 "modules/rtp_rtcp:test_packet_masks_metrics",
321 "modules/video_capture:video_capture_internal_impl",
322 "ortc:ortc_unittests",
323 "pc:peerconnection_unittests",
324 "pc:rtc_pc_unittests",
325 "rtc_base:rtc_base_tests_utils",
326 "stats:rtc_stats_unittests",
327 "system_wrappers:system_wrappers_unittests",
328 "test",
329 "video:screenshare_loopback",
330 "video:video_loopback",
331 "voice_engine:voice_engine_unittests",
332 ]
333 if (is_android) {
334 deps += [
335 ":android_junit_tests",
336 "sdk/android:libjingle_peerconnection_android_unittest",
337 ]
338 } else {
339 deps += [ "modules/video_capture:video_capture_tests" ]
340 }
Mirko Bonadeibb547202017-09-15 06:15:48 +0200341 if (rtc_enable_protobuf) {
342 deps += [
343 "audio:low_bandwidth_audio_test",
344 "logging:rtc_event_log2rtp_dump",
345 ]
346 }
347 }
348 }
349}
350
351rtc_static_library("webrtc_common") {
352 # TODO(mbonadei): Remove (bugs.webrtc.org/7745)
353 # Enabling GN check triggers cyclic dependency error:
354 # :webrtc_common ->
355 # api:video_frame_api ->
356 # system_wrappers:system_wrappers ->
357 # webrtc_common
358 check_includes = false
359 sources = [
360 "common_types.cc",
361 "common_types.h",
362 "typedefs.h",
363 ]
364
365 if (!build_with_chromium && is_clang) {
366 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
367 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
368 }
369}
370
371if (use_libfuzzer || use_drfuzz || use_afl) {
372 # This target is only here for gn to discover fuzzer build targets under
373 # webrtc/test/fuzzers/.
374 group("webrtc_fuzzers_dummy") {
375 testonly = true
376 deps = [
377 "test/fuzzers:webrtc_fuzzer_main",
378 ]
379 }
380}
381
382if (rtc_include_tests) {
383 config("rtc_unittests_config") {
384 # GN orders flags on a target before flags from configs. The default config
385 # adds -Wall, and this flag have to be after -Wall -- so they need to
386 # come from a config and can"t be on the target directly.
387 if (is_clang) {
388 cflags = [
389 "-Wno-sign-compare",
390 "-Wno-unused-const-variable",
391 ]
392 }
393 }
394
395 rtc_test("rtc_unittests") {
396 testonly = true
397
398 deps = [
399 ":webrtc_common",
400 "api:rtc_api_unittests",
401 "api/audio_codecs/test:audio_codecs_api_unittests",
402 "p2p:libstunprober_unittests",
403 "p2p:rtc_p2p_unittests",
404 "rtc_base:rtc_base_approved_unittests",
405 "rtc_base:rtc_base_tests_main",
406 "rtc_base:rtc_base_tests_utils",
407 "rtc_base:rtc_base_unittests",
408 "rtc_base:rtc_numerics_unittests",
409 "rtc_base:rtc_task_queue_unittests",
410 "rtc_base:sequenced_task_checker_unittests",
411 "rtc_base:weak_ptr_unittests",
412 "system_wrappers:metrics_default",
413 ]
414
415 if (rtc_enable_protobuf) {
416 deps += [ "logging:rtc_event_log_tests" ]
417 }
418
419 if (is_android) {
420 deps += [ "//testing/android/native_test:native_test_support" ]
421 shard_timeout = 900
422 }
423
424 if (is_ios || is_mac) {
425 deps += [ "sdk:sdk_unittests_objc" ]
426 }
427 }
428
429 # TODO(pbos): Rename test suite, this is no longer "just" for video targets.
430 video_engine_tests_resources = [
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200431 "resources/foreman_cif_short.yuv",
432 "resources/voice_engine/audio_long16.pcm",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200433 ]
434
435 if (is_ios) {
436 bundle_data("video_engine_tests_bundle_data") {
437 testonly = true
438 sources = video_engine_tests_resources
439 outputs = [
440 "{{bundle_resources_dir}}/{{source_file_part}}",
441 ]
442 }
443 }
444
445 rtc_test("video_engine_tests") {
446 testonly = true
447 deps = [
448 "audio:audio_tests",
449
450 # TODO(eladalon): call_tests aren't actually video-specific, so we
451 # should move them to a more appropriate test suite.
452 "call:call_tests",
453 "modules/video_capture",
454 "rtc_base:rtc_base_tests_utils",
455 "test:test_common",
456 "test:test_main",
457 "test:video_test_common",
458 "video:video_tests",
459 ]
460 data = video_engine_tests_resources
461 if (!build_with_chromium && is_clang) {
462 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
463 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
464 }
465 if (is_android) {
466 deps += [ "//testing/android/native_test:native_test_native_code" ]
467 shard_timeout = 900
468 }
469 if (is_ios) {
470 deps += [ ":video_engine_tests_bundle_data" ]
471 }
472 }
473
474 webrtc_perf_tests_resources = [
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200475 "resources/audio_coding/speech_mono_16kHz.pcm",
476 "resources/audio_coding/speech_mono_32_48kHz.pcm",
477 "resources/audio_coding/testfile32kHz.pcm",
478 "resources/ConferenceMotion_1280_720_50.yuv",
479 "resources/difficult_photo_1850_1110.yuv",
brandtr2cefac62017-09-22 00:46:25 -0700480 "resources/foreman_128x96.yuv",
481 "resources/foreman_320x240.yuv",
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200482 "resources/foreman_cif.yuv",
483 "resources/google-wifi-3mbps.rx",
484 "resources/paris_qcif.yuv",
485 "resources/photo_1850_1110.yuv",
486 "resources/presentation_1850_1110.yuv",
487 "resources/verizon4g-downlink.rx",
488 "resources/voice_engine/audio_long16.pcm",
489 "resources/web_screenshot_1850_1110.yuv",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200490 ]
491
492 if (is_ios) {
493 bundle_data("webrtc_perf_tests_bundle_data") {
494 testonly = true
495 sources = webrtc_perf_tests_resources
496 outputs = [
497 "{{bundle_resources_dir}}/{{source_file_part}}",
498 ]
499 }
500 }
501
502 rtc_test("webrtc_perf_tests") {
503 testonly = true
504 configs += [ ":rtc_unittests_config" ]
505
506 deps = [
507 "audio:audio_perf_tests",
508 "call:call_perf_tests",
509 "modules/audio_coding:audio_coding_perf_tests",
510 "modules/audio_processing:audio_processing_perf_tests",
511 "modules/remote_bitrate_estimator:remote_bitrate_estimator_perf_tests",
512 "test:test_main",
513 "video:video_full_stack_tests",
514 ]
515
516 data = webrtc_perf_tests_resources
517 if (is_android) {
brandtr2cefac62017-09-22 00:46:25 -0700518 deps += [
519 # Including Java classes seems only to be possible from rtc_test
520 # targets. Therefore we include this target here, instead of
521 # in video_full_stack_tests, where it is actually used.
522 "sdk/android:libjingle_peerconnection_java",
523 "//testing/android/native_test:native_test_native_code",
524 ]
Mirko Bonadeibb547202017-09-15 06:15:48 +0200525 shard_timeout = 2700
526 }
527 if (is_ios) {
528 deps += [ ":webrtc_perf_tests_bundle_data" ]
529 }
530 }
531
532 rtc_test("webrtc_nonparallel_tests") {
533 testonly = true
534 deps = [
535 "rtc_base:rtc_base_nonparallel_tests",
536 ]
537 if (is_android) {
538 deps += [ "//testing/android/native_test:native_test_support" ]
539 shard_timeout = 900
540 }
541 }
542
543 if (is_android) {
544 junit_binary("android_junit_tests") {
545 java_files = [
546 "examples/androidjunit/src/org/appspot/apprtc/BluetoothManagerTest.java",
547 "examples/androidjunit/src/org/appspot/apprtc/DirectRTCClientTest.java",
548 "examples/androidjunit/src/org/appspot/apprtc/TCPChannelClientTest.java",
549 "sdk/android/tests/src/org/webrtc/CameraEnumerationTest.java",
550 ]
551
552 deps = [
553 "examples:AppRTCMobile_javalib",
554 "sdk/android:libjingle_peerconnection_java",
555 "//base:base_java_test_support",
556 ]
557 }
ehmaldonado37d7a222016-11-08 06:34:20 -0800558 }
wjia@webrtc.org03cfde22014-01-14 17:48:34 +0000559}