Home | History | Annotate | Download | only in libsrtp
      1 # Copyright 2014 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 declare_args() {
      6   use_system_libsrtp = false
      7 }
      8 
      9 config("libsrtp_config") {
     10   defines = [
     11     "HAVE_STDLIB_H",
     12     "HAVE_STRING_H",
     13   ]
     14 
     15   include_dirs = [
     16     "config",
     17     "srtp/include",
     18     "srtp/crypto/include",
     19   ]
     20 
     21   if (is_posix) {
     22     defines += [
     23       "HAVE_INT16_T",
     24       "HAVE_INT32_T",
     25       "HAVE_INT8_T",
     26       "HAVE_UINT16_T",
     27       "HAVE_UINT32_T",
     28       "HAVE_UINT64_T",
     29       "HAVE_UINT8_T",
     30       "HAVE_STDINT_H",
     31       "HAVE_INTTYPES_H",
     32       "HAVE_NETINET_IN_H",
     33       "INLINE=inline",
     34     ]
     35   }
     36 
     37   if (is_win) {
     38     defines += [
     39       "INLINE=__inline",
     40       "HAVE_BYTESWAP_METHODS_H",
     41       # All Windows architectures are this way.
     42       "SIZEOF_UNSIGNED_LONG=4",
     43       "SIZEOF_UNSIGNED_LONG_LONG=8",
     44     ]
     45   }
     46 
     47   if (cpu_arch == "x64" || cpu_arch == "x86" || cpu_arch == "arm") {
     48     defines += [
     49       # TODO(leozwang): CPU_RISC doesn"t work properly on android/arm
     50       # platform for unknown reasons, need to investigate the root cause
     51       # of it. CPU_RISC is used for optimization only, and CPU_CISC should
     52       # just work just fine, it has been tested on android/arm with srtp
     53       # test applications and libjingle.
     54       "CPU_CISC",
     55     ]
     56   }
     57 
     58   if (cpu_arch == "mipsel") {
     59     defines += [ "CPU_RISC" ]
     60   }
     61 }
     62 
     63 config("system_libsrtp_config") {
     64   defines = [ "USE_SYSTEM_LIBSRTP" ]
     65   include_dirs = [ "/usr/include/srtp" ]
     66 }
     67 
     68 if (use_system_libsrtp) {
     69   group("libsrtp") {
     70     public_configs = [ ":libsrtp_config", ":system_libsrtp_config" ]
     71     libs = [ "-lsrtp" ]
     72   }
     73 } else {
     74   static_library("libsrtp") {
     75     configs -= [ "//build/config/compiler:chromium_code" ]
     76     configs += [ "//build/config/compiler:no_chromium_code" ]
     77     public_configs = [ ":libsrtp_config" ]
     78 
     79     sources = [
     80       # includes
     81       "srtp/include/ekt.h",
     82       "srtp/include/getopt_s.h",
     83       "srtp/include/rtp.h",
     84       "srtp/include/rtp_priv.h",
     85       "srtp/include/srtp.h",
     86       "srtp/include/srtp_priv.h",
     87       "srtp/include/ut_sim.h",
     88 
     89       # headers
     90       "srtp/crypto/include/aes_cbc.h",
     91       "srtp/crypto/include/aes.h",
     92       "srtp/crypto/include/aes_icm.h",
     93       "srtp/crypto/include/alloc.h",
     94       "srtp/crypto/include/auth.h",
     95       "srtp/crypto/include/cipher.h",
     96       "srtp/crypto/include/cryptoalg.h",
     97       "srtp/crypto/include/crypto.h",
     98       "srtp/crypto/include/crypto_kernel.h",
     99       "srtp/crypto/include/crypto_math.h",
    100       "srtp/crypto/include/crypto_types.h",
    101       "srtp/crypto/include/datatypes.h",
    102       "srtp/crypto/include/err.h",
    103       "srtp/crypto/include/gf2_8.h",
    104       "srtp/crypto/include/hmac.h",
    105       "srtp/crypto/include/integers.h",
    106       "srtp/crypto/include/kernel_compat.h",
    107       "srtp/crypto/include/key.h",
    108       "srtp/crypto/include/null_auth.h",
    109       "srtp/crypto/include/null_cipher.h",
    110       "srtp/crypto/include/prng.h",
    111       "srtp/crypto/include/rand_source.h",
    112       "srtp/crypto/include/rdb.h",
    113       "srtp/crypto/include/rdbx.h",
    114       "srtp/crypto/include/sha1.h",
    115       "srtp/crypto/include/stat.h",
    116       "srtp/crypto/include/xfm.h",
    117 
    118       # sources
    119       "srtp/srtp/ekt.c",
    120       "srtp/srtp/srtp.c",
    121 
    122       "srtp/crypto/cipher/aes.c",
    123       "srtp/crypto/cipher/aes_cbc.c",
    124       "srtp/crypto/cipher/aes_icm.c",
    125       "srtp/crypto/cipher/cipher.c",
    126       "srtp/crypto/cipher/null_cipher.c",
    127       "srtp/crypto/hash/auth.c",
    128       "srtp/crypto/hash/hmac.c",
    129       "srtp/crypto/hash/null_auth.c",
    130       "srtp/crypto/hash/sha1.c",
    131       "srtp/crypto/kernel/alloc.c",
    132       "srtp/crypto/kernel/crypto_kernel.c",
    133       "srtp/crypto/kernel/err.c",
    134       "srtp/crypto/kernel/key.c",
    135       "srtp/crypto/math/datatypes.c",
    136       "srtp/crypto/math/gf2_8.c",
    137       "srtp/crypto/math/stat.c",
    138       "srtp/crypto/replay/rdb.c",
    139       "srtp/crypto/replay/rdbx.c",
    140       "srtp/crypto/replay/ut_sim.c",
    141       "srtp/crypto/rng/ctr_prng.c",
    142       "srtp/crypto/rng/prng.c",
    143       "srtp/crypto/rng/rand_source.c",
    144     ]
    145 
    146     if (is_clang) {
    147       cflags = [ "-Wno-implicit-function-declaration" ]
    148     }
    149   }
    150 
    151   # TODO(GYP): A bunch of these tests don't compile (in gyp either). They're
    152   # not very broken, so could probably be made to work if it's useful.
    153   if (!is_win) {
    154     executable("rdbx_driver") {
    155       configs -= [ "//build/config/compiler:chromium_code" ]
    156       configs += [ "//build/config/compiler:no_chromium_code" ]
    157       deps = [ ":libsrtp" ]
    158       sources = [
    159         "srtp/include/getopt_s.h",
    160         "srtp/test/getopt_s.c",
    161         "srtp/test/rdbx_driver.c",
    162       ]
    163     }
    164 
    165     executable("srtp_driver") {
    166       configs -= [ "//build/config/compiler:chromium_code" ]
    167       configs += [ "//build/config/compiler:no_chromium_code" ]
    168       deps = [ ":libsrtp" ]
    169       sources = [
    170         "srtp/include/getopt_s.h",
    171         "srtp/include/srtp_priv.h",
    172         "srtp/test/getopt_s.c",
    173         "srtp/test/srtp_driver.c",
    174       ]
    175     }
    176 
    177     executable("roc_driver") {
    178       configs -= [ "//build/config/compiler:chromium_code" ]
    179       configs += [ "//build/config/compiler:no_chromium_code" ]
    180       deps = [ ":libsrtp" ]
    181       sources = [
    182         "srtp/crypto/include/rdbx.h",
    183         "srtp/include/ut_sim.h",
    184         "srtp/test/roc_driver.c",
    185       ]
    186     }
    187 
    188     executable("replay_driver") {
    189       configs -= [ "//build/config/compiler:chromium_code" ]
    190       configs += [ "//build/config/compiler:no_chromium_code" ]
    191       deps = [ ":libsrtp" ]
    192       sources = [
    193         "srtp/crypto/include/rdbx.h",
    194         "srtp/include/ut_sim.h",
    195         "srtp/test/replay_driver.c",
    196       ]
    197     }
    198 
    199     executable("rtpw") {
    200       configs -= [ "//build/config/compiler:chromium_code" ]
    201       configs += [ "//build/config/compiler:no_chromium_code" ]
    202       deps = [ ":libsrtp" ]
    203       sources = [
    204         "srtp/include/getopt_s.h",
    205         "srtp/include/rtp.h",
    206         "srtp/include/srtp.h",
    207         "srtp/crypto/include/datatypes.h",
    208         "srtp/test/getopt_s.c",
    209         "srtp/test/rtp.c",
    210         "srtp/test/rtpw.c",
    211       ]
    212       if (is_android) {
    213         defines = [ "HAVE_SYS_SOCKET_H" ]
    214       }
    215       if (is_clang) {
    216         cflags = [ "-Wno-implicit-function-declaration" ]
    217       }
    218     }
    219 
    220     executable("srtp_test_cipher_driver") {
    221       configs -= [ "//build/config/compiler:chromium_code" ]
    222       configs += [ "//build/config/compiler:no_chromium_code" ]
    223       deps = [ ":libsrtp" ]
    224       sources = [
    225         "srtp/crypto/test/cipher_driver.c",
    226       ]
    227     }
    228 
    229     executable("srtp_test_datatypes_driver") {
    230       configs -= [ "//build/config/compiler:chromium_code" ]
    231       configs += [ "//build/config/compiler:no_chromium_code" ]
    232       deps = [ ":libsrtp" ]
    233       sources = [
    234         "srtp/crypto/test/datatypes_driver.c",
    235       ]
    236     }
    237 
    238     executable("srtp_test_stat_driver") {
    239       configs -= [ "//build/config/compiler:chromium_code" ]
    240       configs += [ "//build/config/compiler:no_chromium_code" ]
    241       deps = [ ":libsrtp" ]
    242       sources = [
    243         "srtp/crypto/test/stat_driver.c",
    244       ]
    245     }
    246 
    247     executable("srtp_test_sha1_driver") {
    248       configs -= [ "//build/config/compiler:chromium_code" ]
    249       configs += [ "//build/config/compiler:no_chromium_code" ]
    250       deps = [ ":libsrtp" ]
    251       sources = [
    252         "srtp/crypto/test/sha1_driver.c",
    253       ]
    254     }
    255 
    256     executable("srtp_test_kernel_driver") {
    257       configs -= [ "//build/config/compiler:chromium_code" ]
    258       configs += [ "//build/config/compiler:no_chromium_code" ]
    259       deps = [ ":libsrtp" ]
    260       sources = [
    261         "srtp/crypto/test/kernel_driver.c",
    262       ]
    263     }
    264 
    265     executable("srtp_test_aes_calc") {
    266       configs -= [ "//build/config/compiler:chromium_code" ]
    267       configs += [ "//build/config/compiler:no_chromium_code" ]
    268       deps = [ ":libsrtp" ]
    269       sources = [
    270         "srtp/crypto/test/aes_calc.c",
    271       ]
    272     }
    273 
    274     executable("srtp_test_rand_gen") {
    275       configs -= [ "//build/config/compiler:chromium_code" ]
    276       configs += [ "//build/config/compiler:no_chromium_code" ]
    277       deps = [ ":libsrtp" ]
    278       sources = [
    279         "srtp/crypto/test/rand_gen.c",
    280       ]
    281     }
    282 
    283     executable("srtp_test_env") {
    284       configs -= [ "//build/config/compiler:chromium_code" ]
    285       configs += [ "//build/config/compiler:no_chromium_code" ]
    286       deps = [ ":libsrtp" ]
    287       sources = [
    288         "srtp/crypto/test/env.c",
    289       ]
    290     }
    291 
    292     group("srtp_runtest") {
    293       deps = [
    294         ":rdbx_driver",
    295         ":srtp_driver",
    296         ":roc_driver",
    297         ":replay_driver",
    298         ":rtpw",
    299         ":srtp_test_cipher_driver",
    300         ":srtp_test_datatypes_driver",
    301         ":srtp_test_stat_driver",
    302         ":srtp_test_sha1_driver",
    303         ":srtp_test_kernel_driver",
    304         ":srtp_test_aes_calc",
    305         ":srtp_test_rand_gen",
    306         ":srtp_test_env",
    307       ]
    308     }
    309   }
    310 }
    311