| # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| # Use of this source code is governed by a BSD-style license |
| # that can be found in the LICENSE file in the root of the source |
| # tree. An additional intellectual property rights grant can be found |
| # in the file PATENTS. All contributing project authors may |
| # be found in the AUTHORS file in the root of the source tree. |
| """This script generates a C header file of offsets from an ARM assembler file. |
| It parses an ARM assembler generated .S file, finds declarations of variables |
| whose names start with the string specified as the third argument in the |
| command-line, translates the variable names and values into constant defines and |
| writes them into a header file. |
| print("Usage: generate_asm_header.py " + |
| "<input filename> <output filename> <variable name pattern>") |
| outfile = open(argv[1], 'w') |
| for line in infile: # Iterate though all the lines in the input file. |
| if line.startswith(argv[2]): |
| outfile.write('#define ') |
| outfile.write(line.split(':')[0]) # Write the constant name. |
| if line.find('.word') >= 0: |
| outfile.write(line.split('.word')[1]) # Write the constant value. |
| if __name__ == "__main__": |