blob: dee0faccf9466663fe68700a545dd0404e67a793 [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",
"outputs",
"sources",
"public_deps",
"testonly",
"visibility",
])
tool = "//tools/cmc"
tool_output_name = "cmc"
}
}
# Merges together cmx/cml files
#
# Parameters
#
# sources (required)
# [list of files] A list of files that are 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",
"output_name",
"sources",
"testonly",
"visibility",
])
if (!defined(output_name)) {
output_name = target_name
}
merged_output = "${target_out_dir}/${output_name}"
inputs = invoker.sources
outputs = [ merged_output ]
args = [
"merge",
"--output",
rebase_path(merged_output, root_build_dir),
]
foreach(source, sources) {
args += [ rebase_path(source, 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",
"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",
# TODO(shayba): agree on a base include path for Fuchsia tree
rebase_path("//", root_build_dir),
]