| # 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. |
| |
| # 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 (optional) |
| # A component manifest to validate. |
| # If not specified, then must specify component_manifests_rspfile. |
| # Must specify exactly one of component_manifest, component_manifests_rspfile. |
| # Type: path |
| # |
| # component_manifests_rspfile (optional) |
| # A file containing paths to component manifests to validate. |
| # Must specify exactly one of component_manifest, component_manifests_rspfile. |
| # Type: path |
| # |
| # package_manifest (required) |
| # A package manifest to validate against. |
| # Type: path |
| # |
| # deps |
| # testonly |
| # visibility |
| template("validate_component_manifest_references") { |
| assert( |
| defined(invoker.component_manifest) || |
| defined(invoker.component_manifests_rspfile), |
| "Must specify exactly one of component_manifest, component_manifests_rspfile") |
| assert( |
| !defined(invoker.component_manifest) || |
| !defined(invoker.component_manifests_rspfile), |
| "Must specify exactly one of component_manifest, component_manifests_rspfile") |
| assert(defined(invoker.package_manifest), "Must specify package_manifest") |
| |
| stamp_file = "$target_gen_dir/$target_name.action.stamp" |
| action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| "visibility", |
| ]) |
| script = "//tools/cmc/build/validate_component_manifest_references.py" |
| inputs = [ invoker.package_manifest ] |
| outputs = [ stamp_file ] |
| args = [ |
| "--package_manifest", |
| rebase_path(invoker.package_manifest, root_build_dir), |
| "--stamp", |
| rebase_path(stamp_file, root_build_dir), |
| ] |
| |
| if (defined(invoker.component_manifest)) { |
| inputs += [ invoker.component_manifest ] |
| args += [ |
| "--component_manifests", |
| rebase_path(invoker.component_manifest, root_build_dir), |
| ] |
| } |
| if (defined(invoker.component_manifests_rspfile)) { |
| inputs += [ invoker.component_manifests_rspfile ] |
| args += [ |
| "--component_manifests", |
| "@" + rebase_path(invoker.component_manifests_rspfile, root_build_dir), |
| ] |
| } |
| } |
| } |