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

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(
226 !defined(invoker.use_new_js_bindings) ||
227 !defined(invoker.js_bindings_mode),
228 "You shouldn't specify both \"use_new_js_bindings\" and " +
229 "\"js_bindings_mode\".")
230
215 if (defined(invoker.export_class_attribute) || 231 if (defined(invoker.export_class_attribute) ||
216 defined(invoker.export_define) || defined(invoker.export_header)) { 232 defined(invoker.export_define) || defined(invoker.export_header)) {
217 assert(defined(invoker.export_class_attribute)) 233 assert(defined(invoker.export_class_attribute))
218 assert(defined(invoker.export_define)) 234 assert(defined(invoker.export_define))
219 assert(defined(invoker.export_header)) 235 assert(defined(invoker.export_header))
220 assert(!defined(invoker.component_macro_prefix)) 236 assert(!defined(invoker.component_macro_prefix))
221 } 237 }
222 if (defined(invoker.export_class_attribute_blink) || 238 if (defined(invoker.export_class_attribute_blink) ||
223 defined(invoker.export_define_blink) || 239 defined(invoker.export_define_blink) ||
224 defined(invoker.export_header_blink)) { 240 defined(invoker.export_header_blink)) {
225 assert(defined(invoker.export_class_attribute_blink)) 241 assert(defined(invoker.export_class_attribute_blink))
226 assert(defined(invoker.export_define_blink)) 242 assert(defined(invoker.export_define_blink))
227 assert(defined(invoker.export_header_blink)) 243 assert(defined(invoker.export_header_blink))
228 assert(!defined(invoker.component_macro_prefix)) 244 assert(!defined(invoker.component_macro_prefix))
229 } 245 }
230 if (defined(invoker.overridden_deps) || defined(invoker.component_deps)) { 246 if (defined(invoker.overridden_deps) || defined(invoker.component_deps)) {
231 assert(defined(invoker.overridden_deps)) 247 assert(defined(invoker.overridden_deps))
232 assert(defined(invoker.component_deps)) 248 assert(defined(invoker.component_deps))
233 } 249 }
234 250
235 if (defined(invoker.overridden_deps_blink) || 251 if (defined(invoker.overridden_deps_blink) ||
236 defined(invoker.component_deps_blink)) { 252 defined(invoker.component_deps_blink)) {
237 assert(defined(invoker.overridden_deps_blink)) 253 assert(defined(invoker.overridden_deps_blink))
238 assert(defined(invoker.component_deps_blink)) 254 assert(defined(invoker.component_deps_blink))
239 } 255 }
240 256
241 if (defined(invoker.use_new_js_bindings)) { 257 js_bindings_mode = "new"
242 assert(invoker.use_new_js_bindings || !invoker.use_new_js_bindings, 258 if (defined(invoker.js_bindings_mode)) {
243 "Surpress unused variable error when JS bindings are not needed.") 259 js_bindings_mode = invoker.js_bindings_mode
244 } 260 }
261 if (defined(invoker.use_new_js_bindings) && !invoker.use_new_js_bindings) {
262 js_bindings_mode = "old"
263 }
264 assert(js_bindings_mode == "new" || js_bindings_mode == "both" ||
265 js_bindings_mode == "old",
266 "Invalid js_bindings_mode value.")
245 267
246 all_deps = [] 268 all_deps = []
247 if (defined(invoker.deps)) { 269 if (defined(invoker.deps)) {
248 all_deps += invoker.deps 270 all_deps += invoker.deps
249 } 271 }
250 if (defined(invoker.public_deps)) { 272 if (defined(invoker.public_deps)) {
251 all_deps += invoker.public_deps 273 all_deps += invoker.public_deps
252 } 274 }
253 275
254 if (defined(invoker.component_macro_prefix)) { 276 if (defined(invoker.component_macro_prefix)) {
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 deps = [ 892 deps = [
871 "//mojo/public/tools/bindings:precompile_templates", 893 "//mojo/public/tools/bindings:precompile_templates",
872 ] 894 ]
873 outputs = generator_js_outputs 895 outputs = generator_js_outputs
874 args = common_generator_args 896 args = common_generator_args
875 args += [ 897 args += [
876 "-g", 898 "-g",
877 "javascript", 899 "javascript",
878 ] 900 ]
879 901
880 if (!defined(invoker.use_new_js_bindings) || 902 args += [
881 invoker.use_new_js_bindings) { 903 "--js_bindings_mode",
882 args += [ "--use_new_js_bindings" ] 904 js_bindings_mode,
883 } 905 ]
884 } 906 }
885 } 907 }
886 908
887 js_target_name = target_name + "_js" 909 js_target_name = target_name + "_js"
888 group(js_target_name) { 910 group(js_target_name) {
889 public_deps = [] 911 public_deps = []
890 if (defined(invoker.sources)) { 912 if (defined(invoker.sources)) {
891 public_deps += [ ":$generator_js_target_name" ] 913 public_deps += [ ":$generator_js_target_name" ]
892 } 914 }
893 915
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 forward_variables_from(invoker, 948 forward_variables_from(invoker,
927 "*", 949 "*",
928 [ 950 [
929 "output_prefix", 951 "output_prefix",
930 "macro_prefix", 952 "macro_prefix",
931 ]) 953 ])
932 component_output_prefix = invoker.output_prefix 954 component_output_prefix = invoker.output_prefix
933 component_macro_prefix = invoker.macro_prefix 955 component_macro_prefix = invoker.macro_prefix
934 } 956 }
935 } 957 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698