# 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
    }

    if (defined(invoker.deps)) {
      deps = invoker.deps
    } else {
      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)) {
      deps += [ perfetto_root_path + "src/protozero" ]
    }

    forward_variables_from(invoker,
                           [
                             "defines",
                             "generator_plugin_options",
                             "include_dirs",
                             "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
    }

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

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

    forward_variables_from(invoker,
                           [
                             "defines",
                             "generator_plugin_options",
                             "include_dirs",
                             "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"
    deps = [ "$perfetto_root_path/gn:default_deps" ]
    if (perfetto_component_type == "static_library") {
      deps += [ "$perfetto_root_path/src/ipc:perfetto_ipc" ]
    } else {
      deps += [ "$perfetto_root_path/src/ipc:common" ]
    }
    if (defined(invoker.deps)) {
      deps += invoker.deps
    }
    forward_variables_from(invoker,
                           [
                             "defines",
                             "extra_configs",
                             "include_dirs",
                             "proto_in_dir",
                             "proto_out_dir",
                             "generator_plugin_options",
                             "sources",
                             "testonly",
                             "visibility",
                             "propagate_imports_configs",
                             "import_dirs",
                           ])
  }
}

# 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",
      "source_set",
    ]
  }

  # 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_ = []
  }

  vars_to_forward = [
    "sources",
    "visibility",
    "testonly",
  ]
  expansion_token = "@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

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

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

    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 = deps_
        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 = deps_
        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"
        deps = 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
        deps = deps_
        cc_generator_options = "lite=true:"
        propagate_imports_configs = propagate_imports_configs_
        import_dirs = import_dirs_
        forward_variables_from(invoker, vars_to_forward)
      }
    } else if (gen_type == "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)
        deps = deps_
        import_dirs = import_dirs_
        forward_variables_from(invoker, vars_to_forward)
      }

      # Not needed for descriptor proto_library target.
      not_needed([ "propagate_imports_configs_" ])
    } else if (gen_type == "source_set") {
      action(target_name_) {
        out_path = "$target_gen_dir/" + target_name_
        rebased_out_path =
            rebase_path(target_gen_dir, root_build_dir) + "/" + target_name_

        script = "$perfetto_root_path/tools/touch_file.py"
        args = [
          "--output",
          rebased_out_path,
        ]
        outputs = [ out_path ]
        deps = deps_

        metadata = {
          proto_library_sources = invoker.sources
          import_dirs = import_dirs_
        }
        forward_variables_from(invoker, vars_to_forward)
      }

      # Not needed for source_set proto_library target.
      not_needed([
                   "propagate_imports_configs_",
                   "proto_path",
                 ])
    } else {
      assert(false, "Invalid 'proto_generators' value.")
    }
  }
}
