OLD | NEW |
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++ and JavaScript source files from mojom files. The output files | 5 # Generate C++ and JavaScript 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 (required) | 11 # sources (required) |
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 # | |
16 # visibility (optional) | 15 # visibility (optional) |
17 # Normal meaning. However, this must be a list (normal visibility | 16 # Normal meaning. |
18 # allows a single string). | |
19 template("mojom") { | 17 template("mojom") { |
20 assert(defined(invoker.sources), | 18 assert(defined(invoker.sources), |
21 "\"sources\" must be defined for the $target_name template.") | 19 "\"sources\" must be defined for the $target_name template.") |
22 | 20 |
23 generator_root = "//mojo/public/tools/bindings" | 21 generator_root = "//mojo/public/tools/bindings" |
24 generator_script = "$generator_root/mojom_bindings_generator.py" | 22 generator_script = "$generator_root/mojom_bindings_generator.py" |
25 generator_sources = [ | 23 generator_sources = [ |
26 generator_script, | 24 generator_script, |
27 "$generator_root/generators/cpp_templates/enum_declaration.tmpl", | 25 "$generator_root/generators/cpp_templates/enum_declaration.tmpl", |
28 "$generator_root/generators/cpp_templates/interface_declaration.tmpl", | 26 "$generator_root/generators/cpp_templates/interface_declaration.tmpl", |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 "{{source_gen_dir}}/{{source_name_part}}.mojom.h", | 68 "{{source_gen_dir}}/{{source_name_part}}.mojom.h", |
71 "{{source_gen_dir}}/{{source_name_part}}.mojom-internal.h", | 69 "{{source_gen_dir}}/{{source_name_part}}.mojom-internal.h", |
72 ] | 70 ] |
73 generator_js_outputs = [ | 71 generator_js_outputs = [ |
74 "{{source_gen_dir}}/{{source_name_part}}.mojom.js", | 72 "{{source_gen_dir}}/{{source_name_part}}.mojom.js", |
75 ] | 73 ] |
76 generator_python_outputs = [ | 74 generator_python_outputs = [ |
77 "{{source_gen_dir}}/{{source_name_part}}_mojom.py", | 75 "{{source_gen_dir}}/{{source_name_part}}_mojom.py", |
78 ] | 76 ] |
79 | 77 |
80 if (defined(invoker.visibility)) { | 78 target_visibility = ":$target_name" |
81 # Need to save this because the the target_name is overwritten inside the | |
82 # action to be that of the action itself. Only define this in the case the | |
83 # var is used to avoid unused var error. | |
84 target_visibility = ":$target_name" | |
85 } | |
86 | 79 |
87 generator_target_name = target_name + "_generator" | 80 generator_target_name = target_name + "_generator" |
88 action_foreach(generator_target_name) { | 81 action_foreach(generator_target_name) { |
89 if (defined(invoker.visibility)) { | 82 visibility = target_visibility |
90 visibility = [ target_visibility ] + invoker.visibility # If you get an e
rror here, make your visibility be a list. | |
91 } | |
92 script = generator_script | 83 script = generator_script |
93 inputs = generator_sources | 84 inputs = generator_sources |
94 sources = invoker.sources | 85 sources = invoker.sources |
95 outputs = generator_cpp_outputs + | 86 outputs = generator_cpp_outputs + |
96 generator_js_outputs + | 87 generator_js_outputs + |
97 generator_python_outputs | 88 generator_python_outputs |
98 args = [ | 89 args = [ |
99 "{{source}}", | 90 "{{source}}", |
100 "--use_chromium_bundled_pylibs", | 91 "--use_chromium_bundled_pylibs", |
101 "-d", rebase_path("//", root_build_dir), | 92 "-d", rebase_path("//", root_build_dir), |
(...skipping 10 matching lines...) Expand all Loading... |
112 data = process_file_template(invoker.sources, generator_js_outputs) | 103 data = process_file_template(invoker.sources, generator_js_outputs) |
113 deps = [ | 104 deps = [ |
114 ":$generator_target_name", | 105 ":$generator_target_name", |
115 "//mojo/public/cpp/bindings", | 106 "//mojo/public/cpp/bindings", |
116 ] | 107 ] |
117 if (defined(invoker.deps)) { | 108 if (defined(invoker.deps)) { |
118 deps += invoker.deps | 109 deps += invoker.deps |
119 } | 110 } |
120 } | 111 } |
121 } | 112 } |
OLD | NEW |