| # Copyright 2019 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. |
| |
| # Generates a manifest for a given target recently migrated from the ZN build. |
| # |
| # The output of this action is a manifest file that replaces the one supplied |
| # by the ZN build for the given target. This makes it so that the target can be |
| # moved from one build to the other without having to worry about the impact on |
| # system assembly. |
| # |
| # Parameters |
| # |
| # deps (optional) |
| # [list of labels] The targets to generate a manifest for. |
| # |
| # testonly (optional) |
| # Same as for any GN target. |
| template("migrated_manifest") { |
| if (is_fuchsia) { |
| main_target = target_name |
| generate_target = "${target_name}_generate" |
| intermediate_file = "$target_out_dir/$target_name.intermediate.manifest" |
| |
| # Use the same naming scheme as for other unification manifest templates, |
| # this makes them interoperable. |
| manifest_file = "$target_out_dir/$target_name.unification.manifest" |
| |
| # Gather metadata about runtime objects. |
| generated_file(generate_target) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| ]) |
| |
| data_keys = [ |
| "migrated_manifest_files", |
| "migrated_manifest_lines", |
| ] |
| walk_keys = [ "migrated_manifest_barrier" ] |
| |
| outputs = [ intermediate_file ] |
| } |
| |
| # Resolve file references in the gathered metadata. |
| action(main_target) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| "visibility", |
| ]) |
| |
| script = "//build/unification/images/unroll_manifest.py" |
| |
| inputs = [ intermediate_file ] |
| outputs = [ manifest_file ] |
| |
| args = [ |
| "--input", |
| rebase_path(intermediate_file, root_build_dir), |
| "--output", |
| rebase_path(manifest_file, root_build_dir), |
| ] |
| |
| if (!defined(deps)) { |
| deps = [] |
| } |
| deps += [ ":$generate_target" ] |
| |
| metadata = { |
| migrated_manifest_barrier = [] |
| if (defined(invoker.metadata)) { |
| forward_variables_from(invoker.metadata, "*") |
| } |
| } |
| } |
| } else { |
| not_needed(invoker, "*") |
| |
| # This template does nothing on non-Fuchsia platforms. |
| group(target_name) { |
| } |
| } |
| } |