# Copyright 2022 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//third_party/abseil-cpp/absl.gni")

absl_source_set("check_impl") {
  public = [ "check_impl.h" ]
  deps = [
    ":check_op",
    ":conditions",
    ":log_message",
    ":strip",
    "//third_party/abseil-cpp/absl/base:core_headers",
  ]
}

absl_source_set("check_op") {
  sources = [ "check_op.cc" ]
  public = [ "check_op.h" ]
  deps = [
    ":nullguard",
    ":nullstream",
    ":strip",
    "//third_party/abseil-cpp/absl/base",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:nullability",
    "//third_party/abseil-cpp/absl/debugging:leak_check",
    "//third_party/abseil-cpp/absl/strings",
  ]
}

absl_source_set("conditions") {
  sources = [ "conditions.cc" ]
  public = [ "conditions.h" ]
  deps = [
    ":voidify",
    "//third_party/abseil-cpp/absl/base",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
  ]
}

absl_source_set("config") {
  public = [ "config.h" ]
  deps = [
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
  ]
}

absl_source_set("flags") {
  public = [ "flags.h" ]
  deps = [ "//third_party/abseil-cpp/absl/flags:flag" ]
}

absl_source_set("format") {
  sources = [ "log_format.cc" ]
  public = [ "log_format.h" ]
  deps = [
    ":append_truncated",
    ":config",
    ":globals",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:log_severity",
    "//third_party/abseil-cpp/absl/strings",
    "//third_party/abseil-cpp/absl/strings:str_format",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/time",
    "//third_party/abseil-cpp/absl/types:span",
  ]
}

absl_source_set("globals") {
  sources = [ "globals.cc" ]
  public = [ "globals.h" ]
  deps = [
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:log_severity",
    "//third_party/abseil-cpp/absl/base:raw_logging_internal",
    "//third_party/abseil-cpp/absl/strings",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/time",
  ]
}

absl_source_set("log_impl") {
  public = [ "log_impl.h" ]
  deps = [
    ":conditions",
    ":log_message",
    ":strip",
    "//third_party/abseil-cpp/absl/log:absl_vlog_is_on",
  ]
}

absl_source_set("log_message") {
  sources = [ "log_message.cc" ]
  public = [ "log_message.h" ]
  deps = [
    ":append_truncated",
    ":format",
    ":globals",
    ":log_sink_set",
    ":nullguard",
    ":proto",
    ":structured_proto",
    "//third_party/abseil-cpp/absl/base",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:errno_saver",
    "//third_party/abseil-cpp/absl/base:log_severity",
    "//third_party/abseil-cpp/absl/base:nullability",
    "//third_party/abseil-cpp/absl/base:raw_logging_internal",
    "//third_party/abseil-cpp/absl/base:strerror",
    "//third_party/abseil-cpp/absl/container:inlined_vector",
    "//third_party/abseil-cpp/absl/debugging:examine_stack",
    "//third_party/abseil-cpp/absl/log:globals",
    "//third_party/abseil-cpp/absl/log:log_entry",
    "//third_party/abseil-cpp/absl/log:log_sink",
    "//third_party/abseil-cpp/absl/log:log_sink_registry",
    "//third_party/abseil-cpp/absl/memory",
    "//third_party/abseil-cpp/absl/strings",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/time",
    "//third_party/abseil-cpp/absl/types:span",
  ]
}

absl_source_set("append_truncated") {
  public = [ "append_truncated.h" ]
  deps = [
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/types:span",
  ]
}

absl_source_set("log_sink_set") {
  sources = [ "log_sink_set.cc" ]
  public = [ "log_sink_set.h" ]
  deps = [
    ":config",
    ":globals",
    "//third_party/abseil-cpp/absl/base",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:log_severity",
    "//third_party/abseil-cpp/absl/base:no_destructor",
    "//third_party/abseil-cpp/absl/base:raw_logging_internal",
    "//third_party/abseil-cpp/absl/cleanup",
    "//third_party/abseil-cpp/absl/log:globals",
    "//third_party/abseil-cpp/absl/log:log_entry",
    "//third_party/abseil-cpp/absl/log:log_sink",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/synchronization",
    "//third_party/abseil-cpp/absl/types:span",
  ]
  if (is_android) {
    libs = [ "log" ]
  }
}

absl_source_set("nullguard") {
  sources = [ "nullguard.cc" ]
  public = [ "nullguard.h" ]
  deps = [
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
  ]
}

absl_source_set("nullstream") {
  public = [ "nullstream.h" ]
  deps = [
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:log_severity",
    "//third_party/abseil-cpp/absl/strings:string_view",
  ]
}

absl_source_set("strip") {
  public = [ "strip.h" ]
  deps = [
    ":log_message",
    ":nullstream",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:log_severity",
  ]
}

absl_source_set("structured") {
  public = [ "structured.h" ]
  deps = [
    ":log_message",
    ":structured_proto",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/functional:any_invocable",
    "//third_party/abseil-cpp/absl/strings",
    "//third_party/abseil-cpp/absl/strings:string_view",
  ]
}

absl_source_set("structured_proto") {
  sources = [ "structured_proto.cc" ]
  public = [ "structured_proto.h" ]
  visibility = [ "//third_party/abseil-cpp/absl/log/*" ]
  deps = [
    ":proto",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/strings",
    "//third_party/abseil-cpp/absl/types:span",
    "//third_party/abseil-cpp/absl/types:variant",
  ]
}

absl_test("structured_proto_test") {
  sources = [ "structured_proto_test.cc" ]
  deps = [
    ":structured_proto",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/types:span",
    "//third_party/abseil-cpp/absl/utility",
  ]
}

absl_source_set("test_actions") {
  testonly = true
  sources = [ "test_actions.cc" ]
  public = [ "test_actions.h" ]
  deps = [
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:log_severity",
    "//third_party/abseil-cpp/absl/log:log_entry",
    "//third_party/abseil-cpp/absl/strings",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/time",
  ]
}

absl_source_set("test_helpers") {
  testonly = true
  sources = [ "test_helpers.cc" ]
  public = [ "test_helpers.h" ]
  deps = [
    ":globals",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:log_severity",
    "//third_party/abseil-cpp/absl/log:globals",
    "//third_party/abseil-cpp/absl/log:initialize",
    "//third_party/googletest:gtest",
  ]
}

absl_source_set("test_matchers") {
  testonly = true
  sources = [ "test_matchers.cc" ]
  public = [ "test_matchers.h" ]
  deps = [
    ":test_helpers",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:log_severity",
    "//third_party/abseil-cpp/absl/log:log_entry",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/time",
    "//third_party/googletest:gmock",
    "//third_party/googletest:gtest",
  ]
}

absl_source_set("voidify") {
  public = [ "voidify.h" ]
  deps = [ "//third_party/abseil-cpp/absl/base:config" ]
}

absl_source_set("proto") {
  sources = [ "proto.cc" ]
  public = [ "proto.h" ]
  deps = [
    "//third_party/abseil-cpp/absl/base",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/types:span",
  ]
}

absl_source_set("fnmatch") {
  sources = [ "fnmatch.cc" ]
  public = [ "fnmatch.h" ]
  deps = [
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/strings",
  ]
}

absl_source_set("vlog_config") {
  sources = [ "vlog_config.cc" ]
  public = [ "vlog_config.h" ]
  visibility = [ "//third_party/abseil-cpp/absl/log/*" ]
  deps = [
    "//third_party/abseil-cpp/absl/base",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:no_destructor",
    "//third_party/abseil-cpp/absl/log/internal:fnmatch",
    "//third_party/abseil-cpp/absl/memory",
    "//third_party/abseil-cpp/absl/strings",
    "//third_party/abseil-cpp/absl/synchronization",
    "//third_party/abseil-cpp/absl/types:optional",
  ]
}

absl_test("stderr_log_sink_test") {
  sources = [ "stderr_log_sink_test.cc" ]
  if (is_apple || is_android) {
    sources = []
  }
  deps = [
    ":test_helpers",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:log_severity",
    "//third_party/abseil-cpp/absl/log",
    "//third_party/abseil-cpp/absl/log:globals",
  ]
}

absl_test("fnmatch_test") {
  sources = [ "fnmatch_test.cc" ]
  deps = [ ":fnmatch" ]
}
