1#
2# Copyright 2019 The Abseil Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
18load(
19    "//absl:copts/configure_copts.bzl",
20    "ABSL_DEFAULT_COPTS",
21    "ABSL_DEFAULT_LINKOPTS",
22    "ABSL_TEST_COPTS",
23)
24
25package(default_visibility = ["//visibility:public"])
26
27licenses(["notice"])  # Apache 2.0
28
29cc_library(
30    name = "hash",
31    srcs = [
32        "internal/hash.cc",
33        "internal/hash.h",
34    ],
35    hdrs = ["hash.h"],
36    copts = ABSL_DEFAULT_COPTS,
37    linkopts = ABSL_DEFAULT_LINKOPTS,
38    deps = [
39        ":city",
40        "//absl/base:core_headers",
41        "//absl/base:endian",
42        "//absl/container:fixed_array",
43        "//absl/meta:type_traits",
44        "//absl/numeric:int128",
45        "//absl/strings",
46        "//absl/types:optional",
47        "//absl/types:variant",
48        "//absl/utility",
49    ],
50)
51
52cc_library(
53    name = "hash_testing",
54    testonly = 1,
55    hdrs = ["hash_testing.h"],
56    linkopts = ABSL_DEFAULT_LINKOPTS,
57    deps = [
58        ":spy_hash_state",
59        "//absl/meta:type_traits",
60        "//absl/strings",
61        "//absl/types:variant",
62        "@com_google_googletest//:gtest",
63    ],
64)
65
66cc_test(
67    name = "hash_test",
68    srcs = ["hash_test.cc"],
69    copts = ABSL_TEST_COPTS,
70    linkopts = ABSL_DEFAULT_LINKOPTS,
71    deps = [
72        ":hash",
73        ":hash_testing",
74        ":spy_hash_state",
75        "//absl/base:core_headers",
76        "//absl/container:flat_hash_set",
77        "//absl/meta:type_traits",
78        "//absl/numeric:int128",
79        "@com_google_googletest//:gtest_main",
80    ],
81)
82
83cc_library(
84    name = "spy_hash_state",
85    testonly = 1,
86    hdrs = ["internal/spy_hash_state.h"],
87    copts = ABSL_DEFAULT_COPTS,
88    linkopts = ABSL_DEFAULT_LINKOPTS,
89    visibility = ["//visibility:private"],
90    deps = [
91        ":hash",
92        "//absl/strings",
93        "//absl/strings:str_format",
94    ],
95)
96
97cc_library(
98    name = "city",
99    srcs = ["internal/city.cc"],
100    hdrs = [
101        "internal/city.h",
102    ],
103    copts = ABSL_DEFAULT_COPTS,
104    linkopts = ABSL_DEFAULT_LINKOPTS,
105    deps = [
106        "//absl/base:config",
107        "//absl/base:core_headers",
108        "//absl/base:endian",
109    ],
110)
111
112cc_test(
113    name = "city_test",
114    srcs = ["internal/city_test.cc"],
115    copts = ABSL_TEST_COPTS,
116    linkopts = ABSL_DEFAULT_LINKOPTS,
117    deps = [
118        ":city",
119        "@com_google_googletest//:gtest_main",
120    ],
121)
122