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