| # Copyright 2018 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/dart/fidlmerge_dart.gni") |
| import("//build/dart/toolchain.gni") |
| |
| # Declares a library that contains Dart JSON serialization/deserialization |
| # support for the given FIDL library |
| # |
| # Parameters |
| # |
| # fidl_target (required) |
| # Specifies the fidl target from which to read fidl json. For example, |
| # "//sdk/fidl/fuchsia.setui" for fuchsia.setui. |
| # |
| # template_path (optional) |
| # Specifies the template to use to generate the formatting code. Default |
| # //topaz/bin/dart_fidl_json/json.fidlmerge. |
| # |
| # amendments_path (optional) |
| # Specifies a JSON file that contains amendments to be made to the fidl |
| # model before the template is applied. For example, |
| # "//garnet/public/build/fostr/fidl/fuchsia.media/amendments.fidlmerge". |
| # See the fidlmerge README for details. |
| # |
| # deps, public_deps, test_only, visibility (optional) |
| # These parameters are forwarded to the source_set. This template lists |
| # //garnet/public/lib/fostr and the value of fidl_target as public_deps. |
| # |
| |
| template("json_fidl") { |
| assert(defined(invoker.fidl_target), |
| "json_fidl requires parameter fidl_target.") |
| |
| fidl_target = invoker.fidl_target |
| |
| template_path = "//topaz/bin/dart_fidl_json/json.fidlmerge" |
| if (defined(invoker.template_path)) { |
| template_path = invoker.template_path |
| } |
| |
| fidlmerge_dart(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| "visibility", |
| "amendments_path", |
| ]) |
| |
| fidl_target = "$fidl_target" |
| |
| template_path = "$template_path" |
| |
| generated_source_base = "json" |
| |
| if (defined(invoker.additional_include)) { |
| options = "include=${invoker.additional_include}" |
| } |
| } |
| } |