| 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 | 9 from utils import shellcmd |
| 10 from utils import FindBaseNaCl | 10 from utils import FindBaseNaCl |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' | 212 'nm {obj} | sed -n "s/.* [a-zA-Z] //p" > {sym}' |
| 213 ).format(obj=obj_sz, sym=sym_sz), echo=args.verbose) | 213 ).format(obj=obj_sz, sym=sym_sz), echo=args.verbose) |
| 214 | 214 |
| 215 with open(sym_sz_unescaped) as f: | 215 with open(sym_sz_unescaped) as f: |
| 216 sz_syms = f.read().splitlines() | 216 sz_syms = f.read().splitlines() |
| 217 re_include_str = BuildRegex(args.include, sz_syms) | 217 re_include_str = BuildRegex(args.include, sz_syms) |
| 218 re_exclude_str = BuildRegex(args.exclude, sz_syms) | 218 re_exclude_str = BuildRegex(args.exclude, sz_syms) |
| 219 re_include = re.compile(re_include_str) | 219 re_include = re.compile(re_include_str) |
| 220 re_exclude = re.compile(re_exclude_str) | 220 re_exclude = re.compile(re_exclude_str) |
| 221 # If a symbol doesn't explicitly match re_include or re_exclude, | 221 # If a symbol doesn't explicitly match re_include or re_exclude, |
| 222 # the default MatchSymbol() result is False, unless some --exclude | 222 # the default MatchSymbol() result is True, unless some --include |
| 223 # args are provided and no --include args are provided. | 223 # args are provided. |
| 224 default_match = len(args.exclude) and not len(args.include) | 224 default_match = not len(args.include) |
| 225 | 225 |
| 226 whitelist_has_items = False | 226 whitelist_has_items = False |
| 227 with open(whitelist_sz_unescaped, 'w') as f: | 227 with open(whitelist_sz_unescaped, 'w') as f: |
| 228 for sym in sz_syms: | 228 for sym in sz_syms: |
| 229 if MatchSymbol(sym, re_include, re_exclude, default_match): | 229 if MatchSymbol(sym, re_include, re_exclude, default_match): |
| 230 f.write(sym + '\n') | 230 f.write(sym + '\n') |
| 231 whitelist_has_items = True | 231 whitelist_has_items = True |
| 232 shellcmd(( | 232 shellcmd(( |
| 233 'objcopy --weaken {obj} {weak}' | 233 'objcopy --weaken {obj} {weak}' |
| 234 ).format(obj=obj_sz, weak=obj_sz_weak), echo=args.verbose) | 234 ).format(obj=obj_sz, weak=obj_sz_weak), echo=args.verbose) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 265 # Put the extra verbose printing at the end. | 265 # Put the extra verbose printing at the end. |
| 266 if args.verbose: | 266 if args.verbose: |
| 267 print 'PATH={path}'.format(path=os.environ['PATH']) | 267 print 'PATH={path}'.format(path=os.environ['PATH']) |
| 268 print 'include={regex}'.format(regex=re_include_str) | 268 print 'include={regex}'.format(regex=re_include_str) |
| 269 print 'exclude={regex}'.format(regex=re_exclude_str) | 269 print 'exclude={regex}'.format(regex=re_exclude_str) |
| 270 print 'default_match={dm}'.format(dm=default_match) | 270 print 'default_match={dm}'.format(dm=default_match) |
| 271 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) | 271 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) |
| 272 | 272 |
| 273 if __name__ == '__main__': | 273 if __name__ == '__main__': |
| 274 main() | 274 main() |
| OLD | NEW |