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