| # Copyright 2022 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. |
| |
| # Compare two command logs that resulted from image assembly to ensure that |
| # every command in the reference also appears in the comparison. |
| # |
| # Arguments |
| # reference (required) |
| # [path] The path to the reference command log. |
| # |
| # comparison (required) |
| # [path] The path to the comparison command log. |
| # |
| # list_key (optional) |
| # [string] The key to use in the json file to find the list. |
| # |
| # prefixes (optional) |
| # [list] Any prefixes to strip from strings in the json before comparing. |
| # |
| template("compare_json_list") { |
| assert(defined(invoker.reference), "Need to define a reference") |
| assert(defined(invoker.comparison), "Need to define a comparison") |
| |
| action(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| "visibility", |
| ]) |
| script = "//build/assembly/scripts/compare_json_list.py" |
| stamp = "${target_out_dir}/${target_name}_compare_json_list.stamp" |
| outputs = [ stamp ] |
| inputs = [ |
| invoker.reference, |
| invoker.comparison, |
| ] |
| |
| args = [ |
| "--reference", |
| rebase_path(invoker.reference, root_build_dir), |
| "--comparison", |
| rebase_path(invoker.comparison, root_build_dir), |
| "--stamp", |
| rebase_path(stamp, root_build_dir), |
| ] |
| |
| if (defined(invoker.list_key)) { |
| args += [ |
| "--list-key", |
| invoker.list_key, |
| ] |
| } |
| |
| if (defined(invoker.prefixes)) { |
| args += [ "--strip-prefix" ] |
| foreach(prefix, invoker.prefixes) { |
| args += [ prefix ] |
| } |
| } |
| } |
| } |