| # 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. |
| |
| import("//build/compiled_action.gni") |
| |
| # Generates a machine-readable, JSON-formatted, FIDL API summary. |
| # |
| # For details on the FIDL API summary format, see RFC-0076 at: |
| # https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0076_fidl_api_summaries |
| # |
| # Args: |
| # |
| # inputs: list(label) |
| # A singleton list naming the FIDL IR file to read. |
| # |
| # outputs: list(label) |
| # A singleton naming the output API summary file to generate. |
| # |
| # testonly: bool(optional) |
| # deps: list(label) |
| # visiblility: list(label) |
| template("fidl_summary_json") { |
| compiled_action("${target_name}") { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "deps", |
| "metadata", |
| "inputs", |
| "outputs", |
| "visibility", |
| ]) |
| |
| assert(defined(inputs), "inputs is required") |
| assert(inputs != [] && inputs == [ inputs[0] ], |
| "inputs must have exactly one element") |
| _json_representation = inputs[0] |
| |
| assert(defined(outputs), "outputs is required") |
| assert(defined(outputs) && outputs != [] && outputs == [ outputs[0] ], |
| "outputs must have exactly one element") |
| _summary_file_json = outputs[0] |
| |
| tool = "//tools/fidl/fidl_api_summarize" |
| args = [ |
| "--fidl-ir-file", |
| rebase_path(_json_representation, root_build_dir), |
| "--output-file", |
| rebase_path(_summary_file_json, root_build_dir), |
| "--suppress-empty-library", |
| ] |
| } |
| } |