OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # | |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 | |
7 import optparse | |
8 import os | |
9 import sys | |
10 | |
11 from util import build_utils | |
12 | |
13 def DoGcc(options): | |
14 build_utils.MakeDirectory(os.path.dirname(options.output)) | |
15 | |
16 gcc_cmd = [ 'gcc' ] # invoke host gcc. | |
17 if options.defines: | |
18 gcc_cmd.extend(sum(map(lambda w: ['-D', w], options.defines), [])) | |
19 gcc_cmd.extend([ | |
20 '-E', # stop after preprocessing. | |
21 '-D', 'ANDROID', # Specify ANDROID define for pre-processor. | |
22 '-x', 'c-header', # treat sources as C header files | |
23 '-P', # disable line markers, i.e. '#line 309' | |
24 '-I', options.include_path, | |
25 '-o', options.output, | |
26 options.template | |
27 ]) | |
28 | |
29 build_utils.CheckOutput(gcc_cmd) | |
30 | |
31 | |
32 def main(args): | |
33 args = build_utils.ExpandFileArgs(args) | |
34 | |
35 parser = optparse.OptionParser() | |
36 build_utils.AddDepfileOption(parser) | |
37 | |
38 parser.add_option('--include-path', help='Include path for gcc.') | |
39 parser.add_option('--template', help='Path to template.') | |
40 parser.add_option('--output', help='Path for generated file.') | |
41 parser.add_option('--stamp', help='Path to touch on success.') | |
42 parser.add_option('--defines', help='Pre-defines macros', action='append') | |
43 | |
44 options, _ = parser.parse_args(args) | |
45 | |
46 DoGcc(options) | |
47 | |
48 if options.depfile: | |
49 build_utils.WriteDepfile( | |
50 options.depfile, | |
51 build_utils.GetPythonDependencies()) | |
52 | |
53 if options.stamp: | |
54 build_utils.Touch(options.stamp) | |
55 | |
56 | |
57 if __name__ == '__main__': | |
58 sys.exit(main(sys.argv[1:])) | |
OLD | NEW |