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

enable_stack_trace = is_debug && perfetto_build_standalone && !is_wasm

source_set("base") {
  deps = [ "../../gn:default_deps" ]
  public_deps = [
    "../../include/perfetto/base",
    "../../include/perfetto/ext/base",
  ]
  sources = [
    "file_utils.cc",
    "logging.cc",
    "metatrace.cc",
    "paged_memory.cc",
    "string_splitter.cc",
    "string_utils.cc",
    "string_view.cc",
    "subprocess.cc",
    "thread_checker.cc",
    "time.cc",
    "uuid.cc",
    "virtual_destructors.cc",
    "waitable_event.cc",
    "watchdog_posix.cc",
  ]

  # TODO(brucedawson): Enable these for Windows when possible.
  if (!is_win && !is_nacl) {
    sources += [
      "event_fd.cc",
      "pipe.cc",
      "temp_file.cc",
      "thread_task_runner.cc",
      "unix_task_runner.cc",
    ]
  }

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

if (enable_stack_trace) {
  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.
  source_set("unix_socket") {
    deps = [
      "../../gn:default_deps",
      "../../include/perfetto/ext/base",
      "../../include/perfetto/ext/base",
    ]
    sources = [ "unix_socket.cc" ]
  }
}

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

  # The Perfetto task runner is not used on Windows.
  if (!is_win) {
    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 = [
    "circular_queue_unittest.cc",
    "flat_set_unittest.cc",
    "no_destructor_unittest.cc",
    "optional_unittest.cc",
    "paged_memory_unittest.cc",
    "scoped_file_unittest.cc",
    "string_splitter_unittest.cc",
    "string_utils_unittest.cc",
    "string_view_unittest.cc",
    "string_writer_unittest.cc",
    "subprocess_unittest.cc",
    "time_unittest.cc",
    "uuid_unittest.cc",
    "weak_ptr_unittest.cc",
  ]

  # TODO: Enable these for Windows when possible.
  if (!is_win) {
    sources += [
      "metatrace_unittest.cc",
      "task_runner_unittest.cc",
      "temp_file_unittest.cc",
      "thread_checker_unittest.cc",
      "thread_task_runner_unittest.cc",
      "utils_unittest.cc",
    ]
  }
  if (perfetto_build_standalone || perfetto_build_with_android) {
    # This causes some problems on the chromium waterfall.
    sources += [ "unix_socket_unittest.cc" ]
    if (is_linux || is_android) {
      sources += [ "watchdog_unittest.cc" ]
    }
  }
}

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