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("//services/shell/public/constants.gni") | 5 import("//services/shell/public/constants.gni") |
6 | 6 |
7 # Used to produce a Service Manifest for a Service. | 7 # Used to produce a Service Manifest for a Service. |
8 # | 8 # |
9 # Parameters: | 9 # Parameters: |
10 # | 10 # |
11 # source | 11 # source |
12 # The manifest file template for this service, must be valid JSON with | 12 # The manifest file template for this service, must be valid JSON with |
13 # a valid 'url' key matching name. | 13 # a valid 'url' key matching name. |
14 # | 14 # |
15 # base_manifest (optional) | 15 # overlays (optional) |
16 # A manifest file template to use as a base for |source|. Any properties | 16 # A list of partial manifests to overlay onto the source manifest before |
17 # defined in |source| will overwrite or be merged with properties defined | 17 # emitting the final output. Overlays are applied as the last step, after |
18 # in |base_manifest|. | 18 # any packaged manifests are embedded. |
19 # | 19 # |
20 # name | 20 # name |
21 # The host portion of the mojo: URL of the service. A script validates | 21 # The host portion of the mojo: URL of the service. A script validates |
22 # that the value of this parameter matches the host name portion of the | 22 # that the value of this parameter matches the host name portion of the |
23 # 'url' property set in the manifest and throws a ValueError if they do | 23 # 'url' property set in the manifest and throws a ValueError if they do |
24 # not. | 24 # not. |
25 # | 25 # |
26 # base_deps (optional) | 26 # output_name (optional) |
27 # Dependencies required to generate |base_manifest| if applicable. | 27 # The name of the package to output. The default value is copied from |
| 28 # |name|. Note that this has no effect on the contents of the manifest, |
| 29 # but only determines the output subdirectory within ${out}/Packages. |
28 # | 30 # |
29 # deps (optional) | 31 # deps (optional) |
30 # An array of dependent instances of this template. This template enforces | 32 # An array of dependent instances of this template. This template enforces |
31 # that dependencies can only be instances of this template. | 33 # that dependencies can only be instances of this template. |
32 # | 34 # |
33 # packaged_services (optional) | 35 # packaged_services (optional) |
34 # An array of names of the dependent services. | 36 # An array of names of the dependent services. |
35 # | 37 # |
36 # type (default is mojo) | 38 # type (default is mojo) |
37 # Possible values are 'mojo' and 'exe'. Default is 'mojo'. | 39 # Possible values are 'mojo' and 'exe'. Default is 'mojo'. |
38 # | 40 # |
39 # Outputs: | 41 # Outputs: |
40 # | 42 # |
41 # An instantiation of this template produces in | 43 # An instantiation of this template produces in |
42 # $outdir/<name>/manifest.json | 44 # $outdir/<name>/manifest.json |
43 # a meta manifest from the source template and the output manifest of all | 45 # a meta manifest from the source template and the output manifest of all |
44 # dependent children. | 46 # dependent children. |
45 # | 47 # |
46 template("service_manifest") { | 48 template("service_manifest") { |
47 assert(defined(invoker.source), | 49 assert(defined(invoker.source), |
48 "\"source\" must be defined for the $target_name template") | 50 "\"source\" must be defined for the $target_name template") |
49 assert(defined(invoker.name), | 51 assert(defined(invoker.name), |
50 "\"name\" must be defined for the $target_name template") | 52 "\"name\" must be defined for the $target_name template") |
51 if (defined(invoker.deps)) { | 53 if (defined(invoker.deps)) { |
52 assert(defined(invoker.packaged_services), | 54 assert(defined(invoker.packaged_services) || defined(invoker.overlays), |
53 "\"packaged_services\" listing the directory containing the " + | 55 "\"deps\" implies that you also want \"packaged_services\" and/or" + |
54 "manifest.json of dependent services must be provided.") | 56 "\"overlays\", but you have neither.") |
55 } | 57 } |
56 if (defined(invoker.packaged_services)) { | 58 if (defined(invoker.packaged_services)) { |
57 assert(defined(invoker.deps), | 59 assert(defined(invoker.deps), |
58 "\"deps\" building the dependent packaged services must be " + | 60 "\"deps\" building the dependent packaged services must be " + |
59 "provided.") | 61 "provided.") |
60 } | 62 } |
61 if (defined(invoker.type)) { | 63 if (defined(invoker.type)) { |
62 assert(invoker.type == "mojo" || invoker.type == "exe", | 64 assert(invoker.type == "mojo" || invoker.type == "exe", |
63 "\"type\" must be one of \"mojo\" or \"exe\".") | 65 "\"type\" must be one of \"mojo\" or \"exe\".") |
64 } | 66 } |
65 | 67 |
66 action(target_name) { | 68 action(target_name) { |
67 script = "//services/shell/public/tools/manifest/manifest_collator.py" | 69 script = "//services/shell/public/tools/manifest/manifest_collator.py" |
68 | 70 |
69 type = "mojo" | 71 type = "mojo" |
70 if (defined(invoker.type)) { | 72 if (defined(invoker.type)) { |
71 type = invoker.type | 73 type = invoker.type |
72 } | 74 } |
73 | 75 |
74 name = invoker.name | 76 name = invoker.name |
75 inputs = [ | 77 inputs = [ |
76 invoker.source, | 78 invoker.source, |
77 ] | 79 ] |
| 80 if (defined(invoker.overlays)) { |
| 81 inputs += invoker.overlays |
| 82 } |
78 | 83 |
79 if (type == "mojo") { | 84 if (type == "mojo") { |
80 output = "$root_out_dir/$packages_directory/$name/manifest.json" | 85 if (defined(invoker.output_name)) { |
| 86 output = "$root_out_dir/$packages_directory/${invoker.output_name}/manif
est.json" |
| 87 } else { |
| 88 output = "$root_out_dir/$packages_directory/$name/manifest.json" |
| 89 } |
81 } else { | 90 } else { |
82 output = "$root_out_dir/${name}_manifest.json" | 91 output = "$root_out_dir/${name}_manifest.json" |
83 } | 92 } |
84 outputs = [ | 93 outputs = [ |
85 output, | 94 output, |
86 ] | 95 ] |
87 | 96 |
88 rebase_parent = rebase_path(invoker.source, root_build_dir) | 97 rebase_parent = rebase_path(invoker.source, root_build_dir) |
89 rebase_output = rebase_path(output, root_build_dir) | 98 rebase_output = rebase_path(output, root_build_dir) |
90 | 99 |
91 args = [ | 100 args = [ |
92 "--name=$name", | 101 "--name=$name", |
93 "--parent=$rebase_parent", | 102 "--parent=$rebase_parent", |
94 "--output=$rebase_output", | 103 "--output=$rebase_output", |
95 ] | 104 ] |
96 | 105 |
97 if (defined(invoker.base_manifest)) { | 106 if (defined(invoker.overlays)) { |
98 rebase_base = rebase_path(invoker.base_manifest, root_build_dir) | 107 args += [ "--overlays" ] |
99 args += [ "--base-manifest=$rebase_base" ] | 108 foreach(overlay_path, invoker.overlays) { |
| 109 args += [ rebase_path(overlay_path, root_build_dir) ] |
| 110 } |
100 } | 111 } |
101 | 112 |
102 if (defined(invoker.packaged_services)) { | 113 if (defined(invoker.packaged_services)) { |
103 foreach(name, invoker.packaged_services) { | 114 foreach(name, invoker.packaged_services) { |
104 input = "$root_out_dir/$packages_directory/$name/manifest.json" | 115 input = "$root_out_dir/$packages_directory/$name/manifest.json" |
105 inputs += [ input ] | 116 inputs += [ input ] |
106 args += [ rebase_path(input, root_build_dir) ] | 117 args += [ rebase_path(input, root_build_dir) ] |
107 } | 118 } |
108 } | 119 } |
109 deps = [] | 120 deps = [] |
110 data_deps = [] | 121 data_deps = [] |
111 if (defined(invoker.deps)) { | 122 if (defined(invoker.deps)) { |
112 deps += invoker.deps | 123 deps += invoker.deps |
113 data_deps += invoker.deps | 124 data_deps += invoker.deps |
114 } | 125 } |
115 if (defined(invoker.base_deps)) { | |
116 deps += invoker.base_deps | |
117 data_deps += invoker.base_deps | |
118 } | |
119 } | 126 } |
120 | 127 |
121 all_deps = [] | 128 all_deps = [] |
122 if (defined(invoker.deps)) { | 129 if (defined(invoker.deps)) { |
123 all_deps += invoker.deps | 130 all_deps += invoker.deps |
124 } | 131 } |
125 | 132 |
126 group("${target_name}__is_service_manifest") { | 133 group("${target_name}__is_service_manifest") { |
127 } | 134 } |
128 | 135 |
129 # Explicitly ensure that all dependencies are service_manifest | 136 # Explicitly ensure that all dependencies are service_manifest |
130 # targets themselves. | 137 # targets themselves. |
131 group("${target_name}__check_deps_are_all_service_manifest") { | 138 group("${target_name}__check_deps_are_all_service_manifest") { |
132 deps = [] | 139 deps = [] |
133 foreach(d, all_deps) { | 140 foreach(d, all_deps) { |
134 name = get_label_info(d, "label_no_toolchain") | 141 name = get_label_info(d, "label_no_toolchain") |
135 toolchain = get_label_info(d, "toolchain") | 142 toolchain = get_label_info(d, "toolchain") |
136 deps += [ "${name}__is_service_manifest(${toolchain})" ] | 143 deps += [ "${name}__is_service_manifest(${toolchain})" ] |
137 } | 144 } |
138 } | 145 } |
139 } | 146 } |
OLD | NEW |