blob: 5b6cefe1d74d4758b7736ce6345fd0a2935084b5 [file] [log] [blame]
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Used to produce a Mojo Application Manifest for an application.
#
# Parameters:
#
# source
# The manifest file template for this application, must be valid JSON with
# a valid 'url' key matching application_name.
#
# application_name
# The host portion of the mojo: URL of the application. The script
# validates that the value of this parameter matches the host name portion
# of the 'url' property set in the manifest and throws a ValueError if
# they do not.
#
# deps (optional)
# An array of dependent instances of this template. This template enforces
# that dependencies can only be instances of this template.
#
# packaged_applications (optional)
# An array of application_names of the dependent applications.
#
# type (default is mojo)
# Possible values are 'mojo' and 'exe'. Default is 'mojo'.
#
# Outputs:
#
# An instantiation of this template produces in
# $outdir/<application_name>/manifest.json
# a meta manifest from the source template and the output manifest of all
# dependent children.
#
template("mojo_application_manifest") {
assert(defined(invoker.source),
"\"source\" must be defined for the $target_name template")
assert(defined(invoker.application_name),
"\"application_name\" must be defined for the $target_name template")
if (defined(invoker.deps)) {
assert(defined(invoker.packaged_applications),
"\"packaged_applications\" listing the directory containing the " +
"manifest.json of dependent applications must be provided.")
}
if (defined(invoker.packaged_applications)) {
assert(defined(invoker.deps),
"\"deps\" building the dependent packaged applications must be " +
"provided.")
}
if (defined(invoker.type)) {
assert(invoker.type == "mojo" || invoker.type == "exe",
"\"type\" must be one of \"mojo\" or \"exe\".")
}
action(target_name) {
script = "//mojo/public/tools/manifest/manifest_collator.py"
type = "mojo"
if (defined(invoker.type)) {
type = invoker.type
}
application_name = invoker.application_name
inputs = [
invoker.source,
]
if (type == "mojo") {
output = "$root_out_dir/$application_name/manifest.json"
} else {
output = "$root_out_dir/${application_name}_manifest.json"
}
outputs = [
output,
]
rebase_parent = rebase_path(invoker.source, root_build_dir)
rebase_output = rebase_path(output, root_build_dir)
args = [
"--application-name=$application_name",
"--parent=$rebase_parent",
"--output=$rebase_output",
]
if (defined(invoker.packaged_applications)) {
foreach(application_name, invoker.packaged_applications) {
input = "$root_out_dir/$application_name/manifest.json"
inputs += [ input ]
args += [ rebase_path(input, root_build_dir) ]
}
}
deps = []
if (defined(invoker.deps)) {
deps += invoker.deps
}
}
all_deps = []
if (defined(invoker.deps)) {
all_deps += invoker.deps
}
group("${target_name}__is_mojo_application_manifest") {
}
# Explicitly ensure that all dependencies are mojo_application_manifest
# targets themselves.
group("${target_name}__check_deps_are_all_mojo_application_manifest") {
deps = []
foreach(d, all_deps) {
name = get_label_info(d, "label_no_toolchain")
toolchain = get_label_info(d, "toolchain")
deps += [ "${name}__is_mojo_application_manifest(${toolchain})" ]
}
}
}