• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"])
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        ":wyhash",
41        "//absl/base:config",
42        "//absl/base:core_headers",
43        "//absl/base:endian",
44        "//absl/container:fixed_array",
45        "//absl/meta:type_traits",
46        "//absl/numeric:int128",
47        "//absl/strings",
48        "//absl/types:optional",
49        "//absl/types:variant",
50        "//absl/utility",
51    ],
52)
53
54cc_library(
55    name = "hash_testing",
56    testonly = 1,
57    hdrs = ["hash_testing.h"],
58    linkopts = ABSL_DEFAULT_LINKOPTS,
59    deps = [
60        ":spy_hash_state",
61        "//absl/meta:type_traits",
62        "//absl/strings",
63        "//absl/types:variant",
64        "@com_google_googletest//:gtest",
65    ],
66)
67
68cc_test(
69    name = "hash_test",
70    srcs = ["hash_test.cc"],
71    copts = ABSL_TEST_COPTS,
72    linkopts = ABSL_DEFAULT_LINKOPTS,
73    deps = [
74        ":hash",
75        ":hash_testing",
76        ":spy_hash_state",
77        "//absl/base:core_headers",
78        "//absl/container:flat_hash_set",
79        "//absl/meta:type_traits",
80        "//absl/numeric:int128",
81        "//absl/strings:cord_test_helpers",
82        "@com_google_googletest//:gtest_main",
83    ],
84)
85
86cc_binary(
87    name = "hash_benchmark",
88    testonly = 1,
89    srcs = ["hash_benchmark.cc"],
90    copts = ABSL_TEST_COPTS,
91    linkopts = ABSL_DEFAULT_LINKOPTS,
92    tags = ["benchmark"],
93    visibility = ["//visibility:private"],
94    deps = [
95        ":hash",
96        "//absl/base:core_headers",
97        "//absl/random",
98        "//absl/strings",
99        "//absl/strings:cord",
100        "//absl/strings:cord_test_helpers",
101        "@com_github_google_benchmark//:benchmark_main",
102    ],
103)
104
105cc_library(
106    name = "spy_hash_state",
107    testonly = 1,
108    hdrs = ["internal/spy_hash_state.h"],
109    copts = ABSL_DEFAULT_COPTS,
110    linkopts = ABSL_DEFAULT_LINKOPTS,
111    visibility = ["//visibility:private"],
112    deps = [
113        ":hash",
114        "//absl/strings",
115        "//absl/strings:str_format",
116    ],
117)
118
119cc_library(
120    name = "city",
121    srcs = ["internal/city.cc"],
122    hdrs = [
123        "internal/city.h",
124    ],
125    copts = ABSL_DEFAULT_COPTS,
126    linkopts = ABSL_DEFAULT_LINKOPTS,
127    deps = [
128        "//absl/base:config",
129        "//absl/base:core_headers",
130        "//absl/base:endian",
131    ],
132)
133
134cc_test(
135    name = "city_test",
136    srcs = ["internal/city_test.cc"],
137    copts = ABSL_TEST_COPTS,
138    linkopts = ABSL_DEFAULT_LINKOPTS,
139    deps = [
140        ":city",
141        "@com_google_googletest//:gtest_main",
142    ],
143)
144
145cc_library(
146    name = "wyhash",
147    srcs = ["internal/wyhash.cc"],
148    hdrs = ["internal/wyhash.h"],
149    copts = ABSL_DEFAULT_COPTS,
150    linkopts = ABSL_DEFAULT_LINKOPTS,
151    visibility = ["//visibility:private"],
152    deps = [
153        "//absl/base:config",
154        "//absl/base:endian",
155        "//absl/numeric:int128",
156    ],
157)
158
159cc_test(
160    name = "wyhash_test",
161    srcs = ["internal/wyhash_test.cc"],
162    copts = ABSL_TEST_COPTS,
163    linkopts = ABSL_DEFAULT_LINKOPTS,
164    visibility = ["//visibility:private"],
165    deps = [
166        ":wyhash",
167        "//absl/strings",
168        "@com_google_googletest//:gtest_main",
169    ],
170)
171