# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-# Generate C++ and JavaScript source files from mojom files.
+# Generate C++ and JavaScript source files from mojom files. The output files
+# will go under the generated file directory tree with the same path as each
+# input file.
+#
+# Parameters:
+#
+# sources (required)
+# List of source .mojom files to compile.
+#
+# deps (optional)
+# visibility (optional)
+# Normal meaning.
template("mojom") {
assert(defined(invoker.sources),
"\"sources\" must be defined for the $target_name template.")
generator_sources = [
generator_script,
"$generator_root/generators/cpp_templates/enum_declaration.tmpl",
- "$generator_root/generators/cpp_templates/enum_traits.tmpl",
"$generator_root/generators/cpp_templates/interface_declaration.tmpl",
"$generator_root/generators/cpp_templates/interface_definition.tmpl",
"$generator_root/generators/cpp_templates/interface_macros.tmpl",
"$generator_root/generators/cpp_templates/interface_proxy_declaration.tmpl",
+ "$generator_root/generators/cpp_templates/interface_request_validator_declaration.tmpl",
+ "$generator_root/generators/cpp_templates/interface_response_validator_declaration.tmpl",
"$generator_root/generators/cpp_templates/interface_stub_declaration.tmpl",
"$generator_root/generators/cpp_templates/module.cc.tmpl",
"$generator_root/generators/cpp_templates/module.h.tmpl",
"$generator_root/generators/cpp_templates/module-internal.h.tmpl",
"$generator_root/generators/cpp_templates/params_definition.tmpl",
- "$generator_root/generators/cpp_templates/struct_builder_definition.tmpl",
"$generator_root/generators/cpp_templates/struct_declaration.tmpl",
"$generator_root/generators/cpp_templates/struct_definition.tmpl",
- "$generator_root/generators/cpp_templates/struct_destructor.tmpl",
+ "$generator_root/generators/cpp_templates/struct_serialization_declaration.tmpl",
+ "$generator_root/generators/cpp_templates/struct_serialization_definition.tmpl",
"$generator_root/generators/cpp_templates/struct_macros.tmpl",
"$generator_root/generators/cpp_templates/wrapper_class_declaration.tmpl",
+ "$generator_root/generators/cpp_templates/wrapper_class_definition.tmpl",
"$generator_root/generators/js_templates/enum_definition.tmpl",
"$generator_root/generators/js_templates/interface_definition.tmpl",
"$generator_root/generators/js_templates/module.js.tmpl",
"$generator_root/pylib/mojom/parse/translate.py",
]
generator_cpp_outputs = [
- "$target_gen_dir/{{source_name_part}}.mojom.cc",
- "$target_gen_dir/{{source_name_part}}.mojom.h",
- "$target_gen_dir/{{source_name_part}}.mojom-internal.h",
+ "{{source_gen_dir}}/{{source_name_part}}.mojom.cc",
+ "{{source_gen_dir}}/{{source_name_part}}.mojom.h",
+ "{{source_gen_dir}}/{{source_name_part}}.mojom-internal.h",
]
generator_js_outputs = [
- "$target_gen_dir/{{source_name_part}}.mojom.js",
+ "{{source_gen_dir}}/{{source_name_part}}.mojom.js",
]
target_visibility = ":$target_name"
generator_target_name = target_name + "_generator"
action_foreach(generator_target_name) {
visibility = target_visibility
- hard_dep = true
script = generator_script
- source_prereqs = generator_sources
+ inputs = generator_sources
sources = invoker.sources
outputs = generator_cpp_outputs + generator_js_outputs
args = [
"{{source}}",
"--use_chromium_bundled_pylibs",
"-d", rebase_path("//", root_build_dir),
- "-o", rebase_path(target_gen_dir, root_build_dir),
+ "-I", rebase_path("//", root_build_dir),
+ "-o", "{{source_gen_dir}}",
]
}
source_set(target_name) {
- hard_dep = true
+ if (defined(invoker.visibility)) {
+ visibility = invoker.visibility
+ }
sources = process_file_template(invoker.sources, generator_cpp_outputs)
data = process_file_template(invoker.sources, generator_js_outputs)
deps = [
":$generator_target_name",
"//mojo/public/cpp/bindings",
]
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
}
}
-