| OLD | NEW | 
|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 
| 2 # Use of this source code is governed by a BSD-style license that can b | 2 # Use of this source code is governed by a BSD-style license that can b | 
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. | 
| 4 | 4 | 
| 5 """Enumerates the BoringSSL source in src/ and generates two gypi files: | 5 """Enumerates the BoringSSL source in src/ and generates two gypi files: | 
| 6   boringssl.gypi and boringssl_tests.gypi.""" | 6   boringssl.gypi and boringssl_tests.gypi.""" | 
| 7 | 7 | 
| 8 import os | 8 import os | 
| 9 import subprocess | 9 import subprocess | 
| 10 import sys | 10 import sys | 
| 11 | 11 | 
| 12 | 12 | 
| 13 # OS_ARCH_COMBOS maps from OS and platform to the OpenSSL assembly "style" for | 13 # OS_ARCH_COMBOS maps from OS and platform to the OpenSSL assembly "style" for | 
| 14 # that platform and the extension used by asm files. | 14 # that platform and the extension used by asm files. | 
| 15 OS_ARCH_COMBOS = [ | 15 OS_ARCH_COMBOS = [ | 
| 16     ('linux', 'arm', 'elf', 'S'), | 16     ('linux', 'arm', 'elf', [''], 'S'), | 
| 17     ('linux', 'x86', 'elf', 'S'), | 17     ('linux', 'x86', 'elf', ['-fPIC'], 'S'), | 
| 18     ('linux', 'x86_64', 'elf', 'S'), | 18     ('linux', 'x86_64', 'elf', [''], 'S'), | 
| 19     ('mac', 'x86', 'macosx', 'S'), | 19     ('mac', 'x86', 'macosx', ['-fPIC'], 'S'), | 
| 20     ('mac', 'x86_64', 'macosx', 'S'), | 20     ('mac', 'x86_64', 'macosx', [''], 'S'), | 
| 21     ('win', 'x86_64', 'masm', 'asm'), | 21     ('win', 'x86_64', 'masm', [''], 'asm'), | 
| 22 ] | 22 ] | 
| 23 | 23 | 
| 24 # NON_PERL_FILES enumerates assembly files that are not processed by the | 24 # NON_PERL_FILES enumerates assembly files that are not processed by the | 
| 25 # perlasm system. | 25 # perlasm system. | 
| 26 NON_PERL_FILES = { | 26 NON_PERL_FILES = { | 
| 27     ('linux', 'arm'): [ | 27     ('linux', 'arm'): [ | 
| 28         'src/crypto/poly1305/poly1305_arm_asm.S', | 28         'src/crypto/poly1305/poly1305_arm_asm.S', | 
| 29         'src/crypto/chacha/chacha_vec_arm.S', | 29         'src/crypto/chacha/chacha_vec_arm.S', | 
| 30     ], | 30     ], | 
| 31 } | 31 } | 
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 145   else: | 145   else: | 
| 146     raise ValueError('Unknown arch for asm filename: ' + filename) | 146     raise ValueError('Unknown arch for asm filename: ' + filename) | 
| 147 | 147 | 
| 148 | 148 | 
| 149 def WriteAsmFiles(perlasms): | 149 def WriteAsmFiles(perlasms): | 
| 150   """Generates asm files from perlasm directives for each supported OS x | 150   """Generates asm files from perlasm directives for each supported OS x | 
| 151   platform combination.""" | 151   platform combination.""" | 
| 152   asmfiles = {} | 152   asmfiles = {} | 
| 153 | 153 | 
| 154   for osarch in OS_ARCH_COMBOS: | 154   for osarch in OS_ARCH_COMBOS: | 
| 155     (osname, arch, perlasm_style, asm_ext) = osarch | 155     (osname, arch, perlasm_style, extra_args, asm_ext) = osarch | 
| 156     key = (osname, arch) | 156     key = (osname, arch) | 
| 157     outDir = '%s-%s' % key | 157     outDir = '%s-%s' % key | 
| 158 | 158 | 
| 159     for perlasm in perlasms: | 159     for perlasm in perlasms: | 
| 160       filename = os.path.basename(perlasm['input']) | 160       filename = os.path.basename(perlasm['input']) | 
| 161       output = perlasm['output'] | 161       output = perlasm['output'] | 
| 162       if not output.startswith('src'): | 162       if not output.startswith('src'): | 
| 163         raise ValueError('output missing src: %s' % output) | 163         raise ValueError('output missing src: %s' % output) | 
| 164       output = os.path.join(outDir, output[4:]) | 164       output = os.path.join(outDir, output[4:]) | 
| 165       output = output.replace('${ASM_EXT}', asm_ext) | 165       output = output.replace('${ASM_EXT}', asm_ext) | 
| 166 | 166 | 
| 167       if arch == ArchForAsmFilename(filename): | 167       if arch == ArchForAsmFilename(filename): | 
| 168         PerlAsm(output, perlasm['input'], perlasm_style, perlasm['extra_args']) | 168         PerlAsm(output, perlasm['input'], perlasm_style, | 
|  | 169                 perlasm['extra_args'] + extra_args) | 
| 169         asmfiles.setdefault(key, []).append(output) | 170         asmfiles.setdefault(key, []).append(output) | 
| 170 | 171 | 
| 171   for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems(): | 172   for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems(): | 
| 172     asmfiles.setdefault(key, []).extend(non_perl_asm_files) | 173     asmfiles.setdefault(key, []).extend(non_perl_asm_files) | 
| 173 | 174 | 
| 174   return asmfiles | 175   return asmfiles | 
| 175 | 176 | 
| 176 | 177 | 
| 177 def PrintVariableSection(out, name, files): | 178 def PrintVariableSection(out, name, files): | 
| 178   out.write('    \'%s\': [\n' % name) | 179   out.write('    \'%s\': [\n' % name) | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 199                            (osname, arch), asm_files) | 200                            (osname, arch), asm_files) | 
| 200 | 201 | 
| 201     gypi.write('  }\n}\n') | 202     gypi.write('  }\n}\n') | 
| 202 | 203 | 
| 203   test_c_files = FindCFiles(os.path.join('src', 'crypto'), OnlyTests) | 204   test_c_files = FindCFiles(os.path.join('src', 'crypto'), OnlyTests) | 
| 204 | 205 | 
| 205   with open('boringssl_tests.gypi', 'w+') as test_gypi: | 206   with open('boringssl_tests.gypi', 'w+') as test_gypi: | 
| 206     test_gypi.write(FILE_HEADER + '{\n  \'targets\': [\n') | 207     test_gypi.write(FILE_HEADER + '{\n  \'targets\': [\n') | 
| 207 | 208 | 
| 208     test_names = [] | 209     test_names = [] | 
| 209     for test in test_c_files: | 210     for test in sorted(test_c_files): | 
| 210       test_name = 'boringssl_%s' % os.path.splitext(os.path.basename(test))[0] | 211       test_name = 'boringssl_%s' % os.path.splitext(os.path.basename(test))[0] | 
| 211       test_gypi.write("""    { | 212       test_gypi.write("""    { | 
| 212       'target_name': '%s', | 213       'target_name': '%s', | 
| 213       'type': 'executable', | 214       'type': 'executable', | 
| 214       'dependencies': [ | 215       'dependencies': [ | 
| 215         'boringssl', | 216         'boringssl', | 
| 216       ], | 217       ], | 
| 217       'sources': [ | 218       'sources': [ | 
| 218         '%s', | 219         '%s', | 
| 219       ], | 220       ], | 
| 220     },\n""" % (test_name, test)) | 221     },\n""" % (test_name, test)) | 
| 221       test_names.append(test_name) | 222       test_names.append(test_name) | 
| 222 | 223 | 
| 223     test_names.sort() | 224     test_names.sort() | 
| 224 | 225 | 
| 225     test_gypi.write("""  ], | 226     test_gypi.write("""  ], | 
| 226   'variables': { | 227   'variables': { | 
| 227     'boringssl_test_targets': [\n""") | 228     'boringssl_test_targets': [\n""") | 
| 228 | 229 | 
| 229     for test in test_names: | 230     for test in test_names: | 
| 230       test_gypi.write("""      '%s',\n""" % test) | 231       test_gypi.write("""      '%s',\n""" % test) | 
| 231 | 232 | 
| 232     test_gypi.write('    ],\n  }\n}\n') | 233     test_gypi.write('    ],\n  }\n}\n') | 
| 233 | 234 | 
| 234   return 0 | 235   return 0 | 
| 235 | 236 | 
| 236 | 237 | 
| 237 if __name__ == '__main__': | 238 if __name__ == '__main__': | 
| 238   sys.exit(main()) | 239   sys.exit(main()) | 
| OLD | NEW | 
|---|