Upstream version 11.40.277.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 import("//build/config/crypto.gni")
10 import("//build/config/ui.gni")
11 import("../build/webrtc.gni")
12
13 config("webrtc_base_config") {
14   include_dirs = [
15     "//third_party/jsoncpp/overrides/include",
16     "//third_party/jsoncpp/source/include",
17   ]
18
19   defines = [
20     "FEATURE_ENABLE_SSL",
21     "LOGGING=1",
22     "USE_WEBRTC_DEV_BRANCH",
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
30 config("webrtc_base_chromium_config") {
31   defines = [
32     "NO_MAIN_THREAD_WRAPPING",
33   ]
34 }
35
36 config("openssl_config") {
37   defines = [
38     "SSL_USE_OPENSSL",
39     "HAVE_OPENSSL_SSL_H",
40   ]
41 }
42
43 config("nss_config") {
44   defines = [
45     "SSL_USE_NSS",
46     "HAVE_NSS_SSL_H",
47     "SSL_USE_NSS_RNG",
48   ]
49 }
50
51 config("ios_config") {
52   ldflags = [
53     #"Foundation.framework",  # Already included in //build/config:default_libs.
54     "Security.framework",
55     "SystemConfiguration.framework",
56     #"UIKit.framework",  # Already included in //build/config:default_libs.
57   ]
58 }
59
60 config("mac_config") {
61   ldflags = [
62     "Cocoa.framework",
63     #"Foundation.framework",  # Already included in //build/config:default_libs.
64     #"IOKit.framework",  # Already included in //build/config:default_libs.
65     #"Security.framework",  # Already included in //build/config:default_libs.
66     "SystemConfiguration.framework",
67   ]
68 }
69
70 config("mac_x86_config") {
71   libs = [
72     #"Carbon.framework",  # Already included in //build/config:default_libs.
73   ]
74 }
75
76 if (is_linux && !build_with_chromium) {
77   # Provides the same functionality as the //crypto:platform target, which
78   # WebRTC cannot use as we don't sync src/crypto from Chromium.
79   group("linux_system_ssl") {
80     if (use_openssl) {
81       deps = [ "//third_party/boringssl" ]
82     } else {
83       deps = [ "//net/third_party/nss/ssl:libssl" ]
84
85       public_configs = [
86         "//net/third_party/nss/ssl:ssl_config",
87         "//third_party/nss:system_nss_no_ssl_config",
88       ]
89     }
90   }
91 }
92
93 if (rtc_build_ssl == 0) {
94   config("external_ssl_library") {
95     assert(rtc_ssl_root != "",
96            "You must specify rtc_ssl_root when rtc_build_ssl==0.")
97     include_dirs = [ rtc_ssl_root ]
98   }
99 }
100
101 # The subset of rtc_base approved for use outside of libjingle.
102 static_library("rtc_base_approved") {
103   configs += [ "..:common_config" ]
104   public_configs = [ "..:common_inherited_config" ]
105
106   sources = [
107     "checks.cc",
108     "checks.h",
109     "exp_filter.cc",
110     "exp_filter.h",
111     "md5.cc",
112     "md5.h",
113     "md5digest.h",
114     "platform_file.cc",
115     "platform_file.h",
116     "stringencode.cc",
117     "stringencode.h",
118     "stringutils.cc",
119     "stringutils.h",
120     "thread_annotations.h",
121     "timeutils.cc",
122     "timeutils.h",
123   ]
124 }
125
126 static_library("webrtc_base") {
127   cflags = []
128   cflags_cc = []
129   libs = []
130   deps = [
131     ":rtc_base_approved",
132   ]
133
134   configs += [
135     "..:common_config",
136     ":webrtc_base_config",
137   ]
138
139   public_configs = [
140     "..:common_inherited_config",
141     ":webrtc_base_config",
142   ]
143
144   defines = [
145     "LOGGING=1",
146     "USE_WEBRTC_DEV_BRANCH",
147   ]
148
149   sources = [
150     "asyncfile.cc",
151     "asyncfile.h",
152     "asynchttprequest.cc",
153     "asynchttprequest.h",
154     "asyncpacketsocket.h",
155     "asyncsocket.cc",
156     "asyncsocket.h",
157     "asynctcpsocket.cc",
158     "asynctcpsocket.h",
159     "asyncudpsocket.cc",
160     "asyncudpsocket.h",
161     "autodetectproxy.cc",
162     "autodetectproxy.h",
163     "base64.cc",
164     "base64.h",
165     "basicdefs.h",
166     "bytebuffer.cc",
167     "bytebuffer.h",
168     "byteorder.h",
169     "common.cc",
170     "common.h",
171     "cpumonitor.cc",
172     "cpumonitor.h",
173     "crc32.cc",
174     "crc32.h",
175     "criticalsection.h",
176     "cryptstring.h",
177     "diskcache.cc",
178     "diskcache.h",
179     "event.cc",
180     "event.h",
181     "fileutils.cc",
182     "fileutils.h",
183     "firewallsocketserver.cc",
184     "firewallsocketserver.h",
185     "flags.cc",
186     "flags.h",
187     "gunit_prod.h",
188     "helpers.cc",
189     "helpers.h",
190     "httpbase.cc",
191     "httpbase.h",
192     "httpclient.cc",
193     "httpclient.h",
194     "httpcommon-inl.h",
195     "httpcommon.cc",
196     "httpcommon.h",
197     "httprequest.cc",
198     "httprequest.h",
199     "iosfilesystem.mm",
200     "ipaddress.cc",
201     "ipaddress.h",
202     "linked_ptr.h",
203     "mathutils.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     "nullsocketserver.h",
215     "pathutils.cc",
216     "pathutils.h",
217     "physicalsocketserver.cc",
218     "physicalsocketserver.h",
219     "proxydetect.cc",
220     "proxydetect.h",
221     "proxyinfo.cc",
222     "proxyinfo.h",
223     "ratelimiter.cc",
224     "ratelimiter.h",
225     "ratetracker.cc",
226     "ratetracker.h",
227     "safe_conversions.h",
228     "safe_conversions_impl.h",
229     "scoped_autorelease_pool.h",
230     "scoped_autorelease_pool.mm",
231     "scoped_ptr.h",
232     "sha1.cc",
233     "sha1.h",
234     "sha1digest.h",
235     "signalthread.cc",
236     "signalthread.h",
237     "sigslot.h",
238     "sigslotrepeater.h",
239     "socket.h",
240     "socketadapters.cc",
241     "socketadapters.h",
242     "socketaddress.cc",
243     "socketaddress.h",
244     "socketaddresspair.cc",
245     "socketaddresspair.h",
246     "socketfactory.h",
247     "socketpool.cc",
248     "socketpool.h",
249     "socketserver.h",
250     "socketstream.cc",
251     "socketstream.h",
252     "ssladapter.cc",
253     "ssladapter.h",
254     "sslfingerprint.cc",
255     "sslfingerprint.h",
256     "sslidentity.cc",
257     "sslidentity.h",
258     "sslsocketfactory.cc",
259     "sslsocketfactory.h",
260     "sslstreamadapter.cc",
261     "sslstreamadapter.h",
262     "sslstreamadapterhelper.cc",
263     "sslstreamadapterhelper.h",
264     "stream.cc",
265     "stream.h",
266     "systeminfo.cc",
267     "systeminfo.h",
268     "task.cc",
269     "task.h",
270     "taskparent.cc",
271     "taskparent.h",
272     "taskrunner.cc",
273     "taskrunner.h",
274     "thread.cc",
275     "thread.h",
276     "thread_checker.h",
277     "thread_checker_impl.cc",
278     "thread_checker_impl.h",
279     "timing.cc",
280     "timing.h",
281     "urlencode.cc",
282     "urlencode.h",
283     "worker.cc",
284     "worker.h",
285   ]
286
287   if (is_posix) {
288     sources += [
289       "unixfilesystem.cc",
290       "unixfilesystem.h",
291     ]
292   }
293
294   if (build_with_chromium) {
295     sources += [
296       "../overrides/webrtc/base/basictypes.h",
297       "../overrides/webrtc/base/constructormagic.h",
298       "../overrides/webrtc/base/logging.cc",
299       "../overrides/webrtc/base/logging.h",
300     ]
301
302     if (is_win) {
303       sources += [ "../overrides/webrtc/base/win32socketinit.cc" ]
304     }
305
306     include_dirs = [
307       "../overrides",
308       "../../boringssl/src/include",
309     ]
310
311     public_configs += [ ":webrtc_base_chromium_config" ]
312   } else {
313     sources += [
314       "asyncinvoker.cc",
315       "asyncinvoker.h",
316       "asyncinvoker-inl.h",
317       "asyncresolverinterface.h",
318       "atomicops.h",
319       "bandwidthsmoother.cc",
320       "bandwidthsmoother.h",
321       "basictypes.h",
322       "bind.h",
323       "bind.h.pump",
324       "buffer.h",
325       "callback.h",
326       "callback.h.pump",
327       "constructormagic.h",
328       "filelock.cc",
329       "filelock.h",
330       "fileutils_mock.h",
331       "genericslot.h",
332       "genericslot.h.pump",
333       "httpserver.cc",
334       "httpserver.h",
335       "json.cc",
336       "json.h",
337       "logging.cc",
338       "logging.h",
339       "mathutils.h",
340       "multipart.cc",
341       "multipart.h",
342       "natserver.cc",
343       "natserver.h",
344       "natsocketfactory.cc",
345       "natsocketfactory.h",
346       "nattypes.cc",
347       "nattypes.h",
348       "optionsfile.cc",
349       "optionsfile.h",
350       "profiler.cc",
351       "profiler.h",
352       "proxyserver.cc",
353       "proxyserver.h",
354       "refcount.h",
355       "referencecountedsingletonfactory.h",
356       "rollingaccumulator.h",
357       "scopedptrcollection.h",
358       "scoped_ref_ptr.h",
359       "sec_buffer.h",
360       "sharedexclusivelock.cc",
361       "sharedexclusivelock.h",
362       "sslconfig.h",
363       "sslroots.h",
364       "stringdigest.h",
365       "testclient.cc",
366       "testclient.h",
367       "transformadapter.cc",
368       "transformadapter.h",
369       "versionparsing.cc",
370       "versionparsing.h",
371       "virtualsocketserver.cc",
372       "virtualsocketserver.h",
373       "window.h",
374       "windowpickerfactory.h",
375       "windowpicker.h",
376     ]
377
378     if (is_posix) {
379       sources += [
380         "latebindingsymboltable.cc",
381         "latebindingsymboltable.cc.def",
382         "latebindingsymboltable.h",
383         "latebindingsymboltable.h.def",
384         "posix.cc",
385         "posix.h",
386       ]
387     }
388
389     if (is_linux) {
390       sources += [
391         "dbus.cc",
392         "dbus.h",
393         "libdbusglibsymboltable.cc",
394         "libdbusglibsymboltable.h",
395         "linuxfdwalk.c",
396         "linuxfdwalk.h",
397       ]
398     }
399
400     if (is_mac) {
401       sources += [
402         "macasyncsocket.cc",
403         "macasyncsocket.h",
404         "maccocoasocketserver.h",
405         "maccocoasocketserver.mm",
406         "macsocketserver.cc",
407         "macsocketserver.h",
408         "macwindowpicker.cc",
409         "macwindowpicker.h",
410       ]
411     }
412
413     if (is_win) {
414       sources += [
415         "diskcache_win32.cc",
416         "diskcache_win32.h",
417         "win32regkey.cc",
418         "win32regkey.h",
419         "win32socketinit.cc",
420         "win32socketinit.h",
421         "win32socketserver.cc",
422         "win32socketserver.h",
423       ]
424     }
425     if (rtc_build_json) {
426       deps += [ "//third_party/jsoncpp" ]
427     } else {
428       include_dirs += [ rtc_jsoncpp_root ]
429
430       # When defined changes the include path for json.h to where it is
431       # expected to be when building json outside of the standalone build.
432       defines += [ "WEBRTC_EXTERNAL_JSON" ]
433     }
434   }  # !build_with_chromium
435
436   if (is_clang) {
437     # Suppress warnings from the Chrome Clang plugins.
438     # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
439     configs -= [ "//build/config/clang:find_bad_constructs" ]
440   }
441
442   # TODO(henrike): issue 3307, make webrtc_base build with the Chromium default
443   # compiler settings.
444   configs -= [ "//build/config/compiler:chromium_code" ]
445   configs += [ "//build/config/compiler:no_chromium_code" ]
446   cflags += [ "-Wno-uninitialized" ]
447   cflags_cc += [ "-Wno-non-virtual-dtor" ]
448
449   if (use_openssl) {
450     public_configs += [ ":openssl_config" ]
451     if (rtc_build_ssl) {
452       deps += [ "//third_party/boringssl" ]
453     } else {
454       configs += [ "external_ssl_library" ]
455     }
456     sources += [
457       "openssl.h",
458       "openssladapter.cc",
459       "openssladapter.h",
460       "openssldigest.cc",
461       "openssldigest.h",
462       "opensslidentity.cc",
463       "opensslidentity.h",
464       "opensslstreamadapter.cc",
465       "opensslstreamadapter.h",
466     ]
467   } else {
468     public_configs += [ ":nss_config" ]
469     if (rtc_build_ssl) {
470       if (build_with_chromium) {
471         deps += [ "//crypto:platform" ]
472       } else {
473         deps += [ "//net/third_party/nss/ssl:libssl" ]
474         if (is_linux) {
475           deps += [ ":linux_system_ssl" ]
476         } else {
477           deps += [
478             "//third_party/nss:nspr",
479             "//third_party/nss:nss",
480           ]
481         }
482       }
483     } else {
484       configs += [ "external_ssl_library" ]
485     }
486     sources += [
487       "nssidentity.cc",
488       "nssidentity.h",
489       "nssstreamadapter.cc",
490       "nssstreamadapter.h",
491     ]
492   }
493
494   if (is_android) {
495     sources += [
496       "ifaddrs-android.cc",
497       "ifaddrs-android.h",
498     ]
499
500     libs += [
501       "log",
502       "GLESv2"
503     ]
504   }
505
506   if (is_ios) {
507     all_dependent_configs += [ ":ios_config" ]
508   }
509
510   if (use_x11) {
511     sources += [
512       "x11windowpicker.cc",
513       "x11windowpicker.h",
514     ]
515     libs += [
516       "dl",
517       "rt",
518       "Xext",
519       "X11",
520       "Xcomposite",
521       "Xrender",
522     ]
523   }
524
525   if (is_linux) {
526     libs += [
527       "dl",
528       "rt",
529     ]
530   }
531
532   if (is_mac) {
533     sources += [
534       "maccocoathreadhelper.h",
535       "maccocoathreadhelper.mm",
536       "macconversion.cc",
537       "macconversion.h",
538       "macutils.cc",
539       "macutils.h",
540     ]
541
542     all_dependent_configs = [ ":mac_config" ]
543
544     if (cpu_arch == "x86") {
545       all_dependent_configs += [ ":mac_x86_config" ]
546     }
547   }
548
549   if (is_win) {
550     sources += [
551       "schanneladapter.cc",
552       "schanneladapter.h",
553       "win32.cc",
554       "win32.h",
555       "win32filesystem.cc",
556       "win32filesystem.h",
557       "win32securityerrors.cc",
558       "win32window.cc",
559       "win32window.h",
560       "win32windowpicker.cc",
561       "win32windowpicker.h",
562       "winfirewall.cc",
563       "winfirewall.h",
564       "winping.cc",
565       "winping.h",
566     ]
567
568     libs += [
569       "crypt32.lib",
570       "iphlpapi.lib",
571       "secur32.lib",
572     ]
573
574     cflags += [
575       # Suppress warnings about WIN32_LEAN_AND_MEAN.
576       "/wd4005",
577       "/wd4703",
578     ]
579
580     defines += [ "_CRT_NONSTDC_NO_DEPRECATE" ]
581   }
582
583   if (is_posix && is_debug) {
584     # The Chromium build/common.gypi defines this for all posix
585     # _except_ for ios & mac.  We want it there as well, e.g.
586     # because ASSERT and friends trigger off of it.
587     defines += [ "_DEBUG" ]
588   }
589
590   if (is_ios || (is_mac && cpu_arch != "x86")) {
591     defines += [ "CARBON_DEPRECATED=YES" ]
592   }
593
594   if (is_linux || is_android) {
595     sources += [
596       "linux.cc",
597       "linux.h",
598     ]
599   }
600 }