blob: 63e09a007e7168681ef0f49a833a73a4215201bc [file] [log] [blame]
Adam Langley9e1a6602015-05-05 17:47:53 -07001# Copyright (c) 2015, Google Inc.
2#
3# Permission to use, copy, modify, and/or distribute this software for any
4# purpose with or without fee is hereby granted, provided that the above
5# copyright notice and this permission notice appear in all copies.
6#
7# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
15"""Enumerates the BoringSSL source in src/ and either generates two gypi files
16 (boringssl.gypi and boringssl_tests.gypi) for Chromium, or generates
17 source-list files for Android."""
18
19import os
20import subprocess
21import sys
Adam Langley9c164b22015-06-10 18:54:47 -070022import json
Adam Langley9e1a6602015-05-05 17:47:53 -070023
24
25# OS_ARCH_COMBOS maps from OS and platform to the OpenSSL assembly "style" for
26# that platform and the extension used by asm files.
27OS_ARCH_COMBOS = [
28 ('linux', 'arm', 'linux32', [], 'S'),
29 ('linux', 'aarch64', 'linux64', [], 'S'),
30 ('linux', 'x86', 'elf', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'),
31 ('linux', 'x86_64', 'elf', [], 'S'),
32 ('mac', 'x86', 'macosx', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'),
33 ('mac', 'x86_64', 'macosx', [], 'S'),
34 ('win', 'x86', 'win32n', ['-DOPENSSL_IA32_SSE2'], 'asm'),
35 ('win', 'x86_64', 'nasm', [], 'asm'),
36]
37
38# NON_PERL_FILES enumerates assembly files that are not processed by the
39# perlasm system.
40NON_PERL_FILES = {
41 ('linux', 'arm'): [
Adam Langley7b8b9c12016-01-04 07:13:00 -080042 'src/crypto/curve25519/asm/x25519-asm-arm.S',
David Benjamin3c4a5cb2016-03-29 17:43:31 -040043 'src/crypto/poly1305/poly1305_arm_asm.S',
Adam Langley9e1a6602015-05-05 17:47:53 -070044 ],
Matt Braithwaitee021a242016-01-14 13:41:46 -080045 ('linux', 'x86_64'): [
46 'src/crypto/curve25519/asm/x25519-asm-x86_64.S',
47 ],
Adam Langley9e1a6602015-05-05 17:47:53 -070048}
49
50
Adam Langley9e1a6602015-05-05 17:47:53 -070051class Android(object):
52
53 def __init__(self):
54 self.header = \
55"""# Copyright (C) 2015 The Android Open Source Project
56#
57# Licensed under the Apache License, Version 2.0 (the "License");
58# you may not use this file except in compliance with the License.
59# You may obtain a copy of the License at
60#
61# http://www.apache.org/licenses/LICENSE-2.0
62#
63# Unless required by applicable law or agreed to in writing, software
64# distributed under the License is distributed on an "AS IS" BASIS,
65# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66# See the License for the specific language governing permissions and
67# limitations under the License.
68
69"""
70
Adam Langley049ef412015-06-09 18:20:57 -070071 def ExtraFiles(self):
72 return ['android_compat_hacks.c', 'android_compat_keywrap.c']
73
Adam Langley9e1a6602015-05-05 17:47:53 -070074 def PrintVariableSection(self, out, name, files):
75 out.write('%s := \\\n' % name)
76 for f in sorted(files):
77 out.write(' %s\\\n' % f)
78 out.write('\n')
79
80 def WriteFiles(self, files, asm_outputs):
81 with open('sources.mk', 'w+') as makefile:
82 makefile.write(self.header)
83
Piotr Sikora6ae67df2015-11-23 18:46:33 -080084 crypto_files = files['crypto'] + self.ExtraFiles()
85 self.PrintVariableSection(makefile, 'crypto_sources', crypto_files)
Adam Langley9e1a6602015-05-05 17:47:53 -070086 self.PrintVariableSection(makefile, 'ssl_sources', files['ssl'])
87 self.PrintVariableSection(makefile, 'tool_sources', files['tool'])
88
89 for ((osname, arch), asm_files) in asm_outputs:
90 self.PrintVariableSection(
91 makefile, '%s_%s_sources' % (osname, arch), asm_files)
92
93
Adam Langley049ef412015-06-09 18:20:57 -070094class AndroidStandalone(Android):
95 """AndroidStandalone is for Android builds outside of the Android-system, i.e.
96
97 for applications that wish wish to ship BoringSSL.
98 """
99
100 def ExtraFiles(self):
101 return []
102
103
104class Bazel(object):
105 """Bazel outputs files suitable for including in Bazel files."""
106
107 def __init__(self):
108 self.firstSection = True
109 self.header = \
110"""# This file is created by generate_build_files.py. Do not edit manually.
111
112"""
113
114 def PrintVariableSection(self, out, name, files):
115 if not self.firstSection:
116 out.write('\n')
117 self.firstSection = False
118
119 out.write('%s = [\n' % name)
120 for f in sorted(files):
121 out.write(' "%s",\n' % f)
122 out.write(']\n')
123
124 def WriteFiles(self, files, asm_outputs):
Chuck Haysc608d6b2015-10-06 17:54:16 -0700125 with open('BUILD.generated.bzl', 'w+') as out:
Adam Langley049ef412015-06-09 18:20:57 -0700126 out.write(self.header)
127
128 self.PrintVariableSection(out, 'ssl_headers', files['ssl_headers'])
129 self.PrintVariableSection(
130 out, 'ssl_internal_headers', files['ssl_internal_headers'])
131 self.PrintVariableSection(out, 'ssl_sources', files['ssl'])
132 self.PrintVariableSection(out, 'crypto_headers', files['crypto_headers'])
133 self.PrintVariableSection(
134 out, 'crypto_internal_headers', files['crypto_internal_headers'])
135 self.PrintVariableSection(out, 'crypto_sources', files['crypto'])
136 self.PrintVariableSection(out, 'tool_sources', files['tool'])
137
138 for ((osname, arch), asm_files) in asm_outputs:
Adam Langley049ef412015-06-09 18:20:57 -0700139 self.PrintVariableSection(
Piotr Sikora3f5fe602015-10-28 12:24:35 -0700140 out, 'crypto_sources_%s_%s' % (osname, arch), asm_files)
Adam Langley049ef412015-06-09 18:20:57 -0700141
Chuck Haysc608d6b2015-10-06 17:54:16 -0700142 with open('BUILD.generated_tests.bzl', 'w+') as out:
Adam Langley9c164b22015-06-10 18:54:47 -0700143 out.write(self.header)
144
145 out.write('test_support_sources = [\n')
146 for filename in files['test_support']:
147 if os.path.basename(filename) == 'malloc.cc':
148 continue
149 out.write(' "%s",\n' % filename)
Adam Langley9c164b22015-06-10 18:54:47 -0700150
Chuck Haysc608d6b2015-10-06 17:54:16 -0700151 out.write(']\n\n')
152
153 out.write('def create_tests(copts):\n')
154 out.write(' test_support_sources_complete = test_support_sources + \\\n')
155 out.write(' native.glob(["src/crypto/test/*.h"])\n')
Adam Langley9c164b22015-06-10 18:54:47 -0700156 name_counts = {}
157 for test in files['tests']:
158 name = os.path.basename(test[0])
159 name_counts[name] = name_counts.get(name, 0) + 1
160
161 first = True
162 for test in files['tests']:
163 name = os.path.basename(test[0])
164 if name_counts[name] > 1:
165 if '/' in test[1]:
166 name += '_' + os.path.splitext(os.path.basename(test[1]))[0]
167 else:
168 name += '_' + test[1].replace('-', '_')
169
170 if not first:
171 out.write('\n')
172 first = False
173
174 src_prefix = 'src/' + test[0]
175 for src in files['test']:
176 if src.startswith(src_prefix):
177 src = src
178 break
179 else:
180 raise ValueError("Can't find source for %s" % test[0])
181
Chuck Haysc608d6b2015-10-06 17:54:16 -0700182 out.write(' native.cc_test(\n')
183 out.write(' name = "%s",\n' % name)
184 out.write(' size = "small",\n')
185 out.write(' srcs = ["%s"] + test_support_sources_complete,\n' % src)
Adam Langley9c164b22015-06-10 18:54:47 -0700186
187 data_files = []
188 if len(test) > 1:
189
Chuck Haysc608d6b2015-10-06 17:54:16 -0700190 out.write(' args = [\n')
Adam Langley9c164b22015-06-10 18:54:47 -0700191 for arg in test[1:]:
192 if '/' in arg:
Chuck Haysc608d6b2015-10-06 17:54:16 -0700193 out.write(' "$(location src/%s)",\n' % arg)
Adam Langley9c164b22015-06-10 18:54:47 -0700194 data_files.append('src/%s' % arg)
195 else:
Chuck Haysc608d6b2015-10-06 17:54:16 -0700196 out.write(' "%s",\n' % arg)
197 out.write(' ],\n')
Adam Langley9c164b22015-06-10 18:54:47 -0700198
Chuck Haysc608d6b2015-10-06 17:54:16 -0700199 out.write(' copts = copts,\n')
Adam Langley9c164b22015-06-10 18:54:47 -0700200
201 if len(data_files) > 0:
Chuck Haysc608d6b2015-10-06 17:54:16 -0700202 out.write(' data = [\n')
Adam Langley9c164b22015-06-10 18:54:47 -0700203 for filename in data_files:
Chuck Haysc608d6b2015-10-06 17:54:16 -0700204 out.write(' "%s",\n' % filename)
205 out.write(' ],\n')
Adam Langley9c164b22015-06-10 18:54:47 -0700206
207 if 'ssl/' in test[0]:
Chuck Haysc608d6b2015-10-06 17:54:16 -0700208 out.write(' deps = [\n')
209 out.write(' ":crypto",\n')
210 out.write(' ":ssl",\n')
211 out.write(' ],\n')
Adam Langley9c164b22015-06-10 18:54:47 -0700212 else:
Chuck Haysc608d6b2015-10-06 17:54:16 -0700213 out.write(' deps = [":crypto"],\n')
214 out.write(' )\n')
Adam Langley9c164b22015-06-10 18:54:47 -0700215
Adam Langley049ef412015-06-09 18:20:57 -0700216
David Benjamin38d01c62016-04-21 18:47:57 -0400217class GN(object):
218
219 def __init__(self):
220 self.firstSection = True
221 self.header = \
222"""# Copyright (c) 2016 The Chromium Authors. All rights reserved.
223# Use of this source code is governed by a BSD-style license that can be
224# found in the LICENSE file.
225
226# This file is created by generate_build_files.py. Do not edit manually.
227
228"""
229
230 def PrintVariableSection(self, out, name, files):
231 if not self.firstSection:
232 out.write('\n')
233 self.firstSection = False
234
235 out.write('%s = [\n' % name)
236 for f in sorted(files):
237 out.write(' "%s",\n' % f)
238 out.write(']\n')
239
240 def WriteFiles(self, files, asm_outputs):
241 with open('BUILD.generated.gni', 'w+') as out:
242 out.write(self.header)
243
244 self.PrintVariableSection(out, 'crypto_sources', files['crypto'])
245 self.PrintVariableSection(out, 'ssl_sources', files['ssl'])
246
247 for ((osname, arch), asm_files) in asm_outputs:
248 self.PrintVariableSection(
249 out, 'crypto_sources_%s_%s' % (osname, arch), asm_files)
250
251 fuzzers = [os.path.splitext(os.path.basename(fuzzer))[0]
252 for fuzzer in files['fuzz']]
253 self.PrintVariableSection(out, 'fuzzers', fuzzers)
254
255 with open('BUILD.generated_tests.gni', 'w+') as out:
256 self.firstSection = True
257 out.write(self.header)
258
259 self.PrintVariableSection(out, '_test_support_sources',
260 files['test_support'])
261 out.write('\n')
262
263 out.write('template("create_tests") {\n')
264
265 all_tests = []
266 for test in sorted(files['test']):
267 test_name = 'boringssl_%s' % os.path.splitext(os.path.basename(test))[0]
268 all_tests.append(test_name)
269
270 out.write(' executable("%s") {\n' % test_name)
271 out.write(' sources = [\n')
272 out.write(' "%s",\n' % test)
273 out.write(' ]\n')
274 out.write(' sources += _test_support_sources\n')
275 out.write(' configs += invoker.configs\n')
276 out.write(' deps = invoker.deps\n')
277 out.write(' }\n')
278 out.write('\n')
279
280 out.write(' group(target_name) {\n')
281 out.write(' deps = [\n')
282 for test_name in sorted(all_tests):
283 out.write(' ":%s",\n' % test_name)
284 out.write(' ]\n')
285 out.write(' }\n')
286 out.write('}\n')
287
288
289class GYP(object):
290
291 def __init__(self):
292 self.header = \
293"""# Copyright (c) 2016 The Chromium Authors. All rights reserved.
294# Use of this source code is governed by a BSD-style license that can be
295# found in the LICENSE file.
296
297# This file is created by generate_build_files.py. Do not edit manually.
298
299"""
300
301 def PrintVariableSection(self, out, name, files):
302 out.write(' \'%s\': [\n' % name)
303 for f in sorted(files):
304 out.write(' \'%s\',\n' % f)
305 out.write(' ],\n')
306
307 def WriteFiles(self, files, asm_outputs):
308 with open('boringssl.gypi', 'w+') as gypi:
309 gypi.write(self.header + '{\n \'variables\': {\n')
310
311 self.PrintVariableSection(
312 gypi, 'boringssl_ssl_sources', files['ssl'])
313 self.PrintVariableSection(
314 gypi, 'boringssl_crypto_sources', files['crypto'])
315
316 for ((osname, arch), asm_files) in asm_outputs:
317 self.PrintVariableSection(gypi, 'boringssl_%s_%s_sources' %
318 (osname, arch), asm_files)
319
320 gypi.write(' }\n}\n')
321
322 with open('boringssl_tests.gypi', 'w+') as test_gypi:
323 test_gypi.write(self.header + '{\n \'targets\': [\n')
324
325 test_names = []
326 for test in sorted(files['test']):
327 test_name = 'boringssl_%s' % os.path.splitext(os.path.basename(test))[0]
328 test_gypi.write(""" {
329 'target_name': '%s',
330 'type': 'executable',
331 'dependencies': [
332 'boringssl.gyp:boringssl',
333 ],
334 'sources': [
335 '%s',
336 '<@(boringssl_test_support_sources)',
337 ],
338 # TODO(davidben): Fix size_t truncations in BoringSSL.
339 # https://crbug.com/429039
340 'msvs_disabled_warnings': [ 4267, ],
341 },\n""" % (test_name, test))
342 test_names.append(test_name)
343
344 test_names.sort()
345
346 test_gypi.write(' ],\n \'variables\': {\n')
347
348 self.PrintVariableSection(
349 test_gypi, 'boringssl_test_support_sources', files['test_support'])
350
351 test_gypi.write(' \'boringssl_test_targets\': [\n')
352
353 for test in sorted(test_names):
354 test_gypi.write(""" '%s',\n""" % test)
355
356 test_gypi.write(' ],\n }\n}\n')
357
358
Adam Langley9e1a6602015-05-05 17:47:53 -0700359def FindCMakeFiles(directory):
360 """Returns list of all CMakeLists.txt files recursively in directory."""
361 cmakefiles = []
362
363 for (path, _, filenames) in os.walk(directory):
364 for filename in filenames:
365 if filename == 'CMakeLists.txt':
366 cmakefiles.append(os.path.join(path, filename))
367
368 return cmakefiles
369
370
371def NoTests(dent, is_dir):
372 """Filter function that can be passed to FindCFiles in order to remove test
373 sources."""
374 if is_dir:
375 return dent != 'test'
376 return 'test.' not in dent and not dent.startswith('example_')
377
378
379def OnlyTests(dent, is_dir):
380 """Filter function that can be passed to FindCFiles in order to remove
381 non-test sources."""
382 if is_dir:
David Benjamin26073832015-05-11 20:52:48 -0400383 return dent != 'test'
Adam Langley9e1a6602015-05-05 17:47:53 -0700384 return '_test.' in dent or dent.startswith('example_')
385
386
David Benjamin26073832015-05-11 20:52:48 -0400387def AllFiles(dent, is_dir):
388 """Filter function that can be passed to FindCFiles in order to include all
389 sources."""
390 return True
391
392
Adam Langley049ef412015-06-09 18:20:57 -0700393def SSLHeaderFiles(dent, is_dir):
394 return dent in ['ssl.h', 'tls1.h', 'ssl23.h', 'ssl3.h', 'dtls1.h']
395
396
Adam Langley9e1a6602015-05-05 17:47:53 -0700397def FindCFiles(directory, filter_func):
398 """Recurses through directory and returns a list of paths to all the C source
399 files that pass filter_func."""
400 cfiles = []
401
402 for (path, dirnames, filenames) in os.walk(directory):
403 for filename in filenames:
404 if not filename.endswith('.c') and not filename.endswith('.cc'):
405 continue
406 if not filter_func(filename, False):
407 continue
408 cfiles.append(os.path.join(path, filename))
409
410 for (i, dirname) in enumerate(dirnames):
411 if not filter_func(dirname, True):
412 del dirnames[i]
413
414 return cfiles
415
416
Adam Langley049ef412015-06-09 18:20:57 -0700417def FindHeaderFiles(directory, filter_func):
418 """Recurses through directory and returns a list of paths to all the header files that pass filter_func."""
419 hfiles = []
420
421 for (path, dirnames, filenames) in os.walk(directory):
422 for filename in filenames:
423 if not filename.endswith('.h'):
424 continue
425 if not filter_func(filename, False):
426 continue
427 hfiles.append(os.path.join(path, filename))
428
429 return hfiles
430
431
Adam Langley9e1a6602015-05-05 17:47:53 -0700432def ExtractPerlAsmFromCMakeFile(cmakefile):
433 """Parses the contents of the CMakeLists.txt file passed as an argument and
434 returns a list of all the perlasm() directives found in the file."""
435 perlasms = []
436 with open(cmakefile) as f:
437 for line in f:
438 line = line.strip()
439 if not line.startswith('perlasm('):
440 continue
441 if not line.endswith(')'):
442 raise ValueError('Bad perlasm line in %s' % cmakefile)
443 # Remove "perlasm(" from start and ")" from end
444 params = line[8:-1].split()
445 if len(params) < 2:
446 raise ValueError('Bad perlasm line in %s' % cmakefile)
447 perlasms.append({
448 'extra_args': params[2:],
449 'input': os.path.join(os.path.dirname(cmakefile), params[1]),
450 'output': os.path.join(os.path.dirname(cmakefile), params[0]),
451 })
452
453 return perlasms
454
455
456def ReadPerlAsmOperations():
457 """Returns a list of all perlasm() directives found in CMake config files in
458 src/."""
459 perlasms = []
460 cmakefiles = FindCMakeFiles('src')
461
462 for cmakefile in cmakefiles:
463 perlasms.extend(ExtractPerlAsmFromCMakeFile(cmakefile))
464
465 return perlasms
466
467
468def PerlAsm(output_filename, input_filename, perlasm_style, extra_args):
469 """Runs the a perlasm script and puts the output into output_filename."""
470 base_dir = os.path.dirname(output_filename)
471 if not os.path.isdir(base_dir):
472 os.makedirs(base_dir)
473 output = subprocess.check_output(
474 ['perl', input_filename, perlasm_style] + extra_args)
475 with open(output_filename, 'w+') as out_file:
476 out_file.write(output)
477
478
479def ArchForAsmFilename(filename):
480 """Returns the architectures that a given asm file should be compiled for
481 based on substrings in the filename."""
482
483 if 'x86_64' in filename or 'avx2' in filename:
484 return ['x86_64']
485 elif ('x86' in filename and 'x86_64' not in filename) or '586' in filename:
486 return ['x86']
487 elif 'armx' in filename:
488 return ['arm', 'aarch64']
489 elif 'armv8' in filename:
490 return ['aarch64']
491 elif 'arm' in filename:
492 return ['arm']
493 else:
494 raise ValueError('Unknown arch for asm filename: ' + filename)
495
496
497def WriteAsmFiles(perlasms):
498 """Generates asm files from perlasm directives for each supported OS x
499 platform combination."""
500 asmfiles = {}
501
502 for osarch in OS_ARCH_COMBOS:
503 (osname, arch, perlasm_style, extra_args, asm_ext) = osarch
504 key = (osname, arch)
505 outDir = '%s-%s' % key
506
507 for perlasm in perlasms:
508 filename = os.path.basename(perlasm['input'])
509 output = perlasm['output']
510 if not output.startswith('src'):
511 raise ValueError('output missing src: %s' % output)
512 output = os.path.join(outDir, output[4:])
William Hessec618c402015-06-22 16:34:02 +0200513 if output.endswith('-armx.${ASM_EXT}'):
514 output = output.replace('-armx',
515 '-armx64' if arch == 'aarch64' else '-armx32')
Adam Langley9e1a6602015-05-05 17:47:53 -0700516 output = output.replace('${ASM_EXT}', asm_ext)
517
518 if arch in ArchForAsmFilename(filename):
519 PerlAsm(output, perlasm['input'], perlasm_style,
520 perlasm['extra_args'] + extra_args)
521 asmfiles.setdefault(key, []).append(output)
522
523 for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems():
524 asmfiles.setdefault(key, []).extend(non_perl_asm_files)
525
526 return asmfiles
527
528
Adam Langley049ef412015-06-09 18:20:57 -0700529def main(platforms):
Adam Langley9e1a6602015-05-05 17:47:53 -0700530 crypto_c_files = FindCFiles(os.path.join('src', 'crypto'), NoTests)
531 ssl_c_files = FindCFiles(os.path.join('src', 'ssl'), NoTests)
David Benjamin38d01c62016-04-21 18:47:57 -0400532 tool_c_files = FindCFiles(os.path.join('src', 'tool'), NoTests)
Adam Langley9e1a6602015-05-05 17:47:53 -0700533
534 # Generate err_data.c
535 with open('err_data.c', 'w+') as err_data:
536 subprocess.check_call(['go', 'run', 'err_data_generate.go'],
537 cwd=os.path.join('src', 'crypto', 'err'),
538 stdout=err_data)
539 crypto_c_files.append('err_data.c')
540
David Benjamin38d01c62016-04-21 18:47:57 -0400541 test_support_c_files = FindCFiles(os.path.join('src', 'crypto', 'test'),
542 AllFiles)
David Benjamin26073832015-05-11 20:52:48 -0400543
Adam Langley9e1a6602015-05-05 17:47:53 -0700544 test_c_files = FindCFiles(os.path.join('src', 'crypto'), OnlyTests)
545 test_c_files += FindCFiles(os.path.join('src', 'ssl'), OnlyTests)
546
David Benjamin38d01c62016-04-21 18:47:57 -0400547 fuzz_c_files = FindCFiles(os.path.join('src', 'fuzz'), NoTests)
548
Adam Langley049ef412015-06-09 18:20:57 -0700549 ssl_h_files = (
550 FindHeaderFiles(
551 os.path.join('src', 'include', 'openssl'),
552 SSLHeaderFiles))
553
554 def NotSSLHeaderFiles(filename, is_dir):
555 return not SSLHeaderFiles(filename, is_dir)
556 crypto_h_files = (
557 FindHeaderFiles(
558 os.path.join('src', 'include', 'openssl'),
559 NotSSLHeaderFiles))
560
561 ssl_internal_h_files = FindHeaderFiles(os.path.join('src', 'ssl'), NoTests)
562 crypto_internal_h_files = FindHeaderFiles(
563 os.path.join('src', 'crypto'), NoTests)
564
Adam Langley9c164b22015-06-10 18:54:47 -0700565 with open('src/util/all_tests.json', 'r') as f:
566 tests = json.load(f)
David Benjaminf277add2016-03-09 14:38:24 -0500567 # Skip tests for libdecrepit. Consumers import that manually.
568 tests = [test for test in tests if not test[0].startswith("decrepit/")]
Adam Langley9c164b22015-06-10 18:54:47 -0700569 test_binaries = set([test[0] for test in tests])
570 test_sources = set([
571 test.replace('.cc', '').replace('.c', '').replace(
572 'src/',
573 '')
574 for test in test_c_files])
575 if test_binaries != test_sources:
576 print 'Test sources and configured tests do not match'
577 a = test_binaries.difference(test_sources)
578 if len(a) > 0:
579 print 'These tests are configured without sources: ' + str(a)
580 b = test_sources.difference(test_binaries)
581 if len(b) > 0:
582 print 'These test sources are not configured: ' + str(b)
583
Adam Langley9e1a6602015-05-05 17:47:53 -0700584 files = {
585 'crypto': crypto_c_files,
Adam Langley049ef412015-06-09 18:20:57 -0700586 'crypto_headers': crypto_h_files,
587 'crypto_internal_headers': crypto_internal_h_files,
David Benjamin38d01c62016-04-21 18:47:57 -0400588 'fuzz': fuzz_c_files,
Adam Langley9e1a6602015-05-05 17:47:53 -0700589 'ssl': ssl_c_files,
Adam Langley049ef412015-06-09 18:20:57 -0700590 'ssl_headers': ssl_h_files,
591 'ssl_internal_headers': ssl_internal_h_files,
David Benjamin38d01c62016-04-21 18:47:57 -0400592 'tool': tool_c_files,
Adam Langley9e1a6602015-05-05 17:47:53 -0700593 'test': test_c_files,
David Benjamin38d01c62016-04-21 18:47:57 -0400594 'test_support': test_support_c_files,
Adam Langley9c164b22015-06-10 18:54:47 -0700595 'tests': tests,
Adam Langley9e1a6602015-05-05 17:47:53 -0700596 }
597
598 asm_outputs = sorted(WriteAsmFiles(ReadPerlAsmOperations()).iteritems())
599
Adam Langley049ef412015-06-09 18:20:57 -0700600 for platform in platforms:
601 platform.WriteFiles(files, asm_outputs)
Adam Langley9e1a6602015-05-05 17:47:53 -0700602
603 return 0
604
605
606def Usage():
David Benjamin38d01c62016-04-21 18:47:57 -0400607 print 'Usage: python %s [android|android-standalone|bazel|gn|gyp]' % sys.argv[0]
Adam Langley9e1a6602015-05-05 17:47:53 -0700608 sys.exit(1)
609
610
611if __name__ == '__main__':
Adam Langley049ef412015-06-09 18:20:57 -0700612 if len(sys.argv) < 2:
Adam Langley9e1a6602015-05-05 17:47:53 -0700613 Usage()
614
Adam Langley049ef412015-06-09 18:20:57 -0700615 platforms = []
616 for s in sys.argv[1:]:
David Benjamin38d01c62016-04-21 18:47:57 -0400617 if s == 'android':
Adam Langley049ef412015-06-09 18:20:57 -0700618 platforms.append(Android())
619 elif s == 'android-standalone':
620 platforms.append(AndroidStandalone())
621 elif s == 'bazel':
622 platforms.append(Bazel())
David Benjamin38d01c62016-04-21 18:47:57 -0400623 elif s == 'gn':
624 platforms.append(GN())
625 elif s == 'gyp':
626 platforms.append(GYP())
Adam Langley049ef412015-06-09 18:20:57 -0700627 else:
628 Usage()
Adam Langley9e1a6602015-05-05 17:47:53 -0700629
Adam Langley049ef412015-06-09 18:20:57 -0700630 sys.exit(main(platforms))