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