blob: 62566a260afb4162bb1f2a142c6ebbccb3372d87 [file] [log] [blame]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +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
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +00009# TODO(kjellander): Rebase this to base.gyp changes after r6438.
10
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +000011import("//build/config/crypto.gni")
12import("../build/webrtc.gni")
13
14config("webrtc_base_config") {
15 include_dirs = [
16 "//third_party/jsoncpp/overrides/include",
17 "//third_party/jsoncpp/source/include",
18 ]
19
20 defines = [
21 "FEATURE_ENABLE_SSL",
22 "GTEST_RELATIVE_PATH",
23 ]
24
25 # TODO(henrike): issue 3307, make webrtc_base build without disabling
26 # these flags.
27 cflags_cc = [ "-Wno-non-virtual-dtor" ]
28}
29
30config("webrtc_base_chromium_config") {
31 defines = [
32 "NO_MAIN_THREAD_WRAPPING",
33 "SSL_USE_NSS",
34 ]
35}
36
37config("openssl_config") {
38 defines = [
39 "SSL_USE_OPENSSL",
40 "HAVE_OPENSSL_SSL_H",
41 ]
42}
43
44config("no_openssl_config") {
45 defines = [
46 "SSL_USE_NSS",
47 "HAVE_NSS_SSL_H",
48 "SSL_USE_NSS_RNG",
49 ]
50}
51
52config("android_config") {
53 defines = [ "HAVE_OPENSSL_SSL_H" ]
54}
55
56config("no_android_config") {
57 defines = [
58 "HAVE_NSS_SSL_H",
59 "SSL_USE_NSS_RNG",
60 ]
61}
62
63config("ios_config") {
64 ldflags = [
65 #"Foundation.framework", # Already included in //build/config:default_libs.
66 "Security.framework",
67 "SystemConfiguration.framework",
68 #"UIKit.framework", # Already included in //build/config:default_libs.
69 ]
70}
71
72config("mac_config") {
73 ldflags = [
74 "Cocoa.framework",
75 #"Foundation.framework", # Already included in //build/config:default_libs.
76 #"IOKit.framework", # Already included in //build/config:default_libs.
77 #"Security.framework", # Already included in //build/config:default_libs.
78 "SystemConfiguration.framework",
79 ]
80}
81
82config("mac_x86_config") {
83 libs = [
84 #"Carbon.framework", # Already included in //build/config:default_libs.
85 ]
86}
87
88config("linux_system_ssl_config") {
89 visibility = ":*" # Only targets in this file can depend on this.
90
91 # TODO(kjellander): Find out how to convert GYP include_dirs+ (i.e. insert
92 # first in the include path?).
93 include_dirs = [ "//net/third_party/nss/ssl" ]
94
95 configs = [ "//third_party/nss:system_nss_no_ssl_config" ]
96}
97
98# Provides the same functionality as the build/linux/system.gyp:ssl GYP target.
99# This cannot be in build/linux/BUILD.gn since targets in build/ are not allowed
100# to depend on targets outside of it. This could be replaced by the Chromium
101# //crypto:platform target, but as WebRTC currently don't sync src/crypto from
102# Chromium, it is not possible today.
103config("linux_system_ssl") {
104 if (use_openssl) {
105 deps = [ "//third_party/openssl" ]
106 } else {
107 deps = [ "//net/third_party/nss/ssl:libssl" ]
108
109 direct_dependent_configs = [
110 ":linux_system_ssl_config",
111 ]
112
113 if (is_clang) {
114 cflags = [
115 # There is a broken header guard in /usr/include/nss/secmod.h:
116 # https://bugzilla.mozilla.org/show_bug.cgi?id=884072
117 "-Wno-header-guard",
118 ]
119 }
120 }
121}
122
123static_library("webrtc_base") {
124 cflags = []
125 cflags_cc = []
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000126 deps= []
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000127
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000128 configs += [
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000129 "..:common_config",
130 ":webrtc_base_config",
131 ]
132
133 direct_dependent_configs = [
134 "..:common_inherited_config",
135 ":webrtc_base_config",
136 ]
137
138 defines = [
139 "LOGGING=1",
140 "USE_WEBRTC_DEV_BRANCH",
141 ]
142
143 sources = [
144 "asyncfile.cc",
145 "asyncfile.h",
146 "asynchttprequest.cc",
147 "asynchttprequest.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000148 "asyncpacketsocket.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000149 "asyncsocket.cc",
150 "asyncsocket.h",
151 "asynctcpsocket.cc",
152 "asynctcpsocket.h",
153 "asyncudpsocket.cc",
154 "asyncudpsocket.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000155 "autodetectproxy.cc",
156 "autodetectproxy.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000157 "base64.cc",
158 "base64.h",
159 "basicdefs.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000160 "bytebuffer.cc",
161 "bytebuffer.h",
162 "byteorder.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000163 "checks.cc",
164 "checks.h",
165 "common.cc",
166 "common.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000167 "cpumonitor.cc",
168 "cpumonitor.h",
169 "crc32.cc",
170 "crc32.h",
171 "criticalsection.h",
172 "cryptstring.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000173 "diskcache.cc",
174 "diskcache.h",
175 "event.cc",
176 "event.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000177 "fileutils.cc",
178 "fileutils.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000179 "firewallsocketserver.cc",
180 "firewallsocketserver.h",
181 "flags.cc",
182 "flags.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000183 "gunit_prod.h",
184 "helpers.cc",
185 "helpers.h",
186 "httpbase.cc",
187 "httpbase.h",
188 "httpclient.cc",
189 "httpclient.h",
190 "httpcommon-inl.h",
191 "httpcommon.cc",
192 "httpcommon.h",
193 "httprequest.cc",
194 "httprequest.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000195 "iosfilesystem.mm",
196 "ipaddress.cc",
197 "ipaddress.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000198 "linked_ptr.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000199 "mathutils.h",
200 "md5.cc",
201 "md5.h",
202 "md5digest.h",
203 "messagedigest.cc",
204 "messagedigest.h",
205 "messagehandler.cc",
206 "messagehandler.h",
207 "messagequeue.cc",
208 "messagequeue.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000209 "nethelpers.cc",
210 "nethelpers.h",
211 "network.cc",
212 "network.h",
213 "nssidentity.cc",
214 "nssidentity.h",
215 "nssstreamadapter.cc",
216 "nssstreamadapter.h",
217 "nullsocketserver.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000218 "pathutils.cc",
219 "pathutils.h",
220 "physicalsocketserver.cc",
221 "physicalsocketserver.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000222 "proxydetect.cc",
223 "proxydetect.h",
224 "proxyinfo.cc",
225 "proxyinfo.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000226 "ratelimiter.cc",
227 "ratelimiter.h",
228 "ratetracker.cc",
229 "ratetracker.h",
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000230 "safe_conversions.h",
231 "safe_conversions_impl.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000232 "scoped_autorelease_pool.h",
233 "scoped_autorelease_pool.mm",
234 "scoped_ptr.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000235 "sha1.cc",
236 "sha1.h",
237 "sha1digest.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000238 "signalthread.cc",
239 "signalthread.h",
240 "sigslot.h",
241 "sigslotrepeater.h",
242 "socket.h",
243 "socketadapters.cc",
244 "socketadapters.h",
245 "socketaddress.cc",
246 "socketaddress.h",
247 "socketaddresspair.cc",
248 "socketaddresspair.h",
249 "socketfactory.h",
250 "socketpool.cc",
251 "socketpool.h",
252 "socketserver.h",
253 "socketstream.cc",
254 "socketstream.h",
255 "ssladapter.cc",
256 "ssladapter.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000257 "sslfingerprint.cc",
258 "sslfingerprint.h",
259 "sslidentity.cc",
260 "sslidentity.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000261 "sslsocketfactory.cc",
262 "sslsocketfactory.h",
263 "sslstreamadapter.cc",
264 "sslstreamadapter.h",
265 "sslstreamadapterhelper.cc",
266 "sslstreamadapterhelper.h",
267 "stream.cc",
268 "stream.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000269 "stringencode.cc",
270 "stringencode.h",
271 "stringutils.cc",
272 "stringutils.h",
273 "systeminfo.cc",
274 "systeminfo.h",
275 "task.cc",
276 "task.h",
277 "taskparent.cc",
278 "taskparent.h",
279 "taskrunner.cc",
280 "taskrunner.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000281 "thread.cc",
282 "thread.h",
283 "timeutils.cc",
284 "timeutils.h",
285 "timing.cc",
286 "timing.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000287 "urlencode.cc",
288 "urlencode.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000289 "worker.cc",
290 "worker.h",
291 ]
292
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000293 if (is_posix) {
294 sources += [
295 "unixfilesystem.cc",
296 "unixfilesystem.h",
297 ]
298 }
299
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000300 if (build_with_chromium) {
301 sources += [
302 "../overrides/webrtc/base/basictypes.h",
303 "../overrides/webrtc/base/constructormagic.h",
304 "../overrides/webrtc/base/logging.cc",
305 "../overrides/webrtc/base/logging.h",
306 ]
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000307
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000308 if (is_win) {
309 sources += [ "../overrides/webrtc/base/win32socketinit.cc" ]
310 }
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000311
312 include_dirs = [
313 "../overrides",
314 "../../openssl/openssl/include",
315 ]
316
317 direct_dependent_configs += [ ":webrtc_base_chromium_config" ]
318 } else {
319 sources += [
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000320 "asyncinvoker.cc",
321 "asyncinvoker.h",
322 "asyncinvoker-inl.h",
323 "asyncresolverinterface.h",
324 "atomicops.h",
325 "bandwidthsmoother.cc",
326 "bandwidthsmoother.h",
327 "basictypes.h",
328 "bind.h",
329 "bind.h.pump",
330 "buffer.h",
331 "callback.h",
332 "callback.h.pump",
333 "constructormagic.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000334 "filelock.cc",
335 "filelock.h",
336 "fileutils_mock.h",
337 "genericslot.h",
338 "genericslot.h.pump",
339 "httpserver.cc",
340 "httpserver.h",
341 "json.cc",
342 "json.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000343 "logging.cc",
344 "logging.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000345 "mathutils.h",
346 "multipart.cc",
347 "multipart.h",
348 "natserver.cc",
349 "natserver.h",
350 "natsocketfactory.cc",
351 "natsocketfactory.h",
352 "nattypes.cc",
353 "nattypes.h",
354 "openssl.h",
355 "optionsfile.cc",
356 "optionsfile.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000357 "profiler.cc",
358 "profiler.h",
359 "proxyserver.cc",
360 "proxyserver.h",
361 "refcount.h",
362 "referencecountedsingletonfactory.h",
363 "rollingaccumulator.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000364 "scopedptrcollection.h",
365 "scoped_ref_ptr.h",
366 "sec_buffer.h",
367 "sharedexclusivelock.cc",
368 "sharedexclusivelock.h",
369 "sslconfig.h",
370 "sslroots.h",
371 "stringdigest.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000372 "testclient.cc",
373 "testclient.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000374 "transformadapter.cc",
375 "transformadapter.h",
376 "versionparsing.cc",
377 "versionparsing.h",
378 "virtualsocketserver.cc",
379 "virtualsocketserver.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000380 "window.h",
381 "windowpickerfactory.h",
382 "windowpicker.h",
383 ]
384
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000385 if (is_posix) {
386 sources += [
387 "latebindingsymboltable.cc",
388 "latebindingsymboltable.cc.def",
389 "latebindingsymboltable.h",
390 "latebindingsymboltable.h.def",
391 "posix.cc",
392 "posix.h",
393 ]
394 }
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000395
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000396 if (is_linux) {
397 sources += [
398 "dbus.cc",
399 "dbus.h",
400 "libdbusglibsymboltable.cc",
401 "libdbusglibsymboltable.h",
402 "linuxfdwalk.c",
403 "linuxfdwalk.h",
404 "linuxwindowpicker.cc",
405 "linuxwindowpicker.h",
406 ]
407 }
408
409 if (is_mac) {
410 sources += [
411 "macasyncsocket.cc",
412 "macasyncsocket.h",
413 "maccocoasocketserver.h",
414 "maccocoasocketserver.mm",
415 "macsocketserver.cc",
416 "macsocketserver.h",
417 "macwindowpicker.cc",
418 "macwindowpicker.h",
419 ]
420 }
421
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000422 if (is_win) {
423 sources += [
424 "diskcache_win32.cc",
425 "diskcache_win32.h",
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000426 "win32regkey.cc",
427 "win32regkey.h",
428 "win32socketinit.cc",
429 "win32socketinit.h",
430 "win32socketserver.cc",
431 "win32socketserver.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000432 ]
433 }
434
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000435 deps += [ "//third_party/jsoncpp" ]
436 } # !build_with_chromium
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000437
438 # TODO(henrike): issue 3307, make webrtc_base build without disabling
439 # these flags.
440 cflags += [
441 "-Wno-extra",
442 "-Wno-all",
443 ]
444 cflags_cc += [ "-Wno-non-virtual-dtor" ]
445
446 if (use_openssl) {
447 direct_dependent_configs += [ ":openssl_config" ]
448
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000449 deps += [ "//third_party/openssl" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000450 } else {
451 direct_dependent_configs += [ ":no_openssl_config" ]
452 }
453
454 if (is_android) {
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000455 sources += [
456 "ifaddrs-android.cc",
457 "ifaddrs-android.h",
458 ]
459
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000460 direct_dependent_configs += [ ":android_config" ]
461
462 libs = [
463 "log",
464 "GLESv2"
465 ]
466 } else {
467 direct_dependent_configs += [ ":no_android_config" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000468 }
469
470 if (is_ios) {
471 all_dependent_configs += [ ":ios_config" ]
472
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000473 deps += [ "//net/third_party/nss/ssl:libssl" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000474 }
475
476 if (is_linux) {
477 libs = [
478 "crypto",
479 "dl",
480 "rt",
481 "Xext",
482 "X11",
483 "Xcomposite",
484 "Xrender",
485 ]
486 configs += [ "//third_party/nss:system_nss_no_ssl_config" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000487 }
488
489 if (is_mac) {
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000490 sources += [
491 "maccocoathreadhelper.h",
492 "maccocoathreadhelper.mm",
493 "macconversion.cc",
494 "macconversion.h",
495 "macutils.cc",
496 "macutils.h",
497 ]
498
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000499 all_dependent_configs = [ ":mac_config" ]
500
501 libs = [
502 "crypto", # $(SDKROOT)/usr/lib/libcrypto.dylib
503 "ssl", # $(SDKROOT)/usr/lib/libssl.dylib
504 ]
505 if (cpu_arch == "x86") {
506 all_dependent_configs += [ ":mac_x86_config" ]
507 }
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000508 }
509
510 if (is_win) {
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000511 sources += [
512 "schanneladapter.cc",
513 "schanneladapter.h",
514 "win32.cc",
515 "win32.h",
516 "win32filesystem.cc",
517 "win32filesystem.h",
518 "win32securityerrors.cc",
519 "win32window.cc",
520 "win32window.h",
521 "win32windowpicker.cc",
522 "win32windowpicker.h",
523 "winfirewall.cc",
524 "winfirewall.h",
525 "winping.cc",
526 "winping.h",
527 ]
528
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000529 libs = [
530 "crypt32.lib",
531 "iphlpapi.lib",
532 "secur32.lib",
533 ]
534
535 cflags += [
536 # Suppress warnings about WIN32_LEAN_AND_MEAN.
537 "/wd4005",
538 "/wd4703",
539 ]
540
541 defines += [ "_CRT_NONSTDC_NO_DEPRECATE" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000542 }
543
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000544 if (is_posix && is_debug) {
545 # Chromium's build/common.gypi defines this for all posix
546 # _except_ for ios & mac. We want it there as well, e.g.
547 # because ASSERT and friends trigger off of it.
548 defines += [ "_DEBUG" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000549 }
550
551 if (is_ios || (is_mac && cpu_arch != "x86")) {
552 defines += [ "CARBON_DEPRECATED=YES" ]
553 }
554
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000555 if (!is_ios && is_posix) {
556 sources += [
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000557 "openssl.h",
558 "openssladapter.cc",
559 "openssladapter.h",
560 "openssldigest.cc",
561 "openssldigest.h",
562 "opensslidentity.cc",
563 "opensslidentity.h",
564 "opensslstreamadapter.cc",
565 "opensslstreamadapter.h",
566 ]
567 }
568
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000569 if (is_linux || is_android) {
570 sources += [
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000571 "linux.cc",
572 "linux.h",
573 ]
574 }
575
576 if (is_mac || is_ios || is_win) {
577 deps += [
578 "//net/third_party/nss/ssl:libssl",
579 "//third_party/nss:nspr",
580 "//third_party/nss:nss",
581 ]
582 }
583
584 if (is_posix && !is_mac && !is_ios && !is_android) {
585 configs += [ ":linux_system_ssl" ]
586 }
587}