OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 |
| 3 # Copyright 2010 The Native Client Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can |
| 5 # be found in the LICENSE file. |
| 6 |
| 7 import re |
| 8 |
| 9 def GetNaClElfConstants(header_file): |
| 10 |
| 11 symbols = [ 'ELFOSABI_NACL', |
| 12 'EF_NACL_ALIGN_MASK', |
| 13 'EF_NACL_ALIGN_16', |
| 14 'EF_NACL_ALIGN_32', |
| 15 'EF_NACL_ALIGN_LIB', |
| 16 'EF_NACL_ABIVERSION', |
| 17 ] |
| 18 |
| 19 extractors = [ r'#\s*define\s+%s\s+([x\d]+)' % s |
| 20 for s in symbols ] |
| 21 |
| 22 nfas = [ re.compile(extractor) for extractor in extractors ] |
| 23 results = len(extractors) * [ -1 ] |
| 24 for line in open(header_file): |
| 25 for ix, nfa in enumerate(nfas): |
| 26 m = nfa.search(line) |
| 27 if m is not None: |
| 28 results[ix] = int(m.group(1), 0) |
| 29 continue |
| 30 if -1 in results: |
| 31 raise RuntimeError, 'Could not parse header file %s' % header_file |
| 32 return dict(zip(symbols, results)) |
OLD | NEW |