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

Side by Side Diff: extensions/generated_extensions_api.gni

Issue 506253003: Revert "Split bundle generation steps so that API registration is generated in browser, not common." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « extensions/extensions.gyp ('k') | extensions/shell/app_shell.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # schemas [optional, default = false] 19 # bundle [optional, default = false]
20 # Boolean indicating if the schema files should be generated. 20 # Boolean indicating if the schema files should be bundled or not.
21 # 21 #
22 # bundle [optional, default = false] 22 # impl_dir [required if bundle = true, otherwise unused]
23 # Boolean indicating if the schema bundle files should be generated.
24 #
25 # bundle_registration [optional, default = false]
26 # Boolean indicating if the API registration bundle files should be generated.
27 #
28 # impl_dir [required if bundle_registration = true, otherwise unused]
29 # The path containing C++ implementations of API functions. This path is 23 # The path containing C++ implementations of API functions. This path is
30 # used as the root path when looking for {schema}/{schema}_api.h headers 24 # used as the root path when looking for {schema}/{schema}_api.h headers
31 # when generating API registration bundles. Such headers, if found, are 25 # during the API bundle generation phase. Such headers, if found, are
32 # automatically included by the generated code. 26 # automatically included by the generated code.
33 # 27 #
34 # uncompiled_sources [optional, only used when bundle = true or 28 # uncompiled_sources [optional, only used when bundle = true]
35 # bundle_registration = true]
36 # A list of schema files which should not be compiled, but which should still 29 # A list of schema files which should not be compiled, but which should still
37 # be processed for API bundle generation. 30 # be processed for API bundle generation.
38 # 31 #
39 # deps [optional] 32 # deps [optional]
40 # If any deps are specified they will be inherited by the static library 33 # If any deps are specified they will be inherited by the static library
41 # target. 34 # target.
42 # 35 #
43 # The static library target also inherits the visibility and output_name 36 # The static libarary target also inherits the visibility and output_name
44 # of its invoker. 37 # of its invoker.
45 38
46 template("generated_extensions_api") { 39 template("generated_extensions_api") {
47 assert(defined(invoker.sources), 40 assert(defined(invoker.sources),
48 "\"sources\" must be defined for the $target_name template.") 41 "\"sources\" must be defined for the $target_name template.")
49 assert(defined(invoker.root_namespace), 42 assert(defined(invoker.root_namespace),
50 "\"root_namespace\" must be defined for the $target_name template.") 43 "\"root_namespace\" must be defined for the $target_name template.")
51 44
52 schemas = defined(invoker.schemas) && invoker.schemas
53 bundle = defined(invoker.bundle) && invoker.bundle 45 bundle = defined(invoker.bundle) && invoker.bundle
54 bundle_registration = defined(invoker.bundle_registration) &&
55 invoker.bundle_registration
56 46
57 # Keep a copy of the target_name here since it will be trampled 47 # Keep a copy of the target_name here since it will be trampled
58 # in nested targets. 48 # in nested targets.
59 target_visibility = ":$target_name" 49 target_visibility = ":$target_name"
60 50
61 generated_config_name = target_name + "_generated_config" 51 generated_config_name = target_name + "_generated_config"
62 config(generated_config_name) { 52 config(generated_config_name) {
63 include_dirs = [ target_gen_dir ] 53 include_dirs = [ target_gen_dir ]
64 visibility = target_visibility 54 visibility = target_visibility
65 } 55 }
66 56
67 sources = invoker.sources 57 schemas = invoker.sources
68 root_namespace = invoker.root_namespace 58 root_namespace = invoker.root_namespace
69 59
70 compiler_root = "//tools/json_schema_compiler" 60 compiler_root = "//tools/json_schema_compiler"
71 compiler_script = "$compiler_root/compiler.py" 61 compiler_script = "$compiler_root/compiler.py"
72 compiler_sources = [ 62 compiler_sources = [
73 "$compiler_root/cc_generator.py", 63 "$compiler_root/cc_generator.py",
74 "$compiler_root/code.py", 64 "$compiler_root/code.py",
75 "$compiler_root/compiler.py", 65 "$compiler_root/compiler.py",
76 "$compiler_root/cpp_generator.py", 66 "$compiler_root/cpp_generator.py",
77 "$compiler_root/cpp_type_generator.py", 67 "$compiler_root/cpp_type_generator.py",
78 "$compiler_root/cpp_util.py", 68 "$compiler_root/cpp_util.py",
79 "$compiler_root/h_generator.py", 69 "$compiler_root/h_generator.py",
80 "$compiler_root/idl_schema.py", 70 "$compiler_root/idl_schema.py",
81 "$compiler_root/model.py", 71 "$compiler_root/model.py",
82 "$compiler_root/util_cc_helper.py", 72 "$compiler_root/util_cc_helper.py",
83 ] 73 ]
84 74
85 if (schemas) { 75 schema_generator_name = target_name + "_schema_generator"
86 schema_generator_name = target_name + "_schema_generator" 76 action_foreach(schema_generator_name) {
87 action_foreach(schema_generator_name) { 77 script = compiler_script
88 script = compiler_script 78 inputs = compiler_sources
89 inputs = compiler_sources 79 sources = schemas
90 outputs = [ 80 outputs = [
91 "$target_gen_dir/{{source_name_part}}.cc", 81 "$target_gen_dir/{{source_name_part}}.cc",
92 "$target_gen_dir/{{source_name_part}}.h", 82 "$target_gen_dir/{{source_name_part}}.h",
93 ] 83 ]
94 args = [ 84 args = [
95 "{{source}}", 85 "{{source}}",
96 "--root=" + rebase_path("//", root_build_dir), 86 "--root=" + rebase_path("//", root_build_dir),
97 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), 87 "--destdir=" + rebase_path(root_gen_dir, root_build_dir),
98 "--namespace=$root_namespace", 88 "--namespace=$root_namespace",
99 "--generator=cpp" ] 89 "--generator=cpp" ]
100 visibility = target_visibility 90 visibility = target_visibility
101 }
102 } 91 }
103 92
104 if (bundle) { 93 if (bundle) {
105 uncompiled_sources = [] 94 assert(defined(invoker.impl_dir),
95 "\"impl_dir\" must be defined for the $target_name template.")
96 impl_dir = invoker.impl_dir
97
98 uncompiled_schemas = []
106 if (defined(invoker.uncompiled_sources)) { 99 if (defined(invoker.uncompiled_sources)) {
107 uncompiled_sources = invoker.uncompiled_sources 100 uncompiled_schemas = invoker.uncompiled_sources
108 } 101 }
109 102
110 bundle_generator_schema_name = target_name + "_bundle_generator_schema" 103 bundle_generator_name = target_name + "_bundle_generator"
111 action(bundle_generator_schema_name) { 104 action(bundle_generator_name) {
112 script = compiler_script 105 script = compiler_script
113 inputs = compiler_sources + sources + uncompiled_sources 106 inputs = compiler_sources + schemas + uncompiled_schemas
114 outputs = [ 107 outputs = [
108 "$target_gen_dir/generated_api.cc",
109 "$target_gen_dir/generated_api.h",
115 "$target_gen_dir/generated_schemas.cc", 110 "$target_gen_dir/generated_schemas.cc",
116 "$target_gen_dir/generated_schemas.h", 111 "$target_gen_dir/generated_schemas.h",
117 ] 112 ]
118 args = [ 113 args = [
119 "--root=" + rebase_path("//", root_build_dir), 114 "--root=" + rebase_path("//", root_build_dir),
120 "--destdir=" + rebase_path(root_gen_dir, root_build_dir), 115 "--destdir=" + rebase_path(root_gen_dir, root_build_dir),
121 "--namespace=$root_namespace", 116 "--namespace=$root_namespace",
122 "--generator=cpp-bundle-schema", 117 "--generator=cpp-bundle",
123 ] +
124 rebase_path(sources, root_build_dir) +
125 rebase_path(uncompiled_sources, root_build_dir)
126 }
127 }
128
129 if (bundle_registration) {
130 uncompiled_sources = []
131 if (defined(invoker.uncompiled_sources)) {
132 uncompiled_sources = invoker.uncompiled_sources
133 }
134
135 assert(defined(invoker.impl_dir),
136 "\"impl_dir\" must be defined for the $target_name template.")
137 impl_dir = invoker.impl_dir
138
139 bundle_generator_registration_name = target_name +
140 "_bundle_generator_registration"
141 action(bundle_generator_registration_name) {
142 script = compiler_script
143 inputs = compiler_sources + sources + uncompiled_sources
144 outputs = [
145 "$root_gen_dir/$impl_dir/generated_api_registration.cc",
146 "$root_gen_dir/$impl_dir/generated_api_registration.h",
147 ]
148 args = [
149 "--root=" + rebase_path("//", root_build_dir),
150 "--destdir=" + rebase_path(root_gen_dir, root_build_dir),
151 "--namespace=$root_namespace",
152 "--generator=cpp-bundle-registration",
153 "--impl-dir=" + rebase_path(impl_dir, "//"), 118 "--impl-dir=" + rebase_path(impl_dir, "//"),
154 ] + 119 ] +
155 rebase_path(sources, root_build_dir) + 120 rebase_path(schemas, root_build_dir) +
156 rebase_path(uncompiled_sources, root_build_dir) 121 rebase_path(uncompiled_schemas, root_build_dir)
157 } 122 }
158 } 123 }
159 124
160 source_set(target_name) { 125 source_set(target_name) {
161 sources = [] 126 sources = get_target_outputs(":$schema_generator_name")
162 deps = [] 127
163 128 deps = [
164 if (schemas) { 129 ":$schema_generator_name",
165 sources += get_target_outputs(":$schema_generator_name") 130 "//tools/json_schema_compiler:generated_api_util",
166 deps += [ 131 ]
167 ":$schema_generator_name",
168 "//tools/json_schema_compiler:generated_api_util",
169 ]
170 }
171 132
172 if (bundle) { 133 if (bundle) {
173 sources += get_target_outputs(":$bundle_generator_schema_name") 134 sources += get_target_outputs(":$bundle_generator_name")
174 deps += [ ":$bundle_generator_schema_name" ] 135 deps += [ ":$bundle_generator_name" ]
175 }
176
177 if (bundle_registration) {
178 sources += get_target_outputs(":$bundle_generator_registration_name")
179 deps += [ ":$bundle_generator_registration_name" ]
180 } 136 }
181 137
182 if (defined(invoker.deps)) { 138 if (defined(invoker.deps)) {
183 deps += invoker.deps 139 deps += invoker.deps
184 } 140 }
185 direct_dependent_configs = [ ":$generated_config_name" ] 141 direct_dependent_configs = [ ":$generated_config_name" ]
186 142
187 if (defined(invoker.visibility)) { 143 if (defined(invoker.visibility)) {
188 visibility = invoker.visibility 144 visibility = invoker.visibility
189 } 145 }
190 if (defined(invoker.output_name)) { 146 if (defined(invoker.output_name)) {
191 output_name = invoker.output_name 147 output_name = invoker.output_name
192 } 148 }
193 } 149 }
194 } 150 }
OLDNEW
« no previous file with comments | « extensions/extensions.gyp ('k') | extensions/shell/app_shell.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698