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

Side by Side Diff: extensions/generated_extensions_api.gni

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