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

Side by Side Diff: mojo/public/tools/bindings/mojom.gni

Issue 1517043004: [mojo] Add typemap and variant support to generators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pickle3
Patch Set: Created 5 years 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 # Generate C++/JavaScript/Java source files from mojom files. The output files 5 # Generate C++/JavaScript/Java source files from mojom files. The output files
6 # will go under the generated file directory tree with the same path as each 6 # will go under the generated file directory tree with the same path as each
7 # input file. 7 # input file.
8 # 8 #
9 # Parameters: 9 # Parameters:
10 # 10 #
11 # sources (optional if one of the deps sets listed below is present) 11 # sources (optional if one of the deps sets listed below is present)
12 # List of source .mojom files to compile. 12 # List of source .mojom files to compile.
13 # 13 #
14 # deps (optional) 14 # deps (optional)
15 # Note: this can contain only other mojom targets. 15 # Note: this can contain only other mojom targets.
16 # 16 #
17 # public_deps (optional) 17 # public_deps (optional)
18 # Note: this can contain only other mojom targets. 18 # Note: this can contain only other mojom targets.
19 # 19 #
20 # import_dirs (optional) 20 # import_dirs (optional)
21 # List of import directories that will get added when processing sources. 21 # List of import directories that will get added when processing sources.
22 # 22 #
23 # with_environment (optional) 23 # with_environment (optional)
24 # Set to |false| to omit an implicit bindings dependency on the Chromium 24 # Set to |false| to omit an implicit bindings dependency on the Chromium
25 # Mojo environment implementation. Defaults to |true| and in general 25 # Mojo environment implementation. Defaults to |true| and in general
26 # should only be overridden by mojom targets within the Mojo EDK. 26 # should only be overridden by mojom targets within the Mojo EDK.
27 # 27 #
28 # typemaps (optional)
yzshen1 2015/12/15 00:09:10 What about GYP? :) I don't see the corresponding c
29 # A list of typemap files to apply during bindings generation.
30 #
31 # variant (optional)
32 # A variant name to apply to generated bindings. Variant influences
33 # generated source filenames as wells the symbols they define.
34 #
28 # testonly (optional) 35 # testonly (optional)
29 # 36 #
30 # visibility (optional) 37 # visibility (optional)
31 template("mojom") { 38 template("mojom") {
32 assert( 39 assert(
33 defined(invoker.sources) || defined(invoker.deps) || 40 defined(invoker.sources) || defined(invoker.deps) ||
34 defined(invoker.public_deps), 41 defined(invoker.public_deps),
35 "\"sources\" or \"deps\" must be defined for the $target_name template.") 42 "\"sources\" or \"deps\" must be defined for the $target_name template.")
36 43
37 cpp_sources_suffix = "cpp_sources" 44 cpp_sources_suffix = "cpp_sources"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 "$generator_root/pylib/mojom/generate/generator.py", 102 "$generator_root/pylib/mojom/generate/generator.py",
96 "$generator_root/pylib/mojom/generate/module.py", 103 "$generator_root/pylib/mojom/generate/module.py",
97 "$generator_root/pylib/mojom/generate/pack.py", 104 "$generator_root/pylib/mojom/generate/pack.py",
98 "$generator_root/pylib/mojom/generate/template_expander.py", 105 "$generator_root/pylib/mojom/generate/template_expander.py",
99 "$generator_root/pylib/mojom/parse/__init__.py", 106 "$generator_root/pylib/mojom/parse/__init__.py",
100 "$generator_root/pylib/mojom/parse/ast.py", 107 "$generator_root/pylib/mojom/parse/ast.py",
101 "$generator_root/pylib/mojom/parse/lexer.py", 108 "$generator_root/pylib/mojom/parse/lexer.py",
102 "$generator_root/pylib/mojom/parse/parser.py", 109 "$generator_root/pylib/mojom/parse/parser.py",
103 "$generator_root/pylib/mojom/parse/translate.py", 110 "$generator_root/pylib/mojom/parse/translate.py",
104 ] 111 ]
105 generator_cpp_outputs = [ 112 if (defined(invoker.variant)) {
106 "{{source_gen_dir}}/{{source_name_part}}.mojom.cc", 113 variant = invoker.variant
107 "{{source_gen_dir}}/{{source_name_part}}.mojom.h", 114 generator_cpp_outputs = [
108 "{{source_gen_dir}}/{{source_name_part}}.mojom-internal.h", 115 "{{source_gen_dir}}/{{source_name_part}}.mojom-${variant}.cc",
109 ] 116 "{{source_gen_dir}}/{{source_name_part}}.mojom-${variant}.h",
110 generator_js_outputs = 117 "{{source_gen_dir}}/{{source_name_part}}.mojom-${variant}-internal.h",
111 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.js" ] 118 ]
112 generator_java_outputs = 119 generator_js_outputs = []
113 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.srcjar" ] 120 generator_java_outputs = []
121 } else {
122 generator_cpp_outputs = [
123 "{{source_gen_dir}}/{{source_name_part}}.mojom.cc",
124 "{{source_gen_dir}}/{{source_name_part}}.mojom.h",
125 "{{source_gen_dir}}/{{source_name_part}}.mojom-internal.h",
126 ]
127 generator_js_outputs =
128 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.js" ]
129 generator_java_outputs =
130 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.srcjar" ]
131 }
114 } 132 }
115 133
116 if (defined(invoker.sources)) { 134 if (defined(invoker.sources)) {
117 generator_target_name = target_name + "__generator" 135 generator_target_name = target_name + "__generator"
118 action_foreach(generator_target_name) { 136 action_foreach(generator_target_name) {
119 script = generator_script 137 script = generator_script
120 inputs = generator_sources 138 inputs = generator_sources
121 sources = invoker.sources 139 sources = invoker.sources
122 outputs = 140 outputs =
123 generator_cpp_outputs + generator_java_outputs + generator_js_outputs 141 generator_cpp_outputs + generator_java_outputs + generator_js_outputs
124 args = [ 142 args = [
125 "{{source}}", 143 "{{source}}",
126 "--use_bundled_pylibs", 144 "--use_bundled_pylibs",
127 "-d", 145 "-d",
128 rebase_path("//", root_build_dir), 146 rebase_path("//", root_build_dir),
129 "-I", 147 "-I",
130 rebase_path("//", root_build_dir), 148 rebase_path("//", root_build_dir),
131 "-o", 149 "-o",
132 rebase_path(root_gen_dir), 150 rebase_path(root_gen_dir),
133 ] 151 ]
134 152
135 if (defined(invoker.import_dirs)) { 153 if (defined(invoker.import_dirs)) {
136 foreach(import_dir, invoker.import_dirs) { 154 foreach(import_dir, invoker.import_dirs) {
137 args += [ 155 args += [
138 "-I", 156 "-I",
139 rebase_path(import_dir, root_build_dir), 157 rebase_path(import_dir, root_build_dir),
140 ] 158 ]
141 } 159 }
142 } 160 }
161
162 if (defined(invoker.variant)) {
163 args += [
164 "--variant",
165 invoker.variant,
166 ]
167 }
168
169 if (defined(invoker.typemaps)) {
170 foreach(typemap, invoker.typemaps) {
171 args += [
172 "--typemap",
173 rebase_path(typemap, root_build_dir),
174 ]
175 }
176 }
143 } 177 }
144 } 178 }
145 179
146 source_set(target_name) { 180 source_set(target_name) {
147 if (defined(invoker.visibility)) { 181 if (defined(invoker.visibility)) {
148 visibility = invoker.visibility 182 visibility = invoker.visibility
149 } 183 }
150 if (defined(invoker.testonly)) { 184 if (defined(invoker.testonly)) {
151 testonly = invoker.testonly 185 testonly = invoker.testonly
152 } 186 }
153 if (defined(invoker.sources)) { 187 if (defined(invoker.sources) && !defined(invoker.variant)) {
154 data = process_file_template(invoker.sources, generator_js_outputs) 188 data = process_file_template(invoker.sources, generator_js_outputs)
155 } 189 }
156 190
157 public_deps = [ 191 public_deps = [
158 "//mojo/public/cpp/bindings", 192 "//mojo/public/cpp/bindings",
159 ] 193 ]
160 if (defined(invoker.sources)) { 194 if (defined(invoker.sources)) {
161 public_deps += [ ":${cpp_sources_target_name}" ] 195 public_deps += [ ":${cpp_sources_target_name}" ]
162 } 196 }
163 if (defined(invoker.public_deps)) { 197 if (defined(invoker.public_deps)) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 # get the cpp dependency name. 252 # get the cpp dependency name.
219 full_name = get_label_info(d, "label_no_toolchain") 253 full_name = get_label_info(d, "label_no_toolchain")
220 deps += [ "${full_name}_${cpp_sources_suffix}" ] 254 deps += [ "${full_name}_${cpp_sources_suffix}" ]
221 } 255 }
222 if (!defined(invoker.with_environment) || invoker.with_environment) { 256 if (!defined(invoker.with_environment) || invoker.with_environment) {
223 deps += [ "//mojo/environment:chromium" ] 257 deps += [ "//mojo/environment:chromium" ]
224 } 258 }
225 } 259 }
226 } 260 }
227 261
228 if (is_android) { 262 if (is_android && !defined(invoker.variant)) {
229 import("//build/config/android/rules.gni") 263 import("//build/config/android/rules.gni")
230 264
231 java_srcjar_target_name = target_name + "_java_sources" 265 java_srcjar_target_name = target_name + "_java_sources"
232 action(java_srcjar_target_name) { 266 action(java_srcjar_target_name) {
233 script = "//mojo/public/tools/gn/zip.py" 267 script = "//mojo/public/tools/gn/zip.py"
234 inputs = process_file_template(invoker.sources, generator_java_outputs) 268 inputs = process_file_template(invoker.sources, generator_java_outputs)
235 output = "$target_gen_dir/$target_name.srcjar" 269 output = "$target_gen_dir/$target_name.srcjar"
236 outputs = [ 270 outputs = [
237 output, 271 output,
238 ] 272 ]
(...skipping 20 matching lines...) Expand all
259 # //mojo/something:something and we can append "_java" to get the java 293 # //mojo/something:something and we can append "_java" to get the java
260 # dependency name. 294 # dependency name.
261 full_name = get_label_info(d, "label_no_toolchain") 295 full_name = get_label_info(d, "label_no_toolchain")
262 deps += [ "${full_name}_java" ] 296 deps += [ "${full_name}_java" ]
263 } 297 }
264 298
265 srcjar_deps = [ ":$java_srcjar_target_name" ] 299 srcjar_deps = [ ":$java_srcjar_target_name" ]
266 } 300 }
267 } 301 }
268 } 302 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698