snappy-ruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +77 -0
- data/Rakefile +12 -0
- data/ext/snappy/extconf.rb +83 -0
- data/ext/snappy/snappy-src/AUTHORS +1 -0
- data/ext/snappy/snappy-src/BUILD.bazel +211 -0
- data/ext/snappy/snappy-src/CMakeLists.txt +467 -0
- data/ext/snappy/snappy-src/CONTRIBUTING.md +31 -0
- data/ext/snappy/snappy-src/COPYING +54 -0
- data/ext/snappy/snappy-src/MODULE.bazel +23 -0
- data/ext/snappy/snappy-src/NEWS +215 -0
- data/ext/snappy/snappy-src/README.md +165 -0
- data/ext/snappy/snappy-src/WORKSPACE +27 -0
- data/ext/snappy/snappy-src/WORKSPACE.bzlmod +0 -0
- data/ext/snappy/snappy-src/cmake/SnappyConfig.cmake.in +33 -0
- data/ext/snappy/snappy-src/cmake/config.h.in +75 -0
- data/ext/snappy/snappy-src/config.h +78 -0
- data/ext/snappy/snappy-src/docs/README.md +72 -0
- data/ext/snappy/snappy-src/format_description.txt +110 -0
- data/ext/snappy/snappy-src/framing_format.txt +135 -0
- data/ext/snappy/snappy-src/snappy-c.cc +90 -0
- data/ext/snappy/snappy-src/snappy-c.h +138 -0
- data/ext/snappy/snappy-src/snappy-internal.h +444 -0
- data/ext/snappy/snappy-src/snappy-sinksource.cc +121 -0
- data/ext/snappy/snappy-src/snappy-sinksource.h +182 -0
- data/ext/snappy/snappy-src/snappy-stubs-internal.cc +42 -0
- data/ext/snappy/snappy-src/snappy-stubs-internal.h +531 -0
- data/ext/snappy/snappy-src/snappy-stubs-public.h +60 -0
- data/ext/snappy/snappy-src/snappy-stubs-public.h.in +63 -0
- data/ext/snappy/snappy-src/snappy-test.cc +503 -0
- data/ext/snappy/snappy-src/snappy-test.h +342 -0
- data/ext/snappy/snappy-src/snappy.cc +2666 -0
- data/ext/snappy/snappy-src/snappy.h +257 -0
- data/ext/snappy/snappy-src/snappy_test_data.cc +57 -0
- data/ext/snappy/snappy-src/snappy_test_data.h +68 -0
- data/ext/snappy/snappy-src/snappy_test_tool.cc +471 -0
- data/ext/snappy/snappy-src/snappy_unittest.cc +1023 -0
- data/ext/snappy/snappy.c +282 -0
- data/lib/snappy/snappy.so +0 -0
- data/lib/snappy.rb +5 -0
- metadata +142 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
# Copyright 2019 Google Inc. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Redistribution and use in source and binary forms, with or without
|
|
4
|
+
# modification, are permitted provided that the following conditions are
|
|
5
|
+
# met:
|
|
6
|
+
#
|
|
7
|
+
# * Redistributions of source code must retain the above copyright
|
|
8
|
+
# notice, this list of conditions and the following disclaimer.
|
|
9
|
+
# * Redistributions in binary form must reproduce the above
|
|
10
|
+
# copyright notice, this list of conditions and the following disclaimer
|
|
11
|
+
# in the documentation and/or other materials provided with the
|
|
12
|
+
# distribution.
|
|
13
|
+
# * Neither the name of Google Inc. nor the names of its
|
|
14
|
+
# contributors may be used to endorse or promote products derived from
|
|
15
|
+
# this software without specific prior written permission.
|
|
16
|
+
#
|
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
19
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
20
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
21
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
22
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
23
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
24
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
25
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
29
|
+
cmake_minimum_required(VERSION 3.10)
|
|
30
|
+
project(Snappy VERSION 1.2.2 LANGUAGES C CXX)
|
|
31
|
+
|
|
32
|
+
# C++ standard can be overridden when this is used as a sub-project.
|
|
33
|
+
if(NOT CMAKE_CXX_STANDARD)
|
|
34
|
+
# This project requires C++11.
|
|
35
|
+
set(CMAKE_CXX_STANDARD 11)
|
|
36
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
37
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
38
|
+
endif(NOT CMAKE_CXX_STANDARD)
|
|
39
|
+
|
|
40
|
+
# https://github.com/izenecloud/cmake/blob/master/SetCompilerWarningAll.cmake
|
|
41
|
+
if(MSVC)
|
|
42
|
+
# Use the highest warning level for Visual Studio.
|
|
43
|
+
set(CMAKE_CXX_WARNING_LEVEL 4)
|
|
44
|
+
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
|
45
|
+
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
46
|
+
else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
|
47
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
|
48
|
+
endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
|
49
|
+
|
|
50
|
+
# Disable C++ exceptions.
|
|
51
|
+
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
52
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c-")
|
|
53
|
+
add_definitions(-D_HAS_EXCEPTIONS=0)
|
|
54
|
+
|
|
55
|
+
# Disable RTTI.
|
|
56
|
+
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
57
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
|
|
58
|
+
else(MSVC)
|
|
59
|
+
# Use -Wall for clang and gcc.
|
|
60
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
|
|
61
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
|
62
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
|
|
63
|
+
|
|
64
|
+
# Use -Wextra for clang and gcc.
|
|
65
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
|
|
66
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
|
|
67
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra")
|
|
68
|
+
|
|
69
|
+
# Use -Werror for clang only.
|
|
70
|
+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
71
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-Werror")
|
|
72
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
|
73
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Werror")
|
|
74
|
+
endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
75
|
+
|
|
76
|
+
# Disable sign comparison warnings. Matches upcoming Bazel setup.
|
|
77
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wno-sign-compare")
|
|
78
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
|
|
79
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wno-sign-compare")
|
|
80
|
+
|
|
81
|
+
# Disable C++ exceptions.
|
|
82
|
+
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
83
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
|
84
|
+
|
|
85
|
+
# Disable RTTI.
|
|
86
|
+
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
87
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
|
88
|
+
endif(MSVC)
|
|
89
|
+
|
|
90
|
+
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make
|
|
91
|
+
# it prominent in the GUI.
|
|
92
|
+
option(BUILD_SHARED_LIBS "Build shared libraries(DLLs)." OFF)
|
|
93
|
+
|
|
94
|
+
option(SNAPPY_BUILD_TESTS "Build Snappy's own tests." ON)
|
|
95
|
+
|
|
96
|
+
option(SNAPPY_BUILD_BENCHMARKS "Build Snappy's benchmarks" ON)
|
|
97
|
+
|
|
98
|
+
option(SNAPPY_FUZZING_BUILD "Build Snappy for fuzzing." OFF)
|
|
99
|
+
|
|
100
|
+
option(SNAPPY_REQUIRE_AVX "Target processors with AVX support." OFF)
|
|
101
|
+
|
|
102
|
+
option(SNAPPY_REQUIRE_AVX2 "Target processors with AVX2 support." OFF)
|
|
103
|
+
|
|
104
|
+
option(SNAPPY_INSTALL "Install Snappy's header and library" ON)
|
|
105
|
+
|
|
106
|
+
include(TestBigEndian)
|
|
107
|
+
test_big_endian(SNAPPY_IS_BIG_ENDIAN)
|
|
108
|
+
|
|
109
|
+
include(CheckIncludeFile)
|
|
110
|
+
check_include_file("sys/mman.h" HAVE_SYS_MMAN_H)
|
|
111
|
+
check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H)
|
|
112
|
+
check_include_file("sys/time.h" HAVE_SYS_TIME_H)
|
|
113
|
+
check_include_file("sys/uio.h" HAVE_SYS_UIO_H)
|
|
114
|
+
check_include_file("unistd.h" HAVE_UNISTD_H)
|
|
115
|
+
check_include_file("windows.h" HAVE_WINDOWS_H)
|
|
116
|
+
|
|
117
|
+
include(CheckLibraryExists)
|
|
118
|
+
check_library_exists(z zlibVersion "" HAVE_LIBZ)
|
|
119
|
+
check_library_exists(lzo2 lzo1x_1_15_compress "" HAVE_LIBLZO2)
|
|
120
|
+
check_library_exists(lz4 LZ4_compress_default "" HAVE_LIBLZ4)
|
|
121
|
+
|
|
122
|
+
include(CheckCXXCompilerFlag)
|
|
123
|
+
CHECK_CXX_COMPILER_FLAG("/arch:AVX" HAVE_VISUAL_STUDIO_ARCH_AVX)
|
|
124
|
+
CHECK_CXX_COMPILER_FLAG("/arch:AVX2" HAVE_VISUAL_STUDIO_ARCH_AVX2)
|
|
125
|
+
CHECK_CXX_COMPILER_FLAG("-mavx" HAVE_CLANG_MAVX)
|
|
126
|
+
CHECK_CXX_COMPILER_FLAG("-mbmi2" HAVE_CLANG_MBMI2)
|
|
127
|
+
if(SNAPPY_REQUIRE_AVX2)
|
|
128
|
+
if(HAVE_VISUAL_STUDIO_ARCH_AVX2)
|
|
129
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
|
|
130
|
+
endif(HAVE_VISUAL_STUDIO_ARCH_AVX2)
|
|
131
|
+
if(HAVE_CLANG_MAVX)
|
|
132
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
|
133
|
+
endif(HAVE_CLANG_MAVX)
|
|
134
|
+
if(HAVE_CLANG_MBMI2)
|
|
135
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mbmi2")
|
|
136
|
+
endif(HAVE_CLANG_MBMI2)
|
|
137
|
+
elseif (SNAPPY_REQUIRE_AVX)
|
|
138
|
+
if(HAVE_VISUAL_STUDIO_ARCH_AVX)
|
|
139
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX")
|
|
140
|
+
endif(HAVE_VISUAL_STUDIO_ARCH_AVX)
|
|
141
|
+
if(HAVE_CLANG_MAVX)
|
|
142
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
|
143
|
+
endif(HAVE_CLANG_MAVX)
|
|
144
|
+
endif(SNAPPY_REQUIRE_AVX2)
|
|
145
|
+
|
|
146
|
+
# Used by googletest.
|
|
147
|
+
check_cxx_compiler_flag(-Wno-missing-field-initializers
|
|
148
|
+
SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
|
|
149
|
+
check_cxx_compiler_flag(-Wno-implicit-int-float-conversion
|
|
150
|
+
SNAPPY_HAVE_NO_IMPLICIT_INT_FLOAT_CONVERSION)
|
|
151
|
+
|
|
152
|
+
include(CheckCXXSourceCompiles)
|
|
153
|
+
check_cxx_source_compiles("
|
|
154
|
+
int main() {
|
|
155
|
+
return __builtin_expect(0, 1);
|
|
156
|
+
}" HAVE_BUILTIN_EXPECT)
|
|
157
|
+
|
|
158
|
+
check_cxx_source_compiles("
|
|
159
|
+
int main() {
|
|
160
|
+
return __builtin_ctzll(0);
|
|
161
|
+
}" HAVE_BUILTIN_CTZ)
|
|
162
|
+
|
|
163
|
+
check_cxx_source_compiles("
|
|
164
|
+
int main() {
|
|
165
|
+
__builtin_prefetch(0, 0, 3);
|
|
166
|
+
return 0;
|
|
167
|
+
}" HAVE_BUILTIN_PREFETCH)
|
|
168
|
+
|
|
169
|
+
check_cxx_source_compiles("
|
|
170
|
+
__attribute__((always_inline)) int zero() { return 0; }
|
|
171
|
+
|
|
172
|
+
int main() {
|
|
173
|
+
return zero();
|
|
174
|
+
}" HAVE_ATTRIBUTE_ALWAYS_INLINE)
|
|
175
|
+
|
|
176
|
+
check_cxx_source_compiles("
|
|
177
|
+
#include <tmmintrin.h>
|
|
178
|
+
|
|
179
|
+
int main() {
|
|
180
|
+
const __m128i *src = 0;
|
|
181
|
+
__m128i dest;
|
|
182
|
+
const __m128i shuffle_mask = _mm_load_si128(src);
|
|
183
|
+
const __m128i pattern = _mm_shuffle_epi8(_mm_loadl_epi64(src), shuffle_mask);
|
|
184
|
+
_mm_storeu_si128(&dest, pattern);
|
|
185
|
+
return 0;
|
|
186
|
+
}" SNAPPY_HAVE_SSSE3)
|
|
187
|
+
|
|
188
|
+
check_cxx_source_compiles("
|
|
189
|
+
#include <immintrin.h>
|
|
190
|
+
int main() {
|
|
191
|
+
return _mm_crc32_u32(0, 1);
|
|
192
|
+
}" SNAPPY_HAVE_X86_CRC32)
|
|
193
|
+
|
|
194
|
+
check_cxx_source_compiles("
|
|
195
|
+
#include <arm_neon.h>
|
|
196
|
+
#include <arm_acle.h>
|
|
197
|
+
int main() {
|
|
198
|
+
return __crc32cw(0, 1);
|
|
199
|
+
}" SNAPPY_HAVE_NEON_CRC32)
|
|
200
|
+
|
|
201
|
+
check_cxx_source_compiles("
|
|
202
|
+
#include <immintrin.h>
|
|
203
|
+
int main() {
|
|
204
|
+
return _bzhi_u32(0, 1);
|
|
205
|
+
}" SNAPPY_HAVE_BMI2)
|
|
206
|
+
|
|
207
|
+
check_cxx_source_compiles("
|
|
208
|
+
#include <arm_neon.h>
|
|
209
|
+
#include <stdint.h>
|
|
210
|
+
int main() {
|
|
211
|
+
uint8_t val = 3, dup[8];
|
|
212
|
+
uint8x16_t v1 = vld1q_dup_u8(&val);
|
|
213
|
+
uint8x16_t v2 = vqtbl1q_u8(v1, v1);
|
|
214
|
+
vst1q_u8(dup, v1);
|
|
215
|
+
vst1q_u8(dup, v2);
|
|
216
|
+
return 0;
|
|
217
|
+
}" SNAPPY_HAVE_NEON)
|
|
218
|
+
|
|
219
|
+
#check RVV 1.0 need __riscv_ prefix
|
|
220
|
+
check_cxx_source_compiles("
|
|
221
|
+
#include <riscv_vector.h>
|
|
222
|
+
#include <stdint.h>
|
|
223
|
+
#include <stddef.h>
|
|
224
|
+
int main() {
|
|
225
|
+
uint8_t val = 3, dup[8];
|
|
226
|
+
size_t vl = __riscv_vsetvl_e8m1(8);
|
|
227
|
+
vuint8m1_t v = __riscv_vmv_v_x_u8m1(val, vl);
|
|
228
|
+
return 0;
|
|
229
|
+
}" SNAPPY_RVV_1)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
#check RVV 0.7.1 not __riscv_ prefix
|
|
233
|
+
check_cxx_source_compiles("
|
|
234
|
+
#include <riscv_vector.h>
|
|
235
|
+
#include <stdint.h>
|
|
236
|
+
#include <stddef.h>
|
|
237
|
+
int main() {
|
|
238
|
+
uint8_t val = 3, dup[8];
|
|
239
|
+
size_t vl = vsetvl_e8m1(8);
|
|
240
|
+
vuint8m1_t v = vmv_v_x_u8m1(val, vl);
|
|
241
|
+
return 0;
|
|
242
|
+
}" SNAPPY_RVV_0_7)
|
|
243
|
+
|
|
244
|
+
include(CheckSymbolExists)
|
|
245
|
+
check_symbol_exists("mmap" "sys/mman.h" HAVE_FUNC_MMAP)
|
|
246
|
+
check_symbol_exists("sysconf" "unistd.h" HAVE_FUNC_SYSCONF)
|
|
247
|
+
|
|
248
|
+
configure_file(
|
|
249
|
+
"cmake/config.h.in"
|
|
250
|
+
"${PROJECT_BINARY_DIR}/config.h"
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
# We don't want to define HAVE_ macros in public headers. Instead, we use
|
|
254
|
+
# CMake's variable substitution with 0/1 variables, which will be seen by the
|
|
255
|
+
# preprocessor as constants.
|
|
256
|
+
set(HAVE_SYS_UIO_H_01 ${HAVE_SYS_UIO_H})
|
|
257
|
+
if(NOT HAVE_SYS_UIO_H_01)
|
|
258
|
+
set(HAVE_SYS_UIO_H_01 0)
|
|
259
|
+
endif(NOT HAVE_SYS_UIO_H_01)
|
|
260
|
+
|
|
261
|
+
if (SNAPPY_FUZZING_BUILD)
|
|
262
|
+
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
263
|
+
message(WARNING "Fuzzing builds are only supported with Clang")
|
|
264
|
+
endif (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
265
|
+
|
|
266
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=address")
|
|
267
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
|
268
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=address")
|
|
269
|
+
|
|
270
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=fuzzer-no-link")
|
|
271
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer-no-link")
|
|
272
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=fuzzer-no-link")
|
|
273
|
+
endif (SNAPPY_FUZZING_BUILD)
|
|
274
|
+
|
|
275
|
+
configure_file(
|
|
276
|
+
"snappy-stubs-public.h.in"
|
|
277
|
+
"${PROJECT_BINARY_DIR}/snappy-stubs-public.h")
|
|
278
|
+
|
|
279
|
+
add_library(snappy "")
|
|
280
|
+
target_sources(snappy
|
|
281
|
+
PRIVATE
|
|
282
|
+
"snappy-internal.h"
|
|
283
|
+
"snappy-stubs-internal.h"
|
|
284
|
+
"snappy-c.cc"
|
|
285
|
+
"snappy-sinksource.cc"
|
|
286
|
+
"snappy-stubs-internal.cc"
|
|
287
|
+
"snappy.cc"
|
|
288
|
+
"${PROJECT_BINARY_DIR}/config.h"
|
|
289
|
+
PUBLIC
|
|
290
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-c.h>
|
|
291
|
+
$<INSTALL_INTERFACE:include/snappy-c.h>
|
|
292
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-sinksource.h>
|
|
293
|
+
$<INSTALL_INTERFACE:include/snappy-sinksource.h>
|
|
294
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy.h>
|
|
295
|
+
$<INSTALL_INTERFACE:include/snappy.h>
|
|
296
|
+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/snappy-stubs-public.h>
|
|
297
|
+
$<INSTALL_INTERFACE:include/snappy-stubs-public.h>
|
|
298
|
+
)
|
|
299
|
+
target_include_directories(snappy
|
|
300
|
+
PUBLIC
|
|
301
|
+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
|
|
302
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
|
303
|
+
$<INSTALL_INTERFACE:include>
|
|
304
|
+
)
|
|
305
|
+
set_target_properties(snappy
|
|
306
|
+
PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
|
|
307
|
+
|
|
308
|
+
target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H)
|
|
309
|
+
if(BUILD_SHARED_LIBS)
|
|
310
|
+
set_target_properties(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
311
|
+
endif(BUILD_SHARED_LIBS)
|
|
312
|
+
|
|
313
|
+
if(SNAPPY_BUILD_TESTS OR SNAPPY_BUILD_BENCHMARKS)
|
|
314
|
+
add_library(snappy_test_support "")
|
|
315
|
+
target_sources(snappy_test_support
|
|
316
|
+
PRIVATE
|
|
317
|
+
"snappy-test.cc"
|
|
318
|
+
"snappy-test.h"
|
|
319
|
+
"snappy_test_data.cc"
|
|
320
|
+
"snappy_test_data.h"
|
|
321
|
+
"${PROJECT_BINARY_DIR}/config.h"
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
# Test files include snappy-test.h, HAVE_CONFIG_H must be defined.
|
|
325
|
+
target_compile_definitions(snappy_test_support PUBLIC -DHAVE_CONFIG_H)
|
|
326
|
+
if(BUILD_SHARED_LIBS)
|
|
327
|
+
set_target_properties(snappy_test_support PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
328
|
+
endif(BUILD_SHARED_LIBS)
|
|
329
|
+
|
|
330
|
+
target_link_libraries(snappy_test_support snappy)
|
|
331
|
+
|
|
332
|
+
if(HAVE_LIBZ)
|
|
333
|
+
target_link_libraries(snappy_test_support z)
|
|
334
|
+
endif(HAVE_LIBZ)
|
|
335
|
+
if(HAVE_LIBLZO2)
|
|
336
|
+
target_link_libraries(snappy_test_support lzo2)
|
|
337
|
+
endif(HAVE_LIBLZO2)
|
|
338
|
+
if(HAVE_LIBLZ4)
|
|
339
|
+
target_link_libraries(snappy_test_support lz4)
|
|
340
|
+
endif(HAVE_LIBLZ4)
|
|
341
|
+
|
|
342
|
+
target_include_directories(snappy_test_support
|
|
343
|
+
BEFORE PUBLIC
|
|
344
|
+
"${PROJECT_SOURCE_DIR}"
|
|
345
|
+
)
|
|
346
|
+
endif(SNAPPY_BUILD_TESTS OR SNAPPY_BUILD_BENCHMARKS)
|
|
347
|
+
|
|
348
|
+
if(SNAPPY_BUILD_TESTS)
|
|
349
|
+
enable_testing()
|
|
350
|
+
|
|
351
|
+
# Prevent overriding the parent project's compiler/linker settings on Windows.
|
|
352
|
+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
353
|
+
set(install_gtest OFF)
|
|
354
|
+
set(install_gmock OFF)
|
|
355
|
+
set(build_gmock ON)
|
|
356
|
+
|
|
357
|
+
# This project is tested using GoogleTest.
|
|
358
|
+
add_subdirectory("third_party/googletest")
|
|
359
|
+
|
|
360
|
+
# GoogleTest triggers a missing field initializers warning.
|
|
361
|
+
if(SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
|
|
362
|
+
set_property(TARGET gtest
|
|
363
|
+
APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
|
|
364
|
+
set_property(TARGET gmock
|
|
365
|
+
APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
|
|
366
|
+
endif(SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
|
|
367
|
+
|
|
368
|
+
if(SNAPPY_HAVE_NO_IMPLICIT_INT_FLOAT_CONVERSION)
|
|
369
|
+
set_property(TARGET gtest
|
|
370
|
+
APPEND PROPERTY COMPILE_OPTIONS -Wno-implicit-int-float-conversion)
|
|
371
|
+
endif(SNAPPY_HAVE_NO_IMPLICIT_INT_FLOAT_CONVERSION)
|
|
372
|
+
|
|
373
|
+
add_executable(snappy_unittest "")
|
|
374
|
+
target_sources(snappy_unittest
|
|
375
|
+
PRIVATE
|
|
376
|
+
"snappy_unittest.cc"
|
|
377
|
+
)
|
|
378
|
+
target_link_libraries(snappy_unittest snappy_test_support gmock_main gtest)
|
|
379
|
+
|
|
380
|
+
add_test(
|
|
381
|
+
NAME snappy_unittest
|
|
382
|
+
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
|
383
|
+
COMMAND "${PROJECT_BINARY_DIR}/snappy_unittest")
|
|
384
|
+
|
|
385
|
+
add_executable(snappy_test_tool "")
|
|
386
|
+
target_sources(snappy_test_tool
|
|
387
|
+
PRIVATE
|
|
388
|
+
"snappy_test_tool.cc"
|
|
389
|
+
)
|
|
390
|
+
target_link_libraries(snappy_test_tool snappy_test_support)
|
|
391
|
+
endif(SNAPPY_BUILD_TESTS)
|
|
392
|
+
|
|
393
|
+
if(SNAPPY_BUILD_BENCHMARKS)
|
|
394
|
+
add_executable(snappy_benchmark "")
|
|
395
|
+
target_sources(snappy_benchmark
|
|
396
|
+
PRIVATE
|
|
397
|
+
"snappy_benchmark.cc"
|
|
398
|
+
)
|
|
399
|
+
target_link_libraries(snappy_benchmark snappy_test_support benchmark_main)
|
|
400
|
+
|
|
401
|
+
# This project uses Google benchmark for benchmarking.
|
|
402
|
+
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
|
|
403
|
+
set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "" FORCE)
|
|
404
|
+
add_subdirectory("third_party/benchmark")
|
|
405
|
+
endif(SNAPPY_BUILD_BENCHMARKS)
|
|
406
|
+
|
|
407
|
+
if(SNAPPY_FUZZING_BUILD)
|
|
408
|
+
add_executable(snappy_compress_fuzzer "")
|
|
409
|
+
target_sources(snappy_compress_fuzzer
|
|
410
|
+
PRIVATE "snappy_compress_fuzzer.cc"
|
|
411
|
+
)
|
|
412
|
+
target_link_libraries(snappy_compress_fuzzer snappy)
|
|
413
|
+
set_target_properties(snappy_compress_fuzzer
|
|
414
|
+
PROPERTIES LINK_FLAGS "-fsanitize=fuzzer"
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
add_executable(snappy_uncompress_fuzzer "")
|
|
418
|
+
target_sources(snappy_uncompress_fuzzer
|
|
419
|
+
PRIVATE "snappy_uncompress_fuzzer.cc"
|
|
420
|
+
)
|
|
421
|
+
target_link_libraries(snappy_uncompress_fuzzer snappy)
|
|
422
|
+
set_target_properties(snappy_uncompress_fuzzer
|
|
423
|
+
PROPERTIES LINK_FLAGS "-fsanitize=fuzzer"
|
|
424
|
+
)
|
|
425
|
+
endif(SNAPPY_FUZZING_BUILD)
|
|
426
|
+
|
|
427
|
+
# Must be included before CMAKE_INSTALL_INCLUDEDIR is used.
|
|
428
|
+
include(GNUInstallDirs)
|
|
429
|
+
|
|
430
|
+
if(SNAPPY_INSTALL)
|
|
431
|
+
install(TARGETS snappy
|
|
432
|
+
EXPORT SnappyTargets
|
|
433
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
434
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
435
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
436
|
+
)
|
|
437
|
+
install(
|
|
438
|
+
FILES
|
|
439
|
+
"snappy-c.h"
|
|
440
|
+
"snappy-sinksource.h"
|
|
441
|
+
"snappy.h"
|
|
442
|
+
"${PROJECT_BINARY_DIR}/snappy-stubs-public.h"
|
|
443
|
+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
include(CMakePackageConfigHelpers)
|
|
447
|
+
configure_package_config_file(
|
|
448
|
+
"cmake/${PROJECT_NAME}Config.cmake.in"
|
|
449
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
|
|
450
|
+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
|
451
|
+
)
|
|
452
|
+
write_basic_package_version_file(
|
|
453
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
|
|
454
|
+
COMPATIBILITY SameMajorVersion
|
|
455
|
+
)
|
|
456
|
+
install(
|
|
457
|
+
EXPORT SnappyTargets
|
|
458
|
+
NAMESPACE Snappy::
|
|
459
|
+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
|
460
|
+
)
|
|
461
|
+
install(
|
|
462
|
+
FILES
|
|
463
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
|
|
464
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
|
|
465
|
+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
|
466
|
+
)
|
|
467
|
+
endif(SNAPPY_INSTALL)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# How to Contribute
|
|
2
|
+
|
|
3
|
+
We'd love to accept your patches and contributions to this project. There are
|
|
4
|
+
just a few small guidelines you need to follow.
|
|
5
|
+
|
|
6
|
+
## Contributor License Agreement
|
|
7
|
+
|
|
8
|
+
Contributions to this project must be accompanied by a Contributor License
|
|
9
|
+
Agreement. You (or your employer) retain the copyright to your contribution;
|
|
10
|
+
this simply gives us permission to use and redistribute your contributions as
|
|
11
|
+
part of the project. Head over to <https://cla.developers.google.com/> to see
|
|
12
|
+
your current agreements on file or to sign a new one.
|
|
13
|
+
|
|
14
|
+
You generally only need to submit a CLA once, so if you've already submitted one
|
|
15
|
+
(even if it was for a different project), you probably don't need to do it
|
|
16
|
+
again.
|
|
17
|
+
|
|
18
|
+
## Code Reviews
|
|
19
|
+
|
|
20
|
+
All submissions, including submissions by project members, require review. We
|
|
21
|
+
use GitHub pull requests for this purpose. Consult
|
|
22
|
+
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
|
|
23
|
+
information on using pull requests.
|
|
24
|
+
|
|
25
|
+
See [the README](README.md#contributing-to-the-snappy-project) for areas
|
|
26
|
+
where we are likely to accept external contributions.
|
|
27
|
+
|
|
28
|
+
## Community Guidelines
|
|
29
|
+
|
|
30
|
+
This project follows [Google's Open Source Community
|
|
31
|
+
Guidelines](https://opensource.google/conduct/).
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Copyright 2011, Google Inc.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are
|
|
6
|
+
met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
* Redistributions in binary form must reproduce the above
|
|
11
|
+
copyright notice, this list of conditions and the following disclaimer
|
|
12
|
+
in the documentation and/or other materials provided with the
|
|
13
|
+
distribution.
|
|
14
|
+
* Neither the name of Google Inc. nor the names of its
|
|
15
|
+
contributors may be used to endorse or promote products derived from
|
|
16
|
+
this software without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
19
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
20
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
21
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
22
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
23
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
24
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
25
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
26
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
27
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
|
|
30
|
+
===
|
|
31
|
+
|
|
32
|
+
Some of the benchmark data in testdata/ is licensed differently:
|
|
33
|
+
|
|
34
|
+
- fireworks.jpeg is Copyright 2013 Steinar H. Gunderson, and
|
|
35
|
+
is licensed under the Creative Commons Attribution 3.0 license
|
|
36
|
+
(CC-BY-3.0). See https://creativecommons.org/licenses/by/3.0/
|
|
37
|
+
for more information.
|
|
38
|
+
|
|
39
|
+
- kppkn.gtb is taken from the Gaviota chess tablebase set, and
|
|
40
|
+
is licensed under the MIT License. See
|
|
41
|
+
https://sites.google.com/site/gaviotachessengine/Home/endgame-tablebases-1
|
|
42
|
+
for more information.
|
|
43
|
+
|
|
44
|
+
- paper-100k.pdf is an excerpt (bytes 92160 to 194560) from the paper
|
|
45
|
+
“Combinatorial Modeling of Chromatin Features Quantitatively Predicts DNA
|
|
46
|
+
Replication Timing in _Drosophila_” by Federico Comoglio and Renato Paro,
|
|
47
|
+
which is licensed under the CC-BY license. See
|
|
48
|
+
http://www.ploscompbiol.org/static/license for more ifnormation.
|
|
49
|
+
|
|
50
|
+
- alice29.txt, asyoulik.txt, plrabn12.txt and lcet10.txt are from Project
|
|
51
|
+
Gutenberg. The first three have expired copyrights and are in the public
|
|
52
|
+
domain; the latter does not have expired copyright, but is still in the
|
|
53
|
+
public domain according to the license information
|
|
54
|
+
(http://www.gutenberg.org/ebooks/53).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module(
|
|
2
|
+
name = "snappy",
|
|
3
|
+
version = "1.2.2",
|
|
4
|
+
compatibility_level = 1,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
bazel_dep(
|
|
8
|
+
name = "googletest",
|
|
9
|
+
version = "1.14.0.bcr.1",
|
|
10
|
+
dev_dependency = True,
|
|
11
|
+
repo_name = "com_google_googletest",
|
|
12
|
+
)
|
|
13
|
+
bazel_dep(
|
|
14
|
+
name = "google_benchmark",
|
|
15
|
+
version = "1.9.0",
|
|
16
|
+
dev_dependency = True,
|
|
17
|
+
repo_name = "com_google_benchmark",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
bazel_dep(
|
|
21
|
+
name = "platforms",
|
|
22
|
+
version = "0.0.9",
|
|
23
|
+
)
|