Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

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