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

Side by Side Diff: mojo/public/tools/bindings/mojom.gni

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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
(Empty)
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
3 # found in the LICENSE file.
4
5 import("../../mojo_sdk.gni")
6
7 # Generate C++ and JavaScript source files from mojom files. The output files
8 # will go under the generated file directory tree with the same path as each
9 # input file.
10 #
11 # If a mojom target is intended for use in a client repo where the location of
12 # the Mojo SDK will be different than its location in the Mojo repo,
13 # dependencies on the SDK should be specified relative to the parent directory
14 # of the Mojo public SDK in |mojo_sdk_deps| rather than via absolute paths in
15 # |deps|.
16 #
17 # Parameters:
18 #
19 # sources (required)
20 # List of source .mojom files to compile.
21 #
22 # deps (optional)
23 # Note: this can contain only other mojom targets.
24 #
25 # mojo_sdk_deps (optional)
26 # List of deps specified relative to the parent directory of the Mojo
27 # public SDK. These deps will be added as ordinary deps rebased to the
28 # current directory.
29 #
30 # public_deps (optional)
31 # Note: this can contain only other mojom targets.
32 #
33 # mojo_sdk_public_deps (optional)
34 # List of public deps specified relative to the parent directory of the
35 # Mojo public SDK. These deps will be added as ordinary public deps
36 # rebased to the current directory.
37 #
38 # import_dirs (optional)
39 # List of import directories that will get added when processing sources.
40 #
41 # testonly (optional)
42 #
43 # visibility (optional)
44 template("mojom") {
45 assert(defined(invoker.sources),
46 "\"sources\" must be defined for the $target_name template.")
47
48 generator_root = rebase_path("mojo/public/tools/bindings", ".", mojo_root)
49 generator_script = "$generator_root/mojom_bindings_generator.py"
50 generator_sources = [
51 generator_script,
52 "$generator_root/generators/cpp_templates/enum_declaration.tmpl",
53 "$generator_root/generators/cpp_templates/interface_declaration.tmpl",
54 "$generator_root/generators/cpp_templates/interface_definition.tmpl",
55 "$generator_root/generators/cpp_templates/interface_macros.tmpl",
56 "$generator_root/generators/cpp_templates/interface_proxy_declaration.tmpl",
57 "$generator_root/generators/cpp_templates/interface_request_validator_declar ation.tmpl",
58 "$generator_root/generators/cpp_templates/interface_response_validator_decla ration.tmpl",
59 "$generator_root/generators/cpp_templates/interface_stub_declaration.tmpl",
60 "$generator_root/generators/cpp_templates/module.cc.tmpl",
61 "$generator_root/generators/cpp_templates/module.h.tmpl",
62 "$generator_root/generators/cpp_templates/module-internal.h.tmpl",
63 "$generator_root/generators/cpp_templates/params_definition.tmpl",
64 "$generator_root/generators/cpp_templates/struct_declaration.tmpl",
65 "$generator_root/generators/cpp_templates/struct_definition.tmpl",
66 "$generator_root/generators/cpp_templates/struct_serialization_declaration.t mpl",
67 "$generator_root/generators/cpp_templates/struct_serialization_definition.tm pl",
68 "$generator_root/generators/cpp_templates/struct_macros.tmpl",
69 "$generator_root/generators/cpp_templates/wrapper_class_declaration.tmpl",
70 "$generator_root/generators/cpp_templates/wrapper_class_definition.tmpl",
71 "$generator_root/generators/dart_templates/enum_definition.tmpl",
72 "$generator_root/generators/dart_templates/interface_definition.tmpl",
73 "$generator_root/generators/dart_templates/module.lib.tmpl",
74 "$generator_root/generators/dart_templates/module_definition.tmpl",
75 "$generator_root/generators/dart_templates/struct_definition.tmpl",
76 "$generator_root/generators/java_templates/constant_definition.tmpl",
77 "$generator_root/generators/java_templates/constants.java.tmpl",
78 "$generator_root/generators/java_templates/enum.java.tmpl",
79 "$generator_root/generators/java_templates/enum_definition.tmpl",
80 "$generator_root/generators/java_templates/header.java.tmpl",
81 "$generator_root/generators/java_templates/interface.java.tmpl",
82 "$generator_root/generators/java_templates/interface_definition.tmpl",
83 "$generator_root/generators/java_templates/interface_internal.java.tmpl",
84 "$generator_root/generators/java_templates/struct.java.tmpl",
85 "$generator_root/generators/java_templates/struct_definition.tmpl",
86 "$generator_root/generators/js_templates/enum_definition.tmpl",
87 "$generator_root/generators/js_templates/interface_definition.tmpl",
88 "$generator_root/generators/js_templates/module.amd.tmpl",
89 "$generator_root/generators/js_templates/module.sky.tmpl",
90 "$generator_root/generators/js_templates/module_definition.tmpl",
91 "$generator_root/generators/js_templates/struct_definition.tmpl",
92 "$generator_root/generators/python_templates/module_macros.tmpl",
93 "$generator_root/generators/python_templates/module.py.tmpl",
94 "$generator_root/generators/mojom_cpp_generator.py",
95 "$generator_root/generators/mojom_dart_generator.py",
96 "$generator_root/generators/mojom_js_generator.py",
97 "$generator_root/generators/mojom_java_generator.py",
98 "$generator_root/generators/mojom_python_generator.py",
99 "$generator_root/pylib/mojom/__init__.py",
100 "$generator_root/pylib/mojom/error.py",
101 "$generator_root/pylib/mojom/generate/__init__.py",
102 "$generator_root/pylib/mojom/generate/data.py",
103 "$generator_root/pylib/mojom/generate/generator.py",
104 "$generator_root/pylib/mojom/generate/module.py",
105 "$generator_root/pylib/mojom/generate/pack.py",
106 "$generator_root/pylib/mojom/generate/template_expander.py",
107 "$generator_root/pylib/mojom/parse/__init__.py",
108 "$generator_root/pylib/mojom/parse/ast.py",
109 "$generator_root/pylib/mojom/parse/lexer.py",
110 "$generator_root/pylib/mojom/parse/parser.py",
111 "$generator_root/pylib/mojom/parse/translate.py",
112 ]
113 generator_cpp_outputs = [
114 "{{source_gen_dir}}/{{source_name_part}}.mojom.cc",
115 "{{source_gen_dir}}/{{source_name_part}}.mojom.h",
116 "{{source_gen_dir}}/{{source_name_part}}.mojom-internal.h",
117 ]
118 generator_dart_outputs =
119 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.dart" ]
120 generator_java_outputs =
121 [ "{{source_gen_dir}}/{{source_name_part}}.mojom.srcjar" ]
122 generator_js_outputs = [ "{{source_gen_dir}}/{{source_name_part}}.mojom.js" ]
123 generator_python_outputs =
124 [ "{{source_gen_dir}}/{{source_name_part}}_mojom.py" ]
125
126 rebased_mojo_sdk_public_deps = []
127 if (defined(invoker.mojo_sdk_public_deps)) {
128 foreach(sdk_dep, invoker.mojo_sdk_public_deps) {
129 # Check that the SDK dep was not mistakenly given as an absolute path.
130 assert(get_path_info(sdk_dep, "abspath") != sdk_dep)
131 rebased_mojo_sdk_public_deps += [ rebase_path(sdk_dep, ".", mojo_root) ]
132 }
133 }
134
135 rebased_mojo_sdk_deps = []
136 if (defined(invoker.mojo_sdk_deps)) {
137 foreach(sdk_dep, invoker.mojo_sdk_deps) {
138 # Check that the SDK dep was not mistakenly given as an absolute path.
139 assert(get_path_info(sdk_dep, "abspath") != sdk_dep)
140 rebased_mojo_sdk_deps += [ rebase_path(sdk_dep, ".", mojo_root) ]
141 }
142 }
143
144 if (defined(invoker.visibility)) {
145 # Need to save this because the the target_name is overwritten inside the
146 # action to be that of the action itself. Only define this in the case the
147 # var is used to avoid unused var error.
148 target_visibility = [ ":$target_name" ]
149 }
150
151 generator_target_name = target_name + "__generator"
152 action_foreach(generator_target_name) {
153 if (defined(invoker.visibility)) {
154 visibility = target_visibility + invoker.visibility
155 }
156 script = generator_script
157 inputs = generator_sources
158 sources = invoker.sources
159 outputs =
160 generator_cpp_outputs + generator_dart_outputs +
161 generator_java_outputs + generator_js_outputs + generator_python_outputs
162 args = [
163 "{{source}}",
164 "--use_bundled_pylibs",
165 "-d",
166 rebase_path("//", root_build_dir),
167 "-I",
168 rebase_path("//", root_build_dir),
169 "-I",
170 rebase_path(mojo_root, root_build_dir),
171 "-o",
172 rebase_path(root_gen_dir),
173 ]
174
175 if (defined(invoker.import_dirs)) {
176 foreach(import_dir, invoker.import_dirs) {
177 args += [
178 "-I",
179 rebase_path(import_dir, root_build_dir),
180 ]
181 }
182 }
183 }
184
185 source_set(target_name) {
186 if (defined(invoker.visibility)) {
187 visibility = invoker.visibility
188 }
189 if (defined(invoker.testonly)) {
190 testonly = invoker.testonly
191 }
192 sources = process_file_template(invoker.sources, generator_cpp_outputs)
193 data = process_file_template(invoker.sources, generator_js_outputs)
194
195 public_configs =
196 rebase_path([ "mojo/public/build/config:mojo_sdk" ], ".", mojo_root)
197
198 public_deps = rebase_path([ "mojo/public/cpp/bindings" ], ".", mojo_root)
199 public_deps += rebased_mojo_sdk_public_deps
200 if (defined(invoker.public_deps)) {
201 public_deps += invoker.public_deps
202 }
203
204 deps = [
205 ":$generator_target_name",
206 ]
207 deps += rebased_mojo_sdk_deps
208 if (defined(invoker.deps)) {
209 deps += invoker.deps
210 }
211 }
212
213 all_deps = rebased_mojo_sdk_deps + rebased_mojo_sdk_public_deps
214 if (defined(invoker.deps)) {
215 all_deps += invoker.deps
216 }
217 if (defined(invoker.public_deps)) {
218 all_deps += invoker.public_deps
219 }
220
221 group("${target_name}__is_mojom") {
222 }
223
224 # Explicitly ensure that all dependencies (invoker.deps and
225 # invoker.public_deps) are mojom targets themselves.
226 group("${target_name}__check_deps_are_all_mojom") {
227 deps = []
228 foreach(d, all_deps) {
229 name = get_label_info(d, "label_no_toolchain")
230 toolchain = get_label_info(d, "toolchain")
231 deps += [ "${name}__is_mojom(${toolchain})" ]
232 }
233 }
234
235 if (is_android) {
236 import("//build/config/android/rules.gni")
237
238 java_target_name = target_name + "_java"
239 android_library(java_target_name) {
240 deps = rebase_path([
241 "mojo/public/java:bindings",
242 "mojo/public/java:system",
243 ],
244 ".",
245 mojo_root)
246
247 foreach(d, all_deps) {
248 # Resolve the name, so that a target //mojo/something becomes
249 # //mojo/something:something and we can append "_java" to get the java
250 # dependency name.
251 full_name = get_label_info(d, "label_no_toolchain")
252 deps += [ "${full_name}_java" ]
253 }
254
255 srcjars = process_file_template(invoker.sources, generator_java_outputs)
256 }
257 }
258 }
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/run_cpp_generator.py ('k') | mojo/public/tools/bindings/mojom_bindings_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698