# Copyright 2018 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("random") {
  public = [ "random.h" ]
  deps = [
    ":distributions",
    ":seed_sequences",
    "//third_party/abseil-cpp/absl/random/internal:nonsecure_base",
    "//third_party/abseil-cpp/absl/random/internal:pcg_engine",
    "//third_party/abseil-cpp/absl/random/internal:pool_urbg",
    "//third_party/abseil-cpp/absl/random/internal:randen_engine",
  ]
}

absl_source_set("distributions") {
  public = [
    "bernoulli_distribution.h",
    "beta_distribution.h",
    "discrete_distribution.h",
    "distributions.h",
    "exponential_distribution.h",
    "gaussian_distribution.h",
    "log_uniform_int_distribution.h",
    "poisson_distribution.h",
    "uniform_int_distribution.h",
    "uniform_real_distribution.h",
    "zipf_distribution.h",
  ]
  sources = [
    "discrete_distribution.cc",
    "gaussian_distribution.cc",
  ]
  deps = [
    "//third_party/abseil-cpp/absl/base:base_internal",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/meta:type_traits",
    "//third_party/abseil-cpp/absl/random/internal:distribution_caller",
    "//third_party/abseil-cpp/absl/random/internal:fast_uniform_bits",
    "//third_party/abseil-cpp/absl/random/internal:fastmath",
    "//third_party/abseil-cpp/absl/random/internal:generate_real",
    "//third_party/abseil-cpp/absl/random/internal:iostream_state_saver",
    "//third_party/abseil-cpp/absl/random/internal:traits",
    "//third_party/abseil-cpp/absl/random/internal:uniform_helper",
    "//third_party/abseil-cpp/absl/random/internal:wide_multiply",
    "//third_party/abseil-cpp/absl/strings",
  ]
}

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

absl_source_set("seed_sequences") {
  public = [ "seed_sequences.h" ]
  sources = [ "seed_sequences.cc" ]
  deps = [
    ":seed_gen_exception",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:nullability",
    "//third_party/abseil-cpp/absl/random/internal:pool_urbg",
    "//third_party/abseil-cpp/absl/random/internal:salted_seed_seq",
    "//third_party/abseil-cpp/absl/random/internal:seed_material",
    "//third_party/abseil-cpp/absl/strings:string_view",
    "//third_party/abseil-cpp/absl/types:span",
  ]
}

absl_source_set("bit_gen_ref") {
  public = [ "bit_gen_ref.h" ]
  deps = [
    ":random",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:core_headers",
    "//third_party/abseil-cpp/absl/base:fast_type_id",
    "//third_party/abseil-cpp/absl/meta:type_traits",
    "//third_party/abseil-cpp/absl/random/internal:distribution_caller",
    "//third_party/abseil-cpp/absl/random/internal:fast_uniform_bits",
  ]
}

absl_source_set("mock_distributions") {
  testonly = true
  public = [ "mock_distributions.h" ]
  deps = [
    ":distributions",
    ":mocking_bit_gen",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/random/internal:mock_overload_set",
    "//third_party/abseil-cpp/absl/random/internal:mock_validators",
  ]
}

absl_source_set("mocking_bit_gen") {
  testonly = true
  public = [ "mocking_bit_gen.h" ]
  deps = [
    ":random",
    "//third_party/abseil-cpp/absl/base:config",
    "//third_party/abseil-cpp/absl/base:fast_type_id",
    "//third_party/abseil-cpp/absl/container:flat_hash_map",
    "//third_party/abseil-cpp/absl/meta:type_traits",
    "//third_party/abseil-cpp/absl/random/internal:mock_helpers",
    "//third_party/abseil-cpp/absl/utility",
    "//third_party/googletest:gtest",
  ]
}

absl_test("distributions_test") {
  sources = [ "distributions_test.cc" ]
  deps = [
    ":distributions",
    ":random",
    "//third_party/abseil-cpp/absl/meta:type_traits",
    "//third_party/abseil-cpp/absl/numeric:int128",
    "//third_party/abseil-cpp/absl/random/internal:distribution_test_util",
  ]
}

absl_test("mock_distributions_test") {
  sources = [ "mock_distributions_test.cc" ]
  deps = [
    ":distributions",
    ":mock_distributions",
    ":mocking_bit_gen",
    ":random",
    "//third_party/abseil-cpp/absl/numeric:int128",
  ]
}
