Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 1 | # coding=utf8 |
| 2 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 3 | # Copyright (c) 2015, Google Inc. |
| 4 | # |
| 5 | # Permission to use, copy, modify, and/or distribute this software for any |
| 6 | # purpose with or without fee is hereby granted, provided that the above |
| 7 | # copyright notice and this permission notice appear in all copies. |
| 8 | # |
| 9 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 12 | # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 14 | # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 15 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 17 | """Enumerates source files for consumption by various build systems.""" |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 18 | |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 19 | import optparse |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 20 | import os |
| 21 | import subprocess |
| 22 | import sys |
Adam Langley | 9c164b2 | 2015-06-10 18:54:47 -0700 | [diff] [blame] | 23 | import json |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 24 | |
| 25 | |
| 26 | # OS_ARCH_COMBOS maps from OS and platform to the OpenSSL assembly "style" for |
| 27 | # that platform and the extension used by asm files. |
David Benjamin | 1967621 | 2023-01-25 10:03:53 -0500 | [diff] [blame] | 28 | # |
| 29 | # TODO(https://crbug.com/boringssl/524): This probably should be a map, but some |
| 30 | # downstream scripts import this to find what folders to add/remove from git. |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 31 | OS_ARCH_COMBOS = [ |
David Benjamin | 351b2f8 | 2022-02-06 12:57:17 -0500 | [diff] [blame] | 32 | ('apple', 'arm', 'ios32', [], 'S'), |
| 33 | ('apple', 'aarch64', 'ios64', [], 'S'), |
| 34 | ('apple', 'x86', 'macosx', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'), |
| 35 | ('apple', 'x86_64', 'macosx', [], 'S'), |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 36 | ('linux', 'arm', 'linux32', [], 'S'), |
| 37 | ('linux', 'aarch64', 'linux64', [], 'S'), |
| 38 | ('linux', 'x86', 'elf', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'), |
| 39 | ('linux', 'x86_64', 'elf', [], 'S'), |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 40 | ('win', 'x86', 'win32n', ['-DOPENSSL_IA32_SSE2'], 'asm'), |
| 41 | ('win', 'x86_64', 'nasm', [], 'asm'), |
Anthony Roberts | afd5dba | 2020-10-19 12:27:51 +0100 | [diff] [blame] | 42 | ('win', 'aarch64', 'win64', [], 'S'), |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 43 | ] |
| 44 | |
| 45 | # NON_PERL_FILES enumerates assembly files that are not processed by the |
| 46 | # perlasm system. |
| 47 | NON_PERL_FILES = { |
| 48 | ('linux', 'arm'): [ |
Adam Langley | 7b8b9c1 | 2016-01-04 07:13:00 -0800 | [diff] [blame] | 49 | 'src/crypto/curve25519/asm/x25519-asm-arm.S', |
David Benjamin | 3c4a5cb | 2016-03-29 17:43:31 -0400 | [diff] [blame] | 50 | 'src/crypto/poly1305/poly1305_arm_asm.S', |
Adam Langley | 7b93593 | 2018-11-12 13:53:42 -0800 | [diff] [blame] | 51 | ], |
Adam Langley | 04b3a96 | 2023-02-08 21:08:49 +0000 | [diff] [blame^] | 52 | ('linux', 'x86_64'): [ |
| 53 | 'src/crypto/hrss/asm/poly_rq_mul.S', |
| 54 | ], |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 57 | PREFIX = None |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 58 | EMBED_TEST_DATA = True |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 59 | |
| 60 | |
| 61 | def PathOf(x): |
| 62 | return x if not PREFIX else os.path.join(PREFIX, x) |
| 63 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 64 | |
David Benjamin | 70690f7 | 2023-01-25 09:56:43 -0500 | [diff] [blame] | 65 | LICENSE_TEMPLATE = """Copyright (c) 2015, Google Inc. |
| 66 | |
| 67 | Permission to use, copy, modify, and/or distribute this software for any |
| 68 | purpose with or without fee is hereby granted, provided that the above |
| 69 | copyright notice and this permission notice appear in all copies. |
| 70 | |
| 71 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 72 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 73 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 74 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 75 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 76 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 77 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.""".split("\n") |
| 78 | |
| 79 | def LicenseHeader(comment): |
| 80 | lines = [] |
| 81 | for line in LICENSE_TEMPLATE: |
| 82 | if not line: |
| 83 | lines.append(comment) |
| 84 | else: |
| 85 | lines.append("%s %s" % (comment, line)) |
| 86 | lines.append("") |
| 87 | return "\n".join(lines) |
| 88 | |
| 89 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 90 | class Android(object): |
| 91 | |
| 92 | def __init__(self): |
David Benjamin | 70690f7 | 2023-01-25 09:56:43 -0500 | [diff] [blame] | 93 | self.header = LicenseHeader("#") + """ |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 94 | # This file is created by generate_build_files.py. Do not edit manually. |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 95 | """ |
| 96 | |
| 97 | def PrintVariableSection(self, out, name, files): |
| 98 | out.write('%s := \\\n' % name) |
| 99 | for f in sorted(files): |
| 100 | out.write(' %s\\\n' % f) |
| 101 | out.write('\n') |
| 102 | |
| 103 | def WriteFiles(self, files, asm_outputs): |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 104 | # New Android.bp format |
| 105 | with open('sources.bp', 'w+') as blueprint: |
| 106 | blueprint.write(self.header.replace('#', '//')) |
| 107 | |
Pete Bentley | 44544d9 | 2019-08-15 15:01:26 +0100 | [diff] [blame] | 108 | # Separate out BCM files to allow different compilation rules (specific to Android FIPS) |
| 109 | bcm_c_files = files['bcm_crypto'] |
| 110 | non_bcm_c_files = [file for file in files['crypto'] if file not in bcm_c_files] |
| 111 | non_bcm_asm = self.FilterBcmAsm(asm_outputs, False) |
| 112 | bcm_asm = self.FilterBcmAsm(asm_outputs, True) |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 113 | |
Pete Bentley | 44544d9 | 2019-08-15 15:01:26 +0100 | [diff] [blame] | 114 | self.PrintDefaults(blueprint, 'libcrypto_sources', non_bcm_c_files, non_bcm_asm) |
| 115 | self.PrintDefaults(blueprint, 'libcrypto_bcm_sources', bcm_c_files, bcm_asm) |
| 116 | self.PrintDefaults(blueprint, 'libssl_sources', files['ssl']) |
| 117 | self.PrintDefaults(blueprint, 'bssl_sources', files['tool']) |
| 118 | self.PrintDefaults(blueprint, 'boringssl_test_support_sources', files['test_support']) |
| 119 | self.PrintDefaults(blueprint, 'boringssl_crypto_test_sources', files['crypto_test']) |
| 120 | self.PrintDefaults(blueprint, 'boringssl_ssl_test_sources', files['ssl_test']) |
| 121 | |
| 122 | # Legacy Android.mk format, only used by Trusty in new branches |
| 123 | with open('sources.mk', 'w+') as makefile: |
| 124 | makefile.write(self.header) |
| 125 | makefile.write('\n') |
| 126 | self.PrintVariableSection(makefile, 'crypto_sources', files['crypto']) |
| 127 | |
| 128 | for ((osname, arch), asm_files) in asm_outputs: |
| 129 | if osname != 'linux': |
| 130 | continue |
| 131 | self.PrintVariableSection( |
| 132 | makefile, '%s_%s_sources' % (osname, arch), asm_files) |
| 133 | |
| 134 | def PrintDefaults(self, blueprint, name, files, asm_outputs={}): |
| 135 | """Print a cc_defaults section from a list of C files and optionally assembly outputs""" |
| 136 | blueprint.write('\n') |
| 137 | blueprint.write('cc_defaults {\n') |
| 138 | blueprint.write(' name: "%s",\n' % name) |
| 139 | blueprint.write(' srcs: [\n') |
| 140 | for f in sorted(files): |
| 141 | blueprint.write(' "%s",\n' % f) |
| 142 | blueprint.write(' ],\n') |
| 143 | |
| 144 | if asm_outputs: |
| 145 | blueprint.write(' target: {\n') |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 146 | for ((osname, arch), asm_files) in asm_outputs: |
David Benjamin | 5fdc03f | 2023-01-26 18:55:32 -0500 | [diff] [blame] | 147 | if osname != 'linux': |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 148 | continue |
| 149 | if arch == 'aarch64': |
| 150 | arch = 'arm64' |
| 151 | |
Dan Willemsen | 2eb4bc5 | 2017-10-16 14:37:00 -0700 | [diff] [blame] | 152 | blueprint.write(' linux_%s: {\n' % arch) |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 153 | blueprint.write(' srcs: [\n') |
| 154 | for f in sorted(asm_files): |
| 155 | blueprint.write(' "%s",\n' % f) |
| 156 | blueprint.write(' ],\n') |
| 157 | blueprint.write(' },\n') |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 158 | blueprint.write(' },\n') |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 159 | |
Pete Bentley | 44544d9 | 2019-08-15 15:01:26 +0100 | [diff] [blame] | 160 | blueprint.write('}\n') |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 161 | |
Pete Bentley | 44544d9 | 2019-08-15 15:01:26 +0100 | [diff] [blame] | 162 | def FilterBcmAsm(self, asm, want_bcm): |
| 163 | """Filter a list of assembly outputs based on whether they belong in BCM |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 164 | |
Pete Bentley | 44544d9 | 2019-08-15 15:01:26 +0100 | [diff] [blame] | 165 | Args: |
| 166 | asm: Assembly file lists to filter |
| 167 | want_bcm: If true then include BCM files, otherwise do not |
Dan Willemsen | b57e4fc | 2016-07-21 11:08:44 -0700 | [diff] [blame] | 168 | |
Pete Bentley | 44544d9 | 2019-08-15 15:01:26 +0100 | [diff] [blame] | 169 | Returns: |
| 170 | A copy of |asm| with files filtered according to |want_bcm| |
| 171 | """ |
David Benjamin | 1967621 | 2023-01-25 10:03:53 -0500 | [diff] [blame] | 172 | # TODO(https://crbug.com/boringssl/542): Rather than filtering by filename, |
| 173 | # use the variable listed in the CMake perlasm line, available in |
| 174 | # ExtractPerlAsmFromCMakeFile. |
Pete Bentley | 44544d9 | 2019-08-15 15:01:26 +0100 | [diff] [blame] | 175 | return [(archinfo, filter(lambda p: ("/crypto/fipsmodule/" in p) == want_bcm, files)) |
| 176 | for (archinfo, files) in asm] |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 177 | |
| 178 | |
David Benjamin | eca48e5 | 2019-08-13 11:51:53 -0400 | [diff] [blame] | 179 | class AndroidCMake(object): |
| 180 | |
| 181 | def __init__(self): |
David Benjamin | 70690f7 | 2023-01-25 09:56:43 -0500 | [diff] [blame] | 182 | self.header = LicenseHeader("#") + """ |
David Benjamin | eca48e5 | 2019-08-13 11:51:53 -0400 | [diff] [blame] | 183 | # This file is created by generate_build_files.py. Do not edit manually. |
| 184 | # To specify a custom path prefix, set BORINGSSL_ROOT before including this |
| 185 | # file, or use list(TRANSFORM ... PREPEND) from CMake 3.12. |
| 186 | |
| 187 | """ |
| 188 | |
| 189 | def PrintVariableSection(self, out, name, files): |
| 190 | out.write('set(%s\n' % name) |
| 191 | for f in sorted(files): |
| 192 | # Ideally adding the prefix would be the caller's job, but |
| 193 | # list(TRANSFORM ... PREPEND) is only available starting CMake 3.12. When |
| 194 | # sources.cmake is the source of truth, we can ask Android to either write |
| 195 | # a CMake function or update to 3.12. |
| 196 | out.write(' ${BORINGSSL_ROOT}%s\n' % f) |
| 197 | out.write(')\n') |
| 198 | |
| 199 | def WriteFiles(self, files, asm_outputs): |
| 200 | # The Android emulator uses a custom CMake buildsystem. |
| 201 | # |
| 202 | # TODO(davidben): Move our various source lists into sources.cmake and have |
| 203 | # Android consume that directly. |
| 204 | with open('android-sources.cmake', 'w+') as out: |
| 205 | out.write(self.header) |
| 206 | |
| 207 | self.PrintVariableSection(out, 'crypto_sources', files['crypto']) |
| 208 | self.PrintVariableSection(out, 'ssl_sources', files['ssl']) |
| 209 | self.PrintVariableSection(out, 'tool_sources', files['tool']) |
| 210 | self.PrintVariableSection(out, 'test_support_sources', |
| 211 | files['test_support']) |
| 212 | self.PrintVariableSection(out, 'crypto_test_sources', |
| 213 | files['crypto_test']) |
| 214 | self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test']) |
| 215 | |
| 216 | for ((osname, arch), asm_files) in asm_outputs: |
| 217 | self.PrintVariableSection( |
| 218 | out, 'crypto_sources_%s_%s' % (osname, arch), asm_files) |
| 219 | |
| 220 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 221 | class Bazel(object): |
| 222 | """Bazel outputs files suitable for including in Bazel files.""" |
| 223 | |
| 224 | def __init__(self): |
| 225 | self.firstSection = True |
| 226 | self.header = \ |
| 227 | """# This file is created by generate_build_files.py. Do not edit manually. |
| 228 | |
| 229 | """ |
| 230 | |
| 231 | def PrintVariableSection(self, out, name, files): |
| 232 | if not self.firstSection: |
| 233 | out.write('\n') |
| 234 | self.firstSection = False |
| 235 | |
| 236 | out.write('%s = [\n' % name) |
| 237 | for f in sorted(files): |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 238 | out.write(' "%s",\n' % PathOf(f)) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 239 | out.write(']\n') |
| 240 | |
| 241 | def WriteFiles(self, files, asm_outputs): |
Chuck Hays | c608d6b | 2015-10-06 17:54:16 -0700 | [diff] [blame] | 242 | with open('BUILD.generated.bzl', 'w+') as out: |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 243 | out.write(self.header) |
| 244 | |
| 245 | self.PrintVariableSection(out, 'ssl_headers', files['ssl_headers']) |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 246 | self.PrintVariableSection(out, 'fips_fragments', files['fips_fragments']) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 247 | self.PrintVariableSection( |
| 248 | out, 'ssl_internal_headers', files['ssl_internal_headers']) |
| 249 | self.PrintVariableSection(out, 'ssl_sources', files['ssl']) |
| 250 | self.PrintVariableSection(out, 'crypto_headers', files['crypto_headers']) |
| 251 | self.PrintVariableSection( |
| 252 | out, 'crypto_internal_headers', files['crypto_internal_headers']) |
| 253 | self.PrintVariableSection(out, 'crypto_sources', files['crypto']) |
| 254 | self.PrintVariableSection(out, 'tool_sources', files['tool']) |
Adam Langley | f11f233 | 2016-06-30 11:56:19 -0700 | [diff] [blame] | 255 | self.PrintVariableSection(out, 'tool_headers', files['tool_headers']) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 256 | |
| 257 | for ((osname, arch), asm_files) in asm_outputs: |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 258 | self.PrintVariableSection( |
Piotr Sikora | 3f5fe60 | 2015-10-28 12:24:35 -0700 | [diff] [blame] | 259 | out, 'crypto_sources_%s_%s' % (osname, arch), asm_files) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 260 | |
David Benjamin | 23776d0 | 2022-12-09 11:33:17 -0500 | [diff] [blame] | 261 | # Generate combined source lists for gas and nasm. Consumers have a choice |
| 262 | # of using the per-platform ones or the combined ones. In the combined |
| 263 | # mode, Windows x86 and Windows x86_64 must still be special-cased, but |
| 264 | # otherwise all assembly files can be linked together. |
| 265 | out.write('\n') |
| 266 | out.write('crypto_sources_asm = []\n') |
| 267 | for (osname, arch, _, _, asm_ext) in OS_ARCH_COMBOS: |
| 268 | if asm_ext == 'S': |
| 269 | out.write('crypto_sources_asm.extend(crypto_sources_%s_%s)\n' % |
| 270 | (osname, arch)) |
| 271 | out.write('\n') |
| 272 | out.write('crypto_sources_nasm = []\n') |
| 273 | for (osname, arch, _, _, asm_ext) in OS_ARCH_COMBOS: |
| 274 | if asm_ext == 'asm': |
| 275 | out.write('crypto_sources_nasm.extend(crypto_sources_%s_%s)\n' % |
| 276 | (osname, arch)) |
| 277 | |
Chuck Hays | c608d6b | 2015-10-06 17:54:16 -0700 | [diff] [blame] | 278 | with open('BUILD.generated_tests.bzl', 'w+') as out: |
Adam Langley | 9c164b2 | 2015-06-10 18:54:47 -0700 | [diff] [blame] | 279 | out.write(self.header) |
| 280 | |
| 281 | out.write('test_support_sources = [\n') |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 282 | for filename in sorted(files['test_support'] + |
| 283 | files['test_support_headers'] + |
| 284 | files['crypto_internal_headers'] + |
| 285 | files['ssl_internal_headers']): |
Adam Langley | 9c164b2 | 2015-06-10 18:54:47 -0700 | [diff] [blame] | 286 | if os.path.basename(filename) == 'malloc.cc': |
| 287 | continue |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 288 | out.write(' "%s",\n' % PathOf(filename)) |
Adam Langley | 9c164b2 | 2015-06-10 18:54:47 -0700 | [diff] [blame] | 289 | |
Adam Langley | 7b6acc5 | 2017-07-27 16:33:27 -0700 | [diff] [blame] | 290 | out.write(']\n') |
Chuck Hays | c608d6b | 2015-10-06 17:54:16 -0700 | [diff] [blame] | 291 | |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 292 | self.PrintVariableSection(out, 'crypto_test_sources', |
| 293 | files['crypto_test']) |
| 294 | self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test']) |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 295 | self.PrintVariableSection(out, 'crypto_test_data', |
| 296 | files['crypto_test_data']) |
Adam Langley | 3e502c8 | 2019-10-16 09:56:38 -0700 | [diff] [blame] | 297 | self.PrintVariableSection(out, 'urandom_test_sources', |
| 298 | files['urandom_test']) |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 299 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 300 | |
Robert Sloan | e091af4 | 2017-10-09 12:47:17 -0700 | [diff] [blame] | 301 | class Eureka(object): |
| 302 | |
| 303 | def __init__(self): |
David Benjamin | 70690f7 | 2023-01-25 09:56:43 -0500 | [diff] [blame] | 304 | self.header = LicenseHeader("#") + """ |
Robert Sloan | e091af4 | 2017-10-09 12:47:17 -0700 | [diff] [blame] | 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 |
David Benjamin | 70690f7 | 2023-01-25 09:56:43 -0500 | [diff] [blame] | 335 | self.header = LicenseHeader("#") + """ |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 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 | if not self.firstSection: |
| 342 | out.write('\n') |
| 343 | self.firstSection = False |
| 344 | |
| 345 | out.write('%s = [\n' % name) |
| 346 | for f in sorted(files): |
| 347 | out.write(' "%s",\n' % f) |
| 348 | out.write(']\n') |
| 349 | |
| 350 | def WriteFiles(self, files, asm_outputs): |
| 351 | with open('BUILD.generated.gni', 'w+') as out: |
| 352 | out.write(self.header) |
| 353 | |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 354 | self.PrintVariableSection(out, 'crypto_sources', |
James Robinson | 98dd68f | 2018-04-11 14:47:34 -0700 | [diff] [blame] | 355 | files['crypto'] + |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 356 | files['crypto_internal_headers']) |
James Robinson | 98dd68f | 2018-04-11 14:47:34 -0700 | [diff] [blame] | 357 | self.PrintVariableSection(out, 'crypto_headers', |
| 358 | files['crypto_headers']) |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 359 | self.PrintVariableSection(out, 'ssl_sources', |
James Robinson | 98dd68f | 2018-04-11 14:47:34 -0700 | [diff] [blame] | 360 | files['ssl'] + files['ssl_internal_headers']) |
| 361 | self.PrintVariableSection(out, 'ssl_headers', files['ssl_headers']) |
David Benjamin | bb0cb95 | 2020-12-17 16:35:39 -0500 | [diff] [blame] | 362 | self.PrintVariableSection(out, 'tool_sources', |
| 363 | files['tool'] + files['tool_headers']) |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 364 | |
| 365 | for ((osname, arch), asm_files) in asm_outputs: |
| 366 | self.PrintVariableSection( |
| 367 | out, 'crypto_sources_%s_%s' % (osname, arch), asm_files) |
| 368 | |
| 369 | fuzzers = [os.path.splitext(os.path.basename(fuzzer))[0] |
| 370 | for fuzzer in files['fuzz']] |
| 371 | self.PrintVariableSection(out, 'fuzzers', fuzzers) |
| 372 | |
| 373 | with open('BUILD.generated_tests.gni', 'w+') as out: |
| 374 | self.firstSection = True |
| 375 | out.write(self.header) |
| 376 | |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 377 | self.PrintVariableSection(out, 'test_support_sources', |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 378 | files['test_support'] + |
| 379 | files['test_support_headers']) |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 380 | self.PrintVariableSection(out, 'crypto_test_sources', |
| 381 | files['crypto_test']) |
David Benjamin | f014d60 | 2019-05-07 18:58:06 -0500 | [diff] [blame] | 382 | self.PrintVariableSection(out, 'crypto_test_data', |
| 383 | files['crypto_test_data']) |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 384 | self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test']) |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 385 | |
| 386 | |
| 387 | class GYP(object): |
| 388 | |
| 389 | def __init__(self): |
David Benjamin | 70690f7 | 2023-01-25 09:56:43 -0500 | [diff] [blame] | 390 | self.header = LicenseHeader("#") + """ |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 391 | # This file is created by generate_build_files.py. Do not edit manually. |
| 392 | |
| 393 | """ |
| 394 | |
| 395 | def PrintVariableSection(self, out, name, files): |
| 396 | out.write(' \'%s\': [\n' % name) |
| 397 | for f in sorted(files): |
| 398 | out.write(' \'%s\',\n' % f) |
| 399 | out.write(' ],\n') |
| 400 | |
| 401 | def WriteFiles(self, files, asm_outputs): |
| 402 | with open('boringssl.gypi', 'w+') as gypi: |
| 403 | gypi.write(self.header + '{\n \'variables\': {\n') |
| 404 | |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 405 | self.PrintVariableSection(gypi, 'boringssl_ssl_sources', |
| 406 | files['ssl'] + files['ssl_headers'] + |
| 407 | files['ssl_internal_headers']) |
| 408 | self.PrintVariableSection(gypi, 'boringssl_crypto_sources', |
| 409 | files['crypto'] + files['crypto_headers'] + |
| 410 | files['crypto_internal_headers']) |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 411 | |
| 412 | for ((osname, arch), asm_files) in asm_outputs: |
| 413 | self.PrintVariableSection(gypi, 'boringssl_%s_%s_sources' % |
| 414 | (osname, arch), asm_files) |
| 415 | |
| 416 | gypi.write(' }\n}\n') |
| 417 | |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 418 | class CMake(object): |
| 419 | |
| 420 | def __init__(self): |
David Benjamin | 70690f7 | 2023-01-25 09:56:43 -0500 | [diff] [blame] | 421 | self.header = LicenseHeader("#") + R''' |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 422 | # This file is created by generate_build_files.py. Do not edit manually. |
| 423 | |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 424 | cmake_minimum_required(VERSION 3.10) |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 425 | |
| 426 | project(BoringSSL LANGUAGES C CXX) |
| 427 | |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 428 | set(CMAKE_CXX_STANDARD 14) |
| 429 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 430 | set(CMAKE_C_STANDARD 11) |
| 431 | set(CMAKE_C_STANDARD_REQUIRED ON) |
| 432 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 433 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fno-common -fno-exceptions -fno-rtti") |
| 434 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fno-common") |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 435 | endif() |
| 436 | |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 437 | # pthread_rwlock_t requires a feature flag on glibc. |
| 438 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 439 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=700") |
| 440 | endif() |
| 441 | |
| 442 | if(WIN32) |
| 443 | add_definitions(-D_HAS_EXCEPTIONS=0) |
| 444 | add_definitions(-DWIN32_LEAN_AND_MEAN) |
| 445 | add_definitions(-DNOMINMAX) |
| 446 | # Allow use of fopen. |
| 447 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 448 | endif() |
| 449 | |
| 450 | add_definitions(-DBORINGSSL_IMPLEMENTATION) |
| 451 | |
David Benjamin | 67bb28c | 2023-02-01 14:40:03 -0500 | [diff] [blame] | 452 | if(OPENSSL_NO_ASM) |
| 453 | add_definitions(-DOPENSSL_NO_ASM) |
| 454 | else() |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 455 | # On x86 and x86_64 Windows, we use the NASM output. |
| 456 | if(WIN32 AND CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|x86_64|amd64|x86|i[3-6]86") |
| 457 | enable_language(ASM_NASM) |
| 458 | set(OPENSSL_NASM TRUE) |
| 459 | set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -gcv8") |
| 460 | else() |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 461 | enable_language(ASM) |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 462 | set(OPENSSL_ASM TRUE) |
David Benjamin | 61266e4 | 2023-01-29 15:53:30 -0500 | [diff] [blame] | 463 | # Work around https://gitlab.kitware.com/cmake/cmake/-/issues/20771 in older |
| 464 | # CMake versions. |
| 465 | if(APPLE AND CMAKE_VERSION VERSION_LESS 3.19) |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 466 | if(CMAKE_OSX_SYSROOT) |
| 467 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -isysroot \"${CMAKE_OSX_SYSROOT}\"") |
| 468 | endif() |
| 469 | foreach(arch ${CMAKE_OSX_ARCHITECTURES}) |
| 470 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -arch ${arch}") |
| 471 | endforeach() |
| 472 | endif() |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 473 | if(NOT WIN32) |
| 474 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack") |
| 475 | endif() |
| 476 | # Clang's integerated assembler does not support debug symbols. |
| 477 | if(NOT CMAKE_ASM_COMPILER_ID MATCHES "Clang") |
| 478 | set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,-g") |
| 479 | endif() |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 480 | endif() |
| 481 | endif() |
| 482 | |
Adam Langley | a0cdbf9 | 2020-01-21 09:07:46 -0800 | [diff] [blame] | 483 | if(BUILD_SHARED_LIBS) |
| 484 | add_definitions(-DBORINGSSL_SHARED_LIBRARY) |
| 485 | # Enable position-independent code globally. This is needed because |
| 486 | # some library targets are OBJECT libraries. |
| 487 | set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) |
| 488 | endif() |
| 489 | |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 490 | include_directories(src/include) |
| 491 | |
| 492 | ''' |
| 493 | |
| 494 | def PrintLibrary(self, out, name, files): |
| 495 | out.write('add_library(\n') |
| 496 | out.write(' %s\n\n' % name) |
| 497 | |
| 498 | for f in sorted(files): |
| 499 | out.write(' %s\n' % PathOf(f)) |
| 500 | |
| 501 | out.write(')\n\n') |
| 502 | |
| 503 | def PrintExe(self, out, name, files, libs): |
| 504 | out.write('add_executable(\n') |
| 505 | out.write(' %s\n\n' % name) |
| 506 | |
| 507 | for f in sorted(files): |
| 508 | out.write(' %s\n' % PathOf(f)) |
| 509 | |
| 510 | out.write(')\n\n') |
| 511 | out.write('target_link_libraries(%s %s)\n\n' % (name, ' '.join(libs))) |
| 512 | |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 513 | def PrintVariable(self, out, name, files): |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 514 | out.write('set(\n') |
| 515 | out.write(' %s\n\n' % name) |
| 516 | for f in sorted(files): |
| 517 | out.write(' %s\n' % PathOf(f)) |
| 518 | out.write(')\n\n') |
| 519 | |
| 520 | def WriteFiles(self, files, asm_outputs): |
| 521 | with open('CMakeLists.txt', 'w+') as cmake: |
| 522 | cmake.write(self.header) |
| 523 | |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 524 | asm_sources = [] |
| 525 | nasm_sources = [] |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 526 | for ((osname, arch), asm_files) in asm_outputs: |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 527 | if (osname, arch) in (('win', 'x86'), ('win', 'x86_64')): |
| 528 | nasm_sources.extend(asm_files) |
| 529 | else: |
| 530 | asm_sources.extend(asm_files) |
| 531 | self.PrintVariable(cmake, 'CRYPTO_SOURCES_ASM', sorted(asm_sources)) |
| 532 | self.PrintVariable(cmake, 'CRYPTO_SOURCES_NASM', sorted(nasm_sources)) |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 533 | |
| 534 | cmake.write( |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 535 | R'''if(OPENSSL_ASM) |
| 536 | list(APPEND CRYPTO_SOURCES_ASM_USED ${CRYPTO_SOURCES_ASM}) |
| 537 | endif() |
| 538 | if(OPENSSL_NASM) |
| 539 | list(APPEND CRYPTO_SOURCES_ASM_USED ${CRYPTO_SOURCES_NASM}) |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 540 | endif() |
| 541 | |
| 542 | ''') |
| 543 | |
| 544 | self.PrintLibrary(cmake, 'crypto', |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 545 | files['crypto'] + ['${CRYPTO_SOURCES_ASM_USED}']) |
Adam Langley | cfd80a9 | 2019-11-08 14:40:08 -0800 | [diff] [blame] | 546 | self.PrintLibrary(cmake, 'ssl', files['ssl']) |
Adam Langley | ff63113 | 2020-01-13 15:24:22 -0800 | [diff] [blame] | 547 | self.PrintExe(cmake, 'bssl', files['tool'], ['ssl', 'crypto']) |
| 548 | |
| 549 | cmake.write( |
David Benjamin | 741c153 | 2023-01-25 17:37:16 -0500 | [diff] [blame] | 550 | R'''if(NOT ANDROID) |
| 551 | find_package(Threads REQUIRED) |
| 552 | target_link_libraries(crypto Threads::Threads) |
Adam Langley | ff63113 | 2020-01-13 15:24:22 -0800 | [diff] [blame] | 553 | endif() |
| 554 | |
David Benjamin | 8f88b27 | 2020-07-09 13:35:01 -0400 | [diff] [blame] | 555 | if(WIN32) |
David Benjamin | 0586618 | 2023-01-29 18:25:06 -0500 | [diff] [blame] | 556 | target_link_libraries(crypto ws2_32) |
David Benjamin | 8f88b27 | 2020-07-09 13:35:01 -0400 | [diff] [blame] | 557 | endif() |
| 558 | |
Adam Langley | ff63113 | 2020-01-13 15:24:22 -0800 | [diff] [blame] | 559 | ''') |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 560 | |
David Benjamin | 8c0a6eb | 2020-07-16 14:45:51 -0400 | [diff] [blame] | 561 | class JSON(object): |
| 562 | def WriteFiles(self, files, asm_outputs): |
| 563 | sources = dict(files) |
| 564 | for ((osname, arch), asm_files) in asm_outputs: |
| 565 | sources['crypto_%s_%s' % (osname, arch)] = asm_files |
| 566 | with open('sources.json', 'w+') as f: |
| 567 | json.dump(sources, f, sort_keys=True, indent=2) |
| 568 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 569 | def FindCMakeFiles(directory): |
| 570 | """Returns list of all CMakeLists.txt files recursively in directory.""" |
| 571 | cmakefiles = [] |
| 572 | |
| 573 | for (path, _, filenames) in os.walk(directory): |
| 574 | for filename in filenames: |
| 575 | if filename == 'CMakeLists.txt': |
| 576 | cmakefiles.append(os.path.join(path, filename)) |
| 577 | |
| 578 | return cmakefiles |
| 579 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 580 | def OnlyFIPSFragments(path, dent, is_dir): |
Matthew Braithwaite | 95511e9 | 2017-05-08 16:38:03 -0700 | [diff] [blame] | 581 | return is_dir or (path.startswith( |
| 582 | os.path.join('src', 'crypto', 'fipsmodule', '')) and |
| 583 | NoTests(path, dent, is_dir)) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 584 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 585 | def NoTestsNorFIPSFragments(path, dent, is_dir): |
Adam Langley | 323f1eb | 2017-04-06 17:29:10 -0700 | [diff] [blame] | 586 | return (NoTests(path, dent, is_dir) and |
| 587 | (is_dir or not OnlyFIPSFragments(path, dent, is_dir))) |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 588 | |
| 589 | def NoTests(path, dent, is_dir): |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 590 | """Filter function that can be passed to FindCFiles in order to remove test |
| 591 | sources.""" |
| 592 | if is_dir: |
| 593 | return dent != 'test' |
David Benjamin | 96ee4a8 | 2017-07-09 23:46:47 -0400 | [diff] [blame] | 594 | return 'test.' not in dent |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 595 | |
| 596 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 597 | def OnlyTests(path, dent, is_dir): |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 598 | """Filter function that can be passed to FindCFiles in order to remove |
| 599 | non-test sources.""" |
| 600 | if is_dir: |
David Benjamin | 2607383 | 2015-05-11 20:52:48 -0400 | [diff] [blame] | 601 | return dent != 'test' |
David Benjamin | 96ee4a8 | 2017-07-09 23:46:47 -0400 | [diff] [blame] | 602 | return '_test.' in dent |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 603 | |
| 604 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 605 | def AllFiles(path, dent, is_dir): |
David Benjamin | 2607383 | 2015-05-11 20:52:48 -0400 | [diff] [blame] | 606 | """Filter function that can be passed to FindCFiles in order to include all |
| 607 | sources.""" |
| 608 | return True |
| 609 | |
| 610 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 611 | def NoTestRunnerFiles(path, dent, is_dir): |
Martin Kreichgauer | 8b487b7 | 2017-04-03 16:07:27 -0700 | [diff] [blame] | 612 | """Filter function that can be passed to FindCFiles or FindHeaderFiles in |
| 613 | order to exclude test runner files.""" |
| 614 | # NOTE(martinkr): This prevents .h/.cc files in src/ssl/test/runner, which |
| 615 | # are in their own subpackage, from being included in boringssl/BUILD files. |
| 616 | return not is_dir or dent != 'runner' |
| 617 | |
| 618 | |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 619 | def NotGTestSupport(path, dent, is_dir): |
David Benjamin | c388963 | 2019-03-01 15:03:05 -0500 | [diff] [blame] | 620 | return 'gtest' not in dent and 'abi_test' not in dent |
David Benjamin | 9662843 | 2017-01-19 19:05:47 -0500 | [diff] [blame] | 621 | |
| 622 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 623 | def SSLHeaderFiles(path, dent, is_dir): |
Aaron Green | 0e15002 | 2018-10-16 12:05:29 -0700 | [diff] [blame] | 624 | 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] | 625 | |
| 626 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 627 | def FindCFiles(directory, filter_func): |
| 628 | """Recurses through directory and returns a list of paths to all the C source |
| 629 | files that pass filter_func.""" |
| 630 | cfiles = [] |
| 631 | |
| 632 | for (path, dirnames, filenames) in os.walk(directory): |
| 633 | for filename in filenames: |
| 634 | if not filename.endswith('.c') and not filename.endswith('.cc'): |
| 635 | continue |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 636 | if not filter_func(path, filename, False): |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 637 | continue |
| 638 | cfiles.append(os.path.join(path, filename)) |
| 639 | |
| 640 | for (i, dirname) in enumerate(dirnames): |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 641 | if not filter_func(path, dirname, True): |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 642 | del dirnames[i] |
| 643 | |
David Benjamin | edd4c5f | 2020-08-19 14:46:17 -0400 | [diff] [blame] | 644 | cfiles.sort() |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 645 | return cfiles |
| 646 | |
| 647 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 648 | def FindHeaderFiles(directory, filter_func): |
| 649 | """Recurses through directory and returns a list of paths to all the header files that pass filter_func.""" |
| 650 | hfiles = [] |
| 651 | |
| 652 | for (path, dirnames, filenames) in os.walk(directory): |
| 653 | for filename in filenames: |
| 654 | if not filename.endswith('.h'): |
| 655 | continue |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 656 | if not filter_func(path, filename, False): |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 657 | continue |
| 658 | hfiles.append(os.path.join(path, filename)) |
| 659 | |
Matt Braithwaite | dfdd49c | 2016-06-13 17:06:48 -0700 | [diff] [blame] | 660 | for (i, dirname) in enumerate(dirnames): |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 661 | if not filter_func(path, dirname, True): |
Matt Braithwaite | dfdd49c | 2016-06-13 17:06:48 -0700 | [diff] [blame] | 662 | del dirnames[i] |
| 663 | |
David Benjamin | edd4c5f | 2020-08-19 14:46:17 -0400 | [diff] [blame] | 664 | hfiles.sort() |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 665 | return hfiles |
| 666 | |
| 667 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 668 | def ExtractPerlAsmFromCMakeFile(cmakefile): |
| 669 | """Parses the contents of the CMakeLists.txt file passed as an argument and |
| 670 | returns a list of all the perlasm() directives found in the file.""" |
| 671 | perlasms = [] |
| 672 | with open(cmakefile) as f: |
| 673 | for line in f: |
| 674 | line = line.strip() |
| 675 | if not line.startswith('perlasm('): |
| 676 | continue |
| 677 | if not line.endswith(')'): |
| 678 | raise ValueError('Bad perlasm line in %s' % cmakefile) |
| 679 | # Remove "perlasm(" from start and ")" from end |
| 680 | params = line[8:-1].split() |
David Benjamin | 1967621 | 2023-01-25 10:03:53 -0500 | [diff] [blame] | 681 | if len(params) != 4: |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 682 | raise ValueError('Bad perlasm line in %s' % cmakefile) |
| 683 | perlasms.append({ |
David Benjamin | 1967621 | 2023-01-25 10:03:53 -0500 | [diff] [blame] | 684 | 'arch': params[1], |
| 685 | 'output': os.path.join(os.path.dirname(cmakefile), params[2]), |
| 686 | 'input': os.path.join(os.path.dirname(cmakefile), params[3]), |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 687 | }) |
| 688 | |
| 689 | return perlasms |
| 690 | |
| 691 | |
| 692 | def ReadPerlAsmOperations(): |
| 693 | """Returns a list of all perlasm() directives found in CMake config files in |
| 694 | src/.""" |
| 695 | perlasms = [] |
| 696 | cmakefiles = FindCMakeFiles('src') |
| 697 | |
| 698 | for cmakefile in cmakefiles: |
| 699 | perlasms.extend(ExtractPerlAsmFromCMakeFile(cmakefile)) |
| 700 | |
| 701 | return perlasms |
| 702 | |
| 703 | |
| 704 | def PerlAsm(output_filename, input_filename, perlasm_style, extra_args): |
| 705 | """Runs the a perlasm script and puts the output into output_filename.""" |
| 706 | base_dir = os.path.dirname(output_filename) |
| 707 | if not os.path.isdir(base_dir): |
| 708 | os.makedirs(base_dir) |
David Benjamin | fdd8e9c | 2016-06-26 13:18:50 -0400 | [diff] [blame] | 709 | subprocess.check_call( |
| 710 | ['perl', input_filename, perlasm_style] + extra_args + [output_filename]) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 711 | |
| 712 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 713 | def WriteAsmFiles(perlasms): |
| 714 | """Generates asm files from perlasm directives for each supported OS x |
| 715 | platform combination.""" |
| 716 | asmfiles = {} |
| 717 | |
David Benjamin | 1967621 | 2023-01-25 10:03:53 -0500 | [diff] [blame] | 718 | for perlasm in perlasms: |
| 719 | for (osname, arch, perlasm_style, extra_args, asm_ext) in OS_ARCH_COMBOS: |
| 720 | if arch != perlasm['arch']: |
| 721 | continue |
| 722 | # TODO(https://crbug.com/boringssl/524): Now that we incorporate osname in |
| 723 | # the output filename, the asm files can just go in a single directory. |
| 724 | # For now, we keep them in target-specific directories to avoid breaking |
| 725 | # downstream scripts. |
| 726 | key = (osname, arch) |
| 727 | outDir = '%s-%s' % key |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 728 | output = perlasm['output'] |
| 729 | if not output.startswith('src'): |
| 730 | raise ValueError('output missing src: %s' % output) |
| 731 | output = os.path.join(outDir, output[4:]) |
David Benjamin | 1967621 | 2023-01-25 10:03:53 -0500 | [diff] [blame] | 732 | output = '%s-%s.%s' % (output, osname, asm_ext) |
| 733 | PerlAsm(output, perlasm['input'], perlasm_style, extra_args) |
| 734 | asmfiles.setdefault(key, []).append(output) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 735 | |
Yoshisato Yanagisawa | 5650816 | 2021-03-23 05:34:47 +0000 | [diff] [blame] | 736 | for (key, non_perl_asm_files) in NON_PERL_FILES.items(): |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 737 | asmfiles.setdefault(key, []).extend(non_perl_asm_files) |
| 738 | |
Yoshisato Yanagisawa | 5650816 | 2021-03-23 05:34:47 +0000 | [diff] [blame] | 739 | for files in asmfiles.values(): |
David Benjamin | edd4c5f | 2020-08-19 14:46:17 -0400 | [diff] [blame] | 740 | files.sort() |
| 741 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 742 | return asmfiles |
| 743 | |
| 744 | |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 745 | def ExtractVariablesFromCMakeFile(cmakefile): |
| 746 | """Parses the contents of the CMakeLists.txt file passed as an argument and |
| 747 | returns a dictionary of exported source lists.""" |
| 748 | variables = {} |
| 749 | in_set_command = False |
| 750 | set_command = [] |
| 751 | with open(cmakefile) as f: |
| 752 | for line in f: |
| 753 | if '#' in line: |
| 754 | line = line[:line.index('#')] |
| 755 | line = line.strip() |
| 756 | |
| 757 | if not in_set_command: |
| 758 | if line.startswith('set('): |
| 759 | in_set_command = True |
| 760 | set_command = [] |
| 761 | elif line == ')': |
| 762 | in_set_command = False |
| 763 | if not set_command: |
| 764 | raise ValueError('Empty set command') |
| 765 | variables[set_command[0]] = set_command[1:] |
| 766 | else: |
| 767 | set_command.extend([c for c in line.split(' ') if c]) |
| 768 | |
| 769 | if in_set_command: |
| 770 | raise ValueError('Unfinished set command') |
| 771 | return variables |
| 772 | |
| 773 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 774 | def main(platforms): |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 775 | cmake = ExtractVariablesFromCMakeFile(os.path.join('src', 'sources.cmake')) |
Andres Erbsen | 5b280a8 | 2017-10-30 15:58:33 +0000 | [diff] [blame] | 776 | crypto_c_files = (FindCFiles(os.path.join('src', 'crypto'), NoTestsNorFIPSFragments) + |
Adam Langley | 7f02881 | 2019-10-18 14:48:11 -0700 | [diff] [blame] | 777 | FindCFiles(os.path.join('src', 'third_party', 'fiat'), NoTestsNorFIPSFragments)) |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 778 | fips_fragments = FindCFiles(os.path.join('src', 'crypto', 'fipsmodule'), OnlyFIPSFragments) |
Adam Langley | feca9e5 | 2017-01-23 13:07:50 -0800 | [diff] [blame] | 779 | ssl_source_files = FindCFiles(os.path.join('src', 'ssl'), NoTests) |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 780 | tool_c_files = FindCFiles(os.path.join('src', 'tool'), NoTests) |
Adam Langley | f11f233 | 2016-06-30 11:56:19 -0700 | [diff] [blame] | 781 | tool_h_files = FindHeaderFiles(os.path.join('src', 'tool'), AllFiles) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 782 | |
Pete Bentley | 44544d9 | 2019-08-15 15:01:26 +0100 | [diff] [blame] | 783 | # BCM shared library C files |
| 784 | bcm_crypto_c_files = [ |
| 785 | os.path.join('src', 'crypto', 'fipsmodule', 'bcm.c') |
| 786 | ] |
| 787 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 788 | # Generate err_data.c |
| 789 | with open('err_data.c', 'w+') as err_data: |
| 790 | subprocess.check_call(['go', 'run', 'err_data_generate.go'], |
| 791 | cwd=os.path.join('src', 'crypto', 'err'), |
| 792 | stdout=err_data) |
| 793 | crypto_c_files.append('err_data.c') |
David Benjamin | edd4c5f | 2020-08-19 14:46:17 -0400 | [diff] [blame] | 794 | crypto_c_files.sort() |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 795 | |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 796 | test_support_c_files = FindCFiles(os.path.join('src', 'crypto', 'test'), |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 797 | NotGTestSupport) |
Matt Braithwaite | dfdd49c | 2016-06-13 17:06:48 -0700 | [diff] [blame] | 798 | test_support_h_files = ( |
| 799 | FindHeaderFiles(os.path.join('src', 'crypto', 'test'), AllFiles) + |
Martin Kreichgauer | 8b487b7 | 2017-04-03 16:07:27 -0700 | [diff] [blame] | 800 | FindHeaderFiles(os.path.join('src', 'ssl', 'test'), NoTestRunnerFiles)) |
David Benjamin | 2607383 | 2015-05-11 20:52:48 -0400 | [diff] [blame] | 801 | |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 802 | crypto_test_files = [] |
| 803 | if EMBED_TEST_DATA: |
| 804 | # Generate crypto_test_data.cc |
| 805 | with open('crypto_test_data.cc', 'w+') as out: |
| 806 | subprocess.check_call( |
| 807 | ['go', 'run', 'util/embed_test_data.go'] + cmake['CRYPTO_TEST_DATA'], |
| 808 | cwd='src', |
| 809 | stdout=out) |
| 810 | crypto_test_files += ['crypto_test_data.cc'] |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 811 | |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 812 | crypto_test_files += FindCFiles(os.path.join('src', 'crypto'), OnlyTests) |
David Benjamin | 96ee4a8 | 2017-07-09 23:46:47 -0400 | [diff] [blame] | 813 | crypto_test_files += [ |
David Benjamin | c388963 | 2019-03-01 15:03:05 -0500 | [diff] [blame] | 814 | 'src/crypto/test/abi_test.cc', |
David Benjamin | 3ecd0a5 | 2017-05-19 15:26:18 -0400 | [diff] [blame] | 815 | 'src/crypto/test/file_test_gtest.cc', |
| 816 | 'src/crypto/test/gtest_main.cc', |
| 817 | ] |
Adam Langley | 3e502c8 | 2019-10-16 09:56:38 -0700 | [diff] [blame] | 818 | # urandom_test.cc is in a separate binary so that it can be test PRNG |
| 819 | # initialisation. |
| 820 | crypto_test_files = [ |
| 821 | file for file in crypto_test_files |
| 822 | if not file.endswith('/urandom_test.cc') |
| 823 | ] |
David Benjamin | edd4c5f | 2020-08-19 14:46:17 -0400 | [diff] [blame] | 824 | crypto_test_files.sort() |
David Benjamin | 1d5a570 | 2017-02-13 22:11:49 -0500 | [diff] [blame] | 825 | |
| 826 | ssl_test_files = FindCFiles(os.path.join('src', 'ssl'), OnlyTests) |
Robert Sloan | ae1e087 | 2019-03-01 16:01:30 -0800 | [diff] [blame] | 827 | ssl_test_files += [ |
| 828 | 'src/crypto/test/abi_test.cc', |
| 829 | 'src/crypto/test/gtest_main.cc', |
| 830 | ] |
David Benjamin | edd4c5f | 2020-08-19 14:46:17 -0400 | [diff] [blame] | 831 | ssl_test_files.sort() |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 832 | |
Adam Langley | 3e502c8 | 2019-10-16 09:56:38 -0700 | [diff] [blame] | 833 | urandom_test_files = [ |
| 834 | 'src/crypto/fipsmodule/rand/urandom_test.cc', |
| 835 | ] |
| 836 | |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 837 | fuzz_c_files = FindCFiles(os.path.join('src', 'fuzz'), NoTests) |
| 838 | |
David Benjamin | edd4c5f | 2020-08-19 14:46:17 -0400 | [diff] [blame] | 839 | ssl_h_files = FindHeaderFiles(os.path.join('src', 'include', 'openssl'), |
| 840 | SSLHeaderFiles) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 841 | |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 842 | def NotSSLHeaderFiles(path, filename, is_dir): |
| 843 | return not SSLHeaderFiles(path, filename, is_dir) |
David Benjamin | edd4c5f | 2020-08-19 14:46:17 -0400 | [diff] [blame] | 844 | crypto_h_files = FindHeaderFiles(os.path.join('src', 'include', 'openssl'), |
| 845 | NotSSLHeaderFiles) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 846 | |
| 847 | ssl_internal_h_files = FindHeaderFiles(os.path.join('src', 'ssl'), NoTests) |
Andres Erbsen | 5b280a8 | 2017-10-30 15:58:33 +0000 | [diff] [blame] | 848 | crypto_internal_h_files = ( |
| 849 | FindHeaderFiles(os.path.join('src', 'crypto'), NoTests) + |
Adam Langley | 7f02881 | 2019-10-18 14:48:11 -0700 | [diff] [blame] | 850 | FindHeaderFiles(os.path.join('src', 'third_party', 'fiat'), NoTests)) |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 851 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 852 | files = { |
Pete Bentley | 44544d9 | 2019-08-15 15:01:26 +0100 | [diff] [blame] | 853 | 'bcm_crypto': bcm_crypto_c_files, |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 854 | 'crypto': crypto_c_files, |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 855 | 'crypto_headers': crypto_h_files, |
| 856 | 'crypto_internal_headers': crypto_internal_h_files, |
David Benjamin | edd4c5f | 2020-08-19 14:46:17 -0400 | [diff] [blame] | 857 | 'crypto_test': crypto_test_files, |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 858 | '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] | 859 | 'fips_fragments': fips_fragments, |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 860 | 'fuzz': fuzz_c_files, |
Adam Langley | feca9e5 | 2017-01-23 13:07:50 -0800 | [diff] [blame] | 861 | 'ssl': ssl_source_files, |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 862 | 'ssl_headers': ssl_h_files, |
| 863 | 'ssl_internal_headers': ssl_internal_h_files, |
David Benjamin | edd4c5f | 2020-08-19 14:46:17 -0400 | [diff] [blame] | 864 | 'ssl_test': ssl_test_files, |
David Benjamin | 38d01c6 | 2016-04-21 18:47:57 -0400 | [diff] [blame] | 865 | 'tool': tool_c_files, |
Adam Langley | f11f233 | 2016-06-30 11:56:19 -0700 | [diff] [blame] | 866 | 'tool_headers': tool_h_files, |
David Benjamin | c5aa841 | 2016-07-29 17:41:58 -0400 | [diff] [blame] | 867 | 'test_support': test_support_c_files, |
| 868 | 'test_support_headers': test_support_h_files, |
David Benjamin | edd4c5f | 2020-08-19 14:46:17 -0400 | [diff] [blame] | 869 | 'urandom_test': urandom_test_files, |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 870 | } |
| 871 | |
Yoshisato Yanagisawa | 5650816 | 2021-03-23 05:34:47 +0000 | [diff] [blame] | 872 | asm_outputs = sorted(WriteAsmFiles(ReadPerlAsmOperations()).items()) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 873 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 874 | for platform in platforms: |
| 875 | platform.WriteFiles(files, asm_outputs) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 876 | |
| 877 | return 0 |
| 878 | |
David Benjamin | 8c0a6eb | 2020-07-16 14:45:51 -0400 | [diff] [blame] | 879 | ALL_PLATFORMS = { |
| 880 | 'android': Android, |
| 881 | 'android-cmake': AndroidCMake, |
| 882 | 'bazel': Bazel, |
| 883 | 'cmake': CMake, |
| 884 | 'eureka': Eureka, |
| 885 | 'gn': GN, |
| 886 | 'gyp': GYP, |
| 887 | 'json': JSON, |
| 888 | } |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 889 | |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 890 | if __name__ == '__main__': |
David Benjamin | 4acc7dd | 2022-11-19 10:13:49 -0500 | [diff] [blame] | 891 | parser = optparse.OptionParser( |
| 892 | usage='Usage: %%prog [--prefix=<path>] [all|%s]' % |
| 893 | '|'.join(sorted(ALL_PLATFORMS.keys()))) |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 894 | parser.add_option('--prefix', dest='prefix', |
| 895 | help='For Bazel, prepend argument to all source files') |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 896 | parser.add_option( |
| 897 | '--embed_test_data', type='choice', dest='embed_test_data', |
| 898 | action='store', default="true", choices=["true", "false"], |
David Benjamin | f014d60 | 2019-05-07 18:58:06 -0500 | [diff] [blame] | 899 | 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] | 900 | options, args = parser.parse_args(sys.argv[1:]) |
| 901 | PREFIX = options.prefix |
Adam Langley | 990a323 | 2018-05-22 10:02:59 -0700 | [diff] [blame] | 902 | EMBED_TEST_DATA = (options.embed_test_data == "true") |
Matt Braithwaite | 1669589 | 2016-06-09 09:34:11 -0700 | [diff] [blame] | 903 | |
| 904 | if not args: |
| 905 | parser.print_help() |
| 906 | sys.exit(1) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 907 | |
David Benjamin | 4acc7dd | 2022-11-19 10:13:49 -0500 | [diff] [blame] | 908 | if 'all' in args: |
| 909 | platforms = [platform() for platform in ALL_PLATFORMS.values()] |
| 910 | else: |
| 911 | platforms = [] |
| 912 | for s in args: |
| 913 | platform = ALL_PLATFORMS.get(s) |
| 914 | if platform is None: |
| 915 | parser.print_help() |
| 916 | sys.exit(1) |
| 917 | platforms.append(platform()) |
Adam Langley | 9e1a660 | 2015-05-05 17:47:53 -0700 | [diff] [blame] | 918 | |
Adam Langley | 049ef41 | 2015-06-09 18:20:57 -0700 | [diff] [blame] | 919 | sys.exit(main(platforms)) |