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