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