Home | History | Annotate | Download | only in base
      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/webrtc.gni")
     11 
     12 config("webrtc_base_config") {
     13   include_dirs = [
     14     "//third_party/jsoncpp/overrides/include",
     15     "//third_party/jsoncpp/source/include",
     16   ]
     17 
     18   defines = [
     19     "FEATURE_ENABLE_SSL",
     20     "GTEST_RELATIVE_PATH",
     21   ]
     22 
     23   # TODO(henrike): issue 3307, make webrtc_base build without disabling
     24   # these flags.
     25   cflags_cc = [ "-Wno-non-virtual-dtor" ]
     26 }
     27 
     28 config("webrtc_base_chromium_config") {
     29   defines = [
     30     "NO_MAIN_THREAD_WRAPPING",
     31     "SSL_USE_NSS",
     32   ]
     33 }
     34 
     35 config("openssl_config") {
     36   defines = [
     37     "SSL_USE_OPENSSL",
     38     "HAVE_OPENSSL_SSL_H",
     39   ]
     40 }
     41 
     42 config("no_openssl_config") {
     43   defines = [
     44     "SSL_USE_NSS",
     45     "HAVE_NSS_SSL_H",
     46     "SSL_USE_NSS_RNG",
     47   ]
     48 }
     49 
     50 config("android_config") {
     51   defines = [ "HAVE_OPENSSL_SSL_H" ]
     52 }
     53 
     54 config("no_android_config") {
     55   defines = [
     56     "HAVE_NSS_SSL_H",
     57     "SSL_USE_NSS_RNG",
     58   ]
     59 }
     60 
     61 config("ios_config") {
     62   ldflags = [
     63     #"Foundation.framework",  # Already included in //build/config:default_libs.
     64     "Security.framework",
     65     "SystemConfiguration.framework",
     66     #"UIKit.framework",  # Already included in //build/config:default_libs.
     67   ]
     68 }
     69 
     70 config("mac_config") {
     71   ldflags = [
     72     "Cocoa.framework",
     73     #"Foundation.framework",  # Already included in //build/config:default_libs.
     74     #"IOKit.framework",  # Already included in //build/config:default_libs.
     75     #"Security.framework",  # Already included in //build/config:default_libs.
     76     "SystemConfiguration.framework",
     77   ]
     78 }
     79 
     80 config("mac_x86_config") {
     81   libs = [
     82     #"Carbon.framework",  # Already included in //build/config:default_libs.
     83   ]
     84 }
     85 
     86 config("linux_system_ssl_config") {
     87   visibility = ":*"  # Only targets in this file can depend on this.
     88 
     89   # TODO(kjellander): Find out how to convert GYP include_dirs+ (i.e. insert
     90   # first in the include path?).
     91   include_dirs = [ "//net/third_party/nss/ssl" ]
     92 
     93   configs = [ "//third_party/nss:system_nss_no_ssl_config" ]
     94 }
     95 
     96 # Provides the same functionality as the build/linux/system.gyp:ssl GYP target.
     97 # This cannot be in build/linux/BUILD.gn since targets in build/ are not allowed
     98 # to depend on targets outside of it. This could be replaced by the Chromium
     99 # //crypto:platform target, but as WebRTC currently don't sync src/crypto from
    100 # Chromium, it is not possible today.
    101 config("linux_system_ssl") {
    102   if (use_openssl) {
    103     deps = [ "//third_party/openssl" ]
    104   } else {
    105     deps = [ "//net/third_party/nss/ssl:libssl" ]
    106 
    107     direct_dependent_configs = [
    108       ":linux_system_ssl_config",
    109     ]
    110 
    111     if (is_clang) {
    112       cflags = [
    113         # There is a broken header guard in /usr/include/nss/secmod.h:
    114         # https://bugzilla.mozilla.org/show_bug.cgi?id=884072
    115         "-Wno-header-guard",
    116       ]
    117     }
    118   }
    119 }
    120 
    121 static_library("webrtc_base") {
    122   cflags = []
    123   cflags_cc = []
    124 
    125   configs -= [ "//build/config/compiler:chromium_code" ]
    126   configs += [ "//build/config/compiler:no_chromium_code" ]
    127   configs += [
    128     "..:common_inherited_config",
    129     "..: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",
    148     "asyncinvoker.cc",
    149     "asyncinvoker.h",
    150     "asyncinvoker-inl.h",
    151     "asyncpacketsocket.h",
    152     "asyncresolverinterface.h",
    153     "asyncsocket.cc",
    154     "asyncsocket.h",
    155     "asynctcpsocket.cc",
    156     "asynctcpsocket.h",
    157     "asyncudpsocket.cc",
    158     "asyncudpsocket.h",
    159     "atomicops.h",
    160     "autodetectproxy.cc",
    161     "autodetectproxy.h",
    162     "bandwidthsmoother.cc",
    163     "bandwidthsmoother.h",
    164     "base64.cc",
    165     "base64.h",
    166     "basicdefs.h",
    167     "basictypes.h",
    168     "bind.h",
    169     "bind.h.pump",
    170     "buffer.h",
    171     "bytebuffer.cc",
    172     "bytebuffer.h",
    173     "byteorder.h",
    174     "callback.h",
    175     "callback.h.pump",
    176     "checks.cc",
    177     "checks.h",
    178     "common.cc",
    179     "common.h",
    180     "constructormagic.h",
    181     "cpumonitor.cc",
    182     "cpumonitor.h",
    183     "crc32.cc",
    184     "crc32.h",
    185     "criticalsection.h",
    186     "cryptstring.h",
    187     "dbus.cc",
    188     "dbus.h",
    189     "diskcache.cc",
    190     "diskcache.h",
    191     "event.cc",
    192     "event.h",
    193     "filelock.cc",
    194     "filelock.h",
    195     "fileutils.cc",
    196     "fileutils.h",
    197     "fileutils_mock.h",
    198     "firewallsocketserver.cc",
    199     "firewallsocketserver.h",
    200     "flags.cc",
    201     "flags.h",
    202     "genericslot.h",
    203     "genericslot.h.pump",
    204     "gunit_prod.h",
    205     "helpers.cc",
    206     "helpers.h",
    207     "httpbase.cc",
    208     "httpbase.h",
    209     "httpclient.cc",
    210     "httpclient.h",
    211     "httpcommon-inl.h",
    212     "httpcommon.cc",
    213     "httpcommon.h",
    214     "httprequest.cc",
    215     "httprequest.h",
    216     "httpserver.cc",
    217     "httpserver.h",
    218     "ifaddrs-android.cc",
    219     "ifaddrs-android.h",
    220     "iosfilesystem.mm",
    221     "ipaddress.cc",
    222     "ipaddress.h",
    223     "json.cc",
    224     "json.h",
    225     "latebindingsymboltable.cc",
    226     "latebindingsymboltable.cc.def",
    227     "latebindingsymboltable.h",
    228     "latebindingsymboltable.h.def",
    229     "libdbusglibsymboltable.cc",
    230     "libdbusglibsymboltable.h",
    231     "linux.cc",
    232     "linux.h",
    233     "linuxfdwalk.c",
    234     "linuxfdwalk.h",
    235     "linuxwindowpicker.cc",
    236     "linuxwindowpicker.h",
    237     "linked_ptr.h",
    238     "logging.cc",
    239     "logging.h",
    240     "macasyncsocket.cc",
    241     "macasyncsocket.h",
    242     "maccocoasocketserver.h",
    243     "maccocoasocketserver.mm",
    244     "maccocoathreadhelper.h",
    245     "maccocoathreadhelper.mm",
    246     "macconversion.cc",
    247     "macconversion.h",
    248     "macsocketserver.cc",
    249     "macsocketserver.h",
    250     "macutils.cc",
    251     "macutils.h",
    252     "macwindowpicker.cc",
    253     "macwindowpicker.h",
    254     "mathutils.h",
    255     "md5.cc",
    256     "md5.h",
    257     "md5digest.h",
    258     "messagedigest.cc",
    259     "messagedigest.h",
    260     "messagehandler.cc",
    261     "messagehandler.h",
    262     "messagequeue.cc",
    263     "messagequeue.h",
    264     "multipart.cc",
    265     "multipart.h",
    266     "natserver.cc",
    267     "natserver.h",
    268     "natsocketfactory.cc",
    269     "natsocketfactory.h",
    270     "nattypes.cc",
    271     "nattypes.h",
    272     "nethelpers.cc",
    273     "nethelpers.h",
    274     "network.cc",
    275     "network.h",
    276     "nssidentity.cc",
    277     "nssidentity.h",
    278     "nssstreamadapter.cc",
    279     "nssstreamadapter.h",
    280     "nullsocketserver.h",
    281     "openssl.h",
    282     "openssladapter.cc",
    283     "openssladapter.h",
    284     "openssldigest.cc",
    285     "openssldigest.h",
    286     "opensslidentity.cc",
    287     "opensslidentity.h",
    288     "opensslstreamadapter.cc",
    289     "opensslstreamadapter.h",
    290     "optionsfile.cc",
    291     "optionsfile.h",
    292     "pathutils.cc",
    293     "pathutils.h",
    294     "physicalsocketserver.cc",
    295     "physicalsocketserver.h",
    296     "posix.cc",
    297     "posix.h",
    298     "profiler.cc",
    299     "profiler.h",
    300     "proxydetect.cc",
    301     "proxydetect.h",
    302     "proxyinfo.cc",
    303     "proxyinfo.h",
    304     "proxyserver.cc",
    305     "proxyserver.h",
    306     "ratelimiter.cc",
    307     "ratelimiter.h",
    308     "ratetracker.cc",
    309     "ratetracker.h",
    310     "refcount.h",
    311     "referencecountedsingletonfactory.h",
    312     "rollingaccumulator.h",
    313     "schanneladapter.cc",
    314     "schanneladapter.h",
    315     "scoped_autorelease_pool.h",
    316     "scoped_autorelease_pool.mm",
    317     "scoped_ptr.h",
    318     "scoped_ref_ptr.h",
    319     "scopedptrcollection.h",
    320     "sec_buffer.h",
    321     "sha1.cc",
    322     "sha1.h",
    323     "sha1digest.h",
    324     "sharedexclusivelock.cc",
    325     "sharedexclusivelock.h",
    326     "signalthread.cc",
    327     "signalthread.h",
    328     "sigslot.h",
    329     "sigslotrepeater.h",
    330     "socket.h",
    331     "socketadapters.cc",
    332     "socketadapters.h",
    333     "socketaddress.cc",
    334     "socketaddress.h",
    335     "socketaddresspair.cc",
    336     "socketaddresspair.h",
    337     "socketfactory.h",
    338     "socketpool.cc",
    339     "socketpool.h",
    340     "socketserver.h",
    341     "socketstream.cc",
    342     "socketstream.h",
    343     "ssladapter.cc",
    344     "ssladapter.h",
    345     "sslconfig.h",
    346     "sslfingerprint.cc",
    347     "sslfingerprint.h",
    348     "sslidentity.cc",
    349     "sslidentity.h",
    350     "sslroots.h",
    351     "sslsocketfactory.cc",
    352     "sslsocketfactory.h",
    353     "sslstreamadapter.cc",
    354     "sslstreamadapter.h",
    355     "sslstreamadapterhelper.cc",
    356     "sslstreamadapterhelper.h",
    357     "stream.cc",
    358     "stream.h",
    359     "stringdigest.h",
    360     "stringencode.cc",
    361     "stringencode.h",
    362     "stringutils.cc",
    363     "stringutils.h",
    364     "systeminfo.cc",
    365     "systeminfo.h",
    366     "task.cc",
    367     "task.h",
    368     "taskparent.cc",
    369     "taskparent.h",
    370     "taskrunner.cc",
    371     "taskrunner.h",
    372     "testclient.cc",
    373     "testclient.h",
    374     "thread.cc",
    375     "thread.h",
    376     "timeutils.cc",
    377     "timeutils.h",
    378     "timing.cc",
    379     "timing.h",
    380     "transformadapter.cc",
    381     "transformadapter.h",
    382     "unixfilesystem.cc",
    383     "unixfilesystem.h",
    384     "urlencode.cc",
    385     "urlencode.h",
    386     "versionparsing.cc",
    387     "versionparsing.h",
    388     "virtualsocketserver.cc",
    389     "virtualsocketserver.h",
    390     "win32.cc",
    391     "win32.h",
    392     "win32filesystem.cc",
    393     "win32filesystem.h",
    394     "win32regkey.cc",
    395     "win32regkey.h",
    396     "win32securityerrors.cc",
    397     "win32socketinit.cc",
    398     "win32socketinit.h",
    399     "win32socketserver.cc",
    400     "win32socketserver.h",
    401     "win32window.cc",
    402     "win32window.h",
    403     "win32windowpicker.cc",
    404     "win32windowpicker.h",
    405     "window.h",
    406     "windowpicker.h",
    407     "windowpickerfactory.h",
    408     "winfirewall.cc",
    409     "winfirewall.h",
    410     "winping.cc",
    411     "winping.h",
    412     "worker.cc",
    413     "worker.h",
    414   ]
    415 
    416   if (build_with_chromium) {
    417     sources += [
    418       "../overrides/webrtc/base/basictypes.h",
    419       "../overrides/webrtc/base/constructormagic.h",
    420       "../overrides/webrtc/base/logging.cc",
    421       "../overrides/webrtc/base/logging.h",
    422     ]
    423     if (is_win) {
    424       sources += [ "../overrides/webrtc/base/win32socketinit.cc" ]
    425     }
    426     sources -= [
    427       "asyncinvoker.cc",
    428       "asyncinvoker.h",
    429       "asyncinvoker-inl.h",
    430       "asyncresolverinterface.h",
    431       "atomicops.h",
    432       "bandwidthsmoother.cc",
    433       "bandwidthsmoother.h",
    434       "basictypes.h",
    435       "bind.h",
    436       "bind.h.pump",
    437       "buffer.h",
    438       "callback.h",
    439       "callback.h.pump",
    440       "constructormagic.h",
    441       "dbus.cc",
    442       "dbus.h",
    443       "filelock.cc",
    444       "filelock.h",
    445       "fileutils_mock.h",
    446       "genericslot.h",
    447       "genericslot.h.pump",
    448       "httpserver.cc",
    449       "httpserver.h",
    450       "json.cc",
    451       "json.h",
    452       "latebindingsymboltable.cc",
    453       "latebindingsymboltable.cc.def",
    454       "latebindingsymboltable.h",
    455       "latebindingsymboltable.h.def",
    456       "libdbusglibsymboltable.cc",
    457       "libdbusglibsymboltable.h",
    458       "linuxfdwalk.c",
    459       "linuxfdwalk.h",
    460       "linuxwindowpicker.cc",
    461       "linuxwindowpicker.h",
    462       "logging.cc",
    463       "logging.h",
    464       #"macasyncsocket.cc",
    465       #"macasyncsocket.h",
    466       #"maccocoasocketserver.h",
    467       #"maccocoasocketserver.mm",
    468       #"macsocketserver.cc",
    469       #"macsocketserver.h",
    470       #"macwindowpicker.cc",
    471       #"macwindowpicker.h",
    472       "mathutils.h",
    473       "multipart.cc",
    474       "multipart.h",
    475       "natserver.cc",
    476       "natserver.h",
    477       "natsocketfactory.cc",
    478       "natsocketfactory.h",
    479       "nattypes.cc",
    480       "nattypes.h",
    481       "openssl.h",
    482       "optionsfile.cc",
    483       "optionsfile.h",
    484       "posix.cc",
    485       "posix.h",
    486       "profiler.cc",
    487       "profiler.h",
    488       "proxyserver.cc",
    489       "proxyserver.h",
    490       "refcount.h",
    491       "referencecountedsingletonfactory.h",
    492       "rollingaccumulator.h",
    493       #"safe_conversions.h",
    494       #"safe_conversions_impl.h",
    495       "scopedptrcollection.h",
    496       "scoped_ref_ptr.h",
    497       "sec_buffer.h",
    498       "sharedexclusivelock.cc",
    499       "sharedexclusivelock.h",
    500       "sslconfig.h",
    501       "sslroots.h",
    502       "stringdigest.h",
    503       #"testbase64.h",
    504       "testclient.cc",
    505       "testclient.h",
    506       #"testutils.h",
    507       "transformadapter.cc",
    508       "transformadapter.h",
    509       "versionparsing.cc",
    510       "versionparsing.h",
    511       "virtualsocketserver.cc",
    512       "virtualsocketserver.h",
    513       #"win32regkey.cc",
    514       #"win32regkey.h",
    515       #"win32socketinit.cc",
    516       #"win32socketinit.h",
    517       #"win32socketserver.cc",
    518       #"win32socketserver.h",
    519       #"win32toolhelp.h",
    520       "window.h",
    521       "windowpickerfactory.h",
    522       "windowpicker.h",
    523     ]
    524 
    525     include_dirs = [
    526       "../overrides",
    527       "../../openssl/openssl/include",
    528     ]
    529 
    530     direct_dependent_configs += [ ":webrtc_base_chromium_config" ]
    531   } else {
    532     if (is_win) {
    533       sources += [
    534         "diskcache_win32.cc",
    535         "diskcache_win32.h",
    536       ]
    537     }
    538 
    539     deps = [ "//third_party/jsoncpp" ]
    540   }
    541 
    542   # TODO(henrike): issue 3307, make webrtc_base build without disabling
    543   # these flags.
    544   cflags += [
    545     "-Wno-extra",
    546     "-Wno-all",
    547   ]
    548   cflags_cc += [ "-Wno-non-virtual-dtor" ]
    549 
    550   if (use_openssl) {
    551     direct_dependent_configs += [ ":openssl_config" ]
    552 
    553     deps = [ "//third_party/openssl" ]
    554   } else {
    555     direct_dependent_configs += [ ":no_openssl_config" ]
    556   }
    557 
    558   if (is_android) {
    559     direct_dependent_configs += [ ":android_config" ]
    560 
    561     libs = [
    562       "log",
    563       "GLESv2"
    564     ]
    565   } else {
    566     direct_dependent_configs += [ ":no_android_config" ]
    567 
    568     sources -= [
    569       "ifaddrs-android.cc",
    570       "ifaddrs-android.h",
    571     ]
    572   }
    573 
    574   if (is_ios) {
    575     all_dependent_configs += [ ":ios_config" ]
    576 
    577     deps = [ "//net/third_party/nss/ssl:libssl" ]
    578   }
    579 
    580   if (is_linux) {
    581     libs = [
    582       "crypto",
    583       "dl",
    584       "rt",
    585       "Xext",
    586       "X11",
    587       "Xcomposite",
    588       "Xrender",
    589     ]
    590     configs += [ "//third_party/nss:system_nss_no_ssl_config" ]
    591   } else {
    592     sources -= [
    593       "dbus.cc",
    594       "dbus.h",
    595       "libdbusglibsymboltable.cc",
    596       "libdbusglibsymboltable.h",
    597       "linuxfdwalk.c",
    598       "linuxfdwalk.h",
    599       "linuxwindowpicker.cc",
    600       "linuxwindowpicker.h",
    601     ]
    602   }
    603 
    604   if (is_mac) {
    605     all_dependent_configs = [ ":mac_config" ]
    606 
    607     libs = [
    608       "crypto",  # $(SDKROOT)/usr/lib/libcrypto.dylib
    609       "ssl",  # $(SDKROOT)/usr/lib/libssl.dylib
    610     ]
    611     if (cpu_arch == "x86") {
    612       all_dependent_configs += [ ":mac_x86_config" ]
    613     }
    614   } else {
    615     sources -= [
    616       "macasyncsocket.cc",
    617       "macasyncsocket.h",
    618       "maccocoasocketserver.h",
    619       #"maccocoasocketserver.mm",  # Seems to be excluded by default with GN.
    620       "macconversion.cc",
    621       "macconversion.h",
    622       "macsocketserver.cc",
    623       "macsocketserver.h",
    624       "macutils.cc",
    625       "macutils.h",
    626       "macwindowpicker.cc",
    627       "macwindowpicker.h",
    628     ]
    629   }
    630 
    631   if (is_win) {
    632     libs = [
    633       "crypt32.lib",
    634       "iphlpapi.lib",
    635       "secur32.lib",
    636     ]
    637 
    638     cflags += [
    639       # Suppress warnings about WIN32_LEAN_AND_MEAN.
    640       "/wd4005",
    641       "/wd4703",
    642     ]
    643 
    644     defines += [ "_CRT_NONSTDC_NO_DEPRECATE" ]
    645   } else {
    646     sources -= [
    647       "schanneladapter.cc",
    648       "schanneladapter.h",
    649       "winping.cc",
    650       "winping.h",
    651       "winfirewall.cc",
    652       "winfirewall.h",
    653       # The files below were covered by a regex exclude in GYP.
    654       "win32.cc",
    655       "win32.h",
    656       "win32filesystem.cc",
    657       "win32filesystem.h",
    658       "win32regkey.cc",
    659       "win32regkey.h",
    660       "win32securityerrors.cc",
    661       "win32socketinit.cc",
    662       "win32socketinit.h",
    663       "win32socketserver.cc",
    664       "win32socketserver.h",
    665       "win32window.cc",
    666       "win32window.h",
    667       "win32windowpicker.cc",
    668       "win32windowpicker.h",
    669     ]
    670   }
    671 
    672   if (is_posix) {
    673     if (is_debug) {
    674       defines += [ "_DEBUG" ]
    675     }
    676   } else {
    677     sources -= [
    678       "latebindingsymboltable.cc",
    679       "latebindingsymboltable.h",
    680       "posix.cc",
    681       "posix.h",
    682       "unixfilesystem.cc",
    683       "unixfilesystem.h",
    684     ]
    685   }
    686 
    687   if (is_ios || (is_mac && cpu_arch != "x86")) {
    688     defines += [ "CARBON_DEPRECATED=YES" ]
    689   }
    690 
    691   if (is_ios || !is_posix) {
    692     sources -= [
    693       "openssl.h",
    694       "openssladapter.cc",
    695       "openssladapter.h",
    696       "openssldigest.cc",
    697       "openssldigest.h",
    698       "opensslidentity.cc",
    699       "opensslidentity.h",
    700       "opensslstreamadapter.cc",
    701       "opensslstreamadapter.h",
    702     ]
    703   }
    704 
    705   if (!is_linux && !is_android) {
    706     sources -= [
    707       "linux.cc",
    708       "linux.h",
    709     ]
    710   }
    711 
    712   if (is_mac || is_ios || is_win) {
    713     deps += [
    714       "//net/third_party/nss/ssl:libssl",
    715       "//third_party/nss:nspr",
    716       "//third_party/nss:nss",
    717     ]
    718   }
    719 
    720   if (is_posix && !is_mac && !is_ios && !is_android) {
    721     configs += [ ":linux_system_ssl" ]
    722   }
    723 }
    724