OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Defines a static library corresponding to the output of schema compiler tools | 5 # Defines a static library corresponding to the output of schema compiler tools |
6 # over a set of extensions API schemas (IDL or JSON format.) The library target | 6 # over a set of extensions API schemas (IDL or JSON format.) The library target |
7 # has implicit hard dependencies on all schema files listed by the invoker and | 7 # has implicit hard dependencies on all schema files listed by the invoker and |
8 # is itself a hard dependency. | 8 # is itself a hard dependency. |
9 # | 9 # |
10 # Invocations of this template may use the following variables: | 10 # Invocations of this template may use the following variables: |
(...skipping 13 matching lines...) Expand all Loading... |
24 # | 24 # |
25 # schemas [optional, default = false] | 25 # schemas [optional, default = false] |
26 # Boolean indicating if the schema files should be generated. | 26 # Boolean indicating if the schema files should be generated. |
27 # | 27 # |
28 # bundle [optional, default = false] | 28 # bundle [optional, default = false] |
29 # Boolean indicating if the schema bundle files should be generated. | 29 # Boolean indicating if the schema bundle files should be generated. |
30 # | 30 # |
31 # bundle_registration [optional, default = false] | 31 # bundle_registration [optional, default = false] |
32 # Boolean indicating if the API registration bundle files should be generated. | 32 # Boolean indicating if the API registration bundle files should be generated. |
33 # | 33 # |
| 34 # bundle_name [required if bundle or bundle_registrations]: |
| 35 # A string to prepend to generated bundle class names, so that multiple |
| 36 # bundle rules can be used without conflicting. Only used with one of |
| 37 # the cpp-bundle generators. |
| 38 # |
34 # impl_dir [required if bundle_registration = true, otherwise unused] | 39 # impl_dir [required if bundle_registration = true, otherwise unused] |
35 # The path containing C++ implementations of API functions. This path is | 40 # The path containing C++ implementations of API functions. This path is |
36 # used as the root path when looking for {schema}/{schema}_api.h headers | 41 # used as the root path when looking for {schema}/{schema}_api.h headers |
37 # when generating API registration bundles. Such headers, if found, are | 42 # when generating API registration bundles. Such headers, if found, are |
38 # automatically included by the generated code. | 43 # automatically included by the generated code. |
39 # | 44 # |
40 # uncompiled_sources [optional, only used when bundle = true or | 45 # uncompiled_sources [optional, only used when bundle = true or |
41 # bundle_registration = true] | 46 # bundle_registration = true] |
42 # A list of schema files which should not be compiled, but which should still | 47 # A list of schema files which should not be compiled, but which should still |
43 # be processed for API bundle generation. | 48 # be processed for API bundle generation. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 84 } |
80 | 85 |
81 root_namespace = invoker.root_namespace | 86 root_namespace = invoker.root_namespace |
82 | 87 |
83 compiler_root = "//tools/json_schema_compiler" | 88 compiler_root = "//tools/json_schema_compiler" |
84 compiler_script = "$compiler_root/compiler.py" | 89 compiler_script = "$compiler_root/compiler.py" |
85 compiler_sources = [ | 90 compiler_sources = [ |
86 "$compiler_root/cc_generator.py", | 91 "$compiler_root/cc_generator.py", |
87 "$compiler_root/code.py", | 92 "$compiler_root/code.py", |
88 "$compiler_root/compiler.py", | 93 "$compiler_root/compiler.py", |
| 94 "$compiler_root/cpp_bundle_generator.py", |
89 "$compiler_root/cpp_generator.py", | 95 "$compiler_root/cpp_generator.py", |
90 "$compiler_root/cpp_type_generator.py", | 96 "$compiler_root/cpp_type_generator.py", |
91 "$compiler_root/cpp_util.py", | 97 "$compiler_root/cpp_util.py", |
92 "$compiler_root/h_generator.py", | 98 "$compiler_root/h_generator.py", |
93 "$compiler_root/idl_schema.py", | 99 "$compiler_root/idl_schema.py", |
94 "$compiler_root/model.py", | 100 "$compiler_root/model.py", |
95 "$compiler_root/util_cc_helper.py", | 101 "$compiler_root/util_cc_helper.py", |
96 ] | 102 ] |
97 | 103 |
98 if (schemas) { | 104 if (schemas) { |
(...skipping 16 matching lines...) Expand all Loading... |
115 ] | 121 ] |
116 | 122 |
117 if (defined(invoker.visibility)) { | 123 if (defined(invoker.visibility)) { |
118 # If visibility is restricted, add our own target to it. | 124 # If visibility is restricted, add our own target to it. |
119 visibility = invoker.visibility + target_visibility | 125 visibility = invoker.visibility + target_visibility |
120 } | 126 } |
121 } | 127 } |
122 } | 128 } |
123 | 129 |
124 if (bundle) { | 130 if (bundle) { |
| 131 assert(defined(invoker.bundle_name), |
| 132 "\"bundle_name\" must be defined for bundles") |
| 133 |
125 uncompiled_sources = [] | 134 uncompiled_sources = [] |
126 if (defined(invoker.uncompiled_sources)) { | 135 if (defined(invoker.uncompiled_sources)) { |
127 uncompiled_sources = invoker.uncompiled_sources | 136 uncompiled_sources = invoker.uncompiled_sources |
128 } | 137 } |
129 | 138 |
130 bundle_generator_schema_name = target_name + "_bundle_generator_schema" | 139 bundle_generator_schema_name = target_name + "_bundle_generator_schema" |
131 action(bundle_generator_schema_name) { | 140 action(bundle_generator_schema_name) { |
132 script = compiler_script | 141 script = compiler_script |
133 inputs = compiler_sources + invoker.sources + uncompiled_sources | 142 inputs = compiler_sources + invoker.sources + uncompiled_sources |
134 outputs = [ | 143 outputs = [ |
135 "$target_gen_dir/generated_schemas.cc", | 144 "$target_gen_dir/generated_schemas.cc", |
136 "$target_gen_dir/generated_schemas.h", | 145 "$target_gen_dir/generated_schemas.h", |
137 ] | 146 ] |
138 args = [ | 147 args = [ |
139 "--root=" + rebase_path("//", root_build_dir), | 148 "--root=" + rebase_path("//", root_build_dir), |
140 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), | 149 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), |
141 "--namespace=$root_namespace", | 150 "--namespace=$root_namespace", |
| 151 "--bundle-name=" + invoker.bundle_name, |
142 "--generator=cpp-bundle-schema", | 152 "--generator=cpp-bundle-schema", |
143 "--include-rules=$schema_include_rules", | 153 "--include-rules=$schema_include_rules", |
144 ] + rebase_path(invoker.sources, root_build_dir) + | 154 ] + rebase_path(invoker.sources, root_build_dir) + |
145 rebase_path(uncompiled_sources, root_build_dir) | 155 rebase_path(uncompiled_sources, root_build_dir) |
146 } | 156 } |
147 } | 157 } |
148 | 158 |
149 if (bundle_registration) { | 159 if (bundle_registration) { |
| 160 assert(defined(invoker.bundle_name), |
| 161 "\"bundle_name\" must be defined for bundle registrations") |
| 162 |
150 uncompiled_sources = [] | 163 uncompiled_sources = [] |
151 if (defined(invoker.uncompiled_sources)) { | 164 if (defined(invoker.uncompiled_sources)) { |
152 uncompiled_sources = invoker.uncompiled_sources | 165 uncompiled_sources = invoker.uncompiled_sources |
153 } | 166 } |
154 | 167 |
155 assert(defined(invoker.impl_dir), | 168 assert(defined(invoker.impl_dir), |
156 "\"impl_dir\" must be defined for the $target_name template.") | 169 "\"impl_dir\" must be defined for the $target_name template.") |
157 | 170 |
158 # Child directory inside the generated file tree. | 171 # Child directory inside the generated file tree. |
159 gen_child_dir = rebase_path(invoker.impl_dir, "//") | 172 gen_child_dir = rebase_path(invoker.impl_dir, "//") |
160 | 173 |
161 bundle_generator_registration_name = | 174 bundle_generator_registration_name = |
162 target_name + "_bundle_generator_registration" | 175 target_name + "_bundle_generator_registration" |
163 action(bundle_generator_registration_name) { | 176 action(bundle_generator_registration_name) { |
164 script = compiler_script | 177 script = compiler_script |
165 inputs = compiler_sources + invoker.sources + uncompiled_sources | 178 inputs = compiler_sources + invoker.sources + uncompiled_sources |
166 outputs = [ | 179 outputs = [ |
167 "$root_gen_dir/$gen_child_dir/generated_api_registration.cc", | 180 "$root_gen_dir/$gen_child_dir/generated_api_registration.cc", |
168 "$root_gen_dir/$gen_child_dir/generated_api_registration.h", | 181 "$root_gen_dir/$gen_child_dir/generated_api_registration.h", |
169 ] | 182 ] |
170 args = [ | 183 args = [ |
171 "--root=" + rebase_path("//", root_build_dir), | 184 "--root=" + rebase_path("//", root_build_dir), |
172 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), | 185 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), |
173 "--namespace=$root_namespace", | 186 "--namespace=$root_namespace", |
| 187 "--bundle-name=" + invoker.bundle_name, |
174 "--generator=cpp-bundle-registration", | 188 "--generator=cpp-bundle-registration", |
175 "--impl-dir=$gen_child_dir", | 189 "--impl-dir=$gen_child_dir", |
176 "--include-rules=$schema_include_rules", | 190 "--include-rules=$schema_include_rules", |
177 ] + rebase_path(invoker.sources, root_build_dir) + | 191 ] + rebase_path(invoker.sources, root_build_dir) + |
178 rebase_path(uncompiled_sources, root_build_dir) | 192 rebase_path(uncompiled_sources, root_build_dir) |
179 } | 193 } |
180 } | 194 } |
181 | 195 |
182 # Compute the contents of the library/source set. | 196 # Compute the contents of the library/source set. |
183 lib_sources = invoker.sources | 197 lib_sources = invoker.sources |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 247 |
234 if (defined(invoker.visibility)) { | 248 if (defined(invoker.visibility)) { |
235 visibility = invoker.visibility | 249 visibility = invoker.visibility |
236 } | 250 } |
237 if (defined(invoker.output_name)) { | 251 if (defined(invoker.output_name)) { |
238 output_name = invoker.output_name | 252 output_name = invoker.output_name |
239 } | 253 } |
240 } | 254 } |
241 } | 255 } |
242 } | 256 } |
OLD | NEW |