blob: 6641e2f636418a5fe69031bf0506162597395ce8 [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 }
341 if (!is_ios) {
342 deps += [ "voice_engine:voe_auto_test" ]
343 }
344 if (rtc_enable_protobuf) {
345 deps += [
346 "audio:low_bandwidth_audio_test",
347 "logging:rtc_event_log2rtp_dump",
348 ]
349 }
350 }
351 }
352}
353
354rtc_static_library("webrtc_common") {
355 # TODO(mbonadei): Remove (bugs.webrtc.org/7745)
356 # Enabling GN check triggers cyclic dependency error:
357 # :webrtc_common ->
358 # api:video_frame_api ->
359 # system_wrappers:system_wrappers ->
360 # webrtc_common
361 check_includes = false
362 sources = [
363 "common_types.cc",
364 "common_types.h",
365 "typedefs.h",
366 ]
367
368 if (!build_with_chromium && is_clang) {
369 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
370 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
371 }
372}
373
374if (use_libfuzzer || use_drfuzz || use_afl) {
375 # This target is only here for gn to discover fuzzer build targets under
376 # webrtc/test/fuzzers/.
377 group("webrtc_fuzzers_dummy") {
378 testonly = true
379 deps = [
380 "test/fuzzers:webrtc_fuzzer_main",
381 ]
382 }
383}
384
385if (rtc_include_tests) {
386 config("rtc_unittests_config") {
387 # GN orders flags on a target before flags from configs. The default config
388 # adds -Wall, and this flag have to be after -Wall -- so they need to
389 # come from a config and can"t be on the target directly.
390 if (is_clang) {
391 cflags = [
392 "-Wno-sign-compare",
393 "-Wno-unused-const-variable",
394 ]
395 }
396 }
397
398 rtc_test("rtc_unittests") {
399 testonly = true
400
401 deps = [
402 ":webrtc_common",
403 "api:rtc_api_unittests",
404 "api/audio_codecs/test:audio_codecs_api_unittests",
405 "p2p:libstunprober_unittests",
406 "p2p:rtc_p2p_unittests",
407 "rtc_base:rtc_base_approved_unittests",
408 "rtc_base:rtc_base_tests_main",
409 "rtc_base:rtc_base_tests_utils",
410 "rtc_base:rtc_base_unittests",
411 "rtc_base:rtc_numerics_unittests",
412 "rtc_base:rtc_task_queue_unittests",
413 "rtc_base:sequenced_task_checker_unittests",
414 "rtc_base:weak_ptr_unittests",
415 "system_wrappers:metrics_default",
416 ]
417
418 if (rtc_enable_protobuf) {
419 deps += [ "logging:rtc_event_log_tests" ]
420 }
421
422 if (is_android) {
423 deps += [ "//testing/android/native_test:native_test_support" ]
424 shard_timeout = 900
425 }
426
427 if (is_ios || is_mac) {
428 deps += [ "sdk:sdk_unittests_objc" ]
429 }
430 }
431
432 # TODO(pbos): Rename test suite, this is no longer "just" for video targets.
433 video_engine_tests_resources = [
434 "../resources/foreman_cif_short.yuv",
435 "../resources/voice_engine/audio_long16.pcm",
436 ]
437
438 if (is_ios) {
439 bundle_data("video_engine_tests_bundle_data") {
440 testonly = true
441 sources = video_engine_tests_resources
442 outputs = [
443 "{{bundle_resources_dir}}/{{source_file_part}}",
444 ]
445 }
446 }
447
448 rtc_test("video_engine_tests") {
449 testonly = true
450 deps = [
451 "audio:audio_tests",
452
453 # TODO(eladalon): call_tests aren't actually video-specific, so we
454 # should move them to a more appropriate test suite.
455 "call:call_tests",
456 "modules/video_capture",
457 "rtc_base:rtc_base_tests_utils",
458 "test:test_common",
459 "test:test_main",
460 "test:video_test_common",
461 "video:video_tests",
462 ]
463 data = video_engine_tests_resources
464 if (!build_with_chromium && is_clang) {
465 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
466 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
467 }
468 if (is_android) {
469 deps += [ "//testing/android/native_test:native_test_native_code" ]
470 shard_timeout = 900
471 }
472 if (is_ios) {
473 deps += [ ":video_engine_tests_bundle_data" ]
474 }
475 }
476
477 webrtc_perf_tests_resources = [
478 "../resources/audio_coding/speech_mono_16kHz.pcm",
479 "../resources/audio_coding/speech_mono_32_48kHz.pcm",
480 "../resources/audio_coding/testfile32kHz.pcm",
481 "../resources/ConferenceMotion_1280_720_50.yuv",
482 "../resources/difficult_photo_1850_1110.yuv",
483 "../resources/foreman_cif.yuv",
484 "../resources/google-wifi-3mbps.rx",
485 "../resources/paris_qcif.yuv",
486 "../resources/photo_1850_1110.yuv",
487 "../resources/presentation_1850_1110.yuv",
488 "../resources/verizon4g-downlink.rx",
489 "../resources/voice_engine/audio_long16.pcm",
490 "../resources/web_screenshot_1850_1110.yuv",
491 ]
492
493 if (is_ios) {
494 bundle_data("webrtc_perf_tests_bundle_data") {
495 testonly = true
496 sources = webrtc_perf_tests_resources
497 outputs = [
498 "{{bundle_resources_dir}}/{{source_file_part}}",
499 ]
500 }
501 }
502
503 rtc_test("webrtc_perf_tests") {
504 testonly = true
505 configs += [ ":rtc_unittests_config" ]
506
507 deps = [
508 "audio:audio_perf_tests",
509 "call:call_perf_tests",
510 "modules/audio_coding:audio_coding_perf_tests",
511 "modules/audio_processing:audio_processing_perf_tests",
512 "modules/remote_bitrate_estimator:remote_bitrate_estimator_perf_tests",
513 "test:test_main",
514 "video:video_full_stack_tests",
515 ]
516
517 data = webrtc_perf_tests_resources
518 if (is_android) {
519 deps += [ "//testing/android/native_test:native_test_native_code" ]
520 shard_timeout = 2700
521 }
522 if (is_ios) {
523 deps += [ ":webrtc_perf_tests_bundle_data" ]
524 }
525 }
526
527 rtc_test("webrtc_nonparallel_tests") {
528 testonly = true
529 deps = [
530 "rtc_base:rtc_base_nonparallel_tests",
531 ]
532 if (is_android) {
533 deps += [ "//testing/android/native_test:native_test_support" ]
534 shard_timeout = 900
535 }
536 }
537
538 if (is_android) {
539 junit_binary("android_junit_tests") {
540 java_files = [
541 "examples/androidjunit/src/org/appspot/apprtc/BluetoothManagerTest.java",
542 "examples/androidjunit/src/org/appspot/apprtc/DirectRTCClientTest.java",
543 "examples/androidjunit/src/org/appspot/apprtc/TCPChannelClientTest.java",
544 "sdk/android/tests/src/org/webrtc/CameraEnumerationTest.java",
545 ]
546
547 deps = [
548 "examples:AppRTCMobile_javalib",
549 "sdk/android:libjingle_peerconnection_java",
550 "//base:base_java_test_support",
551 ]
552 }
ehmaldonado37d7a222016-11-08 06:34:20 -0800553 }
wjia@webrtc.org03cfde22014-01-14 17:48:34 +0000554}