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 import("../../mojo_sdk.gni") |
| 6 |
5 # Generate C++ and JavaScript source files from mojom files. The output files | 7 # 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 | 8 # will go under the generated file directory tree with the same path as each |
7 # input file. | 9 # input file. |
8 # | 10 # |
9 # Parameters: | 11 # Parameters: |
10 # | 12 # |
11 # sources (required) | 13 # sources (required) |
12 # List of source .mojom files to compile. | 14 # List of source .mojom files to compile. |
13 # | 15 # |
14 # deps (optional) | 16 # deps (optional) |
15 # Note: this can contain only other mojom targets. | 17 # Note: this can contain only other mojom targets. |
16 # | 18 # |
17 # public_deps (optional) | 19 # public_deps (optional) |
18 # Note: this can contain only other mojom targets. | 20 # Note: this can contain only other mojom targets. |
19 # | 21 # |
20 # testonly (optional) | 22 # testonly (optional) |
21 # | 23 # |
22 # visibility (optional) | 24 # visibility (optional) |
23 template("mojom") { | 25 template("mojom") { |
24 assert(defined(invoker.sources), | 26 assert(defined(invoker.sources), |
25 "\"sources\" must be defined for the $target_name template.") | 27 "\"sources\" must be defined for the $target_name template.") |
26 | 28 |
27 generator_root = "//mojo/public/tools/bindings" | 29 generator_root = |
| 30 rebase_path("mojo/public/tools/bindings", ".", mojo_root) |
28 generator_script = "$generator_root/mojom_bindings_generator.py" | 31 generator_script = "$generator_root/mojom_bindings_generator.py" |
29 generator_sources = [ | 32 generator_sources = [ |
30 generator_script, | 33 generator_script, |
31 "$generator_root/generators/cpp_templates/enum_declaration.tmpl", | 34 "$generator_root/generators/cpp_templates/enum_declaration.tmpl", |
32 "$generator_root/generators/cpp_templates/interface_declaration.tmpl", | 35 "$generator_root/generators/cpp_templates/interface_declaration.tmpl", |
33 "$generator_root/generators/cpp_templates/interface_definition.tmpl", | 36 "$generator_root/generators/cpp_templates/interface_definition.tmpl", |
34 "$generator_root/generators/cpp_templates/interface_macros.tmpl", | 37 "$generator_root/generators/cpp_templates/interface_macros.tmpl", |
35 "$generator_root/generators/cpp_templates/interface_proxy_declaration.tmpl", | 38 "$generator_root/generators/cpp_templates/interface_proxy_declaration.tmpl", |
36 "$generator_root/generators/cpp_templates/interface_request_validator_declar
ation.tmpl", | 39 "$generator_root/generators/cpp_templates/interface_request_validator_declar
ation.tmpl", |
37 "$generator_root/generators/cpp_templates/interface_response_validator_decla
ration.tmpl", | 40 "$generator_root/generators/cpp_templates/interface_response_validator_decla
ration.tmpl", |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 outputs = generator_cpp_outputs + | 128 outputs = generator_cpp_outputs + |
126 generator_dart_outputs + | 129 generator_dart_outputs + |
127 generator_java_outputs + | 130 generator_java_outputs + |
128 generator_js_outputs + | 131 generator_js_outputs + |
129 generator_python_outputs | 132 generator_python_outputs |
130 args = [ | 133 args = [ |
131 "{{source}}", | 134 "{{source}}", |
132 "--use_chromium_bundled_pylibs", | 135 "--use_chromium_bundled_pylibs", |
133 "-d", rebase_path("//", root_build_dir), | 136 "-d", rebase_path("//", root_build_dir), |
134 "-I", rebase_path("//", root_build_dir), | 137 "-I", rebase_path("//", root_build_dir), |
| 138 "-I", rebase_path(mojo_root, root_build_dir), |
135 "-o", rebase_path(root_gen_dir), | 139 "-o", rebase_path(root_gen_dir), |
136 ] | 140 ] |
137 } | 141 } |
138 | 142 |
139 source_set(target_name) { | 143 source_set(target_name) { |
140 if (defined(invoker.visibility)) { | 144 if (defined(invoker.visibility)) { |
141 visibility = invoker.visibility | 145 visibility = invoker.visibility |
142 } | 146 } |
143 if (defined(invoker.testonly)) { | 147 if (defined(invoker.testonly)) { |
144 testonly = invoker.testonly | 148 testonly = invoker.testonly |
145 } | 149 } |
146 sources = process_file_template(invoker.sources, generator_cpp_outputs) | 150 sources = process_file_template(invoker.sources, generator_cpp_outputs) |
147 data = process_file_template(invoker.sources, generator_js_outputs) | 151 data = process_file_template(invoker.sources, generator_js_outputs) |
| 152 |
| 153 public_configs = rebase_path([ |
| 154 "mojo/public/build/config:mojo_sdk", |
| 155 ], ".", mojo_root) |
| 156 |
| 157 public_deps = rebase_path([ |
| 158 "mojo/public/cpp/bindings", |
| 159 ], ".", mojo_root) |
| 160 if (defined(invoker.public_deps)) { |
| 161 public_deps += invoker.public_deps |
| 162 } |
| 163 |
148 deps = [ | 164 deps = [ |
149 ":$generator_target_name", | 165 ":$generator_target_name", |
150 "//mojo/public/cpp/bindings", | |
151 ] | 166 ] |
152 if (defined(invoker.deps)) { | 167 if (defined(invoker.deps)) { |
153 deps += invoker.deps | 168 deps += invoker.deps |
154 } | 169 } |
155 if (defined(invoker.public_deps)) { | |
156 public_deps = invoker.public_deps | |
157 } | |
158 } | 170 } |
159 | 171 |
160 all_deps = [] | 172 all_deps = [] |
161 if (defined(invoker.deps)) { | 173 if (defined(invoker.deps)) { |
162 all_deps += invoker.deps | 174 all_deps += invoker.deps |
163 } | 175 } |
164 if (defined(invoker.public_deps)) { | 176 if (defined(invoker.public_deps)) { |
165 all_deps += invoker.public_deps | 177 all_deps += invoker.public_deps |
166 } | 178 } |
167 | 179 |
168 group("${target_name}__is_mojom") { | 180 group("${target_name}__is_mojom") { |
169 } | 181 } |
170 | 182 |
171 # Explicitly ensure that all dependencies (invoker.deps and | 183 # Explicitly ensure that all dependencies (invoker.deps and |
172 # invoker.public_deps) are mojom targets themselves. | 184 # invoker.public_deps) are mojom targets themselves. |
173 group("${target_name}__check_deps_are_all_mojom") { | 185 group("${target_name}__check_deps_are_all_mojom") { |
174 deps = [] | 186 deps = [] |
175 foreach(d, all_deps) { | 187 foreach(d, all_deps) { |
176 name = get_label_info(d, "label_no_toolchain") | 188 name = get_label_info(d, "label_no_toolchain") |
177 toolchain = get_label_info(d, "toolchain") | 189 toolchain = get_label_info(d, "toolchain") |
178 deps += [ "${name}__is_mojom(${toolchain})" ] | 190 deps += [ "${name}__is_mojom(${toolchain})" ] |
179 } | 191 } |
180 } | 192 } |
181 | 193 |
182 if (is_android) { | 194 if (is_android) { |
183 import("//build/config/android/rules.gni") | 195 import("//build/config/android/rules.gni") |
184 | 196 |
185 java_target_name = target_name + "_java" | 197 java_target_name = target_name + "_java" |
186 android_library(java_target_name) { | 198 android_library(java_target_name) { |
187 deps = [ | 199 deps = rebase_path([ |
188 "//mojo/public/java:bindings", | 200 "mojo/public/java:bindings", |
189 "//mojo/public/java:system", | 201 "mojo/public/java:system", |
190 ] | 202 ], ".", mojo_root) |
191 | 203 |
192 foreach(d, all_deps) { | 204 foreach(d, all_deps) { |
193 # Resolve the name, so that a target //mojo/something becomes | 205 # Resolve the name, so that a target //mojo/something becomes |
194 # //mojo/something:something and we can append "_java" to get the java | 206 # //mojo/something:something and we can append "_java" to get the java |
195 # dependency name. | 207 # dependency name. |
196 full_name = get_label_info(d, "label_no_toolchain") | 208 full_name = get_label_info(d, "label_no_toolchain") |
197 deps += [ "${full_name}_java" ] | 209 deps += [ "${full_name}_java" ] |
198 } | 210 } |
199 | 211 |
200 srcjars = process_file_template(invoker.sources, generator_java_outputs) | 212 srcjars = process_file_template(invoker.sources, generator_java_outputs) |
201 } | 213 } |
202 } | 214 } |
203 } | 215 } |
OLD | NEW |