# 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/gen_perfetto_version_header.gni")
import("../../gn/perfetto.gni")
import("../../gn/perfetto_component.gni")
import("../../gn/test.gni")
import("../../gn/wasm.gni")

# On standalone builds this is all the OSes we support. On chromium builds,
# though, this really means !is_fuchsia && !is_nacl.
_subprocess_supported =
    is_linux || is_chromeos || is_android || is_mac || is_win

perfetto_component("base") {
  deps = [
    "../../gn:base_platform",
    "../../gn:default_deps",
  ]
  public_deps = [
    "../../include/perfetto/base",
    "../../include/perfetto/ext/base",
  ]
  sources = [
    "android_utils.cc",
    "base64.cc",
    "crash_keys.cc",
    "ctrl_c_handler.cc",
    "event_fd.cc",
    "file_utils.cc",
    "getopt_compat.cc",
    "log_ring_buffer.h",
    "logging.cc",
    "metatrace.cc",
    "paged_memory.cc",
    "periodic_task.cc",
    "pipe.cc",
    "scoped_mmap.cc",
    "status.cc",
    "string_splitter.cc",
    "string_utils.cc",
    "string_view.cc",
    "temp_file.cc",
    "thread_checker.cc",
    "thread_utils.cc",
    "time.cc",
    "utils.cc",
    "uuid.cc",
    "virtual_destructors.cc",
    "waitable_event.cc",
    "watchdog_posix.cc",
  ]

  if (!is_nacl) {
    sources += [
      "thread_task_runner.cc",
      "unix_task_runner.cc",
    ]
  }

  if (_subprocess_supported) {
    sources += [
      "subprocess.cc",
      "subprocess_posix.cc",
      "subprocess_windows.cc",
    ]
  }

  if (enable_perfetto_stderr_crash_dump) {
    deps += [ ":debug_crash_stack_trace" ]
  }
}

# This target needs to be named as such because it's exposed directly in Bazel
# and Android.bp.
perfetto_component("perfetto_base_default_platform") {
  deps = [
    "../../gn:default_deps",
    "../../include/perfetto/ext/base",
  ]
  sources = [ "default_platform.cc" ]
}

perfetto_component("version") {
  deps = [
    ":base",
    "../../gn:default_deps",
  ]
  public_deps = [ "../../include/perfetto/ext/base:version" ]
  sources = [ "version.cc" ]

  if (enable_perfetto_version_gen) {
    deps += [ ":version_gen_h" ]
  }
}

if (enable_perfetto_version_gen) {
  config("version_gen_config") {
    include_dirs = [ root_gen_dir ]
  }

  # Note: the build file translators (tools/gn_utils.py) depend on the hardcoded
  # "//src/base:version_gen_h". If you rename this target, update build file
  # translators accordingly.
  gen_perfetto_version_header("version_gen_h") {
    cpp_out = "${root_gen_dir}/perfetto_version.gen.h"
  }
}

if (enable_perfetto_stderr_crash_dump) {
  source_set("debug_crash_stack_trace") {
    sources = [ "debug_crash_stack_trace.cc" ]
    deps = [
      "../../gn:default_deps",
      "../../include/perfetto/ext/base",
      "../../include/perfetto/ext/base",
    ]
    if (is_linux || is_android) {
      deps += [ "../../gn:libbacktrace" ]
    }
    cflags = [ "-Wno-deprecated" ]
  }
}

if (enable_perfetto_ipc) {
  # This cannot be in :base as it does not build on WASM.
  perfetto_component("unix_socket") {
    deps = [
      "../../gn:default_deps",
      "../../include/perfetto/ext/base",
    ]
    sources = [
      "unix_socket.cc",
      "vm_sockets.h",
    ]
    if (is_win && perfetto_build_standalone) {
      libs = [ "Ws2_32.lib" ]
    }
  }
}

source_set("test_support") {
  testonly = true
  deps = [
    ":base",
    "../../gn:default_deps",
    "../../gn:gtest_and_gmock",
  ]
  sources = [
    "test/status_matchers.h",
    "test/tmp_dir_tree.cc",
    "test/tmp_dir_tree.h",
    "test/utils.cc",
    "test/utils.h",
    "test/vm_test_utils.cc",
    "test/vm_test_utils.h",
  ]

  if (!is_nacl) {
    # test_task_runner depends on unix_task_runner, which isn't available on
    # NaCL.
    sources += [
      "test/test_task_runner.cc",
      "test/test_task_runner.h",
    ]
  }
}

perfetto_unittest_source_set("unittests") {
  testonly = true
  deps = [
    ":base",
    ":test_support",
    "../../gn:default_deps",
    "../../gn:gtest_and_gmock",
  ]

  if (enable_perfetto_ipc) {
    deps += [ "http:unittests" ]
  }

  sources = [
    "base64_unittest.cc",
    "circular_queue_unittest.cc",
    "flat_hash_map_unittest.cc",
    "flat_set_unittest.cc",
    "getopt_compat_unittest.cc",
    "hash_unittest.cc",
    "logging_unittest.cc",
    "no_destructor_unittest.cc",
    "paged_memory_unittest.cc",
    "periodic_task_unittest.cc",
    "scoped_file_unittest.cc",
    "scoped_mmap_unittest.cc",
    "small_vector_unittest.cc",
    "status_or_unittest.cc",
    "status_unittest.cc",
    "string_splitter_unittest.cc",
    "string_utils_unittest.cc",
    "string_view_unittest.cc",
    "string_writer_unittest.cc",
    "task_runner_unittest.cc",
    "temp_file_unittest.cc",
    "thread_checker_unittest.cc",
    "time_unittest.cc",
    "utils_unittest.cc",
    "uuid_unittest.cc",
    "weak_ptr_unittest.cc",
  ]
  if (_subprocess_supported) {
    # Don't run on Fuchsia, NaCL. They pretend to be POSIX but then give up on
    # execve(2).
    sources += [ "subprocess_unittest.cc" ]
  }

  # TODO: Enable these for Windows when possible.
  if (!is_win) {
    sources += [
      "metatrace_unittest.cc",
      "thread_task_runner_unittest.cc",
      "watchdog_posix_unittest.cc",
    ]
  }
  if (is_fuchsia) {
    deps += [ "//third_party/fuchsia-sdk/sdk/pkg/fdio" ]  # nogncheck
  }
  if (perfetto_build_standalone || perfetto_build_with_android) {
    sources += [ "unix_socket_unittest.cc" ]
    deps += [ ":unix_socket" ]

    # This causes some problems on the chromium waterfall.
    if (is_linux || is_android) {
      sources += [ "watchdog_unittest.cc" ]
    }
  }
}

if (enable_perfetto_benchmarks) {
  declare_args() {
    perfetto_benchmark_3p_libs_prefix = ""
  }
  source_set("benchmarks") {
    # If you intend to reproduce the comparison with {Absl, Folly, Tessil}
    # you need to manually install those libraries and then set the GN arg
    # perfetto_benchmark_3p_libs_prefix = "/usr/local"
    testonly = true
    deps = [
      ":base",
      "../../gn:benchmark",
      "../../gn:default_deps",
    ]
    if (perfetto_benchmark_3p_libs_prefix != "") {
      defines = [ "PERFETTO_HASH_MAP_COMPARE_THIRD_PARTY_LIBS" ]
      cflags = [ "-isystem${perfetto_benchmark_3p_libs_prefix}/include" ]
      libs = [
        "${perfetto_benchmark_3p_libs_prefix}/lib/libfolly.a",
        "${perfetto_benchmark_3p_libs_prefix}/lib/libabsl_raw_hash_set.a",
        "${perfetto_benchmark_3p_libs_prefix}/lib/libabsl_hash.a",
      ]
    }
    sources = [
      "flat_hash_map_benchmark.cc",
      "flat_set_benchmark.cc",
    ]
  }
}
