# 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("gn/perfetto.gni")

declare_args() {
  # Only for local development. When true the binaries (perfetto, traced, ...)
  # are monolithic and don't use a common shared library. This is mainly to
  # avoid LD_LIBRARY_PATH dances when testing locally.
  monolithic_binaries = false
}
assert(!monolithic_binaries || !build_with_android)

group("all") {
  testonly = true  # allow to build also test targets
  deps = [
    ":perfetto_unittests",
    "src/ipc/protoc_plugin:ipc_plugin($host_toolchain)",
    "src/protozero/protoc_plugin($host_toolchain)",
    "tools/ftrace_proto_gen:ftrace_proto_gen",
    "tools/proto_to_cpp",
    "tools/trace_to_text",
  ]
  if (!build_with_chromium) {
    deps += [
      ":perfetto",
      ":perfetto_benchmarks",
      ":perfetto_integrationtests",
      ":traced",
      ":traced_probes",
      "protos/perfetto/config:merged_config",  # For syntax-checking the proto.
      "test/configs",
      "tools:protoc_helper",
    ]
  }
}

executable("perfetto_unittests") {
  testonly = true
  deps = [
    "gn:default_deps",
    "gn:gtest_main",
    "src/base:base_unittests",
    "src/ftrace_reader:ftrace_reader_unittests",
    "src/ipc:perfetto_ipc_unittests",
    "src/protozero:protozero_unittests",
    "src/tracing:tracing_unittests",
    "tools/ftrace_proto_gen:ftrace_proto_gen_unittests",
  ]
  if (!build_with_chromium) {
    deps += [ "tools/sanitizers_unittests" ]
  }
}

if (!build_with_chromium) {
  executable("perfetto_benchmarks") {
    testonly = true
    deps = [
      "gn:default_deps",
      "src/ftrace_reader:ftrace_reader_benchmarks",
      "src/tracing:tracing_benchmarks",
      "test:benchmark_main",
    ]
  }

  executable("perfetto_integrationtests") {
    testonly = true
    deps = [
      "gn:default_deps",
      "gn:gtest_main",
      "src/ftrace_reader:ftrace_reader_integrationtests",
      "test:end_to_end_integrationtests",
    ]
    if (build_with_android) {
      cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
    }
  }

  if (monolithic_binaries) {
    libtraced_shared_target_type = "source_set"
  } else {
    libtraced_shared_target_type = "shared_library"
  }

  target(libtraced_shared_target_type, "libtraced_shared") {
    deps = [
      "gn:default_deps",
      "src/traced/probes",
      "src/traced/service",
    ]
  }

  # The unprivileged trace daemon that listens for Producer and Consumer
  # connections, handles the coordination of the tracing sessions and owns the
  # log buffers.
  executable("traced") {
    deps = [
      ":libtraced_shared",
      "gn:default_deps",
    ]
    sources = [
      "src/traced/service/main.cc",
    ]
  }

  # The unprivileged daemon that is allowed to access tracefs (for ftrace).
  # Registers as a Producer on the traced daemon.
  executable("traced_probes") {
    deps = [
      ":libtraced_shared",
      "gn:default_deps",
    ]
    sources = [
      "src/traced/probes/main.cc",
    ]
  }

  # The command line client for Perfetto. Allows to configure / start / stop
  # tracing, acting as a Consumer.
  executable("perfetto") {
    deps = [
      "gn:default_deps",
      "src/traced/perfetto_cmd",
    ]
    sources = [
      "src/traced/perfetto_cmd/main.cc",
    ]
    if (build_with_android) {
      cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
      deps += [ "src/base:android_task_runner" ]
      libs = [
        "binder",
        "services",
        "utils",
      ]
    }
  }
} else {
  group("lib") {
    public_configs = [ "gn:public_config" ]
    deps = [
      "src/tracing",
    ]
  }
}  # !build_with_chromium
