Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / base / BUILD.gn
1 # 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
9 # TODO(kjellander): Rebase this to base.gyp changes after r6438.
10
11 import("//build/config/crypto.gni")
12 import("//build/config/ui.gni")
13 import("../build/webrtc.gni")
14
15 config("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
31 config("webrtc_base_chromium_config") {
32   defines = [
33     "NO_MAIN_THREAD_WRAPPING",
34     "SSL_USE_NSS",
35   ]
36 }
37
38 config("openssl_config") {
39   defines = [
40     "SSL_USE_OPENSSL",
41     "HAVE_OPENSSL_SSL_H",
42   ]
43 }
44
45 config("no_openssl_config") {
46   defines = [
47     "SSL_USE_NSS",
48     "HAVE_NSS_SSL_H",
49     "SSL_USE_NSS_RNG",
50   ]
51 }
52
53 config("android_config") {
54   defines = [ "HAVE_OPENSSL_SSL_H" ]
55 }
56
57 config("no_android_config") {
58   defines = [
59     "HAVE_NSS_SSL_H",
60     "SSL_USE_NSS_RNG",
61   ]
62 }
63
64 config("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
73 config("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
83 config("mac_x86_config") {
84   libs = [
85     #"Carbon.framework",  # Already included in //build/config:default_libs.
86   ]
87 }
88
89 config("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.
104 config("linux_system_ssl") {
105   if (use_openssl) {
106     deps = [ "//third_party/boringssl" ]
107   } 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
124 static_library("webrtc_base") {
125   cflags = []
126   cflags_cc = []
127   deps= []
128
129   configs += [
130     "..: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",
149     "asyncpacketsocket.h",
150     "asyncsocket.cc",
151     "asyncsocket.h",
152     "asynctcpsocket.cc",
153     "asynctcpsocket.h",
154     "asyncudpsocket.cc",
155     "asyncudpsocket.h",
156     "autodetectproxy.cc",
157     "autodetectproxy.h",
158     "base64.cc",
159     "base64.h",
160     "basicdefs.h",
161     "bytebuffer.cc",
162     "bytebuffer.h",
163     "byteorder.h",
164     "checks.cc",
165     "checks.h",
166     "common.cc",
167     "common.h",
168     "cpumonitor.cc",
169     "cpumonitor.h",
170     "crc32.cc",
171     "crc32.h",
172     "criticalsection.h",
173     "cryptstring.h",
174     "diskcache.cc",
175     "diskcache.h",
176     "event.cc",
177     "event.h",
178     "fileutils.cc",
179     "fileutils.h",
180     "firewallsocketserver.cc",
181     "firewallsocketserver.h",
182     "flags.cc",
183     "flags.h",
184     "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",
196     "iosfilesystem.mm",
197     "ipaddress.cc",
198     "ipaddress.h",
199     "linked_ptr.h",
200     "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",
210     "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",
219     "pathutils.cc",
220     "pathutils.h",
221     "physicalsocketserver.cc",
222     "physicalsocketserver.h",
223     "proxydetect.cc",
224     "proxydetect.h",
225     "proxyinfo.cc",
226     "proxyinfo.h",
227     "ratelimiter.cc",
228     "ratelimiter.h",
229     "ratetracker.cc",
230     "ratetracker.h",
231     "safe_conversions.h",
232     "safe_conversions_impl.h",
233     "scoped_autorelease_pool.h",
234     "scoped_autorelease_pool.mm",
235     "scoped_ptr.h",
236     "sha1.cc",
237     "sha1.h",
238     "sha1digest.h",
239     "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",
258     "sslfingerprint.cc",
259     "sslfingerprint.h",
260     "sslidentity.cc",
261     "sslidentity.h",
262     "sslsocketfactory.cc",
263     "sslsocketfactory.h",
264     "sslstreamadapter.cc",
265     "sslstreamadapter.h",
266     "sslstreamadapterhelper.cc",
267     "sslstreamadapterhelper.h",
268     "stream.cc",
269     "stream.h",
270     "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",
282     "thread.cc",
283     "thread.h",
284     "timeutils.cc",
285     "timeutils.h",
286     "timing.cc",
287     "timing.h",
288     "urlencode.cc",
289     "urlencode.h",
290     "worker.cc",
291     "worker.h",
292   ]
293
294   if (is_posix) {
295     sources += [
296       "unixfilesystem.cc",
297       "unixfilesystem.h",
298     ]
299   }
300
301   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     ]
308
309     if (is_win) {
310       sources += [ "../overrides/webrtc/base/win32socketinit.cc" ]
311     }
312
313     include_dirs = [
314       "../overrides",
315       "../../boringssl/src/include",
316     ]
317
318     direct_dependent_configs += [ ":webrtc_base_chromium_config" ]
319   } else {
320     sources += [
321       "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",
335       "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",
344       "logging.cc",
345       "logging.h",
346       "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",
358       "profiler.cc",
359       "profiler.h",
360       "proxyserver.cc",
361       "proxyserver.h",
362       "refcount.h",
363       "referencecountedsingletonfactory.h",
364       "rollingaccumulator.h",
365       "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",
373       "testclient.cc",
374       "testclient.h",
375       "transformadapter.cc",
376       "transformadapter.h",
377       "versionparsing.cc",
378       "versionparsing.h",
379       "virtualsocketserver.cc",
380       "virtualsocketserver.h",
381       "window.h",
382       "windowpickerfactory.h",
383       "windowpicker.h",
384     ]
385
386     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     }
396
397     if (is_linux) {
398       sources += [
399         "dbus.cc",
400         "dbus.h",
401         "libdbusglibsymboltable.cc",
402         "libdbusglibsymboltable.h",
403         "linuxfdwalk.c",
404         "linuxfdwalk.h",
405       ]
406     }
407
408     if (use_x11) {
409       sources += [
410         "x11windowpicker.cc",
411         "x11windowpicker.h",
412       ]
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
428     if (is_win) {
429       sources += [
430         "diskcache_win32.cc",
431         "diskcache_win32.h",
432         "win32regkey.cc",
433         "win32regkey.h",
434         "win32socketinit.cc",
435         "win32socketinit.h",
436         "win32socketserver.cc",
437         "win32socketserver.h",
438       ]
439     }
440
441     deps += [ "//third_party/jsoncpp" ]
442   }  # !build_with_chromium
443
444   # 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" ]
449   cflags_cc += [ "-Wno-non-virtual-dtor" ]
450
451   if (use_openssl) {
452     direct_dependent_configs += [ ":openssl_config" ]
453
454     deps += [ "//third_party/boringssl" ]
455   } else {
456     direct_dependent_configs += [ ":no_openssl_config" ]
457   }
458
459   if (is_android) {
460     sources += [
461       "ifaddrs-android.cc",
462       "ifaddrs-android.h",
463     ]
464
465     direct_dependent_configs += [ ":android_config" ]
466
467     libs = [
468       "log",
469       "GLESv2"
470     ]
471   } else {
472     direct_dependent_configs += [ ":no_android_config" ]
473   }
474
475   if (is_ios) {
476     all_dependent_configs += [ ":ios_config" ]
477
478     deps += [ "//net/third_party/nss/ssl:libssl" ]
479   }
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" ]
492   }
493
494   if (is_mac) {
495     sources += [
496       "maccocoathreadhelper.h",
497       "maccocoathreadhelper.mm",
498       "macconversion.cc",
499       "macconversion.h",
500       "macutils.cc",
501       "macutils.h",
502     ]
503
504     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     }
513   }
514
515   if (is_win) {
516     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
534     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" ]
547   }
548
549   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" ]
554   }
555
556   if (is_ios || (is_mac && cpu_arch != "x86")) {
557     defines += [ "CARBON_DEPRECATED=YES" ]
558   }
559
560   if (!is_ios && is_posix) {
561     sources += [
562       "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
574   if (is_linux || is_android) {
575     sources += [
576       "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 }