chromium/third_party/distributed_point_functions/BUILD.gn

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

import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/distributed_point_functions/features.gni")
import("//third_party/protobuf/proto_library.gni")

# This is Chromium's interface with the third-party distributed_point_functions
# library. Targets outside of //third_party/distributed_point_functions should
# depend on this target rather than using the source directly. This extra layer
# prevents macros from leaking into Chromium code via header includes.
source_set("distributed_point_functions") {
  public_deps = [ "//third_party/distributed_point_functions/shim" ]
}

proto_library("proto") {
  sources = [ "code/dpf/distributed_point_function.proto" ]
  proto_out_dir = "third_party/distributed_point_functions/dpf"
  cc_generator_options = "lite"
}

fuzzer_test("dpf_fuzzer") {
  sources = [ "fuzz/dpf_fuzzer.cc" ]
  deps = [ ":internal" ]

  # Do not apply Chromium code rules to this third-party code.
  suppressed_configs = [ "//build/config/compiler:chromium_code" ]
  additional_configs = [ "//build/config/compiler:no_chromium_code" ]

  additional_configs += [ ":includes" ]
}

# Targets below this line are only visible within this file and shim/.
visibility = [
  ":*",
  "//third_party/distributed_point_functions/shim:*",
]

config("includes") {
  include_dirs = [
    "code",
    "$target_gen_dir",
  ]
}

source_set("internal") {
  sources = [
    "code/dpf/aes_128_fixed_key_hash.cc",
    "code/dpf/aes_128_fixed_key_hash.h",
    "code/dpf/distributed_point_function.cc",
    "code/dpf/distributed_point_function.h",
    "code/dpf/int_mod_n.cc",
    "code/dpf/int_mod_n.h",
    "code/dpf/internal/evaluate_prg_hwy.cc",
    "code/dpf/internal/evaluate_prg_hwy.h",
    "code/dpf/internal/get_hwy_mode.cc",
    "code/dpf/internal/get_hwy_mode.h",
    "code/dpf/internal/proto_validator.cc",
    "code/dpf/internal/proto_validator.h",
    "code/dpf/internal/value_type_helpers.cc",
    "code/dpf/internal/value_type_helpers.h",
    "code/dpf/status_macros.h",
    "code/dpf/tuple.h",
    "code/dpf/xor_wrapper.h",
  ]

  public_deps = [
    ":proto",
    "$dpf_abseil_cpp_dir:absl",
    "$dpf_highway_cpp_dir:libhwy",
    "//third_party/boringssl",
    "//third_party/protobuf:protobuf_lite",
  ]

  # Do not apply Chromium code rules to this third-party code.
  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [ "//build/config/compiler:no_chromium_code" ]

  configs += [ ":includes" ]
}