Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / build / secondary / third_party / libsrtp / BUILD.gn
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     direct_dependent_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     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
147   # TODO(GYP): A bunch of these tests don't compile (in gyp either). They're
148   # not very broken, so could probably be made to work if it's useful.
149   if (!is_win) {
150     executable("rdbx_driver") {
151       configs -= [ "//build/config/compiler:chromium_code" ]
152       configs += [ "//build/config/compiler:no_chromium_code" ]
153       configs += [ ":libsrtp_config" ]
154       deps = [ ":libsrtp" ]
155       sources = [
156         "srtp/include/getopt_s.h",
157         "srtp/test/getopt_s.c",
158         "srtp/test/rdbx_driver.c",
159       ]
160     }
161
162     executable("srtp_driver") {
163       configs -= [ "//build/config/compiler:chromium_code" ]
164       configs += [ "//build/config/compiler:no_chromium_code" ]
165       configs += [ ":libsrtp_config" ]
166       deps = [ ":libsrtp" ]
167       sources = [
168         "srtp/include/getopt_s.h",
169         "srtp/include/srtp_priv.h",
170         "srtp/test/getopt_s.c",
171         "srtp/test/srtp_driver.c",
172       ]
173     }
174
175     executable("roc_driver") {
176       configs -= [ "//build/config/compiler:chromium_code" ]
177       configs += [ "//build/config/compiler:no_chromium_code" ]
178       configs += [ ":libsrtp_config" ]
179       deps = [ ":libsrtp" ]
180       sources = [
181         "srtp/crypto/include/rdbx.h",
182         "srtp/include/ut_sim.h",
183         "srtp/test/roc_driver.c",
184       ]
185     }
186
187     executable("replay_driver") {
188       configs -= [ "//build/config/compiler:chromium_code" ]
189       configs += [ "//build/config/compiler:no_chromium_code" ]
190       configs += [ ":libsrtp_config" ]
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       configs += [ ":libsrtp_config" ]
203       deps = [ ":libsrtp" ]
204       sources = [
205         "srtp/include/getopt_s.h",
206         "srtp/include/rtp.h",
207         "srtp/include/srtp.h",
208         "srtp/crypto/include/datatypes.h",
209         "srtp/test/getopt_s.c",
210         "srtp/test/rtp.c",
211         "srtp/test/rtpw.c",
212       ]
213       if (is_android) {
214         defines = [ "HAVE_SYS_SOCKET_H" ]
215       }
216     }
217
218     executable("srtp_test_cipher_driver") {
219       configs -= [ "//build/config/compiler:chromium_code" ]
220       configs += [ "//build/config/compiler:no_chromium_code" ]
221       configs += [ ":libsrtp_config" ]
222       deps = [ ":libsrtp" ]
223       sources = [
224         "srtp/crypto/test/cipher_driver.c",
225       ]
226     }
227
228     executable("srtp_test_datatypes_driver") {
229       configs -= [ "//build/config/compiler:chromium_code" ]
230       configs += [ "//build/config/compiler:no_chromium_code" ]
231       configs += [ ":libsrtp_config" ]
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       configs += [ ":libsrtp_config" ]
242       deps = [ ":libsrtp" ]
243       sources = [
244         "srtp/crypto/test/stat_driver.c",
245       ]
246     }
247
248     executable("srtp_test_sha1_driver") {
249       configs -= [ "//build/config/compiler:chromium_code" ]
250       configs += [ "//build/config/compiler:no_chromium_code" ]
251       configs += [ ":libsrtp_config" ]
252       deps = [ ":libsrtp" ]
253       sources = [
254         "srtp/crypto/test/sha1_driver.c",
255       ]
256     }
257
258     executable("srtp_test_kernel_driver") {
259       configs -= [ "//build/config/compiler:chromium_code" ]
260       configs += [ "//build/config/compiler:no_chromium_code" ]
261       configs += [ ":libsrtp_config" ]
262       deps = [ ":libsrtp" ]
263       sources = [
264         "srtp/crypto/test/kernel_driver.c",
265       ]
266     }
267
268     executable("srtp_test_aes_calc") {
269       configs -= [ "//build/config/compiler:chromium_code" ]
270       configs += [ "//build/config/compiler:no_chromium_code" ]
271       configs += [ ":libsrtp_config" ]
272       deps = [ ":libsrtp" ]
273       sources = [
274         "srtp/crypto/test/aes_calc.c",
275       ]
276     }
277
278     executable("srtp_test_rand_gen") {
279       configs -= [ "//build/config/compiler:chromium_code" ]
280       configs += [ "//build/config/compiler:no_chromium_code" ]
281       configs += [ ":libsrtp_config" ]
282       deps = [ ":libsrtp" ]
283       sources = [
284         "srtp/crypto/test/rand_gen.c",
285       ]
286     }
287
288     executable("srtp_test_env") {
289       configs -= [ "//build/config/compiler:chromium_code" ]
290       configs += [ "//build/config/compiler:no_chromium_code" ]
291       configs += [ ":libsrtp_config" ]
292       deps = [ ":libsrtp" ]
293       sources = [
294         "srtp/crypto/test/env.c",
295       ]
296     }
297
298     group("srtp_runtest") {
299       deps = [
300         ":rdbx_driver",
301         ":srtp_driver",
302         ":roc_driver",
303         ":replay_driver",
304         ":rtpw",
305         ":srtp_test_cipher_driver",
306         ":srtp_test_datatypes_driver",
307         ":srtp_test_stat_driver",
308         ":srtp_test_sha1_driver",
309         ":srtp_test_kernel_driver",
310         ":srtp_test_aes_calc",
311         ":srtp_test_rand_gen",
312         ":srtp_test_env",
313       ]
314     }
315   }
316 }