blob: 7a15add30372458936fccb469244001ed8c85991 [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) {
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +0000105 deps = [ "//third_party/boringssl" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000106 } 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",
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +0000314 "../../boringssl/src/include",
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000315 ]
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
kjellander@webrtc.org62711f82014-06-29 13:37:08 +0000438 # TODO(henrike): issue 3307, make webrtc_base build with the Chromium default
439 # compiler settings.
440 configs -= [ "//build/config/compiler:chromium_code" ]
441 configs += [ "//build/config/compiler:no_chromium_code" ]
442 cflags += [ "-Wno-uninitialized" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000443 cflags_cc += [ "-Wno-non-virtual-dtor" ]
444
445 if (use_openssl) {
446 direct_dependent_configs += [ ":openssl_config" ]
447
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +0000448 deps += [ "//third_party/boringssl" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000449 } else {
450 direct_dependent_configs += [ ":no_openssl_config" ]
451 }
452
453 if (is_android) {
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000454 sources += [
455 "ifaddrs-android.cc",
456 "ifaddrs-android.h",
457 ]
458
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000459 direct_dependent_configs += [ ":android_config" ]
460
461 libs = [
462 "log",
463 "GLESv2"
464 ]
465 } else {
466 direct_dependent_configs += [ ":no_android_config" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000467 }
468
469 if (is_ios) {
470 all_dependent_configs += [ ":ios_config" ]
471
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000472 deps += [ "//net/third_party/nss/ssl:libssl" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000473 }
474
475 if (is_linux) {
476 libs = [
477 "crypto",
478 "dl",
479 "rt",
480 "Xext",
481 "X11",
482 "Xcomposite",
483 "Xrender",
484 ]
485 configs += [ "//third_party/nss:system_nss_no_ssl_config" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000486 }
487
488 if (is_mac) {
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000489 sources += [
490 "maccocoathreadhelper.h",
491 "maccocoathreadhelper.mm",
492 "macconversion.cc",
493 "macconversion.h",
494 "macutils.cc",
495 "macutils.h",
496 ]
497
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000498 all_dependent_configs = [ ":mac_config" ]
499
500 libs = [
501 "crypto", # $(SDKROOT)/usr/lib/libcrypto.dylib
502 "ssl", # $(SDKROOT)/usr/lib/libssl.dylib
503 ]
504 if (cpu_arch == "x86") {
505 all_dependent_configs += [ ":mac_x86_config" ]
506 }
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000507 }
508
509 if (is_win) {
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000510 sources += [
511 "schanneladapter.cc",
512 "schanneladapter.h",
513 "win32.cc",
514 "win32.h",
515 "win32filesystem.cc",
516 "win32filesystem.h",
517 "win32securityerrors.cc",
518 "win32window.cc",
519 "win32window.h",
520 "win32windowpicker.cc",
521 "win32windowpicker.h",
522 "winfirewall.cc",
523 "winfirewall.h",
524 "winping.cc",
525 "winping.h",
526 ]
527
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000528 libs = [
529 "crypt32.lib",
530 "iphlpapi.lib",
531 "secur32.lib",
532 ]
533
534 cflags += [
535 # Suppress warnings about WIN32_LEAN_AND_MEAN.
536 "/wd4005",
537 "/wd4703",
538 ]
539
540 defines += [ "_CRT_NONSTDC_NO_DEPRECATE" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000541 }
542
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000543 if (is_posix && is_debug) {
544 # Chromium's build/common.gypi defines this for all posix
545 # _except_ for ios & mac. We want it there as well, e.g.
546 # because ASSERT and friends trigger off of it.
547 defines += [ "_DEBUG" ]
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000548 }
549
550 if (is_ios || (is_mac && cpu_arch != "x86")) {
551 defines += [ "CARBON_DEPRECATED=YES" ]
552 }
553
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000554 if (!is_ios && is_posix) {
555 sources += [
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000556 "openssl.h",
557 "openssladapter.cc",
558 "openssladapter.h",
559 "openssldigest.cc",
560 "openssldigest.h",
561 "opensslidentity.cc",
562 "opensslidentity.h",
563 "opensslstreamadapter.cc",
564 "opensslstreamadapter.h",
565 ]
566 }
567
kjellander@webrtc.org7497fa72014-06-28 18:05:22 +0000568 if (is_linux || is_android) {
569 sources += [
kjellander@webrtc.org851a09e2014-06-17 08:54:03 +0000570 "linux.cc",
571 "linux.h",
572 ]
573 }
574
575 if (is_mac || is_ios || is_win) {
576 deps += [
577 "//net/third_party/nss/ssl:libssl",
578 "//third_party/nss:nspr",
579 "//third_party/nss:nss",
580 ]
581 }
582
583 if (is_posix && !is_mac && !is_ios && !is_android) {
584 configs += [ ":linux_system_ssl" ]
585 }
586}