chromium/third_party/grpc/grpc_library.gni

# Copyright 2019 Google Inc. All Rights Reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Compile a grpc service.
#
# Example:
#  grpc_library("mylib") {
#    sources = [
#      "foo.proto",
#    ]
#  }

import("//build/config/sanitizers/sanitizers.gni")
import("//third_party/protobuf/proto_library.gni")

template("grpc_library") {
  assert(defined(invoker.sources), "Need sources for proto_library")
  proto_library(target_name) {
    forward_variables_from(invoker,
                           [
                             "cc_include",
                             "extra_configs",
                             "generate_python",
                             "import_dirs",
                             "link_deps",
                             "proto_in_dir",
                             "proto_out_dir",
                             "sources",
                             "testonly",
                             "visibility",
                             "deps",
                             "proto_deps",
                           ])

    if (defined(invoker.use_protobuf_full)) {
      use_protobuf_full = invoker.use_protobuf_full
    } else {
      cc_generator_options = "lite"
    }

    if (!defined(extra_configs)) {
      extra_configs = []
    }
    extra_configs += [ "//third_party/grpc:grpc_config" ]

    generate_cc = true

    generator_plugin_label = "//third_party/grpc:grpc_cpp_plugin"
    generator_plugin_suffix = ".grpc.pb"
  }
}