| # 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/cpp/fidlmerge_cpp.gni") |
| |
| # Declares a fostr library that contains C++ ostream formatting for a FIDL |
| # library. |
| # |
| # Parameters |
| # |
| # fidl_target (required) |
| # Specifies the fidl target from which to read fidl json. For example, |
| # "//sdk/fidl/fuchsia.sys" for fuchsia.sys. |
| # |
| # template_path (optional) |
| # Specifies the template to use to generate the formatting code. Default |
| # //src/lib/fostr/build/fostr.fidlmerge. |
| # |
| # additional_include (optional) |
| # Specifies a file to be included in the generated formatting.h file. |
| # For example "lib/ui/views/cpp/formatting.h". |
| # |
| # amendments_path (optional) |
| # Specifies a JSON file that contains amendments to be made to the fidl |
| # model before the template is applied. For example, |
| # "//src/lib/fostr/build/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 |
| # //src/lib/fostr and the value of fidl_target as public_deps. |
| # |
| |
| template("fostr_fidl") { |
| assert(defined(invoker.fidl_target), |
| "fostr_fidl requires parameter fidl_target.") |
| |
| fidl_target = invoker.fidl_target |
| |
| template_path = "//src/lib/fostr/build/fostr.fidlmerge" |
| if (defined(invoker.template_path)) { |
| template_path = invoker.template_path |
| } |
| |
| fidlmerge_cpp(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "testonly", |
| "visibility", |
| "amendments_path", |
| ]) |
| if (!defined(deps)) { |
| deps = [] |
| } |
| |
| fidl_target = "$fidl_target" |
| |
| template_path = "$template_path" |
| |
| generated_source_base = "formatting" |
| |
| if (defined(invoker.additional_include)) { |
| options = "include=${invoker.additional_include}" |
| } |
| |
| public_deps = [ |
| "$fidl_target", |
| "//src/lib/fostr", |
| ] |
| |
| if (defined(invoker.public_deps)) { |
| public_deps += invoker.public_deps |
| } |
| } |
| } |