Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: build/json_schema_api.gni

Issue 1226353004: Generate all extension schema namespaces as "api" and instead vary the generated bundle names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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:
11 # 11 #
12 # sources [required] A list of schema files to be compiled. 12 # sources [required] A list of schema files to be compiled.
13 # 13 #
14 # root_namespace [required] 14 # root_namespace [required]
15 # A Python string substituion pattern used to generate the C++ 15 # A Python string substituion pattern used to generate the C++
16 # namespace for each API. Use %(namespace)s to replace with the API 16 # namespace for each API. Use %(namespace)s to replace with the API
17 # namespace, like "toplevel::%(namespace)s_api". 17 # namespace, like "toplevel::%(namespace)s_api".
18 # 18 #
19 # bundle_name [optional]:
20 # A string to prepend to generated bundle class names, so that multiple
21 # bundle rules can be used without conflicting. Only used with one of
22 # the cpp-bundle generators.
23 #
19 # schema_include_rules [optional] 24 # schema_include_rules [optional]
20 # A list of paths to include when searching for referenced objects, 25 # A list of paths to include when searching for referenced objects,
21 # with the namespace separated by a :. 26 # with the namespace separated by a :.
22 # Example: 27 # Example:
23 # [ '/foo/bar:Foo::Bar::%(namespace)s' ] 28 # [ '/foo/bar:Foo::Bar::%(namespace)s' ]
24 # 29 #
25 # schemas [optional, default = false] 30 # schemas [optional, default = false]
26 # Boolean indicating if the schema files should be generated. 31 # Boolean indicating if the schema files should be generated.
27 # 32 #
28 # bundle [optional, default = false] 33 # bundle [optional, default = false]
(...skipping 27 matching lines...) Expand all
56 assert(defined(invoker.sources), 61 assert(defined(invoker.sources),
57 "\"sources\" must be defined for the $target_name template.") 62 "\"sources\" must be defined for the $target_name template.")
58 assert(defined(invoker.root_namespace), 63 assert(defined(invoker.root_namespace),
59 "\"root_namespace\" must be defined for the $target_name template.") 64 "\"root_namespace\" must be defined for the $target_name template.")
60 65
61 schemas = defined(invoker.schemas) && invoker.schemas 66 schemas = defined(invoker.schemas) && invoker.schemas
62 bundle = defined(invoker.bundle) && invoker.bundle 67 bundle = defined(invoker.bundle) && invoker.bundle
63 bundle_registration = 68 bundle_registration =
64 defined(invoker.bundle_registration) && invoker.bundle_registration 69 defined(invoker.bundle_registration) && invoker.bundle_registration
65 70
71 bundle_name = ""
72 if (defined(invoker.bundle_name)) {
73 bundle_name = invoker.bundle_name
74 }
75
66 schema_include_rules = "" 76 schema_include_rules = ""
67 if (defined(invoker.schema_include_rules)) { 77 if (defined(invoker.schema_include_rules)) {
68 schema_include_rules = invoker.schema_include_rules 78 schema_include_rules = invoker.schema_include_rules
69 } 79 }
70 80
71 # Keep a copy of the target_name here since it will be trampled 81 # Keep a copy of the target_name here since it will be trampled
72 # in nested targets. 82 # in nested targets.
73 target_visibility = [ ":$target_name" ] 83 target_visibility = [ ":$target_name" ]
74 84
75 generated_config_name = target_name + "_generated_config" 85 generated_config_name = target_name + "_generated_config"
76 config(generated_config_name) { 86 config(generated_config_name) {
77 include_dirs = [ root_gen_dir ] 87 include_dirs = [ root_gen_dir ]
78 visibility = target_visibility 88 visibility = target_visibility
79 } 89 }
80 90
81 root_namespace = invoker.root_namespace 91 root_namespace = invoker.root_namespace
82 92
83 compiler_root = "//tools/json_schema_compiler" 93 compiler_root = "//tools/json_schema_compiler"
84 compiler_script = "$compiler_root/compiler.py" 94 compiler_script = "$compiler_root/compiler.py"
85 compiler_sources = [ 95 compiler_sources = [
86 "$compiler_root/cc_generator.py", 96 "$compiler_root/cc_generator.py",
87 "$compiler_root/code.py", 97 "$compiler_root/code.py",
88 "$compiler_root/compiler.py", 98 "$compiler_root/compiler.py",
99 "$compiler_root/cpp_bundle_generator.py",
89 "$compiler_root/cpp_generator.py", 100 "$compiler_root/cpp_generator.py",
90 "$compiler_root/cpp_type_generator.py", 101 "$compiler_root/cpp_type_generator.py",
91 "$compiler_root/cpp_util.py", 102 "$compiler_root/cpp_util.py",
92 "$compiler_root/h_generator.py", 103 "$compiler_root/h_generator.py",
93 "$compiler_root/idl_schema.py", 104 "$compiler_root/idl_schema.py",
94 "$compiler_root/model.py", 105 "$compiler_root/model.py",
95 "$compiler_root/util_cc_helper.py", 106 "$compiler_root/util_cc_helper.py",
96 ] 107 ]
97 108
98 if (schemas) { 109 if (schemas) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 script = compiler_script 143 script = compiler_script
133 inputs = compiler_sources + invoker.sources + uncompiled_sources 144 inputs = compiler_sources + invoker.sources + uncompiled_sources
134 outputs = [ 145 outputs = [
135 "$target_gen_dir/generated_schemas.cc", 146 "$target_gen_dir/generated_schemas.cc",
136 "$target_gen_dir/generated_schemas.h", 147 "$target_gen_dir/generated_schemas.h",
137 ] 148 ]
138 args = [ 149 args = [
139 "--root=" + rebase_path("//", root_build_dir), 150 "--root=" + rebase_path("//", root_build_dir),
140 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), 151 "--destdir=" + rebase_path(root_gen_dir, root_build_dir),
141 "--namespace=$root_namespace", 152 "--namespace=$root_namespace",
153 "--bundle-name=$bundle_name",
142 "--generator=cpp-bundle-schema", 154 "--generator=cpp-bundle-schema",
143 "--include-rules=$schema_include_rules", 155 "--include-rules=$schema_include_rules",
144 ] + rebase_path(invoker.sources, root_build_dir) + 156 ] + rebase_path(invoker.sources, root_build_dir) +
145 rebase_path(uncompiled_sources, root_build_dir) 157 rebase_path(uncompiled_sources, root_build_dir)
146 } 158 }
147 } 159 }
148 160
149 if (bundle_registration) { 161 if (bundle_registration) {
150 uncompiled_sources = [] 162 uncompiled_sources = []
151 if (defined(invoker.uncompiled_sources)) { 163 if (defined(invoker.uncompiled_sources)) {
(...skipping 12 matching lines...) Expand all
164 script = compiler_script 176 script = compiler_script
165 inputs = compiler_sources + invoker.sources + uncompiled_sources 177 inputs = compiler_sources + invoker.sources + uncompiled_sources
166 outputs = [ 178 outputs = [
167 "$root_gen_dir/$gen_child_dir/generated_api_registration.cc", 179 "$root_gen_dir/$gen_child_dir/generated_api_registration.cc",
168 "$root_gen_dir/$gen_child_dir/generated_api_registration.h", 180 "$root_gen_dir/$gen_child_dir/generated_api_registration.h",
169 ] 181 ]
170 args = [ 182 args = [
171 "--root=" + rebase_path("//", root_build_dir), 183 "--root=" + rebase_path("//", root_build_dir),
172 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), 184 "--destdir=" + rebase_path(root_gen_dir, root_build_dir),
173 "--namespace=$root_namespace", 185 "--namespace=$root_namespace",
186 "--bundle-name=$bundle_name",
174 "--generator=cpp-bundle-registration", 187 "--generator=cpp-bundle-registration",
175 "--impl-dir=$gen_child_dir", 188 "--impl-dir=$gen_child_dir",
176 "--include-rules=$schema_include_rules", 189 "--include-rules=$schema_include_rules",
177 ] + rebase_path(invoker.sources, root_build_dir) + 190 ] + rebase_path(invoker.sources, root_build_dir) +
178 rebase_path(uncompiled_sources, root_build_dir) 191 rebase_path(uncompiled_sources, root_build_dir)
179 } 192 }
180 } 193 }
181 194
182 # Compute the contents of the library/source set. 195 # Compute the contents of the library/source set.
183 lib_sources = invoker.sources 196 lib_sources = invoker.sources
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 246
234 if (defined(invoker.visibility)) { 247 if (defined(invoker.visibility)) {
235 visibility = invoker.visibility 248 visibility = invoker.visibility
236 } 249 }
237 if (defined(invoker.output_name)) { 250 if (defined(invoker.output_name)) {
238 output_name = invoker.output_name 251 output_name = invoker.output_name
239 } 252 }
240 } 253 }
241 } 254 }
242 } 255 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698