No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

716 líneas
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. ('ios', 'arm', 'ios32', [], 'S'),
  24. ('ios', 'aarch64', 'ios64', [], 'S'),
  25. ('linux', 'arm', 'linux32', [], 'S'),
  26. ('linux', 'aarch64', 'linux64', [], 'S'),
  27. ('linux', 'ppc64le', 'linux64le', [], 'S'),
  28. ('linux', 'x86', 'elf', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'),
  29. ('linux', 'x86_64', 'elf', [], 'S'),
  30. ('mac', 'x86', 'macosx', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'),
  31. ('mac', 'x86_64', 'macosx', [], 'S'),
  32. ('win', 'x86', 'win32n', ['-DOPENSSL_IA32_SSE2'], 'asm'),
  33. ('win', 'x86_64', 'nasm', [], 'asm'),
  34. ]
  35. # NON_PERL_FILES enumerates assembly files that are not processed by the
  36. # perlasm system.
  37. NON_PERL_FILES = {
  38. ('linux', 'arm'): [
  39. 'src/crypto/curve25519/asm/x25519-asm-arm.S',
  40. 'src/crypto/poly1305/poly1305_arm_asm.S',
  41. ],
  42. ('linux', 'x86_64'): [
  43. 'src/crypto/hrss/asm/poly_rq_mul.S',
  44. ],
  45. }
  46. PREFIX = None
  47. EMBED_TEST_DATA = True
  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(' linux_%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. blueprint.write(' },\n')
  96. blueprint.write('}\n\n')
  97. blueprint.write('cc_defaults {\n')
  98. blueprint.write(' name: "libssl_sources",\n')
  99. blueprint.write(' srcs: [\n')
  100. for f in sorted(files['ssl']):
  101. blueprint.write(' "%s",\n' % f)
  102. blueprint.write(' ],\n')
  103. blueprint.write('}\n\n')
  104. blueprint.write('cc_defaults {\n')
  105. blueprint.write(' name: "bssl_sources",\n')
  106. blueprint.write(' srcs: [\n')
  107. for f in sorted(files['tool']):
  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: "boringssl_test_support_sources",\n')
  113. blueprint.write(' srcs: [\n')
  114. for f in sorted(files['test_support']):
  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_crypto_test_sources",\n')
  120. blueprint.write(' srcs: [\n')
  121. for f in sorted(files['crypto_test']):
  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_ssl_test_sources",\n')
  127. blueprint.write(' srcs: [\n')
  128. for f in sorted(files['ssl_test']):
  129. blueprint.write(' "%s",\n' % f)
  130. blueprint.write(' ],\n')
  131. blueprint.write('}\n\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(out, 'fips_fragments', files['fips_fragments'])
  161. self.PrintVariableSection(
  162. out, 'ssl_internal_headers', files['ssl_internal_headers'])
  163. self.PrintVariableSection(out, 'ssl_sources', files['ssl'])
  164. self.PrintVariableSection(out, 'crypto_headers', files['crypto_headers'])
  165. self.PrintVariableSection(
  166. out, 'crypto_internal_headers', files['crypto_internal_headers'])
  167. self.PrintVariableSection(out, 'crypto_sources', files['crypto'])
  168. self.PrintVariableSection(out, 'tool_sources', files['tool'])
  169. self.PrintVariableSection(out, 'tool_headers', files['tool_headers'])
  170. for ((osname, arch), asm_files) in asm_outputs:
  171. self.PrintVariableSection(
  172. out, 'crypto_sources_%s_%s' % (osname, arch), asm_files)
  173. with open('BUILD.generated_tests.bzl', 'w+') as out:
  174. out.write(self.header)
  175. out.write('test_support_sources = [\n')
  176. for filename in sorted(files['test_support'] +
  177. files['test_support_headers'] +
  178. files['crypto_internal_headers'] +
  179. files['ssl_internal_headers']):
  180. if os.path.basename(filename) == 'malloc.cc':
  181. continue
  182. out.write(' "%s",\n' % PathOf(filename))
  183. out.write(']\n')
  184. self.PrintVariableSection(out, 'crypto_test_sources',
  185. files['crypto_test'])
  186. self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test'])
  187. self.PrintVariableSection(out, 'crypto_test_data',
  188. files['crypto_test_data'])
  189. class Eureka(object):
  190. def __init__(self):
  191. self.header = \
  192. """# Copyright (C) 2017 The Android Open Source Project
  193. #
  194. # Licensed under the Apache License, Version 2.0 (the "License");
  195. # you may not use this file except in compliance with the License.
  196. # You may obtain a copy of the License at
  197. #
  198. # http://www.apache.org/licenses/LICENSE-2.0
  199. #
  200. # Unless required by applicable law or agreed to in writing, software
  201. # distributed under the License is distributed on an "AS IS" BASIS,
  202. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  203. # See the License for the specific language governing permissions and
  204. # limitations under the License.
  205. # This file is created by generate_build_files.py. Do not edit manually.
  206. """
  207. def PrintVariableSection(self, out, name, files):
  208. out.write('%s := \\\n' % name)
  209. for f in sorted(files):
  210. out.write(' %s\\\n' % f)
  211. out.write('\n')
  212. def WriteFiles(self, files, asm_outputs):
  213. # Legacy Android.mk format
  214. with open('eureka.mk', 'w+') as makefile:
  215. makefile.write(self.header)
  216. self.PrintVariableSection(makefile, 'crypto_sources', files['crypto'])
  217. self.PrintVariableSection(makefile, 'ssl_sources', files['ssl'])
  218. self.PrintVariableSection(makefile, 'tool_sources', files['tool'])
  219. for ((osname, arch), asm_files) in asm_outputs:
  220. if osname != 'linux':
  221. continue
  222. self.PrintVariableSection(
  223. makefile, '%s_%s_sources' % (osname, arch), asm_files)
  224. class GN(object):
  225. def __init__(self):
  226. self.firstSection = True
  227. self.header = \
  228. """# Copyright (c) 2016 The Chromium Authors. All rights reserved.
  229. # Use of this source code is governed by a BSD-style license that can be
  230. # found in the LICENSE file.
  231. # This file is created by generate_build_files.py. Do not edit manually.
  232. """
  233. def PrintVariableSection(self, out, name, files):
  234. if not self.firstSection:
  235. out.write('\n')
  236. self.firstSection = False
  237. out.write('%s = [\n' % name)
  238. for f in sorted(files):
  239. out.write(' "%s",\n' % f)
  240. out.write(']\n')
  241. def WriteFiles(self, files, asm_outputs):
  242. with open('BUILD.generated.gni', 'w+') as out:
  243. out.write(self.header)
  244. self.PrintVariableSection(out, 'crypto_sources',
  245. files['crypto'] +
  246. files['crypto_internal_headers'])
  247. self.PrintVariableSection(out, 'crypto_headers',
  248. files['crypto_headers'])
  249. self.PrintVariableSection(out, 'ssl_sources',
  250. files['ssl'] + files['ssl_internal_headers'])
  251. self.PrintVariableSection(out, 'ssl_headers', files['ssl_headers'])
  252. for ((osname, arch), asm_files) in asm_outputs:
  253. self.PrintVariableSection(
  254. out, 'crypto_sources_%s_%s' % (osname, arch), asm_files)
  255. fuzzers = [os.path.splitext(os.path.basename(fuzzer))[0]
  256. for fuzzer in files['fuzz']]
  257. self.PrintVariableSection(out, 'fuzzers', fuzzers)
  258. with open('BUILD.generated_tests.gni', 'w+') as out:
  259. self.firstSection = True
  260. out.write(self.header)
  261. self.PrintVariableSection(out, 'test_support_sources',
  262. files['test_support'] +
  263. files['test_support_headers'])
  264. self.PrintVariableSection(out, 'crypto_test_sources',
  265. files['crypto_test'])
  266. self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test'])
  267. class GYP(object):
  268. def __init__(self):
  269. self.header = \
  270. """# Copyright (c) 2016 The Chromium Authors. All rights reserved.
  271. # Use of this source code is governed by a BSD-style license that can be
  272. # found in the LICENSE file.
  273. # This file is created by generate_build_files.py. Do not edit manually.
  274. """
  275. def PrintVariableSection(self, out, name, files):
  276. out.write(' \'%s\': [\n' % name)
  277. for f in sorted(files):
  278. out.write(' \'%s\',\n' % f)
  279. out.write(' ],\n')
  280. def WriteFiles(self, files, asm_outputs):
  281. with open('boringssl.gypi', 'w+') as gypi:
  282. gypi.write(self.header + '{\n \'variables\': {\n')
  283. self.PrintVariableSection(gypi, 'boringssl_ssl_sources',
  284. files['ssl'] + files['ssl_headers'] +
  285. files['ssl_internal_headers'])
  286. self.PrintVariableSection(gypi, 'boringssl_crypto_sources',
  287. files['crypto'] + files['crypto_headers'] +
  288. files['crypto_internal_headers'])
  289. for ((osname, arch), asm_files) in asm_outputs:
  290. self.PrintVariableSection(gypi, 'boringssl_%s_%s_sources' %
  291. (osname, arch), asm_files)
  292. gypi.write(' }\n}\n')
  293. def FindCMakeFiles(directory):
  294. """Returns list of all CMakeLists.txt files recursively in directory."""
  295. cmakefiles = []
  296. for (path, _, filenames) in os.walk(directory):
  297. for filename in filenames:
  298. if filename == 'CMakeLists.txt':
  299. cmakefiles.append(os.path.join(path, filename))
  300. return cmakefiles
  301. def OnlyFIPSFragments(path, dent, is_dir):
  302. return is_dir or (path.startswith(
  303. os.path.join('src', 'crypto', 'fipsmodule', '')) and
  304. NoTests(path, dent, is_dir))
  305. def NoTestsNorFIPSFragments(path, dent, is_dir):
  306. return (NoTests(path, dent, is_dir) and
  307. (is_dir or not OnlyFIPSFragments(path, dent, is_dir)))
  308. def NoTests(path, dent, is_dir):
  309. """Filter function that can be passed to FindCFiles in order to remove test
  310. sources."""
  311. if is_dir:
  312. return dent != 'test'
  313. return 'test.' not in dent
  314. def OnlyTests(path, dent, is_dir):
  315. """Filter function that can be passed to FindCFiles in order to remove
  316. non-test sources."""
  317. if is_dir:
  318. return dent != 'test'
  319. return '_test.' in dent
  320. def AllFiles(path, dent, is_dir):
  321. """Filter function that can be passed to FindCFiles in order to include all
  322. sources."""
  323. return True
  324. def NoTestRunnerFiles(path, dent, is_dir):
  325. """Filter function that can be passed to FindCFiles or FindHeaderFiles in
  326. order to exclude test runner files."""
  327. # NOTE(martinkr): This prevents .h/.cc files in src/ssl/test/runner, which
  328. # are in their own subpackage, from being included in boringssl/BUILD files.
  329. return not is_dir or dent != 'runner'
  330. def NotGTestSupport(path, dent, is_dir):
  331. return 'gtest' not in dent
  332. def SSLHeaderFiles(path, dent, is_dir):
  333. return dent in ['ssl.h', 'tls1.h', 'ssl23.h', 'ssl3.h', 'dtls1.h', 'srtp.h']
  334. def FindCFiles(directory, filter_func):
  335. """Recurses through directory and returns a list of paths to all the C source
  336. files that pass filter_func."""
  337. cfiles = []
  338. for (path, dirnames, filenames) in os.walk(directory):
  339. for filename in filenames:
  340. if not filename.endswith('.c') and not filename.endswith('.cc'):
  341. continue
  342. if not filter_func(path, filename, False):
  343. continue
  344. cfiles.append(os.path.join(path, filename))
  345. for (i, dirname) in enumerate(dirnames):
  346. if not filter_func(path, dirname, True):
  347. del dirnames[i]
  348. return cfiles
  349. def FindHeaderFiles(directory, filter_func):
  350. """Recurses through directory and returns a list of paths to all the header files that pass filter_func."""
  351. hfiles = []
  352. for (path, dirnames, filenames) in os.walk(directory):
  353. for filename in filenames:
  354. if not filename.endswith('.h'):
  355. continue
  356. if not filter_func(path, filename, False):
  357. continue
  358. hfiles.append(os.path.join(path, filename))
  359. for (i, dirname) in enumerate(dirnames):
  360. if not filter_func(path, dirname, True):
  361. del dirnames[i]
  362. return hfiles
  363. def ExtractPerlAsmFromCMakeFile(cmakefile):
  364. """Parses the contents of the CMakeLists.txt file passed as an argument and
  365. returns a list of all the perlasm() directives found in the file."""
  366. perlasms = []
  367. with open(cmakefile) as f:
  368. for line in f:
  369. line = line.strip()
  370. if not line.startswith('perlasm('):
  371. continue
  372. if not line.endswith(')'):
  373. raise ValueError('Bad perlasm line in %s' % cmakefile)
  374. # Remove "perlasm(" from start and ")" from end
  375. params = line[8:-1].split()
  376. if len(params) < 2:
  377. raise ValueError('Bad perlasm line in %s' % cmakefile)
  378. perlasms.append({
  379. 'extra_args': params[2:],
  380. 'input': os.path.join(os.path.dirname(cmakefile), params[1]),
  381. 'output': os.path.join(os.path.dirname(cmakefile), params[0]),
  382. })
  383. return perlasms
  384. def ReadPerlAsmOperations():
  385. """Returns a list of all perlasm() directives found in CMake config files in
  386. src/."""
  387. perlasms = []
  388. cmakefiles = FindCMakeFiles('src')
  389. for cmakefile in cmakefiles:
  390. perlasms.extend(ExtractPerlAsmFromCMakeFile(cmakefile))
  391. return perlasms
  392. def PerlAsm(output_filename, input_filename, perlasm_style, extra_args):
  393. """Runs the a perlasm script and puts the output into output_filename."""
  394. base_dir = os.path.dirname(output_filename)
  395. if not os.path.isdir(base_dir):
  396. os.makedirs(base_dir)
  397. subprocess.check_call(
  398. ['perl', input_filename, perlasm_style] + extra_args + [output_filename])
  399. def ArchForAsmFilename(filename):
  400. """Returns the architectures that a given asm file should be compiled for
  401. based on substrings in the filename."""
  402. if 'x86_64' in filename or 'avx2' in filename:
  403. return ['x86_64']
  404. elif ('x86' in filename and 'x86_64' not in filename) or '586' in filename:
  405. return ['x86']
  406. elif 'armx' in filename:
  407. return ['arm', 'aarch64']
  408. elif 'armv8' in filename:
  409. return ['aarch64']
  410. elif 'arm' in filename:
  411. return ['arm']
  412. elif 'ppc' in filename:
  413. return ['ppc64le']
  414. else:
  415. raise ValueError('Unknown arch for asm filename: ' + filename)
  416. def WriteAsmFiles(perlasms):
  417. """Generates asm files from perlasm directives for each supported OS x
  418. platform combination."""
  419. asmfiles = {}
  420. for osarch in OS_ARCH_COMBOS:
  421. (osname, arch, perlasm_style, extra_args, asm_ext) = osarch
  422. key = (osname, arch)
  423. outDir = '%s-%s' % key
  424. for perlasm in perlasms:
  425. filename = os.path.basename(perlasm['input'])
  426. output = perlasm['output']
  427. if not output.startswith('src'):
  428. raise ValueError('output missing src: %s' % output)
  429. output = os.path.join(outDir, output[4:])
  430. if output.endswith('-armx.${ASM_EXT}'):
  431. output = output.replace('-armx',
  432. '-armx64' if arch == 'aarch64' else '-armx32')
  433. output = output.replace('${ASM_EXT}', asm_ext)
  434. if arch in ArchForAsmFilename(filename):
  435. PerlAsm(output, perlasm['input'], perlasm_style,
  436. perlasm['extra_args'] + extra_args)
  437. asmfiles.setdefault(key, []).append(output)
  438. for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems():
  439. asmfiles.setdefault(key, []).extend(non_perl_asm_files)
  440. return asmfiles
  441. def ExtractVariablesFromCMakeFile(cmakefile):
  442. """Parses the contents of the CMakeLists.txt file passed as an argument and
  443. returns a dictionary of exported source lists."""
  444. variables = {}
  445. in_set_command = False
  446. set_command = []
  447. with open(cmakefile) as f:
  448. for line in f:
  449. if '#' in line:
  450. line = line[:line.index('#')]
  451. line = line.strip()
  452. if not in_set_command:
  453. if line.startswith('set('):
  454. in_set_command = True
  455. set_command = []
  456. elif line == ')':
  457. in_set_command = False
  458. if not set_command:
  459. raise ValueError('Empty set command')
  460. variables[set_command[0]] = set_command[1:]
  461. else:
  462. set_command.extend([c for c in line.split(' ') if c])
  463. if in_set_command:
  464. raise ValueError('Unfinished set command')
  465. return variables
  466. def main(platforms):
  467. cmake = ExtractVariablesFromCMakeFile(os.path.join('src', 'sources.cmake'))
  468. crypto_c_files = (FindCFiles(os.path.join('src', 'crypto'), NoTestsNorFIPSFragments) +
  469. FindCFiles(os.path.join('src', 'third_party', 'fiat'), NoTestsNorFIPSFragments))
  470. fips_fragments = FindCFiles(os.path.join('src', 'crypto', 'fipsmodule'), OnlyFIPSFragments)
  471. ssl_source_files = FindCFiles(os.path.join('src', 'ssl'), NoTests)
  472. tool_c_files = FindCFiles(os.path.join('src', 'tool'), NoTests)
  473. tool_h_files = FindHeaderFiles(os.path.join('src', 'tool'), AllFiles)
  474. # third_party/fiat/p256.c lives in third_party/fiat, but it is a FIPS
  475. # fragment, not a normal source file.
  476. p256 = os.path.join('src', 'third_party', 'fiat', 'p256.c')
  477. fips_fragments.append(p256)
  478. crypto_c_files.remove(p256)
  479. # Generate err_data.c
  480. with open('err_data.c', 'w+') as err_data:
  481. subprocess.check_call(['go', 'run', 'err_data_generate.go'],
  482. cwd=os.path.join('src', 'crypto', 'err'),
  483. stdout=err_data)
  484. crypto_c_files.append('err_data.c')
  485. test_support_c_files = FindCFiles(os.path.join('src', 'crypto', 'test'),
  486. NotGTestSupport)
  487. test_support_h_files = (
  488. FindHeaderFiles(os.path.join('src', 'crypto', 'test'), AllFiles) +
  489. FindHeaderFiles(os.path.join('src', 'ssl', 'test'), NoTestRunnerFiles))
  490. crypto_test_files = []
  491. if EMBED_TEST_DATA:
  492. # Generate crypto_test_data.cc
  493. with open('crypto_test_data.cc', 'w+') as out:
  494. subprocess.check_call(
  495. ['go', 'run', 'util/embed_test_data.go'] + cmake['CRYPTO_TEST_DATA'],
  496. cwd='src',
  497. stdout=out)
  498. crypto_test_files += ['crypto_test_data.cc']
  499. crypto_test_files += FindCFiles(os.path.join('src', 'crypto'), OnlyTests)
  500. crypto_test_files += [
  501. 'src/crypto/test/file_test_gtest.cc',
  502. 'src/crypto/test/gtest_main.cc',
  503. ]
  504. ssl_test_files = FindCFiles(os.path.join('src', 'ssl'), OnlyTests)
  505. ssl_test_files.append('src/crypto/test/gtest_main.cc')
  506. fuzz_c_files = FindCFiles(os.path.join('src', 'fuzz'), NoTests)
  507. ssl_h_files = (
  508. FindHeaderFiles(
  509. os.path.join('src', 'include', 'openssl'),
  510. SSLHeaderFiles))
  511. def NotSSLHeaderFiles(path, filename, is_dir):
  512. return not SSLHeaderFiles(path, filename, is_dir)
  513. crypto_h_files = (
  514. FindHeaderFiles(
  515. os.path.join('src', 'include', 'openssl'),
  516. NotSSLHeaderFiles))
  517. ssl_internal_h_files = FindHeaderFiles(os.path.join('src', 'ssl'), NoTests)
  518. crypto_internal_h_files = (
  519. FindHeaderFiles(os.path.join('src', 'crypto'), NoTests) +
  520. FindHeaderFiles(os.path.join('src', 'third_party', 'fiat'), NoTests))
  521. files = {
  522. 'crypto': crypto_c_files,
  523. 'crypto_headers': crypto_h_files,
  524. 'crypto_internal_headers': crypto_internal_h_files,
  525. 'crypto_test': sorted(crypto_test_files),
  526. 'crypto_test_data': sorted('src/' + x for x in cmake['CRYPTO_TEST_DATA']),
  527. 'fips_fragments': fips_fragments,
  528. 'fuzz': fuzz_c_files,
  529. 'ssl': ssl_source_files,
  530. 'ssl_headers': ssl_h_files,
  531. 'ssl_internal_headers': ssl_internal_h_files,
  532. 'ssl_test': sorted(ssl_test_files),
  533. 'tool': tool_c_files,
  534. 'tool_headers': tool_h_files,
  535. 'test_support': test_support_c_files,
  536. 'test_support_headers': test_support_h_files,
  537. }
  538. asm_outputs = sorted(WriteAsmFiles(ReadPerlAsmOperations()).iteritems())
  539. for platform in platforms:
  540. platform.WriteFiles(files, asm_outputs)
  541. return 0
  542. if __name__ == '__main__':
  543. parser = optparse.OptionParser(usage='Usage: %prog [--prefix=<path>]'
  544. ' [android|bazel|eureka|gn|gyp]')
  545. parser.add_option('--prefix', dest='prefix',
  546. help='For Bazel, prepend argument to all source files')
  547. parser.add_option(
  548. '--embed_test_data', type='choice', dest='embed_test_data',
  549. action='store', default="true", choices=["true", "false"],
  550. help='For Bazel, don\'t embed data files in crypto_test_data.cc')
  551. options, args = parser.parse_args(sys.argv[1:])
  552. PREFIX = options.prefix
  553. EMBED_TEST_DATA = (options.embed_test_data == "true")
  554. if not args:
  555. parser.print_help()
  556. sys.exit(1)
  557. platforms = []
  558. for s in args:
  559. if s == 'android':
  560. platforms.append(Android())
  561. elif s == 'bazel':
  562. platforms.append(Bazel())
  563. elif s == 'eureka':
  564. platforms.append(Eureka())
  565. elif s == 'gn':
  566. platforms.append(GN())
  567. elif s == 'gyp':
  568. platforms.append(GYP())
  569. else:
  570. parser.print_help()
  571. sys.exit(1)
  572. sys.exit(main(platforms))