Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: third_party/boringssl/update_gypi_and_asm.py

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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', 'aarch64', 'linux64', [''], 'S'),
17 ('linux', 'x86', 'elf', ['-fPIC'], 'S'), 18 ('linux', 'x86', 'elf', ['-fPIC'], 'S'),
18 ('linux', 'x86_64', 'elf', [''], 'S'), 19 ('linux', 'x86_64', 'elf', [''], 'S'),
19 ('mac', 'x86', 'macosx', ['-fPIC'], 'S'), 20 ('mac', 'x86', 'macosx', ['-fPIC'], 'S'),
20 ('mac', 'x86_64', 'macosx', [''], 'S'), 21 ('mac', 'x86_64', 'macosx', [''], 'S'),
21 ('win', 'x86', 'win32n', [''], 'asm'), 22 ('win', 'x86', 'win32n', [''], 'asm'),
22 ('win', 'x86_64', 'nasm', [''], 'asm'), 23 ('win', 'x86_64', 'nasm', [''], 'asm'),
23 ] 24 ]
24 25
25 # NON_PERL_FILES enumerates assembly files that are not processed by the 26 # NON_PERL_FILES enumerates assembly files that are not processed by the
26 # perlasm system. 27 # perlasm system.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 base_dir = os.path.dirname(output_filename) 128 base_dir = os.path.dirname(output_filename)
128 if not os.path.isdir(base_dir): 129 if not os.path.isdir(base_dir):
129 os.makedirs(base_dir) 130 os.makedirs(base_dir)
130 output = subprocess.check_output( 131 output = subprocess.check_output(
131 ['perl', input_filename, perlasm_style] + extra_args) 132 ['perl', input_filename, perlasm_style] + extra_args)
132 with open(output_filename, 'w+') as out_file: 133 with open(output_filename, 'w+') as out_file:
133 out_file.write(output) 134 out_file.write(output)
134 135
135 136
136 def ArchForAsmFilename(filename): 137 def ArchForAsmFilename(filename):
137 """Returns the architecture that a given asm file should be compiled for 138 """Returns the architectures that a given asm file should be compiled for
138 based on substrings in the filename.""" 139 based on substrings in the filename."""
139 140
140 if 'x86_64' in filename or 'avx2' in filename: 141 if 'x86_64' in filename or 'avx2' in filename:
141 return 'x86_64' 142 return ['x86_64']
142 elif ('x86' in filename and 'x86_64' not in filename) or '586' in filename: 143 elif ('x86' in filename and 'x86_64' not in filename) or '586' in filename:
143 return 'x86' 144 return ['x86']
145 elif 'armx' in filename:
146 return ['arm', 'aarch64']
147 elif 'armv8' in filename:
148 return ['aarch64']
144 elif 'arm' in filename: 149 elif 'arm' in filename:
145 return 'arm' 150 return ['arm']
146 else: 151 else:
147 raise ValueError('Unknown arch for asm filename: ' + filename) 152 raise ValueError('Unknown arch for asm filename: ' + filename)
148 153
149 154
150 def WriteAsmFiles(perlasms): 155 def WriteAsmFiles(perlasms):
151 """Generates asm files from perlasm directives for each supported OS x 156 """Generates asm files from perlasm directives for each supported OS x
152 platform combination.""" 157 platform combination."""
153 asmfiles = {} 158 asmfiles = {}
154 159
155 for osarch in OS_ARCH_COMBOS: 160 for osarch in OS_ARCH_COMBOS:
156 (osname, arch, perlasm_style, extra_args, asm_ext) = osarch 161 (osname, arch, perlasm_style, extra_args, asm_ext) = osarch
157 key = (osname, arch) 162 key = (osname, arch)
158 outDir = '%s-%s' % key 163 outDir = '%s-%s' % key
159 164
160 for perlasm in perlasms: 165 for perlasm in perlasms:
161 filename = os.path.basename(perlasm['input']) 166 filename = os.path.basename(perlasm['input'])
162 output = perlasm['output'] 167 output = perlasm['output']
163 if not output.startswith('src'): 168 if not output.startswith('src'):
164 raise ValueError('output missing src: %s' % output) 169 raise ValueError('output missing src: %s' % output)
165 output = os.path.join(outDir, output[4:]) 170 output = os.path.join(outDir, output[4:])
166 output = output.replace('${ASM_EXT}', asm_ext) 171 output = output.replace('${ASM_EXT}', asm_ext)
167 172
168 if arch == ArchForAsmFilename(filename): 173 if arch in ArchForAsmFilename(filename):
169 PerlAsm(output, perlasm['input'], perlasm_style, 174 PerlAsm(output, perlasm['input'], perlasm_style,
170 perlasm['extra_args'] + extra_args) 175 perlasm['extra_args'] + extra_args)
171 asmfiles.setdefault(key, []).append(output) 176 asmfiles.setdefault(key, []).append(output)
172 177
173 for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems(): 178 for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems():
174 asmfiles.setdefault(key, []).extend(non_perl_asm_files) 179 asmfiles.setdefault(key, []).extend(non_perl_asm_files)
175 180
176 return asmfiles 181 return asmfiles
177 182
178 183
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 for test in test_names: 240 for test in test_names:
236 test_gypi.write(""" '%s',\n""" % test) 241 test_gypi.write(""" '%s',\n""" % test)
237 242
238 test_gypi.write(' ],\n }\n}\n') 243 test_gypi.write(' ],\n }\n}\n')
239 244
240 return 0 245 return 0
241 246
242 247
243 if __name__ == '__main__': 248 if __name__ == '__main__':
244 sys.exit(main()) 249 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698