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 mojom_generator_root = "//mojo/public/tools/bindings" | 5 mojom_generator_root = "//mojo/public/tools/bindings" |
6 mojom_generator_script = "$mojom_generator_root/mojom_bindings_generator.py" | 6 mojom_generator_script = "$mojom_generator_root/mojom_bindings_generator.py" |
7 mojom_generator_sources = [ | 7 mojom_generator_sources = [ |
8 "$mojom_generator_root/generators/mojom_cpp_generator.py", | 8 "$mojom_generator_root/generators/mojom_cpp_generator.py", |
9 "$mojom_generator_root/generators/mojom_js_generator.py", | 9 "$mojom_generator_root/generators/mojom_js_generator.py", |
10 "$mojom_generator_root/generators/mojom_java_generator.py", | 10 "$mojom_generator_root/generators/mojom_java_generator.py", |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 # List of import directories that will get added when processing sources. | 44 # List of import directories that will get added when processing sources. |
45 # | 45 # |
46 # with_environment (optional) | 46 # with_environment (optional) |
47 # Set to |false| to omit an implicit bindings dependency on the Chromium | 47 # Set to |false| to omit an implicit bindings dependency on the Chromium |
48 # Mojo environment implementation. Defaults to |true| and in general | 48 # Mojo environment implementation. Defaults to |true| and in general |
49 # should only be overridden by mojom targets within the Mojo EDK. | 49 # should only be overridden by mojom targets within the Mojo EDK. |
50 # | 50 # |
51 # typemaps (optional) | 51 # typemaps (optional) |
52 # A list of typemap files to apply during bindings generation. | 52 # A list of typemap files to apply during bindings generation. |
53 # | 53 # |
| 54 # typemap_deps (optional) |
| 55 # A list of public dependencies needed to support active typemaps. |
| 56 # |
54 # variant (optional) | 57 # variant (optional) |
55 # A variant name to apply to generated bindings. Variant influences | 58 # A variant name to apply to generated bindings. Variant influences |
56 # generated source filenames as wells the symbols they define. | 59 # generated source filenames as wells the symbols they define. |
57 # | 60 # |
| 61 # cpp_only (optional) |
| 62 # If true, only C++ bindings will be generated. This defaults to false |
| 63 # unless |variant| is specified. |
| 64 # |
58 # testonly (optional) | 65 # testonly (optional) |
59 # | 66 # |
60 # visibility (optional) | 67 # visibility (optional) |
61 template("mojom") { | 68 template("mojom") { |
62 assert( | 69 assert( |
63 defined(invoker.sources) || defined(invoker.deps) || | 70 defined(invoker.sources) || defined(invoker.deps) || |
64 defined(invoker.public_deps), | 71 defined(invoker.public_deps), |
65 "\"sources\" or \"deps\" must be defined for the $target_name template.") | 72 "\"sources\" or \"deps\" must be defined for the $target_name template.") |
66 | 73 |
67 cpp_sources_suffix = "cpp_sources" | 74 cpp_sources_suffix = "cpp_sources" |
68 cpp_sources_target_name = "${target_name}_${cpp_sources_suffix}" | 75 cpp_sources_target_name = "${target_name}_${cpp_sources_suffix}" |
| 76 cpp_only = false |
| 77 if (defined(invoker.cpp_only)) { |
| 78 cpp_only = invoker.cpp_only |
| 79 } |
69 if (defined(invoker.sources)) { | 80 if (defined(invoker.sources)) { |
70 if (defined(invoker.variant)) { | 81 if (defined(invoker.variant)) { |
71 variant = invoker.variant | 82 variant = invoker.variant |
| 83 cpp_only = true |
72 generator_cpp_outputs = [ | 84 generator_cpp_outputs = [ |
73 "{{source_gen_dir}}/{{source_name_part}}.mojom-${variant}.cc", | 85 "{{source_gen_dir}}/{{source_name_part}}.mojom-${variant}.cc", |
74 "{{source_gen_dir}}/{{source_name_part}}.mojom-${variant}.h", | 86 "{{source_gen_dir}}/{{source_name_part}}.mojom-${variant}.h", |
75 "{{source_gen_dir}}/{{source_name_part}}.mojom-${variant}-internal.h", | 87 "{{source_gen_dir}}/{{source_name_part}}.mojom-${variant}-internal.h", |
76 ] | 88 ] |
77 generator_js_outputs = [] | |
78 generator_java_outputs = [] | |
79 } else { | 89 } else { |
80 generator_cpp_outputs = [ | 90 generator_cpp_outputs = [ |
81 "{{source_gen_dir}}/{{source_name_part}}.mojom.cc", | 91 "{{source_gen_dir}}/{{source_name_part}}.mojom.cc", |
82 "{{source_gen_dir}}/{{source_name_part}}.mojom.h", | 92 "{{source_gen_dir}}/{{source_name_part}}.mojom.h", |
83 "{{source_gen_dir}}/{{source_name_part}}.mojom-internal.h", | 93 "{{source_gen_dir}}/{{source_name_part}}.mojom-internal.h", |
84 ] | 94 ] |
85 generator_js_outputs = | |
86 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.js" ] | |
87 generator_java_outputs = | |
88 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.srcjar" ] | |
89 } | 95 } |
90 } | 96 } |
91 | 97 |
| 98 if (cpp_only) { |
| 99 generator_js_outputs = [] |
| 100 generator_java_outputs = [] |
| 101 } else { |
| 102 generator_js_outputs = |
| 103 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.js" ] |
| 104 generator_java_outputs = |
| 105 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.srcjar" ] |
| 106 } |
| 107 |
92 if (defined(invoker.sources)) { | 108 if (defined(invoker.sources)) { |
93 generator_target_name = target_name + "__generator" | 109 generator_target_name = target_name + "__generator" |
94 action_foreach(generator_target_name) { | 110 action_foreach(generator_target_name) { |
95 script = mojom_generator_script | 111 script = mojom_generator_script |
96 inputs = mojom_generator_sources | 112 inputs = mojom_generator_sources |
97 sources = invoker.sources | 113 sources = invoker.sources |
98 deps = [ | 114 deps = [ |
99 "//mojo/public/tools/bindings:precompile_templates", | 115 "//mojo/public/tools/bindings:precompile_templates", |
100 ] | 116 ] |
101 outputs = | 117 outputs = |
(...skipping 14 matching lines...) Expand all Loading... |
116 | 132 |
117 if (defined(invoker.import_dirs)) { | 133 if (defined(invoker.import_dirs)) { |
118 foreach(import_dir, invoker.import_dirs) { | 134 foreach(import_dir, invoker.import_dirs) { |
119 args += [ | 135 args += [ |
120 "-I", | 136 "-I", |
121 rebase_path(import_dir, root_build_dir), | 137 rebase_path(import_dir, root_build_dir), |
122 ] | 138 ] |
123 } | 139 } |
124 } | 140 } |
125 | 141 |
126 if (defined(invoker.variant)) { | 142 if (cpp_only) { |
127 args += [ | 143 args += [ |
128 "--variant", | |
129 invoker.variant, | |
130 "-g", | 144 "-g", |
131 "c++", | 145 "c++", |
132 ] | 146 ] |
133 } else { | 147 } else { |
134 args += [ | 148 args += [ |
135 "-g", | 149 "-g", |
136 "c++,javascript,java", | 150 "c++,javascript,java", |
137 ] | 151 ] |
138 } | 152 } |
139 | 153 |
| 154 if (defined(invoker.variant)) { |
| 155 args += [ |
| 156 "--variant", |
| 157 invoker.variant, |
| 158 ] |
| 159 } |
| 160 |
140 if (defined(invoker.typemaps)) { | 161 if (defined(invoker.typemaps)) { |
141 foreach(typemap, invoker.typemaps) { | 162 foreach(typemap, invoker.typemaps) { |
142 args += [ | 163 args += [ |
143 "--typemap", | 164 "--typemap", |
144 rebase_path(typemap, root_build_dir), | 165 rebase_path(typemap, root_build_dir), |
145 ] | 166 ] |
146 } | 167 } |
147 } | 168 } |
148 } | 169 } |
149 } | 170 } |
(...skipping 11 matching lines...) Expand all Loading... |
161 | 182 |
162 public_deps = [ | 183 public_deps = [ |
163 "//mojo/public/cpp/bindings", | 184 "//mojo/public/cpp/bindings", |
164 ] | 185 ] |
165 if (defined(invoker.sources)) { | 186 if (defined(invoker.sources)) { |
166 public_deps += [ ":${cpp_sources_target_name}" ] | 187 public_deps += [ ":${cpp_sources_target_name}" ] |
167 } | 188 } |
168 if (defined(invoker.public_deps)) { | 189 if (defined(invoker.public_deps)) { |
169 public_deps += invoker.public_deps | 190 public_deps += invoker.public_deps |
170 } | 191 } |
| 192 if (defined(invoker.typemap_deps)) { |
| 193 public_deps += invoker.typemap_deps |
| 194 } |
171 | 195 |
172 deps = [] | 196 deps = [] |
173 if (defined(invoker.sources)) { | 197 if (defined(invoker.sources)) { |
174 public_deps += [ ":$generator_target_name" ] | 198 public_deps += [ ":$generator_target_name" ] |
175 } | 199 } |
176 if (defined(invoker.deps)) { | 200 if (defined(invoker.deps)) { |
177 deps += invoker.deps | 201 deps += invoker.deps |
178 } | 202 } |
179 } | 203 } |
180 | 204 |
(...skipping 26 matching lines...) Expand all Loading... |
207 # on mojo/public/cpp/bindings. No external targets should depend directly on | 231 # on mojo/public/cpp/bindings. No external targets should depend directly on |
208 # this target *except* mojo/public/cpp/bindings and other *_cpp_sources | 232 # this target *except* mojo/public/cpp/bindings and other *_cpp_sources |
209 # targets. | 233 # targets. |
210 source_set(cpp_sources_target_name) { | 234 source_set(cpp_sources_target_name) { |
211 if (defined(invoker.testonly)) { | 235 if (defined(invoker.testonly)) { |
212 testonly = invoker.testonly | 236 testonly = invoker.testonly |
213 } | 237 } |
214 sources = process_file_template(invoker.sources, generator_cpp_outputs) | 238 sources = process_file_template(invoker.sources, generator_cpp_outputs) |
215 deps = [ | 239 deps = [ |
216 ":$generator_target_name", | 240 ":$generator_target_name", |
217 "//base", | |
218 "//mojo/public/interfaces/bindings:bindings__generator", | 241 "//mojo/public/interfaces/bindings:bindings__generator", |
219 ] | 242 ] |
| 243 public_deps = [ |
| 244 "//base", |
| 245 ] |
| 246 if (defined(invoker.typemap_deps)) { |
| 247 public_deps += invoker.typemap_deps |
| 248 } |
220 foreach(d, all_deps) { | 249 foreach(d, all_deps) { |
221 # Resolve the name, so that a target //mojo/something becomes | 250 # Resolve the name, so that a target //mojo/something becomes |
222 # //mojo/something:something and we can append cpp_sources_suffix to | 251 # //mojo/something:something and we can append cpp_sources_suffix to |
223 # get the cpp dependency name. | 252 # get the cpp dependency name. |
224 full_name = get_label_info(d, "label_no_toolchain") | 253 full_name = get_label_info(d, "label_no_toolchain") |
225 deps += [ "${full_name}_${cpp_sources_suffix}" ] | 254 deps += [ "${full_name}_${cpp_sources_suffix}" ] |
226 } | 255 } |
227 if (!defined(invoker.with_environment) || invoker.with_environment) { | 256 if (!defined(invoker.with_environment) || invoker.with_environment) { |
228 deps += [ "//mojo/environment:chromium" ] | 257 deps += [ "//mojo/environment:chromium" ] |
229 } | 258 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 # //mojo/something:something and we can append "_java" to get the java | 294 # //mojo/something:something and we can append "_java" to get the java |
266 # dependency name. | 295 # dependency name. |
267 full_name = get_label_info(d, "label_no_toolchain") | 296 full_name = get_label_info(d, "label_no_toolchain") |
268 deps += [ "${full_name}_java" ] | 297 deps += [ "${full_name}_java" ] |
269 } | 298 } |
270 | 299 |
271 srcjar_deps = [ ":$java_srcjar_target_name" ] | 300 srcjar_deps = [ ":$java_srcjar_target_name" ] |
272 } | 301 } |
273 } | 302 } |
274 } | 303 } |
OLD | NEW |