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