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 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 """Runs the a perlasm script and puts the output into output_filename.""" | 125 """Runs the a perlasm script and puts the output into output_filename.""" |
126 base_dir = os.path.dirname(output_filename) | 126 base_dir = os.path.dirname(output_filename) |
127 if not os.path.isdir(base_dir): | 127 if not os.path.isdir(base_dir): |
128 os.makedirs(base_dir) | 128 os.makedirs(base_dir) |
129 output = subprocess.check_output( | 129 output = subprocess.check_output( |
130 ['perl', input_filename, perlasm_style] + extra_args) | 130 ['perl', input_filename, perlasm_style] + extra_args) |
131 with open(output_filename, 'w+') as out_file: | 131 with open(output_filename, 'w+') as out_file: |
132 out_file.write(output) | 132 out_file.write(output) |
133 | 133 |
134 | 134 |
| 135 def ArchForAsmFilename(filename): |
| 136 """Returns the architecture that a given asm file should be compiled for |
| 137 based on substrings in the filename.""" |
| 138 |
| 139 if 'x86_64' in filename or 'avx2' in filename: |
| 140 return 'x86_64' |
| 141 elif ('x86' in filename and 'x86_64' not in filename) or '586' in filename: |
| 142 return 'x86' |
| 143 elif 'arm' in filename: |
| 144 return 'arm' |
| 145 else: |
| 146 raise ValueError('Unknown arch for asm filename: ' + filename) |
| 147 |
| 148 |
135 def WriteAsmFiles(perlasms): | 149 def WriteAsmFiles(perlasms): |
136 """Generates asm files from perlasm directives for each supported OS x | 150 """Generates asm files from perlasm directives for each supported OS x |
137 platform combination.""" | 151 platform combination.""" |
138 asmfiles = {} | 152 asmfiles = {} |
139 | 153 |
140 for osarch in OS_ARCH_COMBOS: | 154 for osarch in OS_ARCH_COMBOS: |
141 (osname, arch, perlasm_style, asm_ext) = osarch | 155 (osname, arch, perlasm_style, asm_ext) = osarch |
142 key = (osname, arch) | 156 key = (osname, arch) |
143 outDir = '%s-%s' % key | 157 outDir = '%s-%s' % key |
144 | 158 |
145 for perlasm in perlasms: | 159 for perlasm in perlasms: |
146 filename = os.path.basename(perlasm['input']) | 160 filename = os.path.basename(perlasm['input']) |
147 output = perlasm['output'] | 161 output = perlasm['output'] |
148 if not output.startswith('src'): | 162 if not output.startswith('src'): |
149 raise ValueError('output missing src: %s' % output) | 163 raise ValueError('output missing src: %s' % output) |
150 output = os.path.join(outDir, output[4:]) | 164 output = os.path.join(outDir, output[4:]) |
151 output = output.replace('${ASM_EXT}', asm_ext) | 165 output = output.replace('${ASM_EXT}', asm_ext) |
152 | 166 |
153 found = False | 167 if arch == ArchForAsmFilename(filename): |
154 if arch == 'x86_64' and ('x86_64' in filename or 'avx2' in filename): | |
155 found = True | |
156 elif arch == 'x86' and 'x86' in filename and 'x86_64' not in filename: | |
157 found = True | |
158 elif arch == 'arm' and 'arm' in filename: | |
159 found = True | |
160 | |
161 if found: | |
162 PerlAsm(output, perlasm['input'], perlasm_style, perlasm['extra_args']) | 168 PerlAsm(output, perlasm['input'], perlasm_style, perlasm['extra_args']) |
163 asmfiles.setdefault(key, []).append(output) | 169 asmfiles.setdefault(key, []).append(output) |
164 | 170 |
165 for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems(): | 171 for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems(): |
166 asmfiles.setdefault(key, []).extend(non_perl_asm_files) | 172 asmfiles.setdefault(key, []).extend(non_perl_asm_files) |
167 | 173 |
168 return asmfiles | 174 return asmfiles |
169 | 175 |
170 | 176 |
171 def PrintVariableSection(out, name, files): | 177 def PrintVariableSection(out, name, files): |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 for test in test_names: | 229 for test in test_names: |
224 test_gypi.write(""" '%s',\n""" % test) | 230 test_gypi.write(""" '%s',\n""" % test) |
225 | 231 |
226 test_gypi.write(' ],\n }\n}\n') | 232 test_gypi.write(' ],\n }\n}\n') |
227 | 233 |
228 return 0 | 234 return 0 |
229 | 235 |
230 | 236 |
231 if __name__ == '__main__': | 237 if __name__ == '__main__': |
232 sys.exit(main()) | 238 sys.exit(main()) |
OLD | NEW |