OLD | NEW |
1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
2 | 2 |
3 import argparse | 3 import argparse |
4 import os | 4 import os |
5 import pipes | 5 import pipes |
6 import re | 6 import re |
7 import sys | 7 import sys |
8 | 8 |
9 from utils import shellcmd, FindBaseNaCl, get_sfi_string | 9 from utils import shellcmd, FindBaseNaCl, get_sfi_string |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 """ | 54 """ |
55 if re_exclude.match(sym): | 55 if re_exclude.match(sym): |
56 # Always honor an explicit exclude before considering | 56 # Always honor an explicit exclude before considering |
57 # includes. | 57 # includes. |
58 return False | 58 return False |
59 if re_include.match(sym): | 59 if re_include.match(sym): |
60 return True | 60 return True |
61 return default_match | 61 return default_match |
62 | 62 |
63 def AddOptionalArgs(argparser): | 63 def AddOptionalArgs(argparser): |
64 argparser.add_argument('--force', dest='force', action='store_true', | 64 argparser.add_argument('--force', dest='force', type=int, choices=[0, 1], |
65 help='Force all re-translations of the pexe') | 65 default=1, |
| 66 help='Force all re-translations of the pexe.' + |
| 67 ' Default %(default)s.') |
66 argparser.add_argument('--include', '-i', default=[], dest='include', | 68 argparser.add_argument('--include', '-i', default=[], dest='include', |
67 action='append', | 69 action='append', |
68 help='Subzero symbols to include ' + | 70 help='Subzero symbols to include ' + |
69 '(regex or line range)') | 71 '(regex or line range)') |
70 argparser.add_argument('--exclude', '-e', default=[], dest='exclude', | 72 argparser.add_argument('--exclude', '-e', default=[], dest='exclude', |
71 action='append', | 73 action='append', |
72 help='Subzero symbols to exclude ' + | 74 help='Subzero symbols to exclude ' + |
73 '(regex or line range)') | 75 '(regex or line range)') |
74 argparser.add_argument('--output', '-o', default='a.out', dest='output', | 76 argparser.add_argument('--output', '-o', default='a.out', dest='output', |
75 action='store', | 77 action='store', |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 235 |
234 Each --include and --exclude argument can be a regular expression or a range | 236 Each --include and --exclude argument can be a regular expression or a range |
235 of lines in the symbol file. Each regular expression is wrapped inside | 237 of lines in the symbol file. Each regular expression is wrapped inside |
236 '^$', so if you want a substring match on 'foo', use '.*foo.*' instead. | 238 '^$', so if you want a substring match on 'foo', use '.*foo.*' instead. |
237 Ranges use python-style 'first:last' notation, so e.g. use '0:10' or ':10' | 239 Ranges use python-style 'first:last' notation, so e.g. use '0:10' or ':10' |
238 for the first 10 lines of the file, or '1' for the second line of the file. | 240 for the first 10 lines of the file, or '1' for the second line of the file. |
239 | 241 |
240 If no --include or --exclude arguments are given, the executable is produced | 242 If no --include or --exclude arguments are given, the executable is produced |
241 entirely using Subzero, without using llc or linker tricks. | 243 entirely using Subzero, without using llc or linker tricks. |
242 | 244 |
243 This script uses file modification timestamps to determine whether llc and | 245 When using the --force=0 option, this script uses file modification |
244 Subzero re-translation are needed. It checks timestamps of llc, pnacl-sz, | 246 timestamps to determine whether llc and Subzero re-translation are needed. |
245 and the pexe against the translated object files to determine the minimal | 247 It checks timestamps of llc, pnacl-sz, and the pexe against the translated |
246 work necessary. The --force option suppresses those checks and | 248 object files to determine the minimal work necessary. The --force=1 option |
247 re-translates everything. | 249 (default) suppresses those checks and re-translates everything. |
248 | 250 |
249 This script expects various PNaCl and LLVM tools to be found within the | 251 This script expects various PNaCl and LLVM tools to be found within the |
250 native_client tree. When changes are made to these tools, copy them this | 252 native_client tree. When changes are made to these tools, copy them this |
251 way: | 253 way: |
252 cd native_client | 254 cd native_client |
253 toolchain_build/toolchain_build_pnacl.py llvm_x86_64_linux \\ | 255 toolchain_build/toolchain_build_pnacl.py llvm_x86_64_linux \\ |
254 --install=toolchain/linux_x86/pnacl_newlib_raw | 256 --install=toolchain/linux_x86/pnacl_newlib_raw |
255 """ | 257 """ |
256 argparser = argparse.ArgumentParser( | 258 argparser = argparse.ArgumentParser( |
257 description=' ' + main.__doc__, | 259 description=' ' + main.__doc__, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 449 |
448 # Put the extra verbose printing at the end. | 450 # Put the extra verbose printing at the end. |
449 if args.verbose and hybrid: | 451 if args.verbose and hybrid: |
450 print 'include={regex}'.format(regex=re_include_str) | 452 print 'include={regex}'.format(regex=re_include_str) |
451 print 'exclude={regex}'.format(regex=re_exclude_str) | 453 print 'exclude={regex}'.format(regex=re_exclude_str) |
452 print 'default_match={dm}'.format(dm=default_match) | 454 print 'default_match={dm}'.format(dm=default_match) |
453 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) | 455 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) |
454 | 456 |
455 if __name__ == '__main__': | 457 if __name__ == '__main__': |
456 main() | 458 main() |
OLD | NEW |