blob: e24c741b10899016e1d98ff1af96c5e8b9cd5803 [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",
Patrik Höglund29dd6d72017-12-01 11:35:26 +010066 ]
67 if (is_android) {
68 deps += [
69 ":android_junit_tests",
70 "sdk/android:libjingle_peerconnection_android_unittest",
71 ]
72 } else {
73 deps += [ "modules/video_capture:video_capture_tests" ]
74 }
75 if (rtc_enable_protobuf) {
76 deps += [
77 "audio:low_bandwidth_audio_test",
78 "logging:rtc_event_log2rtp_dump",
79 ]
80 }
Mirko Bonadeibb547202017-09-15 06:15:48 +020081 }
82 }
83}
84
85# Contains the defines and includes in common.gypi that are duplicated both as
86# target_defaults and direct_dependent_settings.
87config("common_inherited_config") {
88 defines = []
89 cflags = []
90 ldflags = []
91 if (build_with_mozilla) {
92 defines += [ "WEBRTC_MOZILLA_BUILD" ]
93 }
94
95 # Some tests need to declare their own trace event handlers. If this define is
96 # not set, the first time TRACE_EVENT_* is called it will store the return
97 # value for the current handler in an static variable, so that subsequent
98 # changes to the handler for that TRACE_EVENT_* will be ignored.
99 # So when tests are included, we set this define, making it possible to use
100 # different event handlers in different tests.
ehmaldonado37d7a222016-11-08 06:34:20 -0800101 if (rtc_include_tests) {
Mirko Bonadeibb547202017-09-15 06:15:48 +0200102 defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1" ]
103 } else {
104 defines += [ "WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0" ]
105 }
106 if (build_with_chromium) {
107 defines += [
108 # TODO(kjellander): Cleanup unused ones and move defines closer to
109 # the source when webrtc:4256 is completed.
Mirko Bonadeibb547202017-09-15 06:15:48 +0200110 "GTEST_RELATIVE_PATH",
111 "WEBRTC_CHROMIUM_BUILD",
112 ]
113 include_dirs = [
114 # The overrides must be included first as that is the mechanism for
115 # selecting the override headers in Chromium.
116 "../webrtc_overrides",
117
118 # Allow includes to be prefixed with webrtc/ in case it is not an
119 # immediate subdirectory of the top-level.
120 ".",
121 ]
122 }
123 if (is_posix) {
124 defines += [ "WEBRTC_POSIX" ]
125 }
126 if (is_ios) {
127 defines += [
128 "WEBRTC_MAC",
129 "WEBRTC_IOS",
130 ]
131 }
132 if (is_linux) {
133 defines += [ "WEBRTC_LINUX" ]
134 }
135 if (is_mac) {
136 defines += [ "WEBRTC_MAC" ]
137 }
Sergey Ulanov6acefdb2017-12-11 17:38:13 -0800138 if (is_fuchsia) {
139 defines += [ "WEBRTC_FUCHSIA" ]
140 }
Mirko Bonadeibb547202017-09-15 06:15:48 +0200141 if (is_win) {
142 defines += [
143 "WEBRTC_WIN",
144 "_CRT_SECURE_NO_WARNINGS", # Suppress warnings about _vsnprinf
145 ]
146 }
147 if (is_android) {
148 defines += [
149 "WEBRTC_LINUX",
150 "WEBRTC_ANDROID",
151 ]
Dan Minor9c686132018-01-15 10:20:00 -0500152
153 if (build_with_mozilla) {
154 defines += [ "WEBRTC_ANDROID_OPENSLES" ]
155 }
Mirko Bonadeibb547202017-09-15 06:15:48 +0200156 }
157 if (is_chromeos) {
158 defines += [ "CHROMEOS" ]
159 }
160
161 if (rtc_sanitize_coverage != "") {
162 assert(is_clang, "sanitizer coverage requires clang")
163 cflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
164 ldflags += [ "-fsanitize-coverage=${rtc_sanitize_coverage}" ]
165 }
166
167 if (is_ubsan) {
168 cflags += [ "-fsanitize=float-cast-overflow" ]
169 }
Mirko Bonadeibb547202017-09-15 06:15:48 +0200170}
171
172config("common_config") {
173 cflags = []
Mirko Bonadeid7573562018-03-19 16:23:48 +0100174 cflags_c = []
Mirko Bonadeibb547202017-09-15 06:15:48 +0200175 cflags_cc = []
Mirko Bonadeid7573562018-03-19 16:23:48 +0100176 cflags_objc = []
Mirko Bonadeibb547202017-09-15 06:15:48 +0200177 defines = []
178
179 if (rtc_enable_protobuf) {
180 defines += [ "WEBRTC_ENABLE_PROTOBUF=1" ]
181 } else {
182 defines += [ "WEBRTC_ENABLE_PROTOBUF=0" ]
183 }
184
Mirko Bonadeibb547202017-09-15 06:15:48 +0200185 if (rtc_include_internal_audio_device) {
186 defines += [ "WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE" ]
187 }
188
189 if (!rtc_libvpx_build_vp9) {
190 defines += [ "RTC_DISABLE_VP9" ]
191 }
192
193 if (rtc_enable_sctp) {
194 defines += [ "HAVE_SCTP" ]
195 }
196
197 if (rtc_enable_external_auth) {
198 defines += [ "ENABLE_EXTERNAL_AUTH" ]
199 }
200
Anders Carlssondd8c1652018-01-30 10:32:13 +0100201 if (rtc_use_builtin_sw_codecs) {
202 defines += [ "USE_BUILTIN_SW_CODECS" ]
203 }
204
Mirko Bonadeibb547202017-09-15 06:15:48 +0200205 if (build_with_chromium) {
206 defines += [
207 # NOTICE: Since common_inherited_config is used in public_configs for our
208 # targets, there's no point including the defines in that config here.
209 # TODO(kjellander): Cleanup unused ones and move defines closer to the
210 # source when webrtc:4256 is completed.
211 "HAVE_WEBRTC_VIDEO",
212 "HAVE_WEBRTC_VOICE",
213 "LOGGING_INSIDE_WEBRTC",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200214 ]
215 } else {
216 if (is_posix) {
217 # Enable more warnings: -Wextra is currently disabled in Chromium.
218 cflags = [
219 "-Wextra",
220
221 # Repeat some flags that get overridden by -Wextra.
222 "-Wno-unused-parameter",
223 "-Wno-missing-field-initializers",
224 "-Wno-strict-overflow",
225 ]
Mirko Bonadeid7573562018-03-19 16:23:48 +0100226 cflags_c += [
227 # TODO(bugs.webrtc.org/9029): enable commented compiler flags.
228 # Some of these flags should also be added to cflags_objc.
229
230 # "-Wextra", (used when building C++ but not when building C)
231 # "-Wmissing-prototypes", (C/Obj-C only)
232 # "-Wmissing-declarations", (ensure this is always used C/C++, etc..)
233 "-Wstrict-prototypes",
234
235 # "-Wpointer-arith", (ensure this is always used C/C++, etc..)
236 # "-Wbad-function-cast", (C/Obj-C only)
237 # "-Wnested-externs", (C/Obj-C only)
238 ]
239 cflags_objc += [ "-Wstrict-prototypes" ]
Mirko Bonadeibb547202017-09-15 06:15:48 +0200240 cflags_cc = [
241 "-Wnon-virtual-dtor",
242
243 # This is enabled for clang; enable for gcc as well.
244 "-Woverloaded-virtual",
245 ]
246 }
247
248 if (is_clang) {
249 cflags += [
250 "-Wc++11-narrowing",
251 "-Wimplicit-fallthrough",
252 "-Wthread-safety",
253 "-Winconsistent-missing-override",
254 "-Wundef",
255 ]
256
257 # use_xcode_clang only refers to the iOS toolchain, host binaries use
258 # chromium's clang always.
259 if (!is_nacl &&
260 (!use_xcode_clang || current_toolchain == host_toolchain)) {
261 # Flags NaCl (Clang 3.7) and Xcode 7.3 (Clang clang-703.0.31) do not
262 # recognize.
263 cflags += [ "-Wunused-lambda-capture" ]
264 }
265 }
266 }
267
268 if (current_cpu == "arm64") {
269 defines += [ "WEBRTC_ARCH_ARM64" ]
270 defines += [ "WEBRTC_HAS_NEON" ]
271 }
272
273 if (current_cpu == "arm") {
274 defines += [ "WEBRTC_ARCH_ARM" ]
275 if (arm_version >= 7) {
276 defines += [ "WEBRTC_ARCH_ARM_V7" ]
277 if (arm_use_neon) {
278 defines += [ "WEBRTC_HAS_NEON" ]
279 }
280 }
281 }
282
283 if (current_cpu == "mipsel") {
284 defines += [ "MIPS32_LE" ]
285 if (mips_float_abi == "hard") {
286 defines += [ "MIPS_FPU_LE" ]
287 }
288 if (mips_arch_variant == "r2") {
289 defines += [ "MIPS32_R2_LE" ]
290 }
291 if (mips_dsp_rev == 1) {
292 defines += [ "MIPS_DSP_R1_LE" ]
293 } else if (mips_dsp_rev == 2) {
294 defines += [
295 "MIPS_DSP_R1_LE",
296 "MIPS_DSP_R2_LE",
297 ]
298 }
299 }
300
301 if (is_android && !is_clang) {
302 # The Android NDK doesn"t provide optimized versions of these
303 # functions. Ensure they are disabled for all compilers.
304 cflags += [
305 "-fno-builtin-cos",
306 "-fno-builtin-sin",
307 "-fno-builtin-cosf",
308 "-fno-builtin-sinf",
309 ]
310 }
311
312 if (use_libfuzzer || use_drfuzz || use_afl) {
313 # Used in Chromium's overrides to disable logging
314 defines += [ "WEBRTC_UNSAFE_FUZZER_MODE" ]
315 }
316}
317
318config("common_objc") {
319 libs = [ "Foundation.framework" ]
320}
321
322if (!build_with_chromium) {
323 # Target to build all the WebRTC production code.
324 rtc_static_library("webrtc") {
325 # Only the root target should depend on this.
326 visibility = [ "//:default" ]
327
328 sources = []
329 complete_static_lib = true
330 defines = []
331
332 deps = [
333 ":webrtc_common",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200334 "api:transport_api",
335 "audio",
336 "call",
337 "common_audio",
338 "common_video",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200339 "media",
340 "modules",
341 "modules/video_capture:video_capture_internal_impl",
342 "ortc",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200343 "rtc_base",
344 "sdk",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200345 "system_wrappers:system_wrappers_default",
346 "video",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200347 ]
348
Dan Minor9c686132018-01-15 10:20:00 -0500349 if (build_with_mozilla) {
350 deps += [
351 "api:video_frame_api",
352 "system_wrappers:field_trial_default",
353 "system_wrappers:metrics_default",
354 ]
355 } else {
356 deps += [
357 "api",
358 "logging",
359 "p2p",
360 "pc",
361 "stats",
362 ]
363 }
364
Mirko Bonadeibb547202017-09-15 06:15:48 +0200365 if (rtc_enable_protobuf) {
366 defines += [ "ENABLE_RTC_EVENT_LOG" ]
367 deps += [ "logging:rtc_event_log_proto" ]
368 }
369 }
Mirko Bonadeibb547202017-09-15 06:15:48 +0200370}
371
Patrik Höglund3e113432017-12-15 14:40:10 +0100372rtc_source_set("typedefs") {
373 sources = [
374 "typedefs.h",
375 ]
376}
377
Mirko Bonadeibb547202017-09-15 06:15:48 +0200378rtc_static_library("webrtc_common") {
Mirko Bonadeibb547202017-09-15 06:15:48 +0200379 sources = [
380 "common_types.cc",
381 "common_types.h",
Patrik Höglund3e113432017-12-15 14:40:10 +0100382 ]
383 deps = [
384 ":typedefs",
385 "api:array_view",
386 "api:optional",
387 "rtc_base:checks",
388 "rtc_base:deprecation",
389 "rtc_base:stringutils",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200390 ]
391
392 if (!build_with_chromium && is_clang) {
393 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
394 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
395 }
396}
397
398if (use_libfuzzer || use_drfuzz || use_afl) {
399 # This target is only here for gn to discover fuzzer build targets under
400 # webrtc/test/fuzzers/.
401 group("webrtc_fuzzers_dummy") {
402 testonly = true
403 deps = [
404 "test/fuzzers:webrtc_fuzzer_main",
405 ]
406 }
407}
408
409if (rtc_include_tests) {
410 config("rtc_unittests_config") {
411 # GN orders flags on a target before flags from configs. The default config
412 # adds -Wall, and this flag have to be after -Wall -- so they need to
413 # come from a config and can"t be on the target directly.
414 if (is_clang) {
415 cflags = [
416 "-Wno-sign-compare",
417 "-Wno-unused-const-variable",
418 ]
419 }
420 }
421
422 rtc_test("rtc_unittests") {
423 testonly = true
424
425 deps = [
426 ":webrtc_common",
427 "api:rtc_api_unittests",
428 "api/audio_codecs/test:audio_codecs_api_unittests",
429 "p2p:libstunprober_unittests",
430 "p2p:rtc_p2p_unittests",
431 "rtc_base:rtc_base_approved_unittests",
432 "rtc_base:rtc_base_tests_main",
433 "rtc_base:rtc_base_tests_utils",
434 "rtc_base:rtc_base_unittests",
435 "rtc_base:rtc_numerics_unittests",
436 "rtc_base:rtc_task_queue_unittests",
437 "rtc_base:sequenced_task_checker_unittests",
438 "rtc_base:weak_ptr_unittests",
439 "system_wrappers:metrics_default",
Ilya Nikolaevskiy2ffe3e82018-01-17 19:57:24 +0000440 "system_wrappers:runtime_enabled_features_default",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200441 ]
442
443 if (rtc_enable_protobuf) {
444 deps += [ "logging:rtc_event_log_tests" ]
445 }
446
447 if (is_android) {
Sami Kalliomäki78498cf2018-02-07 16:59:33 +0100448 # Do not use Chromium's launcher. native_unittests defines its own JNI_OnLoad.
449 use_default_launcher = false
450
451 deps += [
452 "sdk/android:native_unittests",
453 "sdk/android:native_unittests_java",
454 "//testing/android/native_test:native_test_support",
455 ]
Mirko Bonadeibb547202017-09-15 06:15:48 +0200456 shard_timeout = 900
457 }
458
459 if (is_ios || is_mac) {
460 deps += [ "sdk:sdk_unittests_objc" ]
461 }
462 }
463
464 # TODO(pbos): Rename test suite, this is no longer "just" for video targets.
465 video_engine_tests_resources = [
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200466 "resources/foreman_cif_short.yuv",
467 "resources/voice_engine/audio_long16.pcm",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200468 ]
469
470 if (is_ios) {
471 bundle_data("video_engine_tests_bundle_data") {
472 testonly = true
473 sources = video_engine_tests_resources
474 outputs = [
475 "{{bundle_resources_dir}}/{{source_file_part}}",
476 ]
477 }
478 }
479
480 rtc_test("video_engine_tests") {
481 testonly = true
482 deps = [
483 "audio:audio_tests",
484
485 # TODO(eladalon): call_tests aren't actually video-specific, so we
486 # should move them to a more appropriate test suite.
487 "call:call_tests",
488 "modules/video_capture",
489 "rtc_base:rtc_base_tests_utils",
490 "test:test_common",
491 "test:test_main",
492 "test:video_test_common",
493 "video:video_tests",
494 ]
495 data = video_engine_tests_resources
496 if (!build_with_chromium && is_clang) {
497 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
498 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
499 }
500 if (is_android) {
501 deps += [ "//testing/android/native_test:native_test_native_code" ]
502 shard_timeout = 900
503 }
504 if (is_ios) {
505 deps += [ ":video_engine_tests_bundle_data" ]
506 }
507 }
508
509 webrtc_perf_tests_resources = [
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200510 "resources/audio_coding/speech_mono_16kHz.pcm",
511 "resources/audio_coding/speech_mono_32_48kHz.pcm",
512 "resources/audio_coding/testfile32kHz.pcm",
513 "resources/ConferenceMotion_1280_720_50.yuv",
514 "resources/difficult_photo_1850_1110.yuv",
515 "resources/foreman_cif.yuv",
516 "resources/google-wifi-3mbps.rx",
517 "resources/paris_qcif.yuv",
518 "resources/photo_1850_1110.yuv",
519 "resources/presentation_1850_1110.yuv",
520 "resources/verizon4g-downlink.rx",
521 "resources/voice_engine/audio_long16.pcm",
522 "resources/web_screenshot_1850_1110.yuv",
Mirko Bonadeibb547202017-09-15 06:15:48 +0200523 ]
524
525 if (is_ios) {
526 bundle_data("webrtc_perf_tests_bundle_data") {
527 testonly = true
528 sources = webrtc_perf_tests_resources
529 outputs = [
530 "{{bundle_resources_dir}}/{{source_file_part}}",
531 ]
532 }
533 }
534
535 rtc_test("webrtc_perf_tests") {
536 testonly = true
537 configs += [ ":rtc_unittests_config" ]
538
539 deps = [
540 "audio:audio_perf_tests",
541 "call:call_perf_tests",
542 "modules/audio_coding:audio_coding_perf_tests",
543 "modules/audio_processing:audio_processing_perf_tests",
544 "modules/remote_bitrate_estimator:remote_bitrate_estimator_perf_tests",
545 "test:test_main",
546 "video:video_full_stack_tests",
547 ]
548
549 data = webrtc_perf_tests_resources
550 if (is_android) {
Rasmus Brandt31027342017-09-29 13:48:12 +0000551 deps += [ "//testing/android/native_test:native_test_native_code" ]
Mirko Bonadeibb547202017-09-15 06:15:48 +0200552 shard_timeout = 2700
553 }
554 if (is_ios) {
555 deps += [ ":webrtc_perf_tests_bundle_data" ]
556 }
557 }
558
559 rtc_test("webrtc_nonparallel_tests") {
560 testonly = true
561 deps = [
562 "rtc_base:rtc_base_nonparallel_tests",
563 ]
564 if (is_android) {
565 deps += [ "//testing/android/native_test:native_test_support" ]
566 shard_timeout = 900
567 }
568 }
569
570 if (is_android) {
571 junit_binary("android_junit_tests") {
572 java_files = [
573 "examples/androidjunit/src/org/appspot/apprtc/BluetoothManagerTest.java",
574 "examples/androidjunit/src/org/appspot/apprtc/DirectRTCClientTest.java",
575 "examples/androidjunit/src/org/appspot/apprtc/TCPChannelClientTest.java",
576 "sdk/android/tests/src/org/webrtc/CameraEnumerationTest.java",
577 ]
578
579 deps = [
580 "examples:AppRTCMobile_javalib",
581 "sdk/android:libjingle_peerconnection_java",
582 "//base:base_java_test_support",
583 ]
584 }
ehmaldonado37d7a222016-11-08 06:34:20 -0800585 }
wjia@webrtc.org03cfde22014-01-14 17:48:34 +0000586}