# Copyright 2019 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("path_util") {
  public = [ "internal/path_util.h" ]
  deps = [
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/strings:string_view",
  ]
  visibility = [ ":*" ]
}

absl_source_set("program_name") {
  sources = [ "internal/program_name.cc" ]
  public = [ "internal/program_name.h" ]
  deps = [
    ":path_util",
    "//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/strings:string_view",
    "//third_party/abseil-cpp/absl/synchronization",
  ]
  visibility = [
    ":*",
    "../log:*",
  ]
}

# Since absl/flags are only used by some test binaries (e.g. in WebRTC),
# there is no need to strip flags from mobile platforms binaries.
# This does not affect Chromium.
config("absl_flags_config") {
  defines = [ "ABSL_FLAGS_STRIP_NAMES=0" ]
}

absl_source_set("config") {
  sources = [ "usage_config.cc" ]
  public_configs = [ ":absl_flags_config" ]
  public = [
    "config.h",
    "usage_config.h",
  ]
  deps = [
    ":path_util",
    ":program_name",
    "//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/strings",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/synchronization",
  ]
}

absl_source_set("marshalling") {
  sources = [ "marshalling.cc" ]
  public = [ "marshalling.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/numeric:int128",
    "//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/types:optional",
  ]
}

absl_source_set("commandlineflag_internal") {
  visibility = [ ":*" ]
  public = [ "internal/commandlineflag.h" ]
  sources = [ "internal/commandlineflag.cc" ]
  deps = [
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:fast_type_id",
  ]
}

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

absl_source_set("private_handle_accessor") {
  sources = [ "internal/private_handle_accessor.cc" ]
  public = [ "internal/private_handle_accessor.h" ]
  deps = [
    ":commandlineflag",
    ":commandlineflag_internal",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/strings:string_view",
  ]
  visibility = [ ":*" ]
}

absl_source_set("reflection") {
  sources = [ "reflection.cc" ]
  public = [
    "internal/registry.h",
    "reflection.h",
  ]
  deps = [
    ":commandlineflag",
    ":commandlineflag_internal",
    ":config",
    ":private_handle_accessor",
    "//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/container:flat_hash_map",
    "//third_party/abseil-cpp/absl/strings",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/synchronization",
  ]
}

absl_source_set("flag_internal") {
  sources = [ "internal/flag.cc" ]
  public = [
    "internal/flag.h",
    "internal/sequence_lock.h",
  ]
  deps = [
    ":commandlineflag",
    ":commandlineflag_internal",
    ":config",
    ":marshalling",
    ":reflection",
    "//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:dynamic_annotations",
    "//third_party/abseil-cpp/absl/base:no_destructor",
    "//third_party/abseil-cpp/absl/memory",
    "//third_party/abseil-cpp/absl/meta:type_traits",
    "//third_party/abseil-cpp/absl/strings",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/synchronization",
    "//third_party/abseil-cpp/absl/utility",
  ]
  visibility = [
    ":*",
    "//third_party/abseil-cpp/absl/base/*",
  ]
}

absl_source_set("flag") {
  public = [
    "declare.h",
    "flag.h",
  ]
  deps = [
    ":commandlineflag",
    ":config",
    ":flag_internal",
    ":reflection",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/strings:string_view",
  ]
}

absl_source_set("usage_internal") {
  sources = [ "internal/usage.cc" ]
  public = [ "internal/usage.h" ]
  deps = [
    ":commandlineflag",
    ":config",
    ":flag",
    ":flag_internal",
    ":path_util",
    ":private_handle_accessor",
    ":program_name",
    ":reflection",
    "//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/strings",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/synchronization",
  ]
  visibility = [ ":*" ]
}

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

absl_source_set("parse") {
  sources = [ "parse.cc" ]
  public = [
    "internal/parse.h",
    "parse.h",
  ]
  deps = [
    ":commandlineflag",
    ":commandlineflag_internal",
    ":config",
    ":flag",
    ":flag_internal",
    ":private_handle_accessor",
    ":program_name",
    ":reflection",
    ":usage",
    ":usage_internal",
    "//third_party/abseil-cpp/absl/algorithm:container",
    "//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/strings",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/synchronization",
  ]
}

absl_test("flag_test") {
  sources = [
    "flag_test.cc",
    "flag_test_defs.cc",
  ]
  deps = [
    ":config",
    ":flag",
    ":flag_internal",
    ":marshalling",
    ":parse",
    ":reflection",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:malloc_internal",
    "//third_party/abseil-cpp/absl/base:raw_logging_internal",
    "//third_party/abseil-cpp/absl/numeric:int128",
    "//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:optional",
  ]
}
