1# Copyright (c) 2012 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{
6  'variables': {
7    'chromium_code': 1,
8  },
9  'includes': [
10    'crypto.gypi',
11  ],
12  'targets': [
13    {
14      'target_name': 'crypto',
15      'type': '<(component)',
16      'product_name': 'crcrypto',  # Avoid colliding with OpenSSL's libcrypto
17      'dependencies': [
18        '../base/base.gyp:base',
19        '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
20        '../third_party/boringssl/boringssl.gyp:boringssl',
21      ],
22      'defines': [
23        'CRYPTO_IMPLEMENTATION',
24      ],
25      'conditions': [
26        [ 'os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android"', {
27          'dependencies': [
28            '../build/linux/system.gyp:nss',
29          ],
30          'export_dependent_settings': [
31            '../build/linux/system.gyp:nss',
32          ],
33          'conditions': [
34            [ 'chromeos==1', {
35                'sources/': [ ['include', '_chromeos\\.cc$'] ]
36              },
37            ],
38          ],
39        }],
40        [ 'OS != "mac" and OS != "ios"', {
41          'sources!': [
42            'apple_keychain.h',
43            'mock_apple_keychain.cc',
44            'mock_apple_keychain.h',
45          ],
46        }],
47        [ 'os_bsd==1', {
48          'link_settings': {
49            'libraries': [
50              '-L/usr/local/lib -lexecinfo',
51              ],
52            },
53          },
54        ],
55        [ 'OS == "mac"', {
56          'link_settings': {
57            'libraries': [
58              '$(SDKROOT)/System/Library/Frameworks/Security.framework',
59            ],
60          },
61        }, {  # OS != "mac"
62          'sources!': [
63            'cssm_init.cc',
64            'cssm_init.h',
65            'mac_security_services_lock.cc',
66            'mac_security_services_lock.h',
67          ],
68        }],
69        [ 'OS != "win"', {
70          'sources!': [
71            'capi_util.h',
72            'capi_util.cc',
73          ],
74        }],
75        [ 'OS == "win"', {
76          'msvs_disabled_warnings': [
77            4267,  # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
78          ],
79        }],
80        [ 'use_nss_certs==0', {
81            # Some files are built when NSS is used for the platform certificate library.
82            'sources!': [
83              'nss_key_util.cc',
84              'nss_key_util.h',
85              'nss_util.cc',
86              'nss_util.h',
87              'nss_util_internal.h',
88            ],
89        },],
90      ],
91      'sources': [
92        '<@(crypto_sources)',
93      ],
94    },
95    {
96      'target_name': 'crypto_unittests',
97      'type': 'executable',
98      'sources': [
99        'aead_unittest.cc',
100        'curve25519_unittest.cc',
101        'ec_private_key_unittest.cc',
102        'ec_signature_creator_unittest.cc',
103        'encryptor_unittest.cc',
104        'hkdf_unittest.cc',
105        'hmac_unittest.cc',
106        'nss_key_util_unittest.cc',
107        'nss_util_unittest.cc',
108        'openssl_bio_string_unittest.cc',
109        'p224_unittest.cc',
110        'p224_spake_unittest.cc',
111        'random_unittest.cc',
112        'rsa_private_key_unittest.cc',
113        'secure_hash_unittest.cc',
114        'sha2_unittest.cc',
115        'signature_creator_unittest.cc',
116        'signature_verifier_unittest.cc',
117        'symmetric_key_unittest.cc',
118      ],
119      'dependencies': [
120        'crypto',
121        'crypto_test_support',
122        '../base/base.gyp:base',
123        '../base/base.gyp:run_all_unittests',
124        '../base/base.gyp:test_support_base',
125        '../testing/gmock.gyp:gmock',
126        '../testing/gtest.gyp:gtest',
127        '../third_party/boringssl/boringssl.gyp:boringssl',
128      ],
129      'conditions': [
130        [ 'use_nss_certs == 1', {
131          'dependencies': [
132            '../build/linux/system.gyp:nss',
133          ],
134        }],
135        [ 'use_nss_certs == 0', {
136          # Some files are built when NSS is used for the platform certificate library.
137          'sources!': [
138            'nss_key_util_unittest.cc',
139            'nss_util_unittest.cc',
140          ],
141        }],
142        [ 'OS == "win"', {
143          # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
144          'msvs_disabled_warnings': [4267, ],
145        }],
146      ],
147    },
148  ],
149  'conditions': [
150    ['OS == "win" and target_arch=="ia32"', {
151      'targets': [
152        {
153          'target_name': 'crypto_nacl_win64',
154          # We use the native APIs for the helper.
155          'type': '<(component)',
156          'dependencies': [
157            '../base/base.gyp:base_win64',
158            '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations_win64',
159            '../third_party/boringssl/boringssl.gyp:boringssl_nacl_win64',
160          ],
161          'sources': [
162            '<@(nacl_win64_sources)',
163          ],
164          'defines': [
165           'CRYPTO_IMPLEMENTATION',
166           '<@(nacl_win64_defines)',
167          ],
168          'configurations': {
169            'Common_Base': {
170              'msvs_target_platform': 'x64',
171            },
172          },
173        },
174      ],
175    }],
176    ['use_nss_certs==1', {
177      'targets': [
178        {
179          'target_name': 'crypto_test_support',
180          'type': 'static_library',
181          'dependencies': [
182            '../base/base.gyp:base',
183            'crypto',
184          ],
185          'sources': [
186            'scoped_test_nss_db.cc',
187            'scoped_test_nss_db.h',
188            'scoped_test_nss_chromeos_user.cc',
189            'scoped_test_nss_chromeos_user.h',
190            'scoped_test_system_nss_key_slot.cc',
191            'scoped_test_system_nss_key_slot.h',
192          ],
193          'conditions': [
194            ['use_nss_certs==0', {
195              'sources!': [
196                'scoped_test_nss_db.cc',
197                'scoped_test_nss_db.h',
198              ],
199            }],
200            [ 'chromeos==0', {
201              'sources!': [
202                'scoped_test_nss_chromeos_user.cc',
203                'scoped_test_nss_chromeos_user.h',
204                'scoped_test_system_nss_key_slot.cc',
205                'scoped_test_system_nss_key_slot.h',
206              ],
207            }],
208          ],
209        }
210      ]}, {  # use_nss_certs==0
211      'targets': [
212        {
213          'target_name': 'crypto_test_support',
214          'type': 'none',
215          'sources': [],
216        }
217    ]}],
218    ['test_isolation_mode != "noop"', {
219      'targets': [
220        {
221          'target_name': 'crypto_unittests_run',
222          'type': 'none',
223          'dependencies': [
224            'crypto_unittests',
225          ],
226          'includes': [
227            '../build/isolate.gypi',
228                      ],
229          'sources': [
230            'crypto_unittests.isolate',
231          ],
232        },
233      ],
234    }],
235  ],
236}
237