Add Apps.AppListSearchQueryLength UMA histogram.
[chromium-blink-merge.git] / build / android / gyp / gcc_preprocess.py
blob03becf918fed98b9077d99d86f44416a07d207a5
1 #!/usr/bin/env python
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.
7 import optparse
8 import os
9 import sys
11 from util import build_utils
13 def DoGcc(options):
14 build_utils.MakeDirectory(os.path.dirname(options.output))
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
29 build_utils.CheckOutput(gcc_cmd)
32 def main(args):
33 args = build_utils.ExpandFileArgs(args)
35 parser = optparse.OptionParser()
36 build_utils.AddDepfileOption(parser)
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')
44 options, _ = parser.parse_args(args)
46 DoGcc(options)
48 if options.depfile:
49 build_utils.WriteDepfile(
50 options.depfile,
51 build_utils.GetPythonDependencies())
53 if options.stamp:
54 build_utils.Touch(options.stamp)
57 if __name__ == '__main__':
58 sys.exit(main(sys.argv[1:]))