Re-land: C++ readability review
[chromium-blink-merge.git] / build / secondary / third_party / libsrtp / BUILD.gn
blob8b9647c142e6df2462a544707ae617e94cfd9344
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.
5 declare_args() {
6   use_system_libsrtp = false
9 config("libsrtp_config") {
10   defines = [
11     "HAVE_STDLIB_H",
12     "HAVE_STRING_H",
13   ]
15   include_dirs = [
16     "config",
17     "srtp/include",
18     "srtp/crypto/include",
19   ]
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   }
37   if (is_win) {
38     defines += [
39       "INLINE=__inline",
40       "HAVE_BYTESWAP_METHODS_H",
42       # All Windows architectures are this way.
43       "SIZEOF_UNSIGNED_LONG=4",
44       "SIZEOF_UNSIGNED_LONG_LONG=8",
45     ]
46   }
48   if (current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm") {
49     defines += [
50       # TODO(leozwang): CPU_RISC doesn"t work properly on android/arm
51       # platform for unknown reasons, need to investigate the root cause
52       # of it. CPU_RISC is used for optimization only, and CPU_CISC should
53       # just work just fine, it has been tested on android/arm with srtp
54       # test applications and libjingle.
55       "CPU_CISC",
56     ]
57   }
59   if (current_cpu == "mipsel") {
60     defines += [ "CPU_RISC" ]
61   }
64 config("system_libsrtp_config") {
65   defines = [ "USE_SYSTEM_LIBSRTP" ]
66   include_dirs = [ "/usr/include/srtp" ]
69 if (use_system_libsrtp) {
70   group("libsrtp") {
71     public_configs = [
72       ":libsrtp_config",
73       ":system_libsrtp_config",
74     ]
75     libs = [ "-lsrtp" ]
76   }
77 } else {
78   static_library("libsrtp") {
79     configs -= [ "//build/config/compiler:chromium_code" ]
80     configs += [ "//build/config/compiler:no_chromium_code" ]
81     public_configs = [ ":libsrtp_config" ]
83     sources = [
84       # includes
85       "srtp/include/ekt.h",
86       "srtp/include/getopt_s.h",
87       "srtp/include/rtp.h",
88       "srtp/include/rtp_priv.h",
89       "srtp/include/srtp.h",
90       "srtp/include/srtp_priv.h",
91       "srtp/include/ut_sim.h",
93       # headers
94       "srtp/crypto/include/aes.h",
95       "srtp/crypto/include/aes_cbc.h",
96       "srtp/crypto/include/aes_icm.h",
97       "srtp/crypto/include/alloc.h",
98       "srtp/crypto/include/auth.h",
99       "srtp/crypto/include/cipher.h",
100       "srtp/crypto/include/crypto.h",
101       "srtp/crypto/include/crypto_kernel.h",
102       "srtp/crypto/include/crypto_math.h",
103       "srtp/crypto/include/crypto_types.h",
104       "srtp/crypto/include/cryptoalg.h",
105       "srtp/crypto/include/datatypes.h",
106       "srtp/crypto/include/err.h",
107       "srtp/crypto/include/gf2_8.h",
108       "srtp/crypto/include/hmac.h",
109       "srtp/crypto/include/integers.h",
110       "srtp/crypto/include/kernel_compat.h",
111       "srtp/crypto/include/key.h",
112       "srtp/crypto/include/null_auth.h",
113       "srtp/crypto/include/null_cipher.h",
114       "srtp/crypto/include/prng.h",
115       "srtp/crypto/include/rand_source.h",
116       "srtp/crypto/include/rdb.h",
117       "srtp/crypto/include/rdbx.h",
118       "srtp/crypto/include/sha1.h",
119       "srtp/crypto/include/stat.h",
120       "srtp/crypto/include/xfm.h",
122       # sources
123       "srtp/crypto/cipher/aes.c",
124       "srtp/crypto/cipher/aes_cbc.c",
125       "srtp/crypto/cipher/aes_icm.c",
126       "srtp/crypto/cipher/cipher.c",
127       "srtp/crypto/cipher/null_cipher.c",
128       "srtp/crypto/hash/auth.c",
129       "srtp/crypto/hash/hmac.c",
130       "srtp/crypto/hash/null_auth.c",
131       "srtp/crypto/hash/sha1.c",
132       "srtp/crypto/kernel/alloc.c",
133       "srtp/crypto/kernel/crypto_kernel.c",
134       "srtp/crypto/kernel/err.c",
135       "srtp/crypto/kernel/key.c",
136       "srtp/crypto/math/datatypes.c",
137       "srtp/crypto/math/gf2_8.c",
138       "srtp/crypto/math/stat.c",
139       "srtp/crypto/replay/rdb.c",
140       "srtp/crypto/replay/rdbx.c",
141       "srtp/crypto/replay/ut_sim.c",
142       "srtp/crypto/rng/ctr_prng.c",
143       "srtp/crypto/rng/prng.c",
144       "srtp/crypto/rng/rand_source.c",
145       "srtp/srtp/ekt.c",
146       "srtp/srtp/srtp.c",
147     ]
149     if (is_clang) {
150       cflags = [ "-Wno-implicit-function-declaration" ]
151     }
152   }
154   # TODO(GYP): A bunch of these tests don't compile (in gyp either). They're
155   # not very broken, so could probably be made to work if it's useful.
156   if (!is_win) {
157     executable("rdbx_driver") {
158       configs -= [ "//build/config/compiler:chromium_code" ]
159       configs += [ "//build/config/compiler:no_chromium_code" ]
160       deps = [
161         ":libsrtp",
162       ]
163       sources = [
164         "srtp/include/getopt_s.h",
165         "srtp/test/getopt_s.c",
166         "srtp/test/rdbx_driver.c",
167       ]
168     }
170     executable("srtp_driver") {
171       configs -= [ "//build/config/compiler:chromium_code" ]
172       configs += [ "//build/config/compiler:no_chromium_code" ]
173       deps = [
174         ":libsrtp",
175       ]
176       sources = [
177         "srtp/include/getopt_s.h",
178         "srtp/include/srtp_priv.h",
179         "srtp/test/getopt_s.c",
180         "srtp/test/srtp_driver.c",
181       ]
182     }
184     executable("roc_driver") {
185       configs -= [ "//build/config/compiler:chromium_code" ]
186       configs += [ "//build/config/compiler:no_chromium_code" ]
187       deps = [
188         ":libsrtp",
189       ]
190       sources = [
191         "srtp/crypto/include/rdbx.h",
192         "srtp/include/ut_sim.h",
193         "srtp/test/roc_driver.c",
194       ]
195     }
197     executable("replay_driver") {
198       configs -= [ "//build/config/compiler:chromium_code" ]
199       configs += [ "//build/config/compiler:no_chromium_code" ]
200       deps = [
201         ":libsrtp",
202       ]
203       sources = [
204         "srtp/crypto/include/rdbx.h",
205         "srtp/include/ut_sim.h",
206         "srtp/test/replay_driver.c",
207       ]
208     }
210     executable("rtpw") {
211       configs -= [ "//build/config/compiler:chromium_code" ]
212       configs += [ "//build/config/compiler:no_chromium_code" ]
213       deps = [
214         ":libsrtp",
215       ]
216       sources = [
217         "srtp/crypto/include/datatypes.h",
218         "srtp/include/getopt_s.h",
219         "srtp/include/rtp.h",
220         "srtp/include/srtp.h",
221         "srtp/test/getopt_s.c",
222         "srtp/test/rtp.c",
223         "srtp/test/rtpw.c",
224       ]
225       if (is_android) {
226         defines = [ "HAVE_SYS_SOCKET_H" ]
227       }
228       if (is_clang) {
229         cflags = [ "-Wno-implicit-function-declaration" ]
230       }
231     }
233     executable("srtp_test_cipher_driver") {
234       configs -= [ "//build/config/compiler:chromium_code" ]
235       configs += [ "//build/config/compiler:no_chromium_code" ]
236       deps = [
237         ":libsrtp",
238       ]
239       sources = [
240         "srtp/crypto/test/cipher_driver.c",
241       ]
242     }
244     executable("srtp_test_datatypes_driver") {
245       configs -= [ "//build/config/compiler:chromium_code" ]
246       configs += [ "//build/config/compiler:no_chromium_code" ]
247       deps = [
248         ":libsrtp",
249       ]
250       sources = [
251         "srtp/crypto/test/datatypes_driver.c",
252       ]
253     }
255     executable("srtp_test_stat_driver") {
256       configs -= [ "//build/config/compiler:chromium_code" ]
257       configs += [ "//build/config/compiler:no_chromium_code" ]
258       deps = [
259         ":libsrtp",
260       ]
261       sources = [
262         "srtp/crypto/test/stat_driver.c",
263       ]
264     }
266     executable("srtp_test_sha1_driver") {
267       configs -= [ "//build/config/compiler:chromium_code" ]
268       configs += [ "//build/config/compiler:no_chromium_code" ]
269       deps = [
270         ":libsrtp",
271       ]
272       sources = [
273         "srtp/crypto/test/sha1_driver.c",
274       ]
275     }
277     executable("srtp_test_kernel_driver") {
278       configs -= [ "//build/config/compiler:chromium_code" ]
279       configs += [ "//build/config/compiler:no_chromium_code" ]
280       deps = [
281         ":libsrtp",
282       ]
283       sources = [
284         "srtp/crypto/test/kernel_driver.c",
285       ]
286     }
288     executable("srtp_test_aes_calc") {
289       configs -= [ "//build/config/compiler:chromium_code" ]
290       configs += [ "//build/config/compiler:no_chromium_code" ]
291       deps = [
292         ":libsrtp",
293       ]
294       sources = [
295         "srtp/crypto/test/aes_calc.c",
296       ]
297     }
299     executable("srtp_test_rand_gen") {
300       configs -= [ "//build/config/compiler:chromium_code" ]
301       configs += [ "//build/config/compiler:no_chromium_code" ]
302       deps = [
303         ":libsrtp",
304       ]
305       sources = [
306         "srtp/crypto/test/rand_gen.c",
307       ]
308     }
310     executable("srtp_test_env") {
311       configs -= [ "//build/config/compiler:chromium_code" ]
312       configs += [ "//build/config/compiler:no_chromium_code" ]
313       deps = [
314         ":libsrtp",
315       ]
316       sources = [
317         "srtp/crypto/test/env.c",
318       ]
319     }
321     group("srtp_runtest") {
322       deps = [
323         ":rdbx_driver",
324         ":srtp_driver",
325         ":roc_driver",
326         ":replay_driver",
327         ":rtpw",
328         ":srtp_test_cipher_driver",
329         ":srtp_test_datatypes_driver",
330         ":srtp_test_stat_driver",
331         ":srtp_test_sha1_driver",
332         ":srtp_test_kernel_driver",
333         ":srtp_test_aes_calc",
334         ":srtp_test_rand_gen",
335         ":srtp_test_env",
336       ]
337     }
338   }