blob: 0351a167dbe085d81cadd5004bfdfe3f38630e0e [file] [log] [blame]
# Copyright 2020 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/compiled_action.gni")
import("//build/dist/fini_manifest.gni")
template("cmc") {
compiled_action(target_name) {
forward_variables_from(invoker,
[
"args",
"depfile",
"deps",
"inputs",
"metadata",
"outputs",
"sources",
"public_deps",
"testonly",
"visibility",
])
tool = "//tools/cmc"
tool_output_name = "cmc"
}
}
# Merges together cmx/cml files
#
# Parameters
#
# sources (optional)
# [list of files] A list of files that are to be merged.
#
# from_file (optional)
# [path] A file containing line-delimited paths of files to be merged.
#
# output_name (optional)
# [path] Name for the output.
# If not specified, the target name is used.
#
# deps (optional)
# testonly (optional)
# visibility (optional)
# Standard GN meaning.
template("cmc_merge") {
cmc(target_name) {
forward_variables_from(invoker,
[
"deps",
"metadata",
"output_name",
"sources",
"from_file",
"testonly",
"visibility",
])
if (!defined(output_name)) {
output_name = target_name
}
if (!defined(sources) && !defined(from_file)) {
assert(
false,
"At least one of \"sources\" or \"from_file\" must be specified when calling cmc_merge($target_name)")
}
merged_output = "${target_out_dir}/${output_name}"
inputs = []
outputs = [ merged_output ]
depfile = "${target_out_dir}/${target_name}.d"
args = [
"merge",
"--output",
rebase_path(merged_output, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
]
if (defined(sources)) {
inputs += sources
args += rebase_path(sources, root_build_dir)
}
if (defined(from_file)) {
inputs += [ from_file ]
args += [
"--fromfile",
rebase_path(from_file, root_build_dir),
]
}
}
}
# Validates a component manifest against a package manifest.
# Checks that the component manifest doesn't reference files that are not
# present in the package.
#
# Parameters
#
# component_manifest (required)
# A component manifest to validate.
# Type: path
#
# package_manifest (optional)
# A package manifest to validate against.
# If not provided, a package manifest will be generated out of deps.
# Type: path
#
# label (required)
# A GN label to use in error messages, to make troubleshooting easier.
# Type: label
#
# data_deps
# deps
# public_deps
# testonly
# visibility
template("cmc_validate_references") {
assert(
defined(invoker.component_manifest),
"Must specify exactly one of component_manifest, component_manifests_rspfile")
if (defined(invoker.package_manifest)) {
package_manifest = invoker.package_manifest
} else {
fini_target = "${target_name}_fini"
package_manifest = "$target_gen_dir/${fini_target}_file"
fini_manifest(fini_target) {
forward_variables_from(invoker,
[
"data_deps",
"deps",
"public_deps",
"testonly",
])
visibility = [ ":*" ]
outputs = [ package_manifest ]
}
}
stamp_file = "$target_gen_dir/$target_name.action.stamp"
cmc(target_name) {
forward_variables_from(invoker,
[
"data_deps",
"deps",
"metadata",
"public_deps",
"testonly",
"visibility",
])
inputs = [
package_manifest,
invoker.component_manifest,
]
outputs = [ stamp_file ]
args = [
"--stamp",
rebase_path(stamp_file, root_build_dir),
"validate-references",
"--component-manifest",
rebase_path(invoker.component_manifest, root_build_dir),
"--package-manifest",
rebase_path(package_manifest, root_build_dir),
"--gn-label",
invoker.label,
]
if (!defined(deps)) {
deps = []
}
if (defined(fini_target)) {
deps += [ ":$fini_target" ]
}
}
}
# Common cmc arguments
include_paths = [
"--includeroot",
rebase_path("//", root_build_dir),
"--includepath",
rebase_path("//sdk/lib/", root_build_dir),
]