Reland 596ff54335b2a1b393af10657bc4945114f3beed - Split API bundle generation steps
[chromium-blink-merge.git] / build / json_schema_compile.gypi
blob9672f797e819fad89803bac82bd70c8a4f7633b5
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.
6   'variables': {
7     # When including this gypi, the following variables must be set:
8     #   schema_files:
9     #     An array of json or idl files that comprise the api model.
10     #   cc_dir:
11     #     The directory to put the generated code in.
12     #   root_namespace:
13     #     A Python string substituion pattern used to generate the C++
14     #     namespace for each API. Use %(namespace)s to replace with the API
15     #     namespace, like "toplevel::%(namespace)s_api".
16     #
17     # Functions and namespaces can be excluded by setting "nocompile" to true.
18     'api_gen_dir': '<(DEPTH)/tools/json_schema_compiler',
19     'api_gen': '<(api_gen_dir)/compiler.py',
20   },
21   'rules': [
22     {
23       # GN version: //extensions/generated_extensions_api.gni
24       'rule_name': 'genapi',
25       'msvs_external_rule': 1,
26       'extension': 'json',
27       'inputs': [
28         '<(api_gen_dir)/cc_generator.py',
29         '<(api_gen_dir)/code.py',
30         '<(api_gen_dir)/compiler.py',
31         '<(api_gen_dir)/cpp_generator.py',
32         '<(api_gen_dir)/cpp_type_generator.py',
33         '<(api_gen_dir)/cpp_util.py',
34         '<(api_gen_dir)/h_generator.py',
35         '<(api_gen_dir)/json_schema.py',
36         '<(api_gen_dir)/model.py',
37         '<(api_gen_dir)/util.cc',
38         '<(api_gen_dir)/util.h',
39         '<(api_gen_dir)/util_cc_helper.py',
40         # TODO(calamity): uncomment this when gyp on windows behaves like other
41         # platforms. List expansions of filepaths in inputs expand to different
42         # things.
43         # '<@(schema_files)',
44       ],
45       'outputs': [
46         '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).cc',
47         '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).h',
48       ],
49       'action': [
50         'python',
51         '<(api_gen)',
52         '<(RULE_INPUT_PATH)',
53         '--root=<(DEPTH)',
54         '--destdir=<(SHARED_INTERMEDIATE_DIR)',
55         '--namespace=<(root_namespace)',
56         '--generator=cpp',
57       ],
58       'message': 'Generating C++ code from <(RULE_INPUT_PATH) json files',
59       'process_outputs_as_sources': 1,
60     },
61     {
62       'rule_name': 'genapi_idl',
63       'msvs_external_rule': 1,
64       'extension': 'idl',
65       'inputs': [
66         '<(api_gen_dir)/cc_generator.py',
67         '<(api_gen_dir)/code.py',
68         '<(api_gen_dir)/compiler.py',
69         '<(api_gen_dir)/cpp_generator.py',
70         '<(api_gen_dir)/cpp_type_generator.py',
71         '<(api_gen_dir)/cpp_util.py',
72         '<(api_gen_dir)/h_generator.py',
73         '<(api_gen_dir)/idl_schema.py',
74         '<(api_gen_dir)/model.py',
75         '<(api_gen_dir)/util.cc',
76         '<(api_gen_dir)/util.h',
77         '<(api_gen_dir)/util_cc_helper.py',
78         # TODO(calamity): uncomment this when gyp on windows behaves like other
79         # platforms. List expansions of filepaths in inputs expand to different
80         # things.
81         # '<@(schema_files)',
82       ],
83       'outputs': [
84         '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).cc',
85         '<(SHARED_INTERMEDIATE_DIR)/<(cc_dir)/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).h',
86       ],
87       'action': [
88         'python',
89         '<(api_gen)',
90         '<(RULE_INPUT_PATH)',
91         '--root=<(DEPTH)',
92         '--destdir=<(SHARED_INTERMEDIATE_DIR)',
93         '--namespace=<(root_namespace)',
94         '--generator=cpp',
95       ],
96       'message': 'Generating C++ code from <(RULE_INPUT_PATH) IDL files',
97       'process_outputs_as_sources': 1,
98     },
99   ],
100   'include_dirs': [
101     '<(SHARED_INTERMEDIATE_DIR)',
102     '<(DEPTH)',
103   ],
104   'dependencies':[
105     '<(DEPTH)/tools/json_schema_compiler/api_gen_util.gyp:api_gen_util',
106   ],
107   'direct_dependent_settings': {
108     'include_dirs': [
109       '<(SHARED_INTERMEDIATE_DIR)',
110     ]
111   },
112   # This target exports a hard dependency because it generates header
113   # files.
114   'hard_dependency': 1,