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

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

Issue 2965803003: Mojo JS bindings: add support to generate "dual-mode" code. (Closed)
Patch Set: . Created 3 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 declare_args() { 5 declare_args() {
6 # Indicates whether typemapping should be supported in this build 6 # Indicates whether typemapping should be supported in this build
7 # configuration. This may be disabled when building external projects which 7 # configuration. This may be disabled when building external projects which
8 # depend on //mojo but which do not need/want all of the Chromium tree 8 # depend on //mojo but which do not need/want all of the Chromium tree
9 # dependencies that come with typemapping. 9 # dependencies that come with typemapping.
10 # 10 #
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 # cpp_only (optional) 151 # cpp_only (optional)
152 # If set to true, only the C++ bindings targets will be generated. 152 # If set to true, only the C++ bindings targets will be generated.
153 # 153 #
154 # use_new_js_bindings (optional) 154 # use_new_js_bindings (optional)
155 # If set to true, the generated JS code will use the new module loading 155 # If set to true, the generated JS code will use the new module loading
156 # approach and the core API exposed by Web IDL. 156 # approach and the core API exposed by Web IDL.
157 # Default value is true. 157 # Default value is true.
158 # TODO(yzshen): Convert all users to use new JS bindings and remove the 158 # TODO(yzshen): Convert all users to use new JS bindings and remove the
159 # old mode. 159 # old mode.
160 # 160 #
161 # js_bindings_mode (optional)
162 # |js_bindings_mode| and |use_new_js_bindings| are mutually exclusive. You
163 # can only specify at most one of them.
164 # - "new" (default): generate only the new-style JS bindings;
165 # - "both": generate both the old- and new-style JS bindings;
166 # - "old": generate only the old-style JS bindings.
167 # TODO(yzshen): Convert all users to use new JS bindings and remove the
168 # old mode.
169 #
161 # component_output_prefix (optional) 170 # component_output_prefix (optional)
162 # The prefix to use for the output_name of any component library emitted 171 # The prefix to use for the output_name of any component library emitted
163 # for generated C++ bindings. If this is omitted, C++ bindings targets are 172 # for generated C++ bindings. If this is omitted, C++ bindings targets are
164 # emitted as source_sets instead. Because this controls the name of the 173 # emitted as source_sets instead. Because this controls the name of the
165 # output shared library binary in the root output directory, it must be 174 # output shared library binary in the root output directory, it must be
166 # unique across the entire build configuration. 175 # unique across the entire build configuration.
167 # 176 #
168 # This is required if |component_macro_prefix| is specified. 177 # This is required if |component_macro_prefix| is specified.
169 # 178 #
170 # component_macro_prefix (optional) 179 # component_macro_prefix (optional)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 # component_deps (optional) 214 # component_deps (optional)
206 # The list of component deps to add to replace overridden_deps. 215 # The list of component deps to add to replace overridden_deps.
207 # overridden_deps_blink (optional) 216 # overridden_deps_blink (optional)
208 # component_deps_blink (optional) 217 # component_deps_blink (optional)
209 # These two parameters are the blink variants of the previous two. 218 # These two parameters are the blink variants of the previous two.
210 template("mojom") { 219 template("mojom") {
211 assert( 220 assert(
212 defined(invoker.sources) || defined(invoker.deps) || 221 defined(invoker.sources) || defined(invoker.deps) ||
213 defined(invoker.public_deps), 222 defined(invoker.public_deps),
214 "\"sources\" or \"deps\" must be defined for the $target_name template.") 223 "\"sources\" or \"deps\" must be defined for the $target_name template.")
224
225 assert(!defined(invoker.use_new_js_bindings) ||
226 !defined(invoker.js_bindings_mode),
227 "You shouldn't specify both \"use_new_js_bindings\" and " +
228 "\"js_bindings_mode\".")
229
215 if (defined(invoker.export_class_attribute) || 230 if (defined(invoker.export_class_attribute) ||
216 defined(invoker.export_define) || defined(invoker.export_header)) { 231 defined(invoker.export_define) || defined(invoker.export_header)) {
217 assert(defined(invoker.export_class_attribute)) 232 assert(defined(invoker.export_class_attribute))
218 assert(defined(invoker.export_define)) 233 assert(defined(invoker.export_define))
219 assert(defined(invoker.export_header)) 234 assert(defined(invoker.export_header))
220 assert(!defined(invoker.component_macro_prefix)) 235 assert(!defined(invoker.component_macro_prefix))
221 } 236 }
222 if (defined(invoker.export_class_attribute_blink) || 237 if (defined(invoker.export_class_attribute_blink) ||
223 defined(invoker.export_define_blink) || 238 defined(invoker.export_define_blink) ||
224 defined(invoker.export_header_blink)) { 239 defined(invoker.export_header_blink)) {
225 assert(defined(invoker.export_class_attribute_blink)) 240 assert(defined(invoker.export_class_attribute_blink))
226 assert(defined(invoker.export_define_blink)) 241 assert(defined(invoker.export_define_blink))
227 assert(defined(invoker.export_header_blink)) 242 assert(defined(invoker.export_header_blink))
228 assert(!defined(invoker.component_macro_prefix)) 243 assert(!defined(invoker.component_macro_prefix))
229 } 244 }
230 if (defined(invoker.overridden_deps) || defined(invoker.component_deps)) { 245 if (defined(invoker.overridden_deps) || defined(invoker.component_deps)) {
231 assert(defined(invoker.overridden_deps)) 246 assert(defined(invoker.overridden_deps))
232 assert(defined(invoker.component_deps)) 247 assert(defined(invoker.component_deps))
233 } 248 }
234 249
235 if (defined(invoker.overridden_deps_blink) || 250 if (defined(invoker.overridden_deps_blink) ||
236 defined(invoker.component_deps_blink)) { 251 defined(invoker.component_deps_blink)) {
237 assert(defined(invoker.overridden_deps_blink)) 252 assert(defined(invoker.overridden_deps_blink))
238 assert(defined(invoker.component_deps_blink)) 253 assert(defined(invoker.component_deps_blink))
239 } 254 }
240 255
241 if (defined(invoker.use_new_js_bindings)) { 256 js_bindings_mode = "new"
242 assert(invoker.use_new_js_bindings || !invoker.use_new_js_bindings, 257 if (defined(invoker.js_bindings_mode)) {
243 "Surpress unused variable error when JS bindings are not needed.") 258 js_bindings_mode = invoker.js_bindings_mode
244 } 259 }
260 if (defined(invoker.use_new_js_bindings) && !invoker.use_new_js_bindings) {
261 js_bindings_mode = "old"
262 }
263 assert(js_bindings_mode == "new" || js_bindings_mode == "both" ||
264 js_bindings_mode == "old",
265 "Invalid js_bindings_mode value.")
245 266
246 all_deps = [] 267 all_deps = []
247 if (defined(invoker.deps)) { 268 if (defined(invoker.deps)) {
248 all_deps += invoker.deps 269 all_deps += invoker.deps
249 } 270 }
250 if (defined(invoker.public_deps)) { 271 if (defined(invoker.public_deps)) {
251 all_deps += invoker.public_deps 272 all_deps += invoker.public_deps
252 } 273 }
253 274
254 if (defined(invoker.component_macro_prefix)) { 275 if (defined(invoker.component_macro_prefix)) {
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 deps = [ 891 deps = [
871 "//mojo/public/tools/bindings:precompile_templates", 892 "//mojo/public/tools/bindings:precompile_templates",
872 ] 893 ]
873 outputs = generator_js_outputs 894 outputs = generator_js_outputs
874 args = common_generator_args 895 args = common_generator_args
875 args += [ 896 args += [
876 "-g", 897 "-g",
877 "javascript", 898 "javascript",
878 ] 899 ]
879 900
880 if (!defined(invoker.use_new_js_bindings) || 901 args += [
881 invoker.use_new_js_bindings) { 902 "--js_bindings_mode",
882 args += [ "--use_new_js_bindings" ] 903 js_bindings_mode,
883 } 904 ]
884 } 905 }
885 } 906 }
886 907
887 js_target_name = target_name + "_js" 908 js_target_name = target_name + "_js"
888 group(js_target_name) { 909 group(js_target_name) {
889 public_deps = [] 910 public_deps = []
890 if (defined(invoker.sources)) { 911 if (defined(invoker.sources)) {
891 public_deps += [ ":$generator_js_target_name" ] 912 public_deps += [ ":$generator_js_target_name" ]
892 } 913 }
893 914
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 forward_variables_from(invoker, 947 forward_variables_from(invoker,
927 "*", 948 "*",
928 [ 949 [
929 "output_prefix", 950 "output_prefix",
930 "macro_prefix", 951 "macro_prefix",
931 ]) 952 ])
932 component_output_prefix = invoker.output_prefix 953 component_output_prefix = invoker.output_prefix
933 component_macro_prefix = invoker.macro_prefix 954 component_macro_prefix = invoker.macro_prefix
934 } 955 }
935 } 956 }
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_js_generator.py ('k') | mojo/public/tools/bindings/mojom_bindings_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698