# 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/fidl/toolchain.gni")
import("//build/go/go_library.gni")
import("//build/go/toolchain.gni")

# Generates some Go bindings for a FIDL library.
#
# The parameters for this template are defined in //build/fidl/fidl.gni. The
# relevant parameters in this template are:
#   - name.

template("fidl_go") {
  assert(current_toolchain == go_toolchain,
         "This template can only be used in $go_toolchain.")

  not_needed(invoker, [ "sources" ])

  main_target_name = target_name
  generation_target_name = "${target_name}_go_generate"

  library_name = target_name
  if (defined(invoker.name)) {
    library_name = invoker.name
  }

  fidl_target_gen_dir =
      get_label_info(":$target_name($fidl_toolchain)", "target_gen_dir")
  library_dir = "$fidl_target_gen_dir/$library_name.fidl"
  impl_filename = "$library_dir/impl.go"
  pkg_name_filename = "$library_dir/pkg_name"
  json_representation = "$fidl_target_gen_dir/$target_name.fidl.json"

  compiled_action(generation_target_name) {
    visibility = [ ":*" ]

    tool = "//garnet/go/src/fidl:fidlgen_go"

    inputs = [ json_representation ]

    outputs = [
      impl_filename,
      pkg_name_filename,
    ]

    args = [
      "--json",
      rebase_path(json_representation, root_build_dir),
      "--output-impl",
      rebase_path(impl_filename, root_build_dir),
      "--output-pkg-name",
      rebase_path(pkg_name_filename, root_build_dir),
    ]

    deps = [ ":$main_target_name($fidl_toolchain)" ]

    forward_variables_from(invoker, [ "testonly" ])
  }

  go_library(main_target_name) {
    name_file = pkg_name_filename

    source_dir = library_dir

    sources = [ "impl.go" ]

    non_go_deps = [ ":$generation_target_name" ]

    deps = []
    if (defined(invoker.deps)) {
      deps += invoker.deps
    }
    if (defined(invoker.public_deps)) {
      deps += invoker.public_deps
    }

    forward_variables_from(invoker,
                           [
                             "testonly",
                             "visibility",
                           ])
  }
}
