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