blob: 32bc55601ec6300da2a1a3ba50a0d0d601d16109 [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")
henrike@webrtc.orgfb1eb432014-08-15 14:44:13 +000012import("//build/config/ui.gni")
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +000013import("../build/webrtc.gni")
14
15config("webrtc_base_config") {
16 include_dirs = [
17 "//third_party/jsoncpp/overrides/include",
18 "//third_party/jsoncpp/source/include",
19 ]
20
21 defines = [
22 "FEATURE_ENABLE_SSL",
23 "GTEST_RELATIVE_PATH",
24 ]
25
26 # TODO(henrike): issue 3307, make webrtc_base build without disabling
27 # these flags.
28 cflags_cc = [ "-Wno-non-virtual-dtor" ]
29}
30
31config("webrtc_base_chromium_config") {
32 defines = [
33 "NO_MAIN_THREAD_WRAPPING",
34 "SSL_USE_NSS",
35 ]
36}
37
38config("openssl_config") {
39 defines = [
40 "SSL_USE_OPENSSL",
41 "HAVE_OPENSSL_SSL_H",
42 ]
43}
44
45config("no_openssl_config") {
46 defines = [
47 "SSL_USE_NSS",
48 "HAVE_NSS_SSL_H",
49 "SSL_USE_NSS_RNG",
50 ]
51}
52
53config("android_config") {
54 defines = [ "HAVE_OPENSSL_SSL_H" ]
55}
56
57config("no_android_config") {
58 defines = [
59 "HAVE_NSS_SSL_H",
60 "SSL_USE_NSS_RNG",
61 ]
62}
63
64config("ios_config") {
65 ldflags = [
66 #"Foundation.framework", # Already included in //build/config:default_libs.
67 "Security.framework",
68 "SystemConfiguration.framework",
69 #"UIKit.framework", # Already included in //build/config:default_libs.
70 ]
71}
72
73config("mac_config") {
74 ldflags = [
75 "Cocoa.framework",
76 #"Foundation.framework", # Already included in //build/config:default_libs.
77 #"IOKit.framework", # Already included in //build/config:default_libs.
78 #"Security.framework", # Already included in //build/config:default_libs.
79 "SystemConfiguration.framework",
80 ]
81}
82
83config("mac_x86_config") {
84 libs = [
85 #"Carbon.framework", # Already included in //build/config:default_libs.
86 ]
87}
88
89config("linux_system_ssl_config") {
90 visibility = ":*" # Only targets in this file can depend on this.
91
92 # TODO(kjellander): Find out how to convert GYP include_dirs+ (i.e. insert
93 # first in the include path?).
94 include_dirs = [ "//net/third_party/nss/ssl" ]
95
96 configs = [ "//third_party/nss:system_nss_no_ssl_config" ]
97}
98
99# Provides the same functionality as the build/linux/system.gyp:ssl GYP target.
100# This cannot be in build/linux/BUILD.gn since targets in build/ are not allowed
101# to depend on targets outside of it. This could be replaced by the Chromium
102# //crypto:platform target, but as WebRTC currently don't sync src/crypto from
103# Chromium, it is not possible today.
104config("linux_system_ssl") {
105 if (use_openssl) {
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +0000106 deps = [ "//third_party/boringssl" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000107 } else {
108 deps = [ "//net/third_party/nss/ssl:libssl" ]
109
110 direct_dependent_configs = [
111 ":linux_system_ssl_config",
112 ]
113
114 if (is_clang) {
115 cflags = [
116 # There is a broken header guard in /usr/include/nss/secmod.h:
117 # https://bugzilla.mozilla.org/show_bug.cgi?id=884072
118 "-Wno-header-guard",
119 ]
120 }
121 }
122}
123
124static_library("webrtc_base") {
125 cflags = []
126 cflags_cc = []
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000127 deps= []
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000128
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000129 configs += [
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000130 "..:common_config",
131 ":webrtc_base_config",
132 ]
133
134 direct_dependent_configs = [
135 "..:common_inherited_config",
136 ":webrtc_base_config",
137 ]
138
139 defines = [
140 "LOGGING=1",
141 "USE_WEBRTC_DEV_BRANCH",
142 ]
143
144 sources = [
145 "asyncfile.cc",
146 "asyncfile.h",
147 "asynchttprequest.cc",
148 "asynchttprequest.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000149 "asyncpacketsocket.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000150 "asyncsocket.cc",
151 "asyncsocket.h",
152 "asynctcpsocket.cc",
153 "asynctcpsocket.h",
154 "asyncudpsocket.cc",
155 "asyncudpsocket.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000156 "autodetectproxy.cc",
157 "autodetectproxy.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000158 "base64.cc",
159 "base64.h",
160 "basicdefs.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000161 "bytebuffer.cc",
162 "bytebuffer.h",
163 "byteorder.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000164 "checks.cc",
165 "checks.h",
166 "common.cc",
167 "common.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000168 "cpumonitor.cc",
169 "cpumonitor.h",
170 "crc32.cc",
171 "crc32.h",
172 "criticalsection.h",
173 "cryptstring.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000174 "diskcache.cc",
175 "diskcache.h",
176 "event.cc",
177 "event.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000178 "fileutils.cc",
179 "fileutils.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000180 "firewallsocketserver.cc",
181 "firewallsocketserver.h",
182 "flags.cc",
183 "flags.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000184 "gunit_prod.h",
185 "helpers.cc",
186 "helpers.h",
187 "httpbase.cc",
188 "httpbase.h",
189 "httpclient.cc",
190 "httpclient.h",
191 "httpcommon-inl.h",
192 "httpcommon.cc",
193 "httpcommon.h",
194 "httprequest.cc",
195 "httprequest.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000196 "iosfilesystem.mm",
197 "ipaddress.cc",
198 "ipaddress.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000199 "linked_ptr.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000200 "mathutils.h",
201 "md5.cc",
202 "md5.h",
203 "md5digest.h",
204 "messagedigest.cc",
205 "messagedigest.h",
206 "messagehandler.cc",
207 "messagehandler.h",
208 "messagequeue.cc",
209 "messagequeue.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000210 "nethelpers.cc",
211 "nethelpers.h",
212 "network.cc",
213 "network.h",
214 "nssidentity.cc",
215 "nssidentity.h",
216 "nssstreamadapter.cc",
217 "nssstreamadapter.h",
218 "nullsocketserver.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000219 "pathutils.cc",
220 "pathutils.h",
221 "physicalsocketserver.cc",
222 "physicalsocketserver.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000223 "proxydetect.cc",
224 "proxydetect.h",
225 "proxyinfo.cc",
226 "proxyinfo.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000227 "ratelimiter.cc",
228 "ratelimiter.h",
229 "ratetracker.cc",
230 "ratetracker.h",
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000231 "safe_conversions.h",
232 "safe_conversions_impl.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000233 "scoped_autorelease_pool.h",
234 "scoped_autorelease_pool.mm",
235 "scoped_ptr.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000236 "sha1.cc",
237 "sha1.h",
238 "sha1digest.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000239 "signalthread.cc",
240 "signalthread.h",
241 "sigslot.h",
242 "sigslotrepeater.h",
243 "socket.h",
244 "socketadapters.cc",
245 "socketadapters.h",
246 "socketaddress.cc",
247 "socketaddress.h",
248 "socketaddresspair.cc",
249 "socketaddresspair.h",
250 "socketfactory.h",
251 "socketpool.cc",
252 "socketpool.h",
253 "socketserver.h",
254 "socketstream.cc",
255 "socketstream.h",
256 "ssladapter.cc",
257 "ssladapter.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000258 "sslfingerprint.cc",
259 "sslfingerprint.h",
260 "sslidentity.cc",
261 "sslidentity.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000262 "sslsocketfactory.cc",
263 "sslsocketfactory.h",
264 "sslstreamadapter.cc",
265 "sslstreamadapter.h",
266 "sslstreamadapterhelper.cc",
267 "sslstreamadapterhelper.h",
268 "stream.cc",
269 "stream.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000270 "stringencode.cc",
271 "stringencode.h",
272 "stringutils.cc",
273 "stringutils.h",
274 "systeminfo.cc",
275 "systeminfo.h",
276 "task.cc",
277 "task.h",
278 "taskparent.cc",
279 "taskparent.h",
280 "taskrunner.cc",
281 "taskrunner.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000282 "thread.cc",
283 "thread.h",
284 "timeutils.cc",
285 "timeutils.h",
286 "timing.cc",
287 "timing.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000288 "urlencode.cc",
289 "urlencode.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000290 "worker.cc",
291 "worker.h",
292 ]
293
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000294 if (is_posix) {
295 sources += [
296 "unixfilesystem.cc",
297 "unixfilesystem.h",
298 ]
299 }
300
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000301 if (build_with_chromium) {
302 sources += [
303 "../overrides/webrtc/base/basictypes.h",
304 "../overrides/webrtc/base/constructormagic.h",
305 "../overrides/webrtc/base/logging.cc",
306 "../overrides/webrtc/base/logging.h",
307 ]
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000308
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000309 if (is_win) {
310 sources += [ "../overrides/webrtc/base/win32socketinit.cc" ]
311 }
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000312
313 include_dirs = [
314 "../overrides",
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +0000315 "../../boringssl/src/include",
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000316 ]
317
318 direct_dependent_configs += [ ":webrtc_base_chromium_config" ]
319 } else {
320 sources += [
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000321 "asyncinvoker.cc",
322 "asyncinvoker.h",
323 "asyncinvoker-inl.h",
324 "asyncresolverinterface.h",
325 "atomicops.h",
326 "bandwidthsmoother.cc",
327 "bandwidthsmoother.h",
328 "basictypes.h",
329 "bind.h",
330 "bind.h.pump",
331 "buffer.h",
332 "callback.h",
333 "callback.h.pump",
334 "constructormagic.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000335 "filelock.cc",
336 "filelock.h",
337 "fileutils_mock.h",
338 "genericslot.h",
339 "genericslot.h.pump",
340 "httpserver.cc",
341 "httpserver.h",
342 "json.cc",
343 "json.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000344 "logging.cc",
345 "logging.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000346 "mathutils.h",
347 "multipart.cc",
348 "multipart.h",
349 "natserver.cc",
350 "natserver.h",
351 "natsocketfactory.cc",
352 "natsocketfactory.h",
353 "nattypes.cc",
354 "nattypes.h",
355 "openssl.h",
356 "optionsfile.cc",
357 "optionsfile.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000358 "profiler.cc",
359 "profiler.h",
360 "proxyserver.cc",
361 "proxyserver.h",
362 "refcount.h",
363 "referencecountedsingletonfactory.h",
364 "rollingaccumulator.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000365 "scopedptrcollection.h",
366 "scoped_ref_ptr.h",
367 "sec_buffer.h",
368 "sharedexclusivelock.cc",
369 "sharedexclusivelock.h",
370 "sslconfig.h",
371 "sslroots.h",
372 "stringdigest.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000373 "testclient.cc",
374 "testclient.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000375 "transformadapter.cc",
376 "transformadapter.h",
377 "versionparsing.cc",
378 "versionparsing.h",
379 "virtualsocketserver.cc",
380 "virtualsocketserver.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000381 "window.h",
382 "windowpickerfactory.h",
383 "windowpicker.h",
384 ]
385
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000386 if (is_posix) {
387 sources += [
388 "latebindingsymboltable.cc",
389 "latebindingsymboltable.cc.def",
390 "latebindingsymboltable.h",
391 "latebindingsymboltable.h.def",
392 "posix.cc",
393 "posix.h",
394 ]
395 }
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000396
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000397 if (is_linux) {
398 sources += [
399 "dbus.cc",
400 "dbus.h",
401 "libdbusglibsymboltable.cc",
402 "libdbusglibsymboltable.h",
403 "linuxfdwalk.c",
404 "linuxfdwalk.h",
henrike@webrtc.orgfb1eb432014-08-15 14:44:13 +0000405 ]
406 }
407
408 if (use_x11) {
409 sources += [
410 "x11windowpicker.cc",
411 "x11windowpicker.h",
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000412 ]
413 }
414
415 if (is_mac) {
416 sources += [
417 "macasyncsocket.cc",
418 "macasyncsocket.h",
419 "maccocoasocketserver.h",
420 "maccocoasocketserver.mm",
421 "macsocketserver.cc",
422 "macsocketserver.h",
423 "macwindowpicker.cc",
424 "macwindowpicker.h",
425 ]
426 }
427
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000428 if (is_win) {
429 sources += [
430 "diskcache_win32.cc",
431 "diskcache_win32.h",
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000432 "win32regkey.cc",
433 "win32regkey.h",
434 "win32socketinit.cc",
435 "win32socketinit.h",
436 "win32socketserver.cc",
437 "win32socketserver.h",
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000438 ]
439 }
440
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000441 deps += [ "//third_party/jsoncpp" ]
442 } # !build_with_chromium
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000443
kjellander@webrtc.org62711f82014-06-29 13:37:08 +0000444 # TODO(henrike): issue 3307, make webrtc_base build with the Chromium default
445 # compiler settings.
446 configs -= [ "//build/config/compiler:chromium_code" ]
447 configs += [ "//build/config/compiler:no_chromium_code" ]
448 cflags += [ "-Wno-uninitialized" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000449 cflags_cc += [ "-Wno-non-virtual-dtor" ]
450
451 if (use_openssl) {
452 direct_dependent_configs += [ ":openssl_config" ]
453
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +0000454 deps += [ "//third_party/boringssl" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000455 } else {
456 direct_dependent_configs += [ ":no_openssl_config" ]
457 }
458
459 if (is_android) {
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000460 sources += [
461 "ifaddrs-android.cc",
462 "ifaddrs-android.h",
463 ]
464
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000465 direct_dependent_configs += [ ":android_config" ]
466
467 libs = [
468 "log",
469 "GLESv2"
470 ]
471 } else {
472 direct_dependent_configs += [ ":no_android_config" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000473 }
474
475 if (is_ios) {
476 all_dependent_configs += [ ":ios_config" ]
477
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000478 deps += [ "//net/third_party/nss/ssl:libssl" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000479 }
480
481 if (is_linux) {
482 libs = [
483 "crypto",
484 "dl",
485 "rt",
486 "Xext",
487 "X11",
488 "Xcomposite",
489 "Xrender",
490 ]
491 configs += [ "//third_party/nss:system_nss_no_ssl_config" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000492 }
493
494 if (is_mac) {
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000495 sources += [
496 "maccocoathreadhelper.h",
497 "maccocoathreadhelper.mm",
498 "macconversion.cc",
499 "macconversion.h",
500 "macutils.cc",
501 "macutils.h",
502 ]
503
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000504 all_dependent_configs = [ ":mac_config" ]
505
506 libs = [
507 "crypto", # $(SDKROOT)/usr/lib/libcrypto.dylib
508 "ssl", # $(SDKROOT)/usr/lib/libssl.dylib
509 ]
510 if (cpu_arch == "x86") {
511 all_dependent_configs += [ ":mac_x86_config" ]
512 }
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000513 }
514
515 if (is_win) {
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000516 sources += [
517 "schanneladapter.cc",
518 "schanneladapter.h",
519 "win32.cc",
520 "win32.h",
521 "win32filesystem.cc",
522 "win32filesystem.h",
523 "win32securityerrors.cc",
524 "win32window.cc",
525 "win32window.h",
526 "win32windowpicker.cc",
527 "win32windowpicker.h",
528 "winfirewall.cc",
529 "winfirewall.h",
530 "winping.cc",
531 "winping.h",
532 ]
533
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000534 libs = [
535 "crypt32.lib",
536 "iphlpapi.lib",
537 "secur32.lib",
538 ]
539
540 cflags += [
541 # Suppress warnings about WIN32_LEAN_AND_MEAN.
542 "/wd4005",
543 "/wd4703",
544 ]
545
546 defines += [ "_CRT_NONSTDC_NO_DEPRECATE" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000547 }
548
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000549 if (is_posix && is_debug) {
550 # Chromium's build/common.gypi defines this for all posix
551 # _except_ for ios & mac. We want it there as well, e.g.
552 # because ASSERT and friends trigger off of it.
553 defines += [ "_DEBUG" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000554 }
555
556 if (is_ios || (is_mac && cpu_arch != "x86")) {
557 defines += [ "CARBON_DEPRECATED=YES" ]
558 }
559
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000560 if (!is_ios && is_posix) {
561 sources += [
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000562 "openssl.h",
563 "openssladapter.cc",
564 "openssladapter.h",
565 "openssldigest.cc",
566 "openssldigest.h",
567 "opensslidentity.cc",
568 "opensslidentity.h",
569 "opensslstreamadapter.cc",
570 "opensslstreamadapter.h",
571 ]
572 }
573
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000574 if (is_linux || is_android) {
575 sources += [
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000576 "linux.cc",
577 "linux.h",
578 ]
579 }
580
581 if (is_mac || is_ios || is_win) {
582 deps += [
583 "//net/third_party/nss/ssl:libssl",
584 "//third_party/nss:nspr",
585 "//third_party/nss:nss",
586 ]
587 }
588
589 if (is_posix && !is_mac && !is_ios && !is_android) {
590 configs += [ ":linux_system_ssl" ]
591 }
592}