| 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("//mojo/public/mojo_constants.gni") | |
| 6 | |
| 7 # Used to produce a Mojo Application Manifest for an application. | |
| 8 # | |
| 9 # Parameters: | |
| 10 # | |
| 11 # source | |
| 12 # The manifest file template for this application, must be valid JSON with | |
| 13 # a valid 'url' key matching application_name. | |
| 14 # | |
| 15 # base_manifest (optional) | |
| 16 # A manifest file template to use as a base for |source|. Any properties | |
| 17 # defined in |source| will overwrite or be merged with properties defined | |
| 18 # in |base_manifest|. | |
| 19 # | |
| 20 # application_name | |
| 21 # The host portion of the mojo: URL of the application. The script | |
| 22 # validates that the value of this parameter matches the host name portion | |
| 23 # of the 'url' property set in the manifest and throws a ValueError if | |
| 24 # they do not. | |
| 25 # | |
| 26 # base_deps (optional) | |
| 27 # Dependencies required to generate |base_manifest| if applicable. | |
| 28 # | |
| 29 # deps (optional) | |
| 30 # An array of dependent instances of this template. This template enforces | |
| 31 # that dependencies can only be instances of this template. | |
| 32 # | |
| 33 # packaged_applications (optional) | |
| 34 # An array of application_names of the dependent applications. | |
| 35 # | |
| 36 # type (default is mojo) | |
| 37 # Possible values are 'mojo' and 'exe'. Default is 'mojo'. | |
| 38 # | |
| 39 # Outputs: | |
| 40 # | |
| 41 # An instantiation of this template produces in | |
| 42 # $outdir/<application_name>/manifest.json | |
| 43 # a meta manifest from the source template and the output manifest of all | |
| 44 # dependent children. | |
| 45 # | |
| 46 template("mojo_application_manifest") { | |
| 47 assert(defined(invoker.source), | |
| 48 "\"source\" must be defined for the $target_name template") | |
| 49 assert(defined(invoker.application_name), | |
| 50 "\"application_name\" must be defined for the $target_name template") | |
| 51 if (defined(invoker.deps)) { | |
| 52 assert(defined(invoker.packaged_applications), | |
| 53 "\"packaged_applications\" listing the directory containing the " + | |
| 54 "manifest.json of dependent applications must be provided.") | |
| 55 } | |
| 56 if (defined(invoker.packaged_applications)) { | |
| 57 assert(defined(invoker.deps), | |
| 58 "\"deps\" building the dependent packaged applications must be " + | |
| 59 "provided.") | |
| 60 } | |
| 61 if (defined(invoker.type)) { | |
| 62 assert(invoker.type == "mojo" || invoker.type == "exe", | |
| 63 "\"type\" must be one of \"mojo\" or \"exe\".") | |
| 64 } | |
| 65 | |
| 66 action(target_name) { | |
| 67 script = "//mojo/public/tools/manifest/manifest_collator.py" | |
| 68 | |
| 69 type = "mojo" | |
| 70 if (defined(invoker.type)) { | |
| 71 type = invoker.type | |
| 72 } | |
| 73 | |
| 74 application_name = invoker.application_name | |
| 75 inputs = [ | |
| 76 invoker.source, | |
| 77 ] | |
| 78 | |
| 79 if (type == "mojo") { | |
| 80 output = "$root_out_dir/$mojo_application_subdir/$application_name/manifes
t.json" | |
| 81 } else { | |
| 82 output = "$root_out_dir/${application_name}_manifest.json" | |
| 83 } | |
| 84 outputs = [ | |
| 85 output, | |
| 86 ] | |
| 87 | |
| 88 rebase_parent = rebase_path(invoker.source, root_build_dir) | |
| 89 rebase_output = rebase_path(output, root_build_dir) | |
| 90 | |
| 91 args = [ | |
| 92 "--application-name=$application_name", | |
| 93 "--parent=$rebase_parent", | |
| 94 "--output=$rebase_output", | |
| 95 ] | |
| 96 | |
| 97 if (defined(invoker.base_manifest)) { | |
| 98 rebase_base = rebase_path(invoker.base_manifest, root_build_dir) | |
| 99 args += [ "--base-manifest=$rebase_base" ] | |
| 100 } | |
| 101 | |
| 102 if (defined(invoker.packaged_applications)) { | |
| 103 foreach(application_name, invoker.packaged_applications) { | |
| 104 input = "$root_out_dir/$mojo_application_subdir/$application_name/manife
st.json" | |
| 105 inputs += [ input ] | |
| 106 args += [ rebase_path(input, root_build_dir) ] | |
| 107 } | |
| 108 } | |
| 109 deps = [] | |
| 110 data_deps = [] | |
| 111 if (defined(invoker.deps)) { | |
| 112 deps += invoker.deps | |
| 113 data_deps += invoker.deps | |
| 114 } | |
| 115 if (defined(invoker.base_deps)) { | |
| 116 deps += invoker.base_deps | |
| 117 data_deps += invoker.base_deps | |
| 118 } | |
| 119 } | |
| 120 | |
| 121 all_deps = [] | |
| 122 if (defined(invoker.deps)) { | |
| 123 all_deps += invoker.deps | |
| 124 } | |
| 125 | |
| 126 group("${target_name}__is_mojo_application_manifest") { | |
| 127 } | |
| 128 | |
| 129 # Explicitly ensure that all dependencies are mojo_application_manifest | |
| 130 # targets themselves. | |
| 131 group("${target_name}__check_deps_are_all_mojo_application_manifest") { | |
| 132 deps = [] | |
| 133 foreach(d, all_deps) { | |
| 134 name = get_label_info(d, "label_no_toolchain") | |
| 135 toolchain = get_label_info(d, "toolchain") | |
| 136 deps += [ "${name}__is_mojo_application_manifest(${toolchain})" ] | |
| 137 } | |
| 138 } | |
| 139 } | |
| OLD | NEW |