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