json_schema_compile.gypi revision cedac228d2dd51db4b79ea1e72c7f249408ee061
1# Copyright (c) 2012 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5{
6  'variables': {
7    # When including this gypi, the following variables must be set:
8    #   schema_files: a list of json or IDL files that comprise the api model.
9    #   cc_dir: path to generated files
10    #   root_namespace: the C++ namespace that all generated files go under
11    # Functions and namespaces can be excluded by setting "nocompile" to true.
12    # The default root path of API implementation sources is
13    # chrome/browser/extensions/api and can be overridden by setting "impl_dir".
14    'api_gen_dir': '<(DEPTH)/tools/json_schema_compiler',
15    'api_gen': '<(api_gen_dir)/compiler.py',
16    'impl_dir%': 'chrome/browser/extensions/api',
17  },
18  'rules': [
19    {
20      'rule_name': 'genapi',
21      'msvs_external_rule': 1,
22      'extension': 'json',
23      'inputs': [
24        '<(api_gen_dir)/cc_generator.py',
25        '<(api_gen_dir)/code.py',
26        '<(api_gen_dir)/compiler.py',
27        '<(api_gen_dir)/cpp_generator.py',
28        '<(api_gen_dir)/cpp_type_generator.py',
29        '<(api_gen_dir)/cpp_util.py',
30        '<(api_gen_dir)/h_generator.py',
31        '<(api_gen_dir)/json_schema.py',
32        '<(api_gen_dir)/model.py',
33        '<(api_gen_dir)/util.cc',
34        '<(api_gen_dir)/util.h',
35        '<(api_gen_dir)/util_cc_helper.py',
36        # TODO(calamity): uncomment this when gyp on windows behaves like other
37        # platforms. List expansions of filepaths in inputs expand to different
38        # things.
39        # '<@(schema_files)',
40      ],
41      'outputs': [
42        '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).cc',
43        '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).h',
44      ],
45      'action': [
46        'python',
47        '<(api_gen)',
48        '<(RULE_INPUT_PATH)',
49        '--root=<(DEPTH)',
50        '--destdir=<(SHARED_INTERMEDIATE_DIR)',
51        '--namespace=<(root_namespace)',
52        '--generator=cpp',
53        '--impl-dir=<(impl_dir)'
54      ],
55      'message': 'Generating C++ code from <(RULE_INPUT_PATH) json files',
56      'process_outputs_as_sources': 1,
57    },
58    {
59      'rule_name': 'genapi_idl',
60      'msvs_external_rule': 1,
61      'extension': 'idl',
62      'inputs': [
63        '<(api_gen_dir)/cc_generator.py',
64        '<(api_gen_dir)/code.py',
65        '<(api_gen_dir)/compiler.py',
66        '<(api_gen_dir)/cpp_generator.py',
67        '<(api_gen_dir)/cpp_type_generator.py',
68        '<(api_gen_dir)/cpp_util.py',
69        '<(api_gen_dir)/h_generator.py',
70        '<(api_gen_dir)/idl_schema.py',
71        '<(api_gen_dir)/model.py',
72        '<(api_gen_dir)/util.cc',
73        '<(api_gen_dir)/util.h',
74        '<(api_gen_dir)/util_cc_helper.py',
75        # TODO(calamity): uncomment this when gyp on windows behaves like other
76        # platforms. List expansions of filepaths in inputs expand to different
77        # things.
78        # '<@(schema_files)',
79      ],
80      'outputs': [
81        '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).cc',
82        '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).h',
83      ],
84      'action': [
85        'python',
86        '<(api_gen)',
87        '<(RULE_INPUT_PATH)',
88        '--root=<(DEPTH)',
89        '--destdir=<(SHARED_INTERMEDIATE_DIR)',
90        '--namespace=<(root_namespace)',
91        '--generator=cpp',
92        '--impl-dir=<(impl_dir)'
93      ],
94      'message': 'Generating C++ code from <(RULE_INPUT_PATH) IDL files',
95      'process_outputs_as_sources': 1,
96    },
97  ],
98  'include_dirs': [
99    '<(SHARED_INTERMEDIATE_DIR)',
100    '<(DEPTH)',
101  ],
102  'dependencies':[
103    '<(DEPTH)/tools/json_schema_compiler/api_gen_util.gyp:api_gen_util',
104  ],
105  'direct_dependent_settings': {
106    'include_dirs': [
107      '<(SHARED_INTERMEDIATE_DIR)',
108    ]
109  },
110  # This target exports a hard dependency because it generates header
111  # files.
112  'hard_dependency': 1,
113}
114