Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

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