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