# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("perfetto.gni")
import("perfetto_component.gni")

# This gni file defines rules for proto generation. There are various types of
# proto targets that can be defined in our codebase:
# "lite" targets: these use the standard libprotobuf library. They are used
#     mainly for tests and readback.
# "zero" targets: these use the protozero library and its protoc plugin. They
#     are used pretty much everywhere.
# "descriptor" targets: they are used to generate a proto-encoded reflection
#     descriptor that describes the schema of the proto using protobuf itself.
# All these targets can be generated using the perfetto_proto_library rule. It
# wraps the instantiation of several proto targets using a convenience template.
#
# For instance:
# perfetto_proto_library("xxx_@TYPE@") {
#   proto_generators = [ "lite", "zero" ]  # lite+zero+cpp is the default value.
#   sources = [ "one.proto", "two.proto" ]
#   deps = [ "dep:@TYPE@" ]
# }
#
# Is the equivalent of:
# proto_library("xxx_lite")     { sources = [...], deps = [ "dep:lite"] }
# protozero_library("xxx_zero") { sources = [...], deps = [ "dep:zero"] }

# Load the protobuf's proto_library() definition.
if (!defined(perfetto_protobuf_target_prefix)) {
  if (perfetto_root_path == "//") {
    perfetto_protobuf_target_prefix = "//buildtools"
  } else {
    perfetto_protobuf_target_prefix = "//third_party/protobuf"
  }
}
if (!defined(perfetto_protobuf_gni)) {
  if (perfetto_root_path == "//") {
    perfetto_protobuf_gni = "//gn/standalone/proto_library.gni"
  } else {
    perfetto_protobuf_gni = "//third_party/protobuf/proto_library.gni"
  }
}
if (!defined(perfetto_protobuf_src_dir)) {
  if (perfetto_root_path == "//") {
    perfetto_protobuf_src_dir = "//buildtools/protobuf/src"
  } else {
    perfetto_protobuf_src_dir = "//third_party/protobuf/src"
  }
}
import(perfetto_protobuf_gni)

# Equivalent to proto_library (generation of .h/.cc from .proto files) but
# enables also generation using the protozero plugin.
# The generated files will have the .pbzero.{cc,h} suffix, as opposed to the
# .pb.{cc,h} of the official proto library.
# DO NOT use this target directly, use perfetto_proto_library() below.
template("protozero_library") {
  proto_library(target_name) {
    perfetto_root_path = invoker.perfetto_root_path

    generate_cc = false
    generate_python = false
    generator_plugin_label =
        perfetto_root_path + "src/protozero/protoc_plugin:protozero_plugin"
    generator_plugin_suffix = ".pbzero"
    if (build_with_chromium) {
      component_build_force_source_set = true
    }

    # Convert deps to link_deps: the proto_library rule requires that C++ files
    # are passed in as link_deps wheras in Perfetto, we always works with deps.
    link_deps = []
    if (defined(invoker.deps)) {
      link_deps += invoker.deps
    }

    # omit_protozero_dep is intended to be used when protozero_library
    # is used in Chrome (for generation of code for proto extensions)
    # to avoid ODR violations in case of component builds. The embedder
    # (Chrome) is then responsible for adding the appropriate transitive
    # dependency on Protozero.
    #
    # TODO(b/173041866): use fine-grained components instead when available
    if (!(defined(invoker.omit_protozero_dep) && invoker.omit_protozero_dep)) {
      link_deps += [ perfetto_root_path + "src/protozero" ]
    }

    if (defined(invoker.link_deps)) {
      link_deps += invoker.link_deps
    }

    forward_variables_from(invoker,
                           [
                             "defines",
                             "generator_plugin_options",
                             "include_dirs",
                             "proto_data_sources",
                             "proto_deps",
                             "proto_in_dir",
                             "proto_out_dir",
                             "sources",
                             "testonly",
                             "visibility",
                             "generate_descriptor",
                             "propagate_imports_configs",
                             "import_dirs",
                           ])
  }
}

# This template generates .gen.cc/h files from .proto files. The generated
# sources are actual C++ classes that can be moved and copied around, very
# similar to the libprotobuf generated ones API-wise, but use protozero under
# the hoods, without any zero-copy benefit though.
# They are mainly used for the perfetto IPC layer and tests.
template("protozero_cpp_library") {
  proto_library(target_name) {
    perfetto_root_path = invoker.perfetto_root_path

    generate_cc = false
    generate_python = false
    generator_plugin_label =
        perfetto_root_path + "src/protozero/protoc_plugin:cppgen_plugin"
    generator_plugin_suffix = ".gen"
    if (build_with_chromium) {
      component_build_force_source_set = true
    }

    link_deps = [
      "$perfetto_root_path/gn:default_deps",
      "$perfetto_root_path/include/perfetto/base",
      "$perfetto_root_path/src/protozero",
    ]

    # Convert deps to link_deps: the proto_library rule requires that C++ files
    # are passed in as link_deps wheras in Perfetto, we always works with deps.
    if (defined(invoker.deps)) {
      link_deps += invoker.deps
    }
    forward_variables_from(invoker,
                           [
                             "defines",
                             "generator_plugin_options",
                             "include_dirs",
                             "proto_deps",
                             "proto_in_dir",
                             "proto_out_dir",
                             "sources",
                             "testonly",
                             "visibility",
                             "generate_descriptor",
                             "propagate_imports_configs",
                             "import_dirs",
                           ])
  }
}

# Generates .ipc.{h,cc} stubs for IPC services defined in .proto files.
template("ipc_library") {
  proto_library(target_name) {
    perfetto_root_path = invoker.perfetto_root_path
    generate_cc = false
    generate_python = false
    generator_plugin_label =
        "$perfetto_root_path/src/ipc/protoc_plugin:ipc_plugin"
    generator_plugin_suffix = ".ipc"
    link_deps = [ "$perfetto_root_path/gn:default_deps" ]
    if (perfetto_component_type == "static_library") {
      link_deps += [ "$perfetto_root_path/src/ipc:perfetto_ipc" ]
    } else {
      link_deps += [ "$perfetto_root_path/src/ipc:common" ]
    }
    if (is_win) {
      # TODO(primiano): investigate this. In Windows standalone builds, some
      # executable targets end up in a state where no code pulls a dep on the
      # ipc:client (in turn that seems a subtle consequence of not having
      # traced_probes on Windows). This dep here is effectively needed because
      # the client-side code in the generated .ipc.cc effectively depends on the
      # client-side IPC library. Perhaps we just should do this unconditionally
      # on all platforms?
      if (perfetto_component_type == "static_library") {
        link_deps += [ "$perfetto_root_path/src/ipc:perfetto_ipc" ]
      } else {
        link_deps += [ "$perfetto_root_path/src/ipc:client" ]
      }
    }

    # Convert deps to link_deps: the proto_library rule requires that C++ files
    # are passed in as link_deps wheras in Perfetto, we always works with deps.
    if (defined(invoker.deps)) {
      link_deps += invoker.deps
    }
    forward_variables_from(invoker,
                           [
                             "defines",
                             "extra_configs",
                             "include_dirs",
                             "proto_deps",
                             "proto_in_dir",
                             "proto_out_dir",
                             "generator_plugin_options",
                             "sources",
                             "testonly",
                             "visibility",
                             "propagate_imports_configs",
                             "import_dirs",
                           ])
  }
}

# Generates .grpc.{h,cc} stubs for services defined in .proto files.
# We require explicit opt-in as gRPC is very heavyweight so we do not
# want accidental dependencies on this.
if (enable_perfetto_grpc) {
  template("perfetto_grpc_library") {
    proto_library(target_name) {
      proto_in_dir = perfetto_root_path
      proto_out_dir = perfetto_root_path
      propagate_imports_configs = false

      perfetto_root_path = perfetto_root_path
      generate_cc = false
      generate_python = false
      generator_plugin_label =
          "$perfetto_root_path/buildtools/grpc:grpc_cpp_plugin"
      generator_plugin_suffix = ".grpc.pb"
      link_deps = [ "$perfetto_root_path/buildtools/grpc:grpc++" ]
      public_configs = [ "$perfetto_root_path/buildtools:grpc_gen_config" ]

      # Convert deps to link_deps: the proto_library rule requires that C++
      # files are passed in as link_deps wheras in Perfetto, we always works
      # with deps.
      if (defined(invoker.deps)) {
        link_deps += invoker.deps
      }
      forward_variables_from(invoker,
                             [
                               "defines",
                               "extra_configs",
                               "include_dirs",
                               "sources",
                               "testonly",
                               "visibility",
                             ])
    }
  }
}

# The template used everywhere in the codebase.
template("perfetto_proto_library") {
  if (defined(invoker.proto_generators)) {
    proto_generators = invoker.proto_generators
  } else {
    proto_generators = [
      "zero",
      "lite",
      "cpp",
    ]
  }

  # proto imports and C++ #includes are relative to this path.
  if (defined(invoker.proto_path)) {
    proto_path = invoker.proto_path
  } else {
    proto_path = perfetto_root_path
  }

  if (defined(invoker.import_dirs)) {
    import_dirs_ = invoker.import_dirs
  } else {
    import_dirs_ = []
  }

  expansion_token = "@TYPE@"

  # The source set target should always be generated as it is used by the
  # build generators and for generating descriptors.
  source_set_target_name =
      string_replace(target_name, expansion_token, "source_set")

  # This config is necessary for Chrome proto_library build rule to work
  # correctly.
  source_set_input_config_name = "${source_set_target_name}_input_config"
  config(source_set_input_config_name) {
    inputs = invoker.sources
  }

  group(source_set_target_name) {
    # To propagate indirect inputs dependencies to descendant tareget, we use
    # public_deps and public_configs in this target.
    public_deps = []
    exports_ = []
    if (defined(invoker.public_deps)) {
      foreach(dep, invoker.public_deps) {
        # Get the absolute target path
        mapped_dep = string_replace(dep, expansion_token, "source_set")
        public_deps += [ mapped_dep ]
        exports_ += [ get_label_info(mapped_dep, "dir") + ":" +
                      get_label_info(mapped_dep, "name") ]
      }
    }

    if (defined(invoker.deps)) {
      foreach(dep, invoker.deps) {
        mapped_dep = string_replace(dep, expansion_token, "source_set")
        public_deps += [ mapped_dep ]
      }
    }

    sources = []
    foreach(source, invoker.sources) {
      sources += [ get_path_info(source, "abspath") ]
    }

    public_configs = [ ":${source_set_input_config_name}" ]

    metadata = {
      proto_library_sources = sources
      proto_import_dirs = import_dirs_
      exports = exports_
    }
  }

  # Generate the descriptor if the option is set.
  if (defined(invoker.generate_descriptor)) {
    target_name_ = string_replace(target_name, expansion_token, "descriptor")
    proto_library(target_name_) {
      proto_in_dir = proto_path
      proto_out_dir = proto_path
      generate_python = false
      generate_cc = false
      generate_descriptor = rebase_path(invoker.generate_descriptor, proto_path)
      sources = [ invoker.descriptor_root_source ]
      import_dirs = import_dirs_
      deps = [ ":${source_set_target_name}" ]
      forward_variables_from(invoker,
                             [
                               "visibility",
                               "testonly",
                               "exclude_imports",
                             ])
    }
  }

  foreach(gen_type, proto_generators) {
    target_name_ = string_replace(target_name, expansion_token, gen_type)

    # Translate deps from xxx:@TYPE@ to xxx:lite/zero.
    all_deps_ = []
    if (defined(invoker.deps)) {
      foreach(dep, invoker.deps) {
        all_deps_ += [ string_replace(dep, expansion_token, gen_type) ]
      }
    }

    # The distinction between deps and public_deps does not matter for GN
    # but Bazel cares about the difference so we distinguish between the two.
    if (defined(invoker.public_deps)) {
      foreach(dep, invoker.public_deps) {
        all_deps_ += [ string_replace(dep, expansion_token, gen_type) ]
      }
    }

    # gn:public_config propagates the gen dir as include directory. We
    # disable the proto_library's public_config to avoid duplicate include
    # directory command line flags (crbug.com/1043279, crbug.com/gn/142).
    propagate_imports_configs_ = false
    vars_to_forward = []
    vars_to_forward += [
      "sources",
      "visibility",
      "testonly",
    ]

    if (gen_type == "zero") {
      protozero_library(target_name_) {
        proto_in_dir = proto_path
        proto_out_dir = proto_path
        generator_plugin_options = "wrapper_namespace=pbzero"
        deps = all_deps_
        proto_deps = [ ":$source_set_target_name" ]
        propagate_imports_configs = propagate_imports_configs_
        import_dirs = import_dirs_
        forward_variables_from(invoker, vars_to_forward)
      }
    } else if (gen_type == "cpp") {
      protozero_cpp_library(target_name_) {
        proto_in_dir = proto_path
        proto_out_dir = proto_path
        generator_plugin_options = "wrapper_namespace=gen"
        deps = all_deps_
        proto_deps = [ ":$source_set_target_name" ]
        propagate_imports_configs = propagate_imports_configs_
        import_dirs = import_dirs_
        forward_variables_from(invoker, vars_to_forward)
      }
    } else if (gen_type == "ipc") {
      cpp_target_name_ = string_replace(target_name, expansion_token, "cpp")
      ipc_library(target_name_) {
        proto_in_dir = proto_path
        proto_out_dir = proto_path
        generator_plugin_options = "wrapper_namespace=gen"
        proto_deps = [ ":$source_set_target_name" ]
        deps = all_deps_ + [ ":$cpp_target_name_" ]
        propagate_imports_configs = propagate_imports_configs_
        import_dirs = import_dirs_
        forward_variables_from(invoker, vars_to_forward)
      }
    } else if (gen_type == "lite") {
      proto_library(target_name_) {
        proto_in_dir = proto_path
        proto_out_dir = proto_path
        generate_python = false
        link_deps = all_deps_
        cc_generator_options = "lite=true:"
        propagate_imports_configs = propagate_imports_configs_
        import_dirs = import_dirs_
        proto_deps = [ ":${source_set_target_name}" ]
        forward_variables_from(invoker, vars_to_forward)
      }
    } else {
      assert(false, "Invalid 'proto_generators' value.")
    }
  }
}
