Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 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 | |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 15 | """Enumerates source files for consumption by various build systems.""" |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 16 | |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 17 | import optparse |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 18 | import os |
| 19 | import subprocess |
| 20 | import sys |
Adam Langley | 9c164b2 | 2015-06-10 18:54:47 -0700 | [diff] [blame] | 21 | import json |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 22 | |
| 23 | |
| 24 | # OS_ARCH_COMBOS maps from OS and platform to the OpenSSL assembly "style" for |
| 25 | # that platform and the extension used by asm files. |
| 26 | OS_ARCH_COMBOS = [ |
David Benjamin | f6584e7 | 2017-06-08 16:27:16 -0400 | [diff] [blame] | 27 | ('ios', 'arm', 'ios32', [], 'S'), |
| 28 | ('ios', 'aarch64', 'ios64', [], 'S'), |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 29 | ('linux', 'arm', 'linux32', [], 'S'), |
| 30 | ('linux', 'aarch64', 'linux64', [], 'S'), |
Adam Langley | 7c075b9 | 2017-05-22 15:31:13 -0700 | [diff] [blame] | 31 | ('linux', 'ppc64le', 'linux64le', [], 'S'), |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 32 | ('linux', 'x86', 'elf', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'), |
| 33 | ('linux', 'x86_64', 'elf', [], 'S'), |
| 34 | ('mac', 'x86', 'macosx', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'), |
| 35 | ('mac', 'x86_64', 'macosx', [], 'S'), |
| 36 | ('win', 'x86', 'win32n', ['-DOPENSSL_IA32_SSE2'], 'asm'), |
| 37 | ('win', 'x86_64', 'nasm', [], 'asm'), |
| 38 | ] |
| 39 | |
| 40 | # NON_PERL_FILES enumerates assembly files that are not processed by the |
| 41 | # perlasm system. |
| 42 | NON_PERL_FILES = { |
| 43 | ('linux', 'arm'): [ |
Adam Langley | 7b8b9c1 | 2016-01-04 07:13:00 -0800 | [diff] [blame] | 44 | 'src/crypto/curve25519/asm/x25519-asm-arm.S', |
David Benjamin | 3c4a5cb | 2016-03-29 17:43:31 -0400 | [diff] [blame] | 45 | 'src/crypto/poly1305/poly1305_arm_asm.S', |
Adam Langley | 7b93593 | 2018-11-12 13:53:42 -0800 | [diff] [blame] | 46 | ], |
| 47 | ('linux', 'x86_64'): [ |
| 48 | 'src/crypto/hrss/asm/poly_rq_mul.S', |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 49 | ], |
| 50 | } |
| 51 | |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 52 | PREFIX = None |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 53 | EMBED_TEST_DATA = True |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 54 | |
| 55 | |
| 56 | def PathOf(x): |
| 57 | return x if not PREFIX else os.path.join(PREFIX, x) |
| 58 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 59 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 60 | class Android(object): |
| 61 | |
| 62 | def __init__(self): |
| 63 | self.header = \ |
| 64 | """# Copyright (C) 2015 The Android Open Source Project |
| 65 | # |
| 66 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 67 | # you may not use this file except in compliance with the License. |
| 68 | # You may obtain a copy of the License at |
| 69 | # |
| 70 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 71 | # |
| 72 | # Unless required by applicable law or agreed to in writing, software |
| 73 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 74 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 75 | # See the License for the specific language governing permissions and |
| 76 | # limitations under the License. |
| 77 | |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 78 | # This file is created by generate_build_files.py. Do not edit manually. |
| 79 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 80 | """ |
| 81 | |
| 82 | def PrintVariableSection(self, out, name, files): |
| 83 | out.write('%s := \\\n' % name) |
| 84 | for f in sorted(files): |
| 85 | out.write(' %s\\\n' % f) |
| 86 | out.write('\n') |
| 87 | |
| 88 | def WriteFiles(self, files, asm_outputs): |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 89 | # New Android.bp format |
| 90 | with open('sources.bp', 'w+') as blueprint: |
| 91 | blueprint.write(self.header.replace('#', '//')) |
| 92 | |
| 93 | blueprint.write('cc_defaults {\n') |
| 94 | blueprint.write(' name: "libcrypto_sources",\n') |
| 95 | blueprint.write(' srcs: [\n') |
David Benjamin | 8c29e7d | 2016-09-30 21:34:31 -0400 | [diff] [blame] | 96 | for f in sorted(files['crypto']): |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 97 | blueprint.write(' "%s",\n' % f) |
| 98 | blueprint.write(' ],\n') |
| 99 | blueprint.write(' target: {\n') |
| 100 | |
| 101 | for ((osname, arch), asm_files) in asm_outputs: |
Steven Valdez | 93d242b | 2016-10-06 13:49:01 -0400 | [diff] [blame] | 102 | if osname != 'linux' or arch == 'ppc64le': |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 103 | continue |
| 104 | if arch == 'aarch64': |
| 105 | arch = 'arm64' |
| 106 | |
Dan Willemsen | 2eb4bc5 | 2017-10-16 14:37:00 -0700 | [diff] [blame] | 107 | blueprint.write(' linux_%s: {\n' % arch) |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 108 | blueprint.write(' srcs: [\n') |
| 109 | for f in sorted(asm_files): |
| 110 | blueprint.write(' "%s",\n' % f) |
| 111 | blueprint.write(' ],\n') |
| 112 | blueprint.write(' },\n') |
| 113 | |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 114 | blueprint.write(' },\n') |
| 115 | blueprint.write('}\n\n') |
| 116 | |
| 117 | blueprint.write('cc_defaults {\n') |
| 118 | blueprint.write(' name: "libssl_sources",\n') |
| 119 | blueprint.write(' srcs: [\n') |
| 120 | for f in sorted(files['ssl']): |
| 121 | blueprint.write(' "%s",\n' % f) |
| 122 | blueprint.write(' ],\n') |
| 123 | blueprint.write('}\n\n') |
| 124 | |
| 125 | blueprint.write('cc_defaults {\n') |
| 126 | blueprint.write(' name: "bssl_sources",\n') |
| 127 | blueprint.write(' srcs: [\n') |
| 128 | for f in sorted(files['tool']): |
| 129 | blueprint.write(' "%s",\n' % f) |
| 130 | blueprint.write(' ],\n') |
| 131 | blueprint.write('}\n\n') |
| 132 | |
| 133 | blueprint.write('cc_defaults {\n') |
| 134 | blueprint.write(' name: "boringssl_test_support_sources",\n') |
| 135 | blueprint.write(' srcs: [\n') |
| 136 | for f in sorted(files['test_support']): |
| 137 | blueprint.write(' "%s",\n' % f) |
| 138 | blueprint.write(' ],\n') |
| 139 | blueprint.write('}\n\n') |
| 140 | |
| 141 | blueprint.write('cc_defaults {\n') |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 142 | blueprint.write(' name: "boringssl_crypto_test_sources",\n') |
| 143 | blueprint.write(' srcs: [\n') |
| 144 | for f in sorted(files['crypto_test']): |
| 145 | blueprint.write(' "%s",\n' % f) |
| 146 | blueprint.write(' ],\n') |
| 147 | blueprint.write('}\n\n') |
| 148 | |
| 149 | blueprint.write('cc_defaults {\n') |
| 150 | blueprint.write(' name: "boringssl_ssl_test_sources",\n') |
| 151 | blueprint.write(' srcs: [\n') |
| 152 | for f in sorted(files['ssl_test']): |
| 153 | blueprint.write(' "%s",\n' % f) |
| 154 | blueprint.write(' ],\n') |
| 155 | blueprint.write('}\n\n') |
| 156 | |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 157 | # Legacy Android.mk format, only used by Trusty in new branches |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 158 | with open('sources.mk', 'w+') as makefile: |
| 159 | makefile.write(self.header) |
| 160 | |
David Benjamin | 8c29e7d | 2016-09-30 21:34:31 -0400 | [diff] [blame] | 161 | self.PrintVariableSection(makefile, 'crypto_sources', files['crypto']) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 162 | |
| 163 | for ((osname, arch), asm_files) in asm_outputs: |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 164 | if osname != 'linux': |
| 165 | continue |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 166 | self.PrintVariableSection( |
| 167 | makefile, '%s_%s_sources' % (osname, arch), asm_files) |
| 168 | |
| 169 | |
David Benjamin | eca48e5 | 2019-08-13 11:51:53 -0400 | [diff] [blame] | 170 | class AndroidCMake(object): |
| 171 | |
| 172 | def __init__(self): |
| 173 | self.header = \ |
| 174 | """# Copyright (C) 2019 The Android Open Source Project |
| 175 | # |
| 176 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 177 | # you may not use this file except in compliance with the License. |
| 178 | # You may obtain a copy of the License at |
| 179 | # |
| 180 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 181 | # |
| 182 | # Unless required by applicable law or agreed to in writing, software |
| 183 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 184 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 185 | # See the License for the specific language governing permissions and |
| 186 | # limitations under the License. |
| 187 | |
| 188 | # This file is created by generate_build_files.py. Do not edit manually. |
| 189 | # To specify a custom path prefix, set BORINGSSL_ROOT before including this |
| 190 | # file, or use list(TRANSFORM ... PREPEND) from CMake 3.12. |
| 191 | |
| 192 | """ |
| 193 | |
| 194 | def PrintVariableSection(self, out, name, files): |
| 195 | out.write('set(%s\n' % name) |
| 196 | for f in sorted(files): |
| 197 | # Ideally adding the prefix would be the caller's job, but |
| 198 | # list(TRANSFORM ... PREPEND) is only available starting CMake 3.12. When |
| 199 | # sources.cmake is the source of truth, we can ask Android to either write |
| 200 | # a CMake function or update to 3.12. |
| 201 | out.write(' ${BORINGSSL_ROOT}%s\n' % f) |
| 202 | out.write(')\n') |
| 203 | |
| 204 | def WriteFiles(self, files, asm_outputs): |
| 205 | # The Android emulator uses a custom CMake buildsystem. |
| 206 | # |
| 207 | # TODO(davidben): Move our various source lists into sources.cmake and have |
| 208 | # Android consume that directly. |
| 209 | with open('android-sources.cmake', 'w+') as out: |
| 210 | out.write(self.header) |
| 211 | |
| 212 | self.PrintVariableSection(out, 'crypto_sources', files['crypto']) |
| 213 | self.PrintVariableSection(out, 'ssl_sources', files['ssl']) |
| 214 | self.PrintVariableSection(out, 'tool_sources', files['tool']) |
| 215 | self.PrintVariableSection(out, 'test_support_sources', |
| 216 | files['test_support']) |
| 217 | self.PrintVariableSection(out, 'crypto_test_sources', |
| 218 | files['crypto_test']) |
| 219 | self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test']) |
| 220 | |
| 221 | for ((osname, arch), asm_files) in asm_outputs: |
| 222 | self.PrintVariableSection( |
| 223 | out, 'crypto_sources_%s_%s' % (osname, arch), asm_files) |
| 224 | |
| 225 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 226 | class Bazel(object): |
| 227 | """Bazel outputs files suitable for including in Bazel files.""" |
| 228 | |
| 229 | def __init__(self): |
| 230 | self.firstSection = True |
| 231 | self.header = \ |
| 232 | """# This file is created by generate_build_files.py. Do not edit manually. |
| 233 | |
| 234 | """ |
| 235 | |
| 236 | def PrintVariableSection(self, out, name, files): |
| 237 | if not self.firstSection: |
| 238 | out.write('\n') |
| 239 | self.firstSection = False |
| 240 | |
| 241 | out.write('%s = [\n' % name) |
| 242 | for f in sorted(files): |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 243 | out.write(' "%s",\n' % PathOf(f)) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 244 | out.write(']\n') |
| 245 | |
| 246 | def WriteFiles(self, files, asm_outputs): |
Chuck Hays | c608d6b | 2015-10-06 17:54:16 -0700 | [diff] [blame] | 247 | with open('BUILD.generated.bzl', 'w+') as out: |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 248 | out.write(self.header) |
| 249 | |
| 250 | self.PrintVariableSection(out, 'ssl_headers', files['ssl_headers']) |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 251 | self.PrintVariableSection(out, 'fips_fragments', files['fips_fragments']) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 252 | self.PrintVariableSection( |
| 253 | out, 'ssl_internal_headers', files['ssl_internal_headers']) |
| 254 | self.PrintVariableSection(out, 'ssl_sources', files['ssl']) |
| 255 | self.PrintVariableSection(out, 'crypto_headers', files['crypto_headers']) |
| 256 | self.PrintVariableSection( |
| 257 | out, 'crypto_internal_headers', files['crypto_internal_headers']) |
| 258 | self.PrintVariableSection(out, 'crypto_sources', files['crypto']) |
| 259 | self.PrintVariableSection(out, 'tool_sources', files['tool']) |
Adam Langley | f11f233 | 2016-06-30 11:56:19 -0700 | [diff] [blame] | 260 | self.PrintVariableSection(out, 'tool_headers', files['tool_headers']) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 261 | |
| 262 | for ((osname, arch), asm_files) in asm_outputs: |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 263 | self.PrintVariableSection( |
Piotr Sikora | 3f5fe60 | 2015-10-28 12:24:35 -0700 | [diff] [blame] | 264 | out, 'crypto_sources_%s_%s' % (osname, arch), asm_files) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 265 | |
Chuck Hays | c608d6b | 2015-10-06 17:54:16 -0700 | [diff] [blame] | 266 | with open('BUILD.generated_tests.bzl', 'w+') as out: |
Adam Langley | 9c164b2 | 2015-06-10 18:54:47 -0700 | [diff] [blame] | 267 | out.write(self.header) |
| 268 | |
| 269 | out.write('test_support_sources = [\n') |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 270 | for filename in sorted(files['test_support'] + |
| 271 | files['test_support_headers'] + |
| 272 | files['crypto_internal_headers'] + |
| 273 | files['ssl_internal_headers']): |
Adam Langley | 9c164b2 | 2015-06-10 18:54:47 -0700 | [diff] [blame] | 274 | if os.path.basename(filename) == 'malloc.cc': |
| 275 | continue |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 276 | out.write(' "%s",\n' % PathOf(filename)) |
Adam Langley | 9c164b2 | 2015-06-10 18:54:47 -0700 | [diff] [blame] | 277 | |
Adam Langley | 7b6acc5 | 2017-07-27 16:33:27 -0700 | [diff] [blame] | 278 | out.write(']\n') |
Chuck Hays | c608d6b | 2015-10-06 17:54:16 -0700 | [diff] [blame] | 279 | |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 280 | self.PrintVariableSection(out, 'crypto_test_sources', |
| 281 | files['crypto_test']) |
| 282 | self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test']) |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 283 | self.PrintVariableSection(out, 'crypto_test_data', |
| 284 | files['crypto_test_data']) |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 285 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 286 | |
Robert Sloan | e091af4 | 2017-10-09 12:47:17 -0700 | [diff] [blame] | 287 | class Eureka(object): |
| 288 | |
| 289 | def __init__(self): |
| 290 | self.header = \ |
| 291 | """# Copyright (C) 2017 The Android Open Source Project |
| 292 | # |
| 293 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 294 | # you may not use this file except in compliance with the License. |
| 295 | # You may obtain a copy of the License at |
| 296 | # |
| 297 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 298 | # |
| 299 | # Unless required by applicable law or agreed to in writing, software |
| 300 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 301 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 302 | # See the License for the specific language governing permissions and |
| 303 | # limitations under the License. |
| 304 | |
| 305 | # This file is created by generate_build_files.py. Do not edit manually. |
| 306 | |
| 307 | """ |
| 308 | |
| 309 | def PrintVariableSection(self, out, name, files): |
| 310 | out.write('%s := \\\n' % name) |
| 311 | for f in sorted(files): |
| 312 | out.write(' %s\\\n' % f) |
| 313 | out.write('\n') |
| 314 | |
| 315 | def WriteFiles(self, files, asm_outputs): |
| 316 | # Legacy Android.mk format |
| 317 | with open('eureka.mk', 'w+') as makefile: |
| 318 | makefile.write(self.header) |
| 319 | |
| 320 | self.PrintVariableSection(makefile, 'crypto_sources', files['crypto']) |
| 321 | self.PrintVariableSection(makefile, 'ssl_sources', files['ssl']) |
| 322 | self.PrintVariableSection(makefile, 'tool_sources', files['tool']) |
| 323 | |
| 324 | for ((osname, arch), asm_files) in asm_outputs: |
| 325 | if osname != 'linux': |
| 326 | continue |
| 327 | self.PrintVariableSection( |
| 328 | makefile, '%s_%s_sources' % (osname, arch), asm_files) |
| 329 | |
| 330 | |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 331 | class GN(object): |
| 332 | |
| 333 | def __init__(self): |
| 334 | self.firstSection = True |
| 335 | self.header = \ |
| 336 | """# Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 337 | # Use of this source code is governed by a BSD-style license that can be |
| 338 | # found in the LICENSE file. |
| 339 | |
| 340 | # This file is created by generate_build_files.py. Do not edit manually. |
| 341 | |
| 342 | """ |
| 343 | |
| 344 | def PrintVariableSection(self, out, name, files): |
| 345 | if not self.firstSection: |
| 346 | out.write('\n') |
| 347 | self.firstSection = False |
| 348 | |
| 349 | out.write('%s = [\n' % name) |
| 350 | for f in sorted(files): |
| 351 | out.write(' "%s",\n' % f) |
| 352 | out.write(']\n') |
| 353 | |
| 354 | def WriteFiles(self, files, asm_outputs): |
| 355 | with open('BUILD.generated.gni', 'w+') as out: |
| 356 | out.write(self.header) |
| 357 | |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 358 | self.PrintVariableSection(out, 'crypto_sources', |
James Robinson | 98dd68f | 2018-04-11 14:47:34 -0700 | [diff] [blame] | 359 | files['crypto'] + |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 360 | files['crypto_internal_headers']) |
James Robinson | 98dd68f | 2018-04-11 14:47:34 -0700 | [diff] [blame] | 361 | self.PrintVariableSection(out, 'crypto_headers', |
| 362 | files['crypto_headers']) |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 363 | self.PrintVariableSection(out, 'ssl_sources', |
James Robinson | 98dd68f | 2018-04-11 14:47:34 -0700 | [diff] [blame] | 364 | files['ssl'] + files['ssl_internal_headers']) |
| 365 | self.PrintVariableSection(out, 'ssl_headers', files['ssl_headers']) |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 366 | |
| 367 | for ((osname, arch), asm_files) in asm_outputs: |
| 368 | self.PrintVariableSection( |
| 369 | out, 'crypto_sources_%s_%s' % (osname, arch), asm_files) |
| 370 | |
| 371 | fuzzers = [os.path.splitext(os.path.basename(fuzzer))[0] |
| 372 | for fuzzer in files['fuzz']] |
| 373 | self.PrintVariableSection(out, 'fuzzers', fuzzers) |
| 374 | |
| 375 | with open('BUILD.generated_tests.gni', 'w+') as out: |
| 376 | self.firstSection = True |
| 377 | out.write(self.header) |
| 378 | |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 379 | self.PrintVariableSection(out, 'test_support_sources', |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 380 | files['test_support'] + |
| 381 | files['test_support_headers']) |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 382 | self.PrintVariableSection(out, 'crypto_test_sources', |
| 383 | files['crypto_test']) |
David Benjamin | f014d60 | 2019-05-07 18:58:06 -0500 | [diff] [blame] | 384 | self.PrintVariableSection(out, 'crypto_test_data', |
| 385 | files['crypto_test_data']) |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 386 | self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test']) |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 387 | |
| 388 | |
| 389 | class GYP(object): |
| 390 | |
| 391 | def __init__(self): |
| 392 | self.header = \ |
| 393 | """# Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 394 | # Use of this source code is governed by a BSD-style license that can be |
| 395 | # found in the LICENSE file. |
| 396 | |
| 397 | # This file is created by generate_build_files.py. Do not edit manually. |
| 398 | |
| 399 | """ |
| 400 | |
| 401 | def PrintVariableSection(self, out, name, files): |
| 402 | out.write(' \'%s\': [\n' % name) |
| 403 | for f in sorted(files): |
| 404 | out.write(' \'%s\',\n' % f) |
| 405 | out.write(' ],\n') |
| 406 | |
| 407 | def WriteFiles(self, files, asm_outputs): |
| 408 | with open('boringssl.gypi', 'w+') as gypi: |
| 409 | gypi.write(self.header + '{\n \'variables\': {\n') |
| 410 | |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 411 | self.PrintVariableSection(gypi, 'boringssl_ssl_sources', |
| 412 | files['ssl'] + files['ssl_headers'] + |
| 413 | files['ssl_internal_headers']) |
| 414 | self.PrintVariableSection(gypi, 'boringssl_crypto_sources', |
| 415 | files['crypto'] + files['crypto_headers'] + |
| 416 | files['crypto_internal_headers']) |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 417 | |
| 418 | for ((osname, arch), asm_files) in asm_outputs: |
| 419 | self.PrintVariableSection(gypi, 'boringssl_%s_%s_sources' % |
| 420 | (osname, arch), asm_files) |
| 421 | |
| 422 | gypi.write(' }\n}\n') |
| 423 | |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 424 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 425 | def FindCMakeFiles(directory): |
| 426 | """Returns list of all CMakeLists.txt files recursively in directory.""" |
| 427 | cmakefiles = [] |
| 428 | |
| 429 | for (path, _, filenames) in os.walk(directory): |
| 430 | for filename in filenames: |
| 431 | if filename == 'CMakeLists.txt': |
| 432 | cmakefiles.append(os.path.join(path, filename)) |
| 433 | |
| 434 | return cmakefiles |
| 435 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 436 | def OnlyFIPSFragments(path, dent, is_dir): |
Matthew Braithwaite | 95511e9 | 2017-05-08 16:38:03 -0700 | [diff] [blame] | 437 | return is_dir or (path.startswith( |
| 438 | os.path.join('src', 'crypto', 'fipsmodule', '')) and |
| 439 | NoTests(path, dent, is_dir)) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 440 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 441 | def NoTestsNorFIPSFragments(path, dent, is_dir): |
Adam Langley | 323f1eb | 2017-04-06 17:29:10 -0700 | [diff] [blame] | 442 | return (NoTests(path, dent, is_dir) and |
| 443 | (is_dir or not OnlyFIPSFragments(path, dent, is_dir))) |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 444 | |
| 445 | def NoTests(path, dent, is_dir): |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 446 | """Filter function that can be passed to FindCFiles in order to remove test |
| 447 | sources.""" |
| 448 | if is_dir: |
| 449 | return dent != 'test' |
David Benjamin | 96ee4a8 | 2017-07-09 23:46:47 -0400 | [diff] [blame] | 450 | return 'test.' not in dent |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 451 | |
| 452 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 453 | def OnlyTests(path, dent, is_dir): |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 454 | """Filter function that can be passed to FindCFiles in order to remove |
| 455 | non-test sources.""" |
| 456 | if is_dir: |
David Benjamin | 2607383 | 2015-05-11 20:52:48 -0400 | [diff] [blame] | 457 | return dent != 'test' |
David Benjamin | 96ee4a8 | 2017-07-09 23:46:47 -0400 | [diff] [blame] | 458 | return '_test.' in dent |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 459 | |
| 460 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 461 | def AllFiles(path, dent, is_dir): |
David Benjamin | 2607383 | 2015-05-11 20:52:48 -0400 | [diff] [blame] | 462 | """Filter function that can be passed to FindCFiles in order to include all |
| 463 | sources.""" |
| 464 | return True |
| 465 | |
| 466 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 467 | def NoTestRunnerFiles(path, dent, is_dir): |
Martin Kreichgauer | 8b487b7 | 2017-04-03 16:07:27 -0700 | [diff] [blame] | 468 | """Filter function that can be passed to FindCFiles or FindHeaderFiles in |
| 469 | order to exclude test runner files.""" |
| 470 | # NOTE(martinkr): This prevents .h/.cc files in src/ssl/test/runner, which |
| 471 | # are in their own subpackage, from being included in boringssl/BUILD files. |
| 472 | return not is_dir or dent != 'runner' |
| 473 | |
| 474 | |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 475 | def NotGTestSupport(path, dent, is_dir): |
David Benjamin | c388963 | 2019-03-01 15:03:05 -0500 | [diff] [blame] | 476 | return 'gtest' not in dent and 'abi_test' not in dent |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 477 | |
| 478 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 479 | def SSLHeaderFiles(path, dent, is_dir): |
Aaron Green | 0e15002 | 2018-10-16 12:05:29 -0700 | [diff] [blame] | 480 | return dent in ['ssl.h', 'tls1.h', 'ssl23.h', 'ssl3.h', 'dtls1.h', 'srtp.h'] |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 481 | |
| 482 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 483 | def FindCFiles(directory, filter_func): |
| 484 | """Recurses through directory and returns a list of paths to all the C source |
| 485 | files that pass filter_func.""" |
| 486 | cfiles = [] |
| 487 | |
| 488 | for (path, dirnames, filenames) in os.walk(directory): |
| 489 | for filename in filenames: |
| 490 | if not filename.endswith('.c') and not filename.endswith('.cc'): |
| 491 | continue |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 492 | if not filter_func(path, filename, False): |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 493 | continue |
| 494 | cfiles.append(os.path.join(path, filename)) |
| 495 | |
| 496 | for (i, dirname) in enumerate(dirnames): |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 497 | if not filter_func(path, dirname, True): |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 498 | del dirnames[i] |
| 499 | |
| 500 | return cfiles |
| 501 | |
| 502 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 503 | def FindHeaderFiles(directory, filter_func): |
| 504 | """Recurses through directory and returns a list of paths to all the header files that pass filter_func.""" |
| 505 | hfiles = [] |
| 506 | |
| 507 | for (path, dirnames, filenames) in os.walk(directory): |
| 508 | for filename in filenames: |
| 509 | if not filename.endswith('.h'): |
| 510 | continue |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 511 | if not filter_func(path, filename, False): |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 512 | continue |
| 513 | hfiles.append(os.path.join(path, filename)) |
| 514 | |
Matt Braithwaite | dfdd49c | 2016-06-13 17:06:48 -0700 | [diff] [blame] | 515 | for (i, dirname) in enumerate(dirnames): |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 516 | if not filter_func(path, dirname, True): |
Matt Braithwaite | dfdd49c | 2016-06-13 17:06:48 -0700 | [diff] [blame] | 517 | del dirnames[i] |
| 518 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 519 | return hfiles |
| 520 | |
| 521 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 522 | def ExtractPerlAsmFromCMakeFile(cmakefile): |
| 523 | """Parses the contents of the CMakeLists.txt file passed as an argument and |
| 524 | returns a list of all the perlasm() directives found in the file.""" |
| 525 | perlasms = [] |
| 526 | with open(cmakefile) as f: |
| 527 | for line in f: |
| 528 | line = line.strip() |
| 529 | if not line.startswith('perlasm('): |
| 530 | continue |
| 531 | if not line.endswith(')'): |
| 532 | raise ValueError('Bad perlasm line in %s' % cmakefile) |
| 533 | # Remove "perlasm(" from start and ")" from end |
| 534 | params = line[8:-1].split() |
| 535 | if len(params) < 2: |
| 536 | raise ValueError('Bad perlasm line in %s' % cmakefile) |
| 537 | perlasms.append({ |
| 538 | 'extra_args': params[2:], |
| 539 | 'input': os.path.join(os.path.dirname(cmakefile), params[1]), |
| 540 | 'output': os.path.join(os.path.dirname(cmakefile), params[0]), |
| 541 | }) |
| 542 | |
| 543 | return perlasms |
| 544 | |
| 545 | |
| 546 | def ReadPerlAsmOperations(): |
| 547 | """Returns a list of all perlasm() directives found in CMake config files in |
| 548 | src/.""" |
| 549 | perlasms = [] |
| 550 | cmakefiles = FindCMakeFiles('src') |
| 551 | |
| 552 | for cmakefile in cmakefiles: |
| 553 | perlasms.extend(ExtractPerlAsmFromCMakeFile(cmakefile)) |
| 554 | |
| 555 | return perlasms |
| 556 | |
| 557 | |
| 558 | def PerlAsm(output_filename, input_filename, perlasm_style, extra_args): |
| 559 | """Runs the a perlasm script and puts the output into output_filename.""" |
| 560 | base_dir = os.path.dirname(output_filename) |
| 561 | if not os.path.isdir(base_dir): |
| 562 | os.makedirs(base_dir) |
David Benjamin | fdd8e9c | 2016-06-26 13:18:50 -0400 | [diff] [blame] | 563 | subprocess.check_call( |
| 564 | ['perl', input_filename, perlasm_style] + extra_args + [output_filename]) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 565 | |
| 566 | |
| 567 | def ArchForAsmFilename(filename): |
| 568 | """Returns the architectures that a given asm file should be compiled for |
| 569 | based on substrings in the filename.""" |
| 570 | |
| 571 | if 'x86_64' in filename or 'avx2' in filename: |
| 572 | return ['x86_64'] |
| 573 | elif ('x86' in filename and 'x86_64' not in filename) or '586' in filename: |
| 574 | return ['x86'] |
| 575 | elif 'armx' in filename: |
| 576 | return ['arm', 'aarch64'] |
| 577 | elif 'armv8' in filename: |
| 578 | return ['aarch64'] |
| 579 | elif 'arm' in filename: |
| 580 | return ['arm'] |
David Benjamin | 9f16ce1 | 2016-09-27 16:30:22 -0400 | [diff] [blame] | 581 | elif 'ppc' in filename: |
| 582 | return ['ppc64le'] |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 583 | else: |
| 584 | raise ValueError('Unknown arch for asm filename: ' + filename) |
| 585 | |
| 586 | |
| 587 | def WriteAsmFiles(perlasms): |
| 588 | """Generates asm files from perlasm directives for each supported OS x |
| 589 | platform combination.""" |
| 590 | asmfiles = {} |
| 591 | |
| 592 | for osarch in OS_ARCH_COMBOS: |
| 593 | (osname, arch, perlasm_style, extra_args, asm_ext) = osarch |
| 594 | key = (osname, arch) |
| 595 | outDir = '%s-%s' % key |
| 596 | |
| 597 | for perlasm in perlasms: |
| 598 | filename = os.path.basename(perlasm['input']) |
| 599 | output = perlasm['output'] |
| 600 | if not output.startswith('src'): |
| 601 | raise ValueError('output missing src: %s' % output) |
| 602 | output = os.path.join(outDir, output[4:]) |
William Hesse | c618c40 | 2015-06-22 16:34:02 +0200 | [diff] [blame] | 603 | if output.endswith('-armx.${ASM_EXT}'): |
| 604 | output = output.replace('-armx', |
| 605 | '-armx64' if arch == 'aarch64' else '-armx32') |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 606 | output = output.replace('${ASM_EXT}', asm_ext) |
| 607 | |
| 608 | if arch in ArchForAsmFilename(filename): |
| 609 | PerlAsm(output, perlasm['input'], perlasm_style, |
| 610 | perlasm['extra_args'] + extra_args) |
| 611 | asmfiles.setdefault(key, []).append(output) |
| 612 | |
| 613 | for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems(): |
| 614 | asmfiles.setdefault(key, []).extend(non_perl_asm_files) |
| 615 | |
| 616 | return asmfiles |
| 617 | |
| 618 | |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 619 | def ExtractVariablesFromCMakeFile(cmakefile): |
| 620 | """Parses the contents of the CMakeLists.txt file passed as an argument and |
| 621 | returns a dictionary of exported source lists.""" |
| 622 | variables = {} |
| 623 | in_set_command = False |
| 624 | set_command = [] |
| 625 | with open(cmakefile) as f: |
| 626 | for line in f: |
| 627 | if '#' in line: |
| 628 | line = line[:line.index('#')] |
| 629 | line = line.strip() |
| 630 | |
| 631 | if not in_set_command: |
| 632 | if line.startswith('set('): |
| 633 | in_set_command = True |
| 634 | set_command = [] |
| 635 | elif line == ')': |
| 636 | in_set_command = False |
| 637 | if not set_command: |
| 638 | raise ValueError('Empty set command') |
| 639 | variables[set_command[0]] = set_command[1:] |
| 640 | else: |
| 641 | set_command.extend([c for c in line.split(' ') if c]) |
| 642 | |
| 643 | if in_set_command: |
| 644 | raise ValueError('Unfinished set command') |
| 645 | return variables |
| 646 | |
| 647 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 648 | def main(platforms): |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 649 | cmake = ExtractVariablesFromCMakeFile(os.path.join('src', 'sources.cmake')) |
Andres Erbsen | 5b280a8 | 2017-10-30 15:58:33 +0000 | [diff] [blame] | 650 | crypto_c_files = (FindCFiles(os.path.join('src', 'crypto'), NoTestsNorFIPSFragments) + |
Adam Langley | e0c533a | 2019-05-20 09:50:07 -0700 | [diff] [blame] | 651 | FindCFiles(os.path.join('src', 'third_party', 'fiat'), NoTestsNorFIPSFragments) + |
| 652 | FindCFiles(os.path.join('src', 'third_party', 'sike'), NoTestsNorFIPSFragments)) |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 653 | fips_fragments = FindCFiles(os.path.join('src', 'crypto', 'fipsmodule'), OnlyFIPSFragments) |
Adam Langley | feca9e5 | 2017-01-23 13:07:50 -0800 | [diff] [blame] | 654 | ssl_source_files = FindCFiles(os.path.join('src', 'ssl'), NoTests) |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 655 | tool_c_files = FindCFiles(os.path.join('src', 'tool'), NoTests) |
Adam Langley | f11f233 | 2016-06-30 11:56:19 -0700 | [diff] [blame] | 656 | tool_h_files = FindHeaderFiles(os.path.join('src', 'tool'), AllFiles) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 657 | |
David Benjamin | 0c9c1aa | 2017-12-12 15:19:20 -0500 | [diff] [blame] | 658 | # third_party/fiat/p256.c lives in third_party/fiat, but it is a FIPS |
| 659 | # fragment, not a normal source file. |
| 660 | p256 = os.path.join('src', 'third_party', 'fiat', 'p256.c') |
| 661 | fips_fragments.append(p256) |
| 662 | crypto_c_files.remove(p256) |
| 663 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 664 | # Generate err_data.c |
| 665 | with open('err_data.c', 'w+') as err_data: |
| 666 | subprocess.check_call(['go', 'run', 'err_data_generate.go'], |
| 667 | cwd=os.path.join('src', 'crypto', 'err'), |
| 668 | stdout=err_data) |
| 669 | crypto_c_files.append('err_data.c') |
| 670 | |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 671 | test_support_c_files = FindCFiles(os.path.join('src', 'crypto', 'test'), |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 672 | NotGTestSupport) |
Matt Braithwaite | dfdd49c | 2016-06-13 17:06:48 -0700 | [diff] [blame] | 673 | test_support_h_files = ( |
| 674 | FindHeaderFiles(os.path.join('src', 'crypto', 'test'), AllFiles) + |
Martin Kreichgauer | 8b487b7 | 2017-04-03 16:07:27 -0700 | [diff] [blame] | 675 | FindHeaderFiles(os.path.join('src', 'ssl', 'test'), NoTestRunnerFiles)) |
David Benjamin | 2607383 | 2015-05-11 20:52:48 -0400 | [diff] [blame] | 676 | |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 677 | crypto_test_files = [] |
| 678 | if EMBED_TEST_DATA: |
| 679 | # Generate crypto_test_data.cc |
| 680 | with open('crypto_test_data.cc', 'w+') as out: |
| 681 | subprocess.check_call( |
| 682 | ['go', 'run', 'util/embed_test_data.go'] + cmake['CRYPTO_TEST_DATA'], |
| 683 | cwd='src', |
| 684 | stdout=out) |
| 685 | crypto_test_files += ['crypto_test_data.cc'] |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 686 | |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 687 | crypto_test_files += FindCFiles(os.path.join('src', 'crypto'), OnlyTests) |
David Benjamin | 96ee4a8 | 2017-07-09 23:46:47 -0400 | [diff] [blame] | 688 | crypto_test_files += [ |
David Benjamin | c388963 | 2019-03-01 15:03:05 -0500 | [diff] [blame] | 689 | 'src/crypto/test/abi_test.cc', |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 690 | 'src/crypto/test/file_test_gtest.cc', |
| 691 | 'src/crypto/test/gtest_main.cc', |
| 692 | ] |
David Benjamin | 1d5a570 | 2017-02-13 22:11:49 -0500 | [diff] [blame] | 693 | |
| 694 | ssl_test_files = FindCFiles(os.path.join('src', 'ssl'), OnlyTests) |
Robert Sloan | ae1e087 | 2019-03-01 16:01:30 -0800 | [diff] [blame] | 695 | ssl_test_files += [ |
| 696 | 'src/crypto/test/abi_test.cc', |
| 697 | 'src/crypto/test/gtest_main.cc', |
| 698 | ] |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 699 | |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 700 | fuzz_c_files = FindCFiles(os.path.join('src', 'fuzz'), NoTests) |
| 701 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 702 | ssl_h_files = ( |
| 703 | FindHeaderFiles( |
| 704 | os.path.join('src', 'include', 'openssl'), |
| 705 | SSLHeaderFiles)) |
| 706 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 707 | def NotSSLHeaderFiles(path, filename, is_dir): |
| 708 | return not SSLHeaderFiles(path, filename, is_dir) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 709 | crypto_h_files = ( |
| 710 | FindHeaderFiles( |
| 711 | os.path.join('src', 'include', 'openssl'), |
| 712 | NotSSLHeaderFiles)) |
| 713 | |
| 714 | ssl_internal_h_files = FindHeaderFiles(os.path.join('src', 'ssl'), NoTests) |
Andres Erbsen | 5b280a8 | 2017-10-30 15:58:33 +0000 | [diff] [blame] | 715 | crypto_internal_h_files = ( |
| 716 | FindHeaderFiles(os.path.join('src', 'crypto'), NoTests) + |
Adam Langley | e0c533a | 2019-05-20 09:50:07 -0700 | [diff] [blame] | 717 | FindHeaderFiles(os.path.join('src', 'third_party', 'fiat'), NoTests) + |
| 718 | FindHeaderFiles(os.path.join('src', 'third_party', 'sike'), NoTests)) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 719 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 720 | files = { |
| 721 | 'crypto': crypto_c_files, |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 722 | 'crypto_headers': crypto_h_files, |
| 723 | 'crypto_internal_headers': crypto_internal_h_files, |
David Benjamin | 1d5a570 | 2017-02-13 22:11:49 -0500 | [diff] [blame] | 724 | 'crypto_test': sorted(crypto_test_files), |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 725 | 'crypto_test_data': sorted('src/' + x for x in cmake['CRYPTO_TEST_DATA']), |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 726 | 'fips_fragments': fips_fragments, |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 727 | 'fuzz': fuzz_c_files, |
Adam Langley | feca9e5 | 2017-01-23 13:07:50 -0800 | [diff] [blame] | 728 | 'ssl': ssl_source_files, |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 729 | 'ssl_headers': ssl_h_files, |
| 730 | 'ssl_internal_headers': ssl_internal_h_files, |
David Benjamin | 1d5a570 | 2017-02-13 22:11:49 -0500 | [diff] [blame] | 731 | 'ssl_test': sorted(ssl_test_files), |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 732 | 'tool': tool_c_files, |
Adam Langley | f11f233 | 2016-06-30 11:56:19 -0700 | [diff] [blame] | 733 | 'tool_headers': tool_h_files, |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 734 | 'test_support': test_support_c_files, |
| 735 | 'test_support_headers': test_support_h_files, |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | asm_outputs = sorted(WriteAsmFiles(ReadPerlAsmOperations()).iteritems()) |
| 739 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 740 | for platform in platforms: |
| 741 | platform.WriteFiles(files, asm_outputs) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 742 | |
| 743 | return 0 |
| 744 | |
| 745 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 746 | if __name__ == '__main__': |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 747 | parser = optparse.OptionParser(usage='Usage: %prog [--prefix=<path>]' |
David Benjamin | eca48e5 | 2019-08-13 11:51:53 -0400 | [diff] [blame] | 748 | ' [android|android-cmake|bazel|eureka|gn|gyp]') |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 749 | parser.add_option('--prefix', dest='prefix', |
| 750 | help='For Bazel, prepend argument to all source files') |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 751 | parser.add_option( |
| 752 | '--embed_test_data', type='choice', dest='embed_test_data', |
| 753 | action='store', default="true", choices=["true", "false"], |
David Benjamin | f014d60 | 2019-05-07 18:58:06 -0500 | [diff] [blame] | 754 | help='For Bazel or GN, don\'t embed data files in crypto_test_data.cc') |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 755 | options, args = parser.parse_args(sys.argv[1:]) |
| 756 | PREFIX = options.prefix |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 757 | EMBED_TEST_DATA = (options.embed_test_data == "true") |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 758 | |
| 759 | if not args: |
| 760 | parser.print_help() |
| 761 | sys.exit(1) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 762 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 763 | platforms = [] |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 764 | for s in args: |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 765 | if s == 'android': |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 766 | platforms.append(Android()) |
David Benjamin | eca48e5 | 2019-08-13 11:51:53 -0400 | [diff] [blame] | 767 | elif s == 'android-cmake': |
| 768 | platforms.append(AndroidCMake()) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 769 | elif s == 'bazel': |
| 770 | platforms.append(Bazel()) |
Robert Sloan | e091af4 | 2017-10-09 12:47:17 -0700 | [diff] [blame] | 771 | elif s == 'eureka': |
| 772 | platforms.append(Eureka()) |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 773 | elif s == 'gn': |
| 774 | platforms.append(GN()) |
| 775 | elif s == 'gyp': |
| 776 | platforms.append(GYP()) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 777 | else: |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 778 | parser.print_help() |
| 779 | sys.exit(1) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 780 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 781 | sys.exit(main(platforms)) |