Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

724 wiersze
24 KiB

  1. # 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. """Enumerates source files for consumption by various build systems."""
  15. import optparse
  16. import os
  17. import subprocess
  18. import sys
  19. import json
  20. # OS_ARCH_COMBOS maps from OS and platform to the OpenSSL assembly "style" for
  21. # that platform and the extension used by asm files.
  22. OS_ARCH_COMBOS = [
  23. ('linux', 'arm', 'linux32', [], 'S'),
  24. ('linux', 'aarch64', 'linux64', [], 'S'),
  25. ('linux', 'ppc64le', 'ppc64le', [], 'S'),
  26. ('linux', 'x86', 'elf', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'),
  27. ('linux', 'x86_64', 'elf', [], 'S'),
  28. ('mac', 'x86', 'macosx', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'),
  29. ('mac', 'x86_64', 'macosx', [], 'S'),
  30. ('win', 'x86', 'win32n', ['-DOPENSSL_IA32_SSE2'], 'asm'),
  31. ('win', 'x86_64', 'nasm', [], 'asm'),
  32. ]
  33. # NON_PERL_FILES enumerates assembly files that are not processed by the
  34. # perlasm system.
  35. NON_PERL_FILES = {
  36. ('linux', 'arm'): [
  37. 'src/crypto/curve25519/asm/x25519-asm-arm.S',
  38. 'src/crypto/poly1305/poly1305_arm_asm.S',
  39. ],
  40. ('linux', 'x86_64'): [
  41. 'src/crypto/curve25519/asm/x25519-asm-x86_64.S',
  42. ],
  43. ('mac', 'x86_64'): [
  44. 'src/crypto/curve25519/asm/x25519-asm-x86_64.S',
  45. ],
  46. }
  47. PREFIX = None
  48. def PathOf(x):
  49. return x if not PREFIX else os.path.join(PREFIX, x)
  50. class Android(object):
  51. def __init__(self):
  52. self.header = \
  53. """# Copyright (C) 2015 The Android Open Source Project
  54. #
  55. # Licensed under the Apache License, Version 2.0 (the "License");
  56. # you may not use this file except in compliance with the License.
  57. # You may obtain a copy of the License at
  58. #
  59. # http://www.apache.org/licenses/LICENSE-2.0
  60. #
  61. # Unless required by applicable law or agreed to in writing, software
  62. # distributed under the License is distributed on an "AS IS" BASIS,
  63. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  64. # See the License for the specific language governing permissions and
  65. # limitations under the License.
  66. # This file is created by generate_build_files.py. Do not edit manually.
  67. """
  68. def PrintVariableSection(self, out, name, files):
  69. out.write('%s := \\\n' % name)
  70. for f in sorted(files):
  71. out.write(' %s\\\n' % f)
  72. out.write('\n')
  73. def WriteFiles(self, files, asm_outputs):
  74. # New Android.bp format
  75. with open('sources.bp', 'w+') as blueprint:
  76. blueprint.write(self.header.replace('#', '//'))
  77. blueprint.write('cc_defaults {\n')
  78. blueprint.write(' name: "libcrypto_sources",\n')
  79. blueprint.write(' srcs: [\n')
  80. for f in sorted(files['crypto']):
  81. blueprint.write(' "%s",\n' % f)
  82. blueprint.write(' ],\n')
  83. blueprint.write(' target: {\n')
  84. for ((osname, arch), asm_files) in asm_outputs:
  85. if osname != 'linux' or arch == 'ppc64le':
  86. continue
  87. if arch == 'aarch64':
  88. arch = 'arm64'
  89. blueprint.write(' android_%s: {\n' % arch)
  90. blueprint.write(' srcs: [\n')
  91. for f in sorted(asm_files):
  92. blueprint.write(' "%s",\n' % f)
  93. blueprint.write(' ],\n')
  94. blueprint.write(' },\n')
  95. if arch == 'x86' or arch == 'x86_64':
  96. blueprint.write(' linux_%s: {\n' % arch)
  97. blueprint.write(' srcs: [\n')
  98. for f in sorted(asm_files):
  99. blueprint.write(' "%s",\n' % f)
  100. blueprint.write(' ],\n')
  101. blueprint.write(' },\n')
  102. blueprint.write(' },\n')
  103. blueprint.write('}\n\n')
  104. blueprint.write('cc_defaults {\n')
  105. blueprint.write(' name: "libssl_sources",\n')
  106. blueprint.write(' srcs: [\n')
  107. for f in sorted(files['ssl']):
  108. blueprint.write(' "%s",\n' % f)
  109. blueprint.write(' ],\n')
  110. blueprint.write('}\n\n')
  111. blueprint.write('cc_defaults {\n')
  112. blueprint.write(' name: "bssl_sources",\n')
  113. blueprint.write(' srcs: [\n')
  114. for f in sorted(files['tool']):
  115. blueprint.write(' "%s",\n' % f)
  116. blueprint.write(' ],\n')
  117. blueprint.write('}\n\n')
  118. blueprint.write('cc_defaults {\n')
  119. blueprint.write(' name: "boringssl_test_support_sources",\n')
  120. blueprint.write(' srcs: [\n')
  121. for f in sorted(files['test_support']):
  122. blueprint.write(' "%s",\n' % f)
  123. blueprint.write(' ],\n')
  124. blueprint.write('}\n\n')
  125. blueprint.write('cc_defaults {\n')
  126. blueprint.write(' name: "boringssl_tests_sources",\n')
  127. blueprint.write(' srcs: [\n')
  128. for f in sorted(files['test']):
  129. blueprint.write(' "%s",\n' % f)
  130. blueprint.write(' ],\n')
  131. blueprint.write('}\n')
  132. # Legacy Android.mk format, only used by Trusty in new branches
  133. with open('sources.mk', 'w+') as makefile:
  134. makefile.write(self.header)
  135. self.PrintVariableSection(makefile, 'crypto_sources', files['crypto'])
  136. for ((osname, arch), asm_files) in asm_outputs:
  137. if osname != 'linux':
  138. continue
  139. self.PrintVariableSection(
  140. makefile, '%s_%s_sources' % (osname, arch), asm_files)
  141. class Bazel(object):
  142. """Bazel outputs files suitable for including in Bazel files."""
  143. def __init__(self):
  144. self.firstSection = True
  145. self.header = \
  146. """# This file is created by generate_build_files.py. Do not edit manually.
  147. """
  148. def PrintVariableSection(self, out, name, files):
  149. if not self.firstSection:
  150. out.write('\n')
  151. self.firstSection = False
  152. out.write('%s = [\n' % name)
  153. for f in sorted(files):
  154. out.write(' "%s",\n' % PathOf(f))
  155. out.write(']\n')
  156. def WriteFiles(self, files, asm_outputs):
  157. with open('BUILD.generated.bzl', 'w+') as out:
  158. out.write(self.header)
  159. self.PrintVariableSection(out, 'ssl_headers', files['ssl_headers'])
  160. self.PrintVariableSection(
  161. out, 'ssl_internal_headers', files['ssl_internal_headers'])
  162. self.PrintVariableSection(out, 'ssl_sources', files['ssl'])
  163. self.PrintVariableSection(out, 'crypto_headers', files['crypto_headers'])
  164. self.PrintVariableSection(
  165. out, 'crypto_internal_headers', files['crypto_internal_headers'])
  166. self.PrintVariableSection(out, 'crypto_sources', files['crypto'])
  167. self.PrintVariableSection(out, 'tool_sources', files['tool'])
  168. self.PrintVariableSection(out, 'tool_headers', files['tool_headers'])
  169. for ((osname, arch), asm_files) in asm_outputs:
  170. self.PrintVariableSection(
  171. out, 'crypto_sources_%s_%s' % (osname, arch), asm_files)
  172. with open('BUILD.generated_tests.bzl', 'w+') as out:
  173. out.write(self.header)
  174. out.write('test_support_sources = [\n')
  175. for filename in sorted(files['test_support'] +
  176. files['test_support_headers'] +
  177. files['crypto_internal_headers'] +
  178. files['ssl_internal_headers']):
  179. if os.path.basename(filename) == 'malloc.cc':
  180. continue
  181. out.write(' "%s",\n' % PathOf(filename))
  182. out.write(']\n\n')
  183. out.write('def create_tests(copts, crypto, ssl):\n')
  184. name_counts = {}
  185. for test in files['tests']:
  186. name = os.path.basename(test[0])
  187. name_counts[name] = name_counts.get(name, 0) + 1
  188. first = True
  189. for test in files['tests']:
  190. name = os.path.basename(test[0])
  191. if name_counts[name] > 1:
  192. if '/' in test[1]:
  193. name += '_' + os.path.splitext(os.path.basename(test[1]))[0]
  194. else:
  195. name += '_' + test[1].replace('-', '_')
  196. if not first:
  197. out.write('\n')
  198. first = False
  199. src_prefix = 'src/' + test[0]
  200. for src in files['test']:
  201. if src.startswith(src_prefix):
  202. src = src
  203. break
  204. else:
  205. raise ValueError("Can't find source for %s" % test[0])
  206. out.write(' native.cc_test(\n')
  207. out.write(' name = "%s",\n' % name)
  208. out.write(' size = "small",\n')
  209. out.write(' srcs = ["%s"] + test_support_sources,\n' %
  210. PathOf(src))
  211. data_files = []
  212. if len(test) > 1:
  213. out.write(' args = [\n')
  214. for arg in test[1:]:
  215. if '/' in arg:
  216. out.write(' "$(location %s)",\n' %
  217. PathOf(os.path.join('src', arg)))
  218. data_files.append('src/%s' % arg)
  219. else:
  220. out.write(' "%s",\n' % arg)
  221. out.write(' ],\n')
  222. out.write(' copts = copts,\n')
  223. if len(data_files) > 0:
  224. out.write(' data = [\n')
  225. for filename in data_files:
  226. out.write(' "%s",\n' % PathOf(filename))
  227. out.write(' ],\n')
  228. if 'ssl/' in test[0]:
  229. out.write(' deps = [\n')
  230. out.write(' crypto,\n')
  231. out.write(' ssl,\n')
  232. out.write(' ],\n')
  233. else:
  234. out.write(' deps = [crypto],\n')
  235. out.write(' )\n')
  236. class GN(object):
  237. def __init__(self):
  238. self.firstSection = True
  239. self.header = \
  240. """# Copyright (c) 2016 The Chromium Authors. All rights reserved.
  241. # Use of this source code is governed by a BSD-style license that can be
  242. # found in the LICENSE file.
  243. # This file is created by generate_build_files.py. Do not edit manually.
  244. """
  245. def PrintVariableSection(self, out, name, files):
  246. if not self.firstSection:
  247. out.write('\n')
  248. self.firstSection = False
  249. out.write('%s = [\n' % name)
  250. for f in sorted(files):
  251. out.write(' "%s",\n' % f)
  252. out.write(']\n')
  253. def WriteFiles(self, files, asm_outputs):
  254. with open('BUILD.generated.gni', 'w+') as out:
  255. out.write(self.header)
  256. self.PrintVariableSection(out, 'crypto_sources',
  257. files['crypto'] + files['crypto_headers'] +
  258. files['crypto_internal_headers'])
  259. self.PrintVariableSection(out, 'ssl_sources',
  260. files['ssl'] + files['ssl_headers'] +
  261. files['ssl_internal_headers'])
  262. for ((osname, arch), asm_files) in asm_outputs:
  263. self.PrintVariableSection(
  264. out, 'crypto_sources_%s_%s' % (osname, arch), asm_files)
  265. fuzzers = [os.path.splitext(os.path.basename(fuzzer))[0]
  266. for fuzzer in files['fuzz']]
  267. self.PrintVariableSection(out, 'fuzzers', fuzzers)
  268. with open('BUILD.generated_tests.gni', 'w+') as out:
  269. self.firstSection = True
  270. out.write(self.header)
  271. self.PrintVariableSection(out, '_test_support_sources',
  272. files['test_support'] +
  273. files['test_support_headers'])
  274. out.write('\n')
  275. out.write('template("create_tests") {\n')
  276. all_tests = []
  277. for test in sorted(files['test']):
  278. test_name = 'boringssl_%s' % os.path.splitext(os.path.basename(test))[0]
  279. all_tests.append(test_name)
  280. out.write(' executable("%s") {\n' % test_name)
  281. out.write(' sources = [\n')
  282. out.write(' "%s",\n' % test)
  283. out.write(' ]\n')
  284. out.write(' sources += _test_support_sources\n')
  285. out.write(' if (defined(invoker.configs_exclude)) {\n')
  286. out.write(' configs -= invoker.configs_exclude\n')
  287. out.write(' }\n')
  288. out.write(' configs += invoker.configs\n')
  289. out.write(' deps = invoker.deps\n')
  290. out.write(' }\n')
  291. out.write('\n')
  292. out.write(' group(target_name) {\n')
  293. out.write(' deps = [\n')
  294. for test_name in sorted(all_tests):
  295. out.write(' ":%s",\n' % test_name)
  296. out.write(' ]\n')
  297. out.write(' }\n')
  298. out.write('}\n')
  299. class GYP(object):
  300. def __init__(self):
  301. self.header = \
  302. """# Copyright (c) 2016 The Chromium Authors. All rights reserved.
  303. # Use of this source code is governed by a BSD-style license that can be
  304. # found in the LICENSE file.
  305. # This file is created by generate_build_files.py. Do not edit manually.
  306. """
  307. def PrintVariableSection(self, out, name, files):
  308. out.write(' \'%s\': [\n' % name)
  309. for f in sorted(files):
  310. out.write(' \'%s\',\n' % f)
  311. out.write(' ],\n')
  312. def WriteFiles(self, files, asm_outputs):
  313. with open('boringssl.gypi', 'w+') as gypi:
  314. gypi.write(self.header + '{\n \'variables\': {\n')
  315. self.PrintVariableSection(gypi, 'boringssl_ssl_sources',
  316. files['ssl'] + files['ssl_headers'] +
  317. files['ssl_internal_headers'])
  318. self.PrintVariableSection(gypi, 'boringssl_crypto_sources',
  319. files['crypto'] + files['crypto_headers'] +
  320. files['crypto_internal_headers'])
  321. for ((osname, arch), asm_files) in asm_outputs:
  322. self.PrintVariableSection(gypi, 'boringssl_%s_%s_sources' %
  323. (osname, arch), asm_files)
  324. gypi.write(' }\n}\n')
  325. with open('boringssl_tests.gypi', 'w+') as test_gypi:
  326. test_gypi.write(self.header + '{\n \'targets\': [\n')
  327. test_names = []
  328. for test in sorted(files['test']):
  329. test_name = 'boringssl_%s' % os.path.splitext(os.path.basename(test))[0]
  330. test_gypi.write(""" {
  331. 'target_name': '%s',
  332. 'type': 'executable',
  333. 'dependencies': [
  334. 'boringssl.gyp:boringssl',
  335. ],
  336. 'sources': [
  337. '%s',
  338. '<@(boringssl_test_support_sources)',
  339. ],
  340. # TODO(davidben): Fix size_t truncations in BoringSSL.
  341. # https://crbug.com/429039
  342. 'msvs_disabled_warnings': [ 4267, ],
  343. },\n""" % (test_name, test))
  344. test_names.append(test_name)
  345. test_names.sort()
  346. test_gypi.write(' ],\n \'variables\': {\n')
  347. self.PrintVariableSection(test_gypi, 'boringssl_test_support_sources',
  348. files['test_support'] +
  349. files['test_support_headers'])
  350. test_gypi.write(' \'boringssl_test_targets\': [\n')
  351. for test in sorted(test_names):
  352. test_gypi.write(""" '%s',\n""" % test)
  353. test_gypi.write(' ],\n }\n}\n')
  354. def FindCMakeFiles(directory):
  355. """Returns list of all CMakeLists.txt files recursively in directory."""
  356. cmakefiles = []
  357. for (path, _, filenames) in os.walk(directory):
  358. for filename in filenames:
  359. if filename == 'CMakeLists.txt':
  360. cmakefiles.append(os.path.join(path, filename))
  361. return cmakefiles
  362. def NoTests(dent, is_dir):
  363. """Filter function that can be passed to FindCFiles in order to remove test
  364. sources."""
  365. if is_dir:
  366. return dent != 'test'
  367. return 'test.' not in dent and not dent.startswith('example_')
  368. def OnlyTests(dent, is_dir):
  369. """Filter function that can be passed to FindCFiles in order to remove
  370. non-test sources."""
  371. if is_dir:
  372. return dent != 'test'
  373. return '_test.' in dent or dent.startswith('example_')
  374. def AllFiles(dent, is_dir):
  375. """Filter function that can be passed to FindCFiles in order to include all
  376. sources."""
  377. return True
  378. def SSLHeaderFiles(dent, is_dir):
  379. return dent in ['ssl.h', 'tls1.h', 'ssl23.h', 'ssl3.h', 'dtls1.h']
  380. def FindCFiles(directory, filter_func):
  381. """Recurses through directory and returns a list of paths to all the C source
  382. files that pass filter_func."""
  383. cfiles = []
  384. for (path, dirnames, filenames) in os.walk(directory):
  385. for filename in filenames:
  386. if not filename.endswith('.c') and not filename.endswith('.cc'):
  387. continue
  388. if not filter_func(filename, False):
  389. continue
  390. cfiles.append(os.path.join(path, filename))
  391. for (i, dirname) in enumerate(dirnames):
  392. if not filter_func(dirname, True):
  393. del dirnames[i]
  394. return cfiles
  395. def FindHeaderFiles(directory, filter_func):
  396. """Recurses through directory and returns a list of paths to all the header files that pass filter_func."""
  397. hfiles = []
  398. for (path, dirnames, filenames) in os.walk(directory):
  399. for filename in filenames:
  400. if not filename.endswith('.h'):
  401. continue
  402. if not filter_func(filename, False):
  403. continue
  404. hfiles.append(os.path.join(path, filename))
  405. for (i, dirname) in enumerate(dirnames):
  406. if not filter_func(dirname, True):
  407. del dirnames[i]
  408. return hfiles
  409. def ExtractPerlAsmFromCMakeFile(cmakefile):
  410. """Parses the contents of the CMakeLists.txt file passed as an argument and
  411. returns a list of all the perlasm() directives found in the file."""
  412. perlasms = []
  413. with open(cmakefile) as f:
  414. for line in f:
  415. line = line.strip()
  416. if not line.startswith('perlasm('):
  417. continue
  418. if not line.endswith(')'):
  419. raise ValueError('Bad perlasm line in %s' % cmakefile)
  420. # Remove "perlasm(" from start and ")" from end
  421. params = line[8:-1].split()
  422. if len(params) < 2:
  423. raise ValueError('Bad perlasm line in %s' % cmakefile)
  424. perlasms.append({
  425. 'extra_args': params[2:],
  426. 'input': os.path.join(os.path.dirname(cmakefile), params[1]),
  427. 'output': os.path.join(os.path.dirname(cmakefile), params[0]),
  428. })
  429. return perlasms
  430. def ReadPerlAsmOperations():
  431. """Returns a list of all perlasm() directives found in CMake config files in
  432. src/."""
  433. perlasms = []
  434. cmakefiles = FindCMakeFiles('src')
  435. for cmakefile in cmakefiles:
  436. perlasms.extend(ExtractPerlAsmFromCMakeFile(cmakefile))
  437. return perlasms
  438. def PerlAsm(output_filename, input_filename, perlasm_style, extra_args):
  439. """Runs the a perlasm script and puts the output into output_filename."""
  440. base_dir = os.path.dirname(output_filename)
  441. if not os.path.isdir(base_dir):
  442. os.makedirs(base_dir)
  443. subprocess.check_call(
  444. ['perl', input_filename, perlasm_style] + extra_args + [output_filename])
  445. def ArchForAsmFilename(filename):
  446. """Returns the architectures that a given asm file should be compiled for
  447. based on substrings in the filename."""
  448. if 'x86_64' in filename or 'avx2' in filename:
  449. return ['x86_64']
  450. elif ('x86' in filename and 'x86_64' not in filename) or '586' in filename:
  451. return ['x86']
  452. elif 'armx' in filename:
  453. return ['arm', 'aarch64']
  454. elif 'armv8' in filename:
  455. return ['aarch64']
  456. elif 'arm' in filename:
  457. return ['arm']
  458. elif 'ppc' in filename:
  459. return ['ppc64le']
  460. else:
  461. raise ValueError('Unknown arch for asm filename: ' + filename)
  462. def WriteAsmFiles(perlasms):
  463. """Generates asm files from perlasm directives for each supported OS x
  464. platform combination."""
  465. asmfiles = {}
  466. for osarch in OS_ARCH_COMBOS:
  467. (osname, arch, perlasm_style, extra_args, asm_ext) = osarch
  468. key = (osname, arch)
  469. outDir = '%s-%s' % key
  470. for perlasm in perlasms:
  471. filename = os.path.basename(perlasm['input'])
  472. output = perlasm['output']
  473. if not output.startswith('src'):
  474. raise ValueError('output missing src: %s' % output)
  475. output = os.path.join(outDir, output[4:])
  476. if output.endswith('-armx.${ASM_EXT}'):
  477. output = output.replace('-armx',
  478. '-armx64' if arch == 'aarch64' else '-armx32')
  479. output = output.replace('${ASM_EXT}', asm_ext)
  480. if arch in ArchForAsmFilename(filename):
  481. PerlAsm(output, perlasm['input'], perlasm_style,
  482. perlasm['extra_args'] + extra_args)
  483. asmfiles.setdefault(key, []).append(output)
  484. for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems():
  485. asmfiles.setdefault(key, []).extend(non_perl_asm_files)
  486. return asmfiles
  487. def main(platforms):
  488. crypto_c_files = FindCFiles(os.path.join('src', 'crypto'), NoTests)
  489. ssl_c_files = FindCFiles(os.path.join('src', 'ssl'), NoTests)
  490. tool_c_files = FindCFiles(os.path.join('src', 'tool'), NoTests)
  491. tool_h_files = FindHeaderFiles(os.path.join('src', 'tool'), AllFiles)
  492. # Generate err_data.c
  493. with open('err_data.c', 'w+') as err_data:
  494. subprocess.check_call(['go', 'run', 'err_data_generate.go'],
  495. cwd=os.path.join('src', 'crypto', 'err'),
  496. stdout=err_data)
  497. crypto_c_files.append('err_data.c')
  498. test_support_c_files = FindCFiles(os.path.join('src', 'crypto', 'test'),
  499. AllFiles)
  500. test_support_h_files = (
  501. FindHeaderFiles(os.path.join('src', 'crypto', 'test'), AllFiles) +
  502. FindHeaderFiles(os.path.join('src', 'ssl', 'test'), AllFiles))
  503. test_c_files = FindCFiles(os.path.join('src', 'crypto'), OnlyTests)
  504. test_c_files += FindCFiles(os.path.join('src', 'ssl'), OnlyTests)
  505. fuzz_c_files = FindCFiles(os.path.join('src', 'fuzz'), NoTests)
  506. ssl_h_files = (
  507. FindHeaderFiles(
  508. os.path.join('src', 'include', 'openssl'),
  509. SSLHeaderFiles))
  510. def NotSSLHeaderFiles(filename, is_dir):
  511. return not SSLHeaderFiles(filename, is_dir)
  512. crypto_h_files = (
  513. FindHeaderFiles(
  514. os.path.join('src', 'include', 'openssl'),
  515. NotSSLHeaderFiles))
  516. ssl_internal_h_files = FindHeaderFiles(os.path.join('src', 'ssl'), NoTests)
  517. crypto_internal_h_files = FindHeaderFiles(
  518. os.path.join('src', 'crypto'), NoTests)
  519. with open('src/util/all_tests.json', 'r') as f:
  520. tests = json.load(f)
  521. # Skip tests for libdecrepit. Consumers import that manually.
  522. tests = [test for test in tests if not test[0].startswith("decrepit/")]
  523. test_binaries = set([test[0] for test in tests])
  524. test_sources = set([
  525. test.replace('.cc', '').replace('.c', '').replace(
  526. 'src/',
  527. '')
  528. for test in test_c_files])
  529. if test_binaries != test_sources:
  530. print 'Test sources and configured tests do not match'
  531. a = test_binaries.difference(test_sources)
  532. if len(a) > 0:
  533. print 'These tests are configured without sources: ' + str(a)
  534. b = test_sources.difference(test_binaries)
  535. if len(b) > 0:
  536. print 'These test sources are not configured: ' + str(b)
  537. files = {
  538. 'crypto': crypto_c_files,
  539. 'crypto_headers': crypto_h_files,
  540. 'crypto_internal_headers': crypto_internal_h_files,
  541. 'fuzz': fuzz_c_files,
  542. 'ssl': ssl_c_files,
  543. 'ssl_headers': ssl_h_files,
  544. 'ssl_internal_headers': ssl_internal_h_files,
  545. 'tool': tool_c_files,
  546. 'tool_headers': tool_h_files,
  547. 'test': test_c_files,
  548. 'test_support': test_support_c_files,
  549. 'test_support_headers': test_support_h_files,
  550. 'tests': tests,
  551. }
  552. asm_outputs = sorted(WriteAsmFiles(ReadPerlAsmOperations()).iteritems())
  553. for platform in platforms:
  554. platform.WriteFiles(files, asm_outputs)
  555. return 0
  556. if __name__ == '__main__':
  557. parser = optparse.OptionParser(usage='Usage: %prog [--prefix=<path>]'
  558. ' [android|bazel|gn|gyp]')
  559. parser.add_option('--prefix', dest='prefix',
  560. help='For Bazel, prepend argument to all source files')
  561. options, args = parser.parse_args(sys.argv[1:])
  562. PREFIX = options.prefix
  563. if not args:
  564. parser.print_help()
  565. sys.exit(1)
  566. platforms = []
  567. for s in args:
  568. if s == 'android':
  569. platforms.append(Android())
  570. elif s == 'bazel':
  571. platforms.append(Bazel())
  572. elif s == 'gn':
  573. platforms.append(GN())
  574. elif s == 'gyp':
  575. platforms.append(GYP())
  576. else:
  577. parser.print_help()
  578. sys.exit(1)
  579. sys.exit(main(platforms))