# 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("//build_overrides/build.gni")
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: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",
    "status.cc",
    "string_splitter.cc",
    "string_utils.cc",
    "string_view.cc",
    "temp_file.cc",
    "thread_checker.cc",
    "time.cc",
    "utils.cc",
    "uuid.cc",
    "version.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" ]
  }

  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" ]
    if (is_win && perfetto_build_standalone) {
      libs = [ "Ws2_32.lib" ]
    }
  }
}

source_set("test_support") {
  testonly = true
  deps = [
    ":base",
    "../../gn:default_deps",
  ]
  sources = [
    "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",
  ]

  sources = [
    "base64_unittest.cc",
    "circular_queue_unittest.cc",
    "flat_set_unittest.cc",
    "getopt_compat_unittest.cc",
    "logging_unittest.cc",
    "no_destructor_unittest.cc",
    "optional_unittest.cc",
    "paged_memory_unittest.cc",
    "periodic_task_unittest.cc",
    "scoped_file_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" ]
  }
  if (perfetto_build_standalone || perfetto_build_with_android) {
    # This causes some problems on the chromium waterfall.
    if (is_linux || is_android) {
      sources += [ "watchdog_unittest.cc" ]
    }
    sources += [ "unix_socket_unittest.cc" ]
    deps += [ ":unix_socket" ]
  }
}

if (enable_perfetto_benchmarks) {
  source_set("benchmarks") {
    testonly = true
    deps = [
      ":base",
      "../../gn:benchmark",
      "../../gn:default_deps",
    ]
    sources = [ "flat_set_benchmark.cc" ]
  }
}
