OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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("//build/config/dcheck_always_on.gni") | 5 import("//build/config/dcheck_always_on.gni") |
6 import("//services/service_manager/public/constants.gni") | |
7 | 6 |
8 # Used to produce a Service Manifest for a Service. | 7 # Used to produce a Service Manifest for a Service. |
9 # | 8 # |
9 # Service manifests may be subsequently aggregated into one or more catalog | |
10 # manifests (see //services/catalog/public/tools/catalog.gni). A catalog | |
11 # manifest provides the Service Manager at runtime with a static service layout | |
12 # configuration to dictate which services are supported by the runtime | |
13 # environment as well as how individual services may be launched and | |
14 # interconnected. | |
15 # | |
16 # Note that this target may be used to produce partial manifests, and partial | |
17 # manifests may be aggregated by using one service_manifest target as the | |
18 # |source_manifest| of another (see below.) | |
19 # | |
10 # Parameters: | 20 # Parameters: |
11 # | 21 # |
12 # source | 22 # source (optional**) |
13 # The manifest file template for this service, must be valid JSON with | 23 # The manifest template for this service. Must be the name of a valid JSON |
14 # a valid 'url' key matching name. | 24 # file. |
25 # | |
26 # source_manifest (optional**) | |
27 # The manifest template for this service. Must be the name over another | |
Ben Goodger (Google)
2017/01/20 22:23:15
Must be the name of
Ken Rockot(use gerrit already)
2017/01/23 22:42:46
done
| |
28 # service_manifest target. | |
29 # | |
30 # ** NOTE: Either |source| OR |source_manifest| MUST be specified. | |
31 # | |
32 # name (optional) | |
33 # The name of the service whose manifest is to be generated. A script | |
34 # validates that the value of this parameter matches the name set in the | |
35 # source manifest and raises an error if it does not match. | |
15 # | 36 # |
16 # overlays (optional) | 37 # overlays (optional) |
17 # A list of partial manifests to overlay onto the source manifest before | 38 # A list of other manifest targets whose outputs should be overlayed onto |
18 # emitting the final output. Overlays are applied as the last step, after | 39 # the source manifest before emitting the final output. Overlays are |
19 # any packaged manifests are embedded. | 40 # applied in-order as the last step of output generation, after any |
20 # | 41 # |packaged_services| manifests are embedded. |
21 # name | |
22 # The host portion of the mojo: URL of the service. A script validates | |
23 # that the value of this parameter matches the host name portion of the | |
24 # 'url' property set in the manifest and throws a ValueError if they do | |
25 # not. | |
26 # | |
27 # output_name (optional) | |
28 # The name of the package to output. The default value is copied from | |
29 # |name|. Note that this has no effect on the contents of the manifest, | |
30 # but only determines the output subdirectory within ${out}/Packages. | |
31 # | |
32 # deps (optional) | |
33 # An array of dependent instances of this template. This template enforces | |
34 # that dependencies can only be instances of this template. | |
35 # | 42 # |
36 # packaged_services (optional) | 43 # packaged_services (optional) |
37 # An array of names of the dependent services. | 44 # A list of other manifest targets whose outputs should be packaged |
45 # within this output manifest, specifically within a toplevel "services" | |
46 # list. | |
38 # | 47 # |
39 # Outputs: | 48 # Outputs: |
40 # | 49 # |
41 # An instantiation of this template produces in | 50 # An instantiation of this template produces a meta manifest from the source |
42 # $outdir/<name>/manifest.json | 51 # template and the output manifests of all its |overlay| and |
43 # a meta manifest from the source template and the output manifest of all | 52 # |packaged_services|dependencies. The output file is always |
44 # dependent children. | 53 # "$target_gen_dir/${target_name}.json". |
45 # | 54 # |
46 template("service_manifest") { | 55 template("service_manifest") { |
47 assert(defined(invoker.source), | 56 assert( |
48 "\"source\" must be defined for the $target_name template") | 57 defined(invoker.source) || defined(invoker.source_manifest), |
49 assert(defined(invoker.name), | 58 "\"source\" or \"source_manifest\" must be defined for the $target_name ta rget") |
50 "\"name\" must be defined for the $target_name template") | 59 assert( |
51 if (defined(invoker.deps)) { | 60 !defined(invoker.source) || !defined(invoker.source_manifest), |
52 assert(defined(invoker.packaged_services) || defined(invoker.overlays), | 61 "Only one of \"source\" or \"source_manifest\" must be defined for the $ta rget_name target") |
53 "\"deps\" implies that you also want \"packaged_services\" and/or" + | |
54 "\"overlays\", but you have neither.") | |
55 } | |
56 if (defined(invoker.packaged_services)) { | |
57 assert(defined(invoker.deps), | |
58 "\"deps\" building the dependent packaged services must be " + | |
59 "provided.") | |
60 } | |
61 | 62 |
62 action(target_name) { | 63 action(target_name) { |
63 script = | 64 script = |
64 "//services/service_manager/public/tools/manifest/manifest_collator.py" | 65 "//services/service_manager/public/tools/manifest/manifest_collator.py" |
65 | 66 |
66 name = invoker.name | 67 deps = [] |
67 inputs = [ | 68 if (defined(invoker.deps)) { |
68 invoker.source, | 69 deps += invoker.deps |
69 ] | |
70 if (defined(invoker.overlays)) { | |
71 inputs += invoker.overlays | |
72 } | 70 } |
73 | 71 |
74 if (defined(invoker.output_name)) { | 72 if (defined(invoker.source)) { |
75 output = "$root_out_dir/$packages_directory/${invoker.output_name}/manifes t.json" | 73 source = invoker.source |
76 } else { | 74 } else { |
77 output = "$root_out_dir/$packages_directory/$name/manifest.json" | 75 source_target_dir = |
76 get_label_info(invoker.source_manifest, "target_gen_dir") | |
77 source_target_name = get_label_info(invoker.source_manifest, "name") | |
78 source = "$source_target_dir/${source_target_name}.json" | |
79 deps += [ invoker.source_manifest ] | |
78 } | 80 } |
81 inputs = [ | |
82 source, | |
83 ] | |
84 | |
85 output = "$target_gen_dir/${target_name}.json" | |
79 outputs = [ | 86 outputs = [ |
80 output, | 87 output, |
81 ] | 88 ] |
82 | 89 |
83 rebase_parent = rebase_path(invoker.source, root_build_dir) | 90 rebase_parent = rebase_path(source, root_build_dir) |
84 rebase_output = rebase_path(output, root_build_dir) | 91 rebase_output = rebase_path(output, root_build_dir) |
85 | 92 |
86 args = [ | 93 args = [ |
87 "--name=$name", | |
88 "--parent=$rebase_parent", | |
89 "--output=$rebase_output", | |
90 ] | |
91 | |
92 if (is_debug || dcheck_always_on) { | |
93 args += [ "--pretty" ] | |
94 } | |
95 | |
96 if (defined(invoker.overlays)) { | |
97 args += [ "--overlays" ] | |
98 foreach(overlay_path, invoker.overlays) { | |
99 args += [ rebase_path(overlay_path, root_build_dir) ] | |
100 } | |
101 } | |
102 | |
103 if (defined(invoker.packaged_services)) { | |
104 args += [ "--packaged-services" ] | |
105 foreach(name, invoker.packaged_services) { | |
106 input = "$root_out_dir/$packages_directory/$name/manifest.json" | |
107 inputs += [ input ] | |
108 args += [ rebase_path(input, root_build_dir) ] | |
109 } | |
110 } | |
111 deps = [] | |
112 data_deps = [] | |
113 if (defined(invoker.deps)) { | |
114 deps += invoker.deps | |
115 data_deps += invoker.deps | |
116 } | |
117 } | |
118 | |
119 all_deps = [] | |
120 if (defined(invoker.deps)) { | |
121 all_deps += invoker.deps | |
122 } | |
123 | |
124 group("${target_name}__is_service_manifest_or_overlay") { | |
125 } | |
126 | |
127 # Explicitly ensure that all dependencies are service_manifest | |
128 # or service_manifest_overlay targets themselves. | |
129 group("${target_name}__check_deps_are_all_service_manifest") { | |
130 deps = [] | |
131 foreach(d, all_deps) { | |
132 name = get_label_info(d, "label_no_toolchain") | |
133 toolchain = get_label_info(d, "toolchain") | |
134 deps += [ "${name}__is_service_manifest_or_overlay(${toolchain})" ] | |
135 } | |
136 } | |
137 } | |
138 | |
139 # A simple derivative of the service_manifest template above. This allows for | |
140 # embedding of packaged services into a manifest overlay. | |
141 # | |
142 # Parameters: | |
143 # | |
144 # source | |
145 # The manifest overlay file to procss. | |
146 # | |
147 # overlays (optional) | |
148 # A list of partial manifests to overlay onto the source manifest before | |
149 # emitting the final output. Overlays are applied as the last step, after | |
150 # any packaged manifests are embedded. | |
151 # | |
152 # output_name (optional) | |
153 # The output name of the manifest. Defaults to the target name. | |
154 # | |
155 # deps (optional) | |
156 # An array of the service_manifest targets this overlay depends on. | |
157 # | |
158 # packaged_services (optional) | |
159 # An array of names of the services packaged into this overlay. | |
160 # | |
161 # Outputs: | |
162 # | |
163 # An instantiation of this template produces in | |
164 # ${root_gen_dir}/${output_name}.json | |
165 # | |
166 template("service_manifest_overlay") { | |
167 assert(defined(invoker.source), | |
168 "\"source\" must be defined for the $target_name template") | |
169 if (defined(invoker.deps)) { | |
170 assert(defined(invoker.packaged_services) || defined(invoker.overlays), | |
171 "\"deps\" implies that you also want \"packaged_services\" and/or" + | |
172 "\"overlays\", but you have neither.") | |
173 } | |
174 if (defined(invoker.packaged_services)) { | |
175 assert(defined(invoker.deps), | |
176 "\"deps\" building the dependent packaged services must be " + | |
177 "provided.") | |
178 } | |
179 | |
180 action(target_name) { | |
181 script = | |
182 "//services/service_manager/public/tools/manifest/manifest_collator.py" | |
183 | |
184 inputs = [ | |
185 invoker.source, | |
186 ] | |
187 if (defined(invoker.overlays)) { | |
188 inputs += invoker.overlays | |
189 } | |
190 | |
191 output_name = target_name | |
192 if (defined(invoker.output_name)) { | |
193 output_name = invoker.output_name | |
194 } | |
195 output = "${root_gen_dir}/${output_name}.json" | |
196 | |
197 outputs = [ | |
198 output, | |
199 ] | |
200 | |
201 rebase_parent = rebase_path(invoker.source, root_build_dir) | |
202 rebase_output = rebase_path(output, root_build_dir) | |
203 | |
204 args = [ | |
205 "--parent=$rebase_parent", | 94 "--parent=$rebase_parent", |
206 "--output=$rebase_output", | 95 "--output=$rebase_output", |
207 ] | 96 ] |
208 | 97 |
98 if (defined(invoker.name)) { | |
99 args += [ | |
100 "--name", | |
101 invoker.name, | |
102 ] | |
103 } | |
104 | |
209 if (is_debug || dcheck_always_on) { | 105 if (is_debug || dcheck_always_on) { |
210 args += [ "--pretty" ] | 106 args += [ "--pretty" ] |
211 } | 107 } |
212 | 108 |
213 if (defined(invoker.overlays)) { | 109 if (defined(invoker.overlays)) { |
214 args += [ "--overlays" ] | 110 args += [ "--overlays" ] |
215 foreach(overlay_path, invoker.overlays) { | 111 foreach(manifest_target, invoker.overlays) { |
216 args += [ rebase_path(overlay_path, root_build_dir) ] | 112 manifest_target_dir = get_label_info(manifest_target, "target_gen_dir") |
113 manifest_target_name = get_label_info(manifest_target, "name") | |
114 manifest_filename = "$manifest_target_dir/${manifest_target_name}.json" | |
115 | |
116 inputs += [ manifest_filename ] | |
117 deps += [ manifest_target ] | |
118 args += [ rebase_path(manifest_filename, root_build_dir) ] | |
119 | |
120 # Ensure that each entry does in fact reference a manifest rule. | |
121 label_no_toolchain = | |
122 get_label_info(manifest_target, "label_no_toolchain") | |
123 toolchain = get_label_info(manifest_target, "toolchain") | |
124 deps += [ "${label_no_toolchain}__is_service_manifest(${toolchain})" ] | |
217 } | 125 } |
218 } | 126 } |
219 | 127 |
220 if (defined(invoker.packaged_services)) { | 128 if (defined(invoker.packaged_services)) { |
221 args += [ "--packaged-services" ] | 129 args += [ "--packaged-services" ] |
222 foreach(name, invoker.packaged_services) { | 130 foreach(manifest_target, invoker.packaged_services) { |
223 input = "$root_out_dir/$packages_directory/$name/manifest.json" | 131 manifest_target_dir = get_label_info(manifest_target, "target_gen_dir") |
224 inputs += [ input ] | 132 manifest_target_name = get_label_info(manifest_target, "name") |
225 args += [ rebase_path(input, root_build_dir) ] | 133 manifest_filename = "$manifest_target_dir/${manifest_target_name}.json" |
134 | |
135 inputs += [ manifest_filename ] | |
136 deps += [ manifest_target ] | |
137 args += [ rebase_path(manifest_filename, root_build_dir) ] | |
138 | |
139 # Ensure that each entry does in fact reference a manifest rule. | |
140 label_no_toolchain = | |
141 get_label_info(manifest_target, "label_no_toolchain") | |
142 toolchain = get_label_info(manifest_target, "toolchain") | |
143 deps += [ "${label_no_toolchain}__is_service_manifest(${toolchain})" ] | |
226 } | 144 } |
227 } | 145 } |
228 | |
229 deps = [] | |
230 data_deps = [] | |
231 if (defined(invoker.deps)) { | |
232 deps += invoker.deps | |
233 data_deps += invoker.deps | |
234 } | |
235 } | 146 } |
236 | 147 |
237 group("${target_name}__is_service_manifest_or_overlay") { | 148 group("${target_name}__is_service_manifest") { |
238 } | |
239 | |
240 # Explicitly ensure that all dependencies are service_manifest | |
241 # or service_manifest_overlay targets themselves. | |
242 group("${target_name}__check_deps_are_all_service_manifest") { | |
243 deps = [] | |
244 foreach(d, all_deps) { | |
245 name = get_label_info(d, "label_no_toolchain") | |
246 toolchain = get_label_info(d, "toolchain") | |
247 deps += [ "${name}__is_service_manifest_or_overlay(${toolchain})" ] | |
248 } | |
249 } | 149 } |
250 } | 150 } |
OLD | NEW |