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