couchbase 3.0.0.alpha.1-universal-darwin-19 → 3.0.0.alpha.2-universal-darwin-19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests-6.0.3.yml +49 -0
- data/.github/workflows/tests.yml +47 -0
- data/.gitmodules +3 -0
- data/.idea/dictionaries/gem_terms.xml +5 -0
- data/.idea/inspectionProfiles/Project_Default.xml +1 -0
- data/.idea/vcs.xml +1 -0
- data/Gemfile +1 -0
- data/README.md +55 -2
- data/Rakefile +18 -0
- data/bin/init-cluster +62 -0
- data/bin/setup +1 -0
- data/couchbase.gemspec +3 -2
- data/examples/crud.rb +1 -2
- data/examples/managing_buckets.rb +47 -0
- data/examples/managing_collections.rb +58 -0
- data/examples/managing_query_indexes.rb +63 -0
- data/examples/query.rb +3 -2
- data/examples/query_with_consistency.rb +76 -0
- data/examples/subdocument.rb +23 -1
- data/ext/.clang-format +1 -1
- data/ext/.idea/dictionaries/couchbase_terms.xml +2 -0
- data/ext/.idea/vcs.xml +1 -0
- data/ext/CMakeLists.txt +30 -12
- data/ext/build_version.hxx.in +26 -0
- data/ext/couchbase/bucket.hxx +69 -8
- data/ext/couchbase/cluster.hxx +70 -54
- data/ext/couchbase/collections_manifest.hxx +3 -3
- data/ext/couchbase/configuration.hxx +14 -0
- data/ext/couchbase/couchbase.cxx +2044 -383
- data/ext/couchbase/{operations/document_id.hxx → document_id.hxx} +5 -4
- data/ext/couchbase/io/http_message.hxx +5 -1
- data/ext/couchbase/io/http_parser.hxx +2 -1
- data/ext/couchbase/io/http_session.hxx +6 -3
- data/ext/couchbase/io/{binary_message.hxx → mcbp_message.hxx} +15 -12
- data/ext/couchbase/io/mcbp_parser.hxx +99 -0
- data/ext/couchbase/io/{key_value_session.hxx → mcbp_session.hxx} +200 -95
- data/ext/couchbase/io/session_manager.hxx +37 -22
- data/ext/couchbase/mutation_token.hxx +2 -1
- data/ext/couchbase/operations.hxx +38 -8
- data/ext/couchbase/operations/bucket_create.hxx +138 -0
- data/ext/couchbase/operations/bucket_drop.hxx +65 -0
- data/ext/couchbase/operations/bucket_flush.hxx +65 -0
- data/ext/couchbase/operations/bucket_get.hxx +69 -0
- data/ext/couchbase/operations/bucket_get_all.hxx +62 -0
- data/ext/couchbase/operations/bucket_settings.hxx +111 -0
- data/ext/couchbase/operations/bucket_update.hxx +115 -0
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +60 -0
- data/ext/couchbase/operations/collection_create.hxx +86 -0
- data/ext/couchbase/operations/collection_drop.hxx +82 -0
- data/ext/couchbase/operations/command.hxx +10 -10
- data/ext/couchbase/operations/document_decrement.hxx +80 -0
- data/ext/couchbase/operations/document_exists.hxx +80 -0
- data/ext/couchbase/operations/{get.hxx → document_get.hxx} +4 -2
- data/ext/couchbase/operations/document_get_and_lock.hxx +64 -0
- data/ext/couchbase/operations/document_get_and_touch.hxx +64 -0
- data/ext/couchbase/operations/document_increment.hxx +80 -0
- data/ext/couchbase/operations/document_insert.hxx +74 -0
- data/ext/couchbase/operations/{lookup_in.hxx → document_lookup_in.hxx} +2 -2
- data/ext/couchbase/operations/{mutate_in.hxx → document_mutate_in.hxx} +11 -2
- data/ext/couchbase/operations/{query.hxx → document_query.hxx} +101 -6
- data/ext/couchbase/operations/document_remove.hxx +67 -0
- data/ext/couchbase/operations/document_replace.hxx +76 -0
- data/ext/couchbase/operations/{upsert.hxx → document_touch.hxx} +14 -14
- data/ext/couchbase/operations/{remove.hxx → document_unlock.hxx} +12 -10
- data/ext/couchbase/operations/document_upsert.hxx +74 -0
- data/ext/couchbase/operations/query_index_build_deferred.hxx +85 -0
- data/ext/couchbase/operations/query_index_create.hxx +134 -0
- data/ext/couchbase/operations/query_index_drop.hxx +108 -0
- data/ext/couchbase/operations/query_index_get_all.hxx +106 -0
- data/ext/couchbase/operations/scope_create.hxx +81 -0
- data/ext/couchbase/operations/scope_drop.hxx +79 -0
- data/ext/couchbase/operations/scope_get_all.hxx +72 -0
- data/ext/couchbase/protocol/client_opcode.hxx +35 -0
- data/ext/couchbase/protocol/client_request.hxx +56 -9
- data/ext/couchbase/protocol/client_response.hxx +52 -15
- data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +81 -0
- data/ext/couchbase/protocol/cmd_decrement.hxx +187 -0
- data/ext/couchbase/protocol/cmd_exists.hxx +171 -0
- data/ext/couchbase/protocol/cmd_get.hxx +31 -8
- data/ext/couchbase/protocol/cmd_get_and_lock.hxx +142 -0
- data/ext/couchbase/protocol/cmd_get_and_touch.hxx +142 -0
- data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +16 -3
- data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +16 -3
- data/ext/couchbase/protocol/cmd_get_error_map.hxx +16 -3
- data/ext/couchbase/protocol/cmd_hello.hxx +24 -8
- data/ext/couchbase/protocol/cmd_increment.hxx +187 -0
- data/ext/couchbase/protocol/cmd_info.hxx +1 -0
- data/ext/couchbase/protocol/cmd_insert.hxx +172 -0
- data/ext/couchbase/protocol/cmd_lookup_in.hxx +28 -13
- data/ext/couchbase/protocol/cmd_mutate_in.hxx +65 -13
- data/ext/couchbase/protocol/cmd_remove.hxx +59 -4
- data/ext/couchbase/protocol/cmd_replace.hxx +172 -0
- data/ext/couchbase/protocol/cmd_sasl_auth.hxx +15 -3
- data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +15 -3
- data/ext/couchbase/protocol/cmd_sasl_step.hxx +15 -3
- data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -2
- data/ext/couchbase/protocol/cmd_touch.hxx +102 -0
- data/ext/couchbase/protocol/cmd_unlock.hxx +95 -0
- data/ext/couchbase/protocol/cmd_upsert.hxx +50 -14
- data/ext/couchbase/protocol/durability_level.hxx +67 -0
- data/ext/couchbase/protocol/frame_info_id.hxx +187 -0
- data/ext/couchbase/protocol/hello_feature.hxx +137 -0
- data/ext/couchbase/protocol/server_opcode.hxx +57 -0
- data/ext/couchbase/protocol/server_request.hxx +122 -0
- data/ext/couchbase/protocol/unsigned_leb128.h +15 -15
- data/ext/couchbase/utils/byteswap.hxx +1 -2
- data/ext/couchbase/utils/url_codec.hxx +225 -0
- data/ext/couchbase/version.hxx +3 -1
- data/ext/extconf.rb +4 -1
- data/ext/test/main.cxx +37 -113
- data/ext/third_party/snappy/.appveyor.yml +36 -0
- data/ext/third_party/snappy/.gitignore +8 -0
- data/ext/third_party/snappy/.travis.yml +98 -0
- data/ext/third_party/snappy/AUTHORS +1 -0
- data/ext/third_party/snappy/CMakeLists.txt +345 -0
- data/ext/third_party/snappy/CONTRIBUTING.md +26 -0
- data/ext/third_party/snappy/COPYING +54 -0
- data/ext/third_party/snappy/NEWS +188 -0
- data/ext/third_party/snappy/README.md +148 -0
- data/ext/third_party/snappy/cmake/SnappyConfig.cmake.in +33 -0
- data/ext/third_party/snappy/cmake/config.h.in +59 -0
- data/ext/third_party/snappy/docs/README.md +72 -0
- data/ext/third_party/snappy/format_description.txt +110 -0
- data/ext/third_party/snappy/framing_format.txt +135 -0
- data/ext/third_party/snappy/snappy-c.cc +90 -0
- data/ext/third_party/snappy/snappy-c.h +138 -0
- data/ext/third_party/snappy/snappy-internal.h +315 -0
- data/ext/third_party/snappy/snappy-sinksource.cc +121 -0
- data/ext/third_party/snappy/snappy-sinksource.h +182 -0
- data/ext/third_party/snappy/snappy-stubs-internal.cc +42 -0
- data/ext/third_party/snappy/snappy-stubs-internal.h +493 -0
- data/ext/third_party/snappy/snappy-stubs-public.h.in +63 -0
- data/ext/third_party/snappy/snappy-test.cc +613 -0
- data/ext/third_party/snappy/snappy-test.h +526 -0
- data/ext/third_party/snappy/snappy.cc +1770 -0
- data/ext/third_party/snappy/snappy.h +209 -0
- data/ext/third_party/snappy/snappy_compress_fuzzer.cc +60 -0
- data/ext/third_party/snappy/snappy_uncompress_fuzzer.cc +58 -0
- data/ext/third_party/snappy/snappy_unittest.cc +1512 -0
- data/ext/third_party/snappy/testdata/alice29.txt +3609 -0
- data/ext/third_party/snappy/testdata/asyoulik.txt +4122 -0
- data/ext/third_party/snappy/testdata/baddata1.snappy +0 -0
- data/ext/third_party/snappy/testdata/baddata2.snappy +0 -0
- data/ext/third_party/snappy/testdata/baddata3.snappy +0 -0
- data/ext/third_party/snappy/testdata/fireworks.jpeg +0 -0
- data/ext/third_party/snappy/testdata/geo.protodata +0 -0
- data/ext/third_party/snappy/testdata/html +1 -0
- data/ext/third_party/snappy/testdata/html_x_4 +1 -0
- data/ext/third_party/snappy/testdata/kppkn.gtb +0 -0
- data/ext/third_party/snappy/testdata/lcet10.txt +7519 -0
- data/ext/third_party/snappy/testdata/paper-100k.pdf +600 -2
- data/ext/third_party/snappy/testdata/plrabn12.txt +10699 -0
- data/ext/third_party/snappy/testdata/urls.10K +10000 -0
- data/lib/couchbase/binary_collection.rb +33 -76
- data/lib/couchbase/binary_collection_options.rb +94 -0
- data/lib/couchbase/bucket.rb +9 -3
- data/lib/couchbase/cluster.rb +161 -23
- data/lib/couchbase/collection.rb +108 -191
- data/lib/couchbase/collection_options.rb +430 -0
- data/lib/couchbase/errors.rb +136 -134
- data/lib/couchbase/json_transcoder.rb +32 -0
- data/lib/couchbase/management/analytics_index_manager.rb +185 -9
- data/lib/couchbase/management/bucket_manager.rb +84 -33
- data/lib/couchbase/management/collection_manager.rb +166 -1
- data/lib/couchbase/management/query_index_manager.rb +261 -0
- data/lib/couchbase/management/search_index_manager.rb +291 -0
- data/lib/couchbase/management/user_manager.rb +12 -10
- data/lib/couchbase/management/view_index_manager.rb +151 -1
- data/lib/couchbase/mutation_state.rb +11 -1
- data/lib/couchbase/scope.rb +4 -4
- data/lib/couchbase/version.rb +1 -1
- metadata +113 -18
- data/.travis.yml +0 -7
- data/ext/couchbase/io/binary_parser.hxx +0 -64
- data/lib/couchbase/results.rb +0 -307
@@ -0,0 +1,36 @@
|
|
1
|
+
# Build matrix / environment variables are explained on:
|
2
|
+
# https://www.appveyor.com/docs/appveyor-yml/
|
3
|
+
# This file can be validated on: https://ci.appveyor.com/tools/validate-yaml
|
4
|
+
|
5
|
+
version: "{build}"
|
6
|
+
|
7
|
+
environment:
|
8
|
+
matrix:
|
9
|
+
# AppVeyor currently has no custom job name feature.
|
10
|
+
# http://help.appveyor.com/discussions/questions/1623-can-i-provide-a-friendly-name-for-jobs
|
11
|
+
- JOB: Visual Studio 2019
|
12
|
+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
13
|
+
CMAKE_GENERATOR: Visual Studio 16 2019
|
14
|
+
|
15
|
+
platform:
|
16
|
+
- x86
|
17
|
+
- x64
|
18
|
+
|
19
|
+
configuration:
|
20
|
+
- RelWithDebInfo
|
21
|
+
- Debug
|
22
|
+
|
23
|
+
build_script:
|
24
|
+
- git submodule update --init --recursive
|
25
|
+
- mkdir build
|
26
|
+
- cd build
|
27
|
+
- if "%platform%"=="x86" (set CMAKE_GENERATOR_PLATFORM="Win32")
|
28
|
+
else (set CMAKE_GENERATOR_PLATFORM="%platform%")
|
29
|
+
- cmake --version
|
30
|
+
- cmake .. -G "%CMAKE_GENERATOR%" -A "%CMAKE_GENERATOR_PLATFORM%"
|
31
|
+
-DCMAKE_CONFIGURATION_TYPES="%CONFIGURATION%" -DSNAPPY_REQUIRE_AVX2=ON
|
32
|
+
- cmake --build . --config %CONFIGURATION%
|
33
|
+
- cd ..
|
34
|
+
|
35
|
+
test_script:
|
36
|
+
- build\%CONFIGURATION%\snappy_unittest
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# Build matrix / environment variables are explained on:
|
2
|
+
# http://about.travis-ci.org/docs/user/build-configuration/
|
3
|
+
# This file can be validated on: http://lint.travis-ci.org/
|
4
|
+
|
5
|
+
language: cpp
|
6
|
+
dist: bionic
|
7
|
+
osx_image: xcode11.3
|
8
|
+
|
9
|
+
compiler:
|
10
|
+
- gcc
|
11
|
+
- clang
|
12
|
+
os:
|
13
|
+
- linux
|
14
|
+
- osx
|
15
|
+
|
16
|
+
env:
|
17
|
+
- BUILD_TYPE=Debug CPU_LEVEL=AVX
|
18
|
+
- BUILD_TYPE=Debug CPU_LEVEL=AVX2
|
19
|
+
- BUILD_TYPE=RelWithDebInfo CPU_LEVEL=AVX
|
20
|
+
- BUILD_TYPE=RelWithDebInfo CPU_LEVEL=AVX2
|
21
|
+
|
22
|
+
jobs:
|
23
|
+
exclude:
|
24
|
+
# Travis OSX servers seem to run on pre-Haswell CPUs. Attempting to use AVX2
|
25
|
+
# results in crashes.
|
26
|
+
- env: BUILD_TYPE=Debug CPU_LEVEL=AVX2
|
27
|
+
os: osx
|
28
|
+
- env: BUILD_TYPE=RelWithDebInfo CPU_LEVEL=AVX2
|
29
|
+
os: osx
|
30
|
+
allow_failures:
|
31
|
+
# Homebrew's GCC is currently broken on XCode 11.
|
32
|
+
- compiler: gcc
|
33
|
+
os: osx
|
34
|
+
|
35
|
+
addons:
|
36
|
+
apt:
|
37
|
+
sources:
|
38
|
+
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
|
39
|
+
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
40
|
+
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
41
|
+
packages:
|
42
|
+
- clang-10
|
43
|
+
- cmake
|
44
|
+
- gcc-9
|
45
|
+
- g++-9
|
46
|
+
- ninja-build
|
47
|
+
homebrew:
|
48
|
+
packages:
|
49
|
+
- cmake
|
50
|
+
- gcc@9
|
51
|
+
- llvm@10
|
52
|
+
- ninja
|
53
|
+
update: true
|
54
|
+
|
55
|
+
install:
|
56
|
+
# The following Homebrew packages aren't linked by default, and need to be
|
57
|
+
# prepended to the path explicitly.
|
58
|
+
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
59
|
+
export PATH="$(brew --prefix llvm)/bin:$PATH";
|
60
|
+
fi
|
61
|
+
# Fuzzing is only supported on Clang. Perform fuzzing on Debug builds.
|
62
|
+
- if [ "$CXX" = "clang++" ] && [ "$BUILD_TYPE" = "Debug" ]; then
|
63
|
+
export FUZZING=1;
|
64
|
+
else
|
65
|
+
export FUZZING=0;
|
66
|
+
fi
|
67
|
+
# /usr/bin/gcc points to an older compiler on both Linux and macOS.
|
68
|
+
- if [ "$CXX" = "g++" ]; then export CXX="g++-9" CC="gcc-9"; fi
|
69
|
+
# /usr/bin/clang points to an older compiler on both Linux and macOS.
|
70
|
+
#
|
71
|
+
# Homebrew's llvm package doesn't ship a versioned clang++ binary, so the values
|
72
|
+
# below don't work on macOS. Fortunately, the path change above makes the
|
73
|
+
# default values (clang and clang++) resolve to the correct compiler on macOS.
|
74
|
+
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
75
|
+
if [ "$CXX" = "clang++" ]; then export CXX="clang++-10" CC="clang-10"; fi;
|
76
|
+
fi
|
77
|
+
- echo ${CC}
|
78
|
+
- echo ${CXX}
|
79
|
+
- ${CXX} --version
|
80
|
+
- cmake --version
|
81
|
+
|
82
|
+
before_script:
|
83
|
+
- mkdir -p build && cd build
|
84
|
+
- cmake .. -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
85
|
+
-DSNAPPY_REQUIRE_${CPU_LEVEL}=ON -DSNAPPY_FUZZING_BUILD=${FUZZING}
|
86
|
+
-DCMAKE_INSTALL_PREFIX=$HOME/.local
|
87
|
+
- cmake --build .
|
88
|
+
- cd ..
|
89
|
+
|
90
|
+
script:
|
91
|
+
- build/snappy_unittest
|
92
|
+
- if [ -f build/snappy_compress_fuzzer ]; then
|
93
|
+
build/snappy_compress_fuzzer -runs=1000 -close_fd_mask=3;
|
94
|
+
fi
|
95
|
+
- if [ -f build/snappy_uncompress_fuzzer ]; then
|
96
|
+
build/snappy_uncompress_fuzzer -runs=1000 -close_fd_mask=3;
|
97
|
+
fi
|
98
|
+
- cd build && cmake --build . --target install
|
@@ -0,0 +1 @@
|
|
1
|
+
opensource@google.com
|
@@ -0,0 +1,345 @@
|
|
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.1)
|
30
|
+
project(Snappy VERSION 1.1.8 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(CMAKE_CXX_COMPILER_ID STREQUAL "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(CMAKE_CXX_COMPILER_ID STREQUAL "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 and gcc.
|
70
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-Werror")
|
71
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
72
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-Werror")
|
73
|
+
|
74
|
+
# Disable C++ exceptions.
|
75
|
+
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
76
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
77
|
+
|
78
|
+
# Disable RTTI.
|
79
|
+
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
80
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
81
|
+
endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
82
|
+
|
83
|
+
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make
|
84
|
+
# it prominent in the GUI.
|
85
|
+
option(BUILD_SHARED_LIBS "Build shared libraries(DLLs)." OFF)
|
86
|
+
|
87
|
+
option(SNAPPY_BUILD_TESTS "Build Snappy's own tests." ON)
|
88
|
+
|
89
|
+
option(SNAPPY_FUZZING_BUILD "Build Snappy for fuzzing." OFF)
|
90
|
+
|
91
|
+
option(SNAPPY_REQUIRE_AVX "Target processors with AVX support." OFF)
|
92
|
+
|
93
|
+
option(SNAPPY_REQUIRE_AVX2 "Target processors with AVX2 support." OFF)
|
94
|
+
|
95
|
+
option(SNAPPY_INSTALL "Install Snappy's header and library" ON)
|
96
|
+
|
97
|
+
include(TestBigEndian)
|
98
|
+
test_big_endian(SNAPPY_IS_BIG_ENDIAN)
|
99
|
+
|
100
|
+
include(CheckIncludeFile)
|
101
|
+
check_include_file("sys/mman.h" HAVE_SYS_MMAN_H)
|
102
|
+
check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H)
|
103
|
+
check_include_file("sys/time.h" HAVE_SYS_TIME_H)
|
104
|
+
check_include_file("sys/uio.h" HAVE_SYS_UIO_H)
|
105
|
+
check_include_file("unistd.h" HAVE_UNISTD_H)
|
106
|
+
check_include_file("windows.h" HAVE_WINDOWS_H)
|
107
|
+
|
108
|
+
include(CheckLibraryExists)
|
109
|
+
check_library_exists(z zlibVersion "" HAVE_LIBZ)
|
110
|
+
check_library_exists(lzo2 lzo1x_1_15_compress "" HAVE_LIBLZO2)
|
111
|
+
|
112
|
+
include(CheckCXXCompilerFlag)
|
113
|
+
CHECK_CXX_COMPILER_FLAG("/arch:AVX" HAVE_VISUAL_STUDIO_ARCH_AVX)
|
114
|
+
CHECK_CXX_COMPILER_FLAG("/arch:AVX2" HAVE_VISUAL_STUDIO_ARCH_AVX2)
|
115
|
+
CHECK_CXX_COMPILER_FLAG("-mavx" HAVE_CLANG_MAVX)
|
116
|
+
CHECK_CXX_COMPILER_FLAG("-mbmi2" HAVE_CLANG_MBMI2)
|
117
|
+
if(SNAPPY_REQUIRE_AVX2)
|
118
|
+
if(HAVE_VISUAL_STUDIO_ARCH_AVX2)
|
119
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
|
120
|
+
endif(HAVE_VISUAL_STUDIO_ARCH_AVX2)
|
121
|
+
if(HAVE_CLANG_MAVX)
|
122
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
123
|
+
endif(HAVE_CLANG_MAVX)
|
124
|
+
if(HAVE_CLANG_MBMI2)
|
125
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mbmi2")
|
126
|
+
endif(HAVE_CLANG_MBMI2)
|
127
|
+
elseif (SNAPPY_REQUIRE_AVX)
|
128
|
+
if(HAVE_VISUAL_STUDIO_ARCH_AVX)
|
129
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX")
|
130
|
+
endif(HAVE_VISUAL_STUDIO_ARCH_AVX)
|
131
|
+
if(HAVE_CLANG_MAVX)
|
132
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
133
|
+
endif(HAVE_CLANG_MAVX)
|
134
|
+
endif(SNAPPY_REQUIRE_AVX2)
|
135
|
+
|
136
|
+
include(CheckCXXSourceCompiles)
|
137
|
+
check_cxx_source_compiles("
|
138
|
+
int main() {
|
139
|
+
return __builtin_expect(0, 1);
|
140
|
+
}" HAVE_BUILTIN_EXPECT)
|
141
|
+
|
142
|
+
check_cxx_source_compiles("
|
143
|
+
int main() {
|
144
|
+
return __builtin_ctzll(0);
|
145
|
+
}" HAVE_BUILTIN_CTZ)
|
146
|
+
|
147
|
+
check_cxx_source_compiles("
|
148
|
+
__attribute__((always_inline)) int zero() { return 0; }
|
149
|
+
|
150
|
+
int main() {
|
151
|
+
return zero();
|
152
|
+
}" HAVE_ATTRIBUTE_ALWAYS_INLINE)
|
153
|
+
|
154
|
+
check_cxx_source_compiles("
|
155
|
+
#include <tmmintrin.h>
|
156
|
+
|
157
|
+
int main() {
|
158
|
+
const __m128i *src = 0;
|
159
|
+
__m128i dest;
|
160
|
+
const __m128i shuffle_mask = _mm_load_si128(src);
|
161
|
+
const __m128i pattern = _mm_shuffle_epi8(_mm_loadl_epi64(src), shuffle_mask);
|
162
|
+
_mm_storeu_si128(&dest, pattern);
|
163
|
+
return 0;
|
164
|
+
}" SNAPPY_HAVE_SSSE3)
|
165
|
+
|
166
|
+
check_cxx_source_compiles("
|
167
|
+
#include <immintrin.h>
|
168
|
+
int main() {
|
169
|
+
return _bzhi_u32(0, 1);
|
170
|
+
}" SNAPPY_HAVE_BMI2)
|
171
|
+
|
172
|
+
include(CheckSymbolExists)
|
173
|
+
check_symbol_exists("mmap" "sys/mman.h" HAVE_FUNC_MMAP)
|
174
|
+
check_symbol_exists("sysconf" "unistd.h" HAVE_FUNC_SYSCONF)
|
175
|
+
|
176
|
+
find_package(GTest QUIET)
|
177
|
+
if(GTEST_FOUND)
|
178
|
+
set(HAVE_GTEST 1)
|
179
|
+
endif(GTEST_FOUND)
|
180
|
+
|
181
|
+
find_package(Gflags QUIET)
|
182
|
+
if(GFLAGS_FOUND)
|
183
|
+
set(HAVE_GFLAGS 1)
|
184
|
+
endif(GFLAGS_FOUND)
|
185
|
+
|
186
|
+
configure_file(
|
187
|
+
"cmake/config.h.in"
|
188
|
+
"${PROJECT_BINARY_DIR}/config.h"
|
189
|
+
)
|
190
|
+
|
191
|
+
# We don't want to define HAVE_ macros in public headers. Instead, we use
|
192
|
+
# CMake's variable substitution with 0/1 variables, which will be seen by the
|
193
|
+
# preprocessor as constants.
|
194
|
+
set(HAVE_SYS_UIO_H_01 ${HAVE_SYS_UIO_H})
|
195
|
+
if(NOT HAVE_SYS_UIO_H_01)
|
196
|
+
set(HAVE_SYS_UIO_H_01 0)
|
197
|
+
endif(NOT HAVE_SYS_UIO_H_01)
|
198
|
+
|
199
|
+
if (SNAPPY_FUZZING_BUILD)
|
200
|
+
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
201
|
+
message(WARNING "Fuzzing builds are only supported with Clang")
|
202
|
+
endif (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
203
|
+
|
204
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=address")
|
205
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
206
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=address")
|
207
|
+
|
208
|
+
if(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=fuzzer-no-link")
|
209
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer-no-link")
|
210
|
+
endif(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=fuzzer-no-link")
|
211
|
+
endif (SNAPPY_FUZZING_BUILD)
|
212
|
+
|
213
|
+
configure_file(
|
214
|
+
"snappy-stubs-public.h.in"
|
215
|
+
"${PROJECT_BINARY_DIR}/snappy-stubs-public.h")
|
216
|
+
|
217
|
+
add_library(snappy "")
|
218
|
+
target_sources(snappy
|
219
|
+
PRIVATE
|
220
|
+
"snappy-internal.h"
|
221
|
+
"snappy-stubs-internal.h"
|
222
|
+
"snappy-c.cc"
|
223
|
+
"snappy-sinksource.cc"
|
224
|
+
"snappy-stubs-internal.cc"
|
225
|
+
"snappy.cc"
|
226
|
+
"${PROJECT_BINARY_DIR}/config.h"
|
227
|
+
|
228
|
+
# Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
|
229
|
+
$<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC>
|
230
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-c.h>
|
231
|
+
$<INSTALL_INTERFACE:include/snappy-c.h>
|
232
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-sinksource.h>
|
233
|
+
$<INSTALL_INTERFACE:include/snappy-sinksource.h>
|
234
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy.h>
|
235
|
+
$<INSTALL_INTERFACE:include/snappy.h>
|
236
|
+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/snappy-stubs-public.h>
|
237
|
+
$<INSTALL_INTERFACE:include/snappy-stubs-public.h>
|
238
|
+
)
|
239
|
+
target_include_directories(snappy
|
240
|
+
PUBLIC
|
241
|
+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
|
242
|
+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
243
|
+
$<INSTALL_INTERFACE:include>
|
244
|
+
)
|
245
|
+
set_target_properties(snappy
|
246
|
+
PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
|
247
|
+
|
248
|
+
target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H)
|
249
|
+
if(BUILD_SHARED_LIBS)
|
250
|
+
set_target_properties(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
251
|
+
endif(BUILD_SHARED_LIBS)
|
252
|
+
|
253
|
+
if(SNAPPY_BUILD_TESTS)
|
254
|
+
enable_testing()
|
255
|
+
|
256
|
+
add_executable(snappy_unittest "")
|
257
|
+
target_sources(snappy_unittest
|
258
|
+
PRIVATE
|
259
|
+
"snappy_unittest.cc"
|
260
|
+
"snappy-test.cc"
|
261
|
+
)
|
262
|
+
target_compile_definitions(snappy_unittest PRIVATE -DHAVE_CONFIG_H)
|
263
|
+
target_link_libraries(snappy_unittest snappy ${GFLAGS_LIBRARIES})
|
264
|
+
|
265
|
+
if(HAVE_LIBZ)
|
266
|
+
target_link_libraries(snappy_unittest z)
|
267
|
+
endif(HAVE_LIBZ)
|
268
|
+
if(HAVE_LIBLZO2)
|
269
|
+
target_link_libraries(snappy_unittest lzo2)
|
270
|
+
endif(HAVE_LIBLZO2)
|
271
|
+
|
272
|
+
target_include_directories(snappy_unittest
|
273
|
+
BEFORE PRIVATE
|
274
|
+
"${PROJECT_SOURCE_DIR}"
|
275
|
+
"${GTEST_INCLUDE_DIRS}"
|
276
|
+
"${GFLAGS_INCLUDE_DIRS}"
|
277
|
+
)
|
278
|
+
|
279
|
+
add_test(
|
280
|
+
NAME snappy_unittest
|
281
|
+
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
282
|
+
COMMAND "${PROJECT_BINARY_DIR}/snappy_unittest")
|
283
|
+
endif(SNAPPY_BUILD_TESTS)
|
284
|
+
|
285
|
+
if(SNAPPY_FUZZING_BUILD)
|
286
|
+
add_executable(snappy_compress_fuzzer "")
|
287
|
+
target_sources(snappy_compress_fuzzer
|
288
|
+
PRIVATE "snappy_compress_fuzzer.cc"
|
289
|
+
)
|
290
|
+
target_link_libraries(snappy_compress_fuzzer snappy)
|
291
|
+
set_target_properties(snappy_compress_fuzzer
|
292
|
+
PROPERTIES LINK_FLAGS "-fsanitize=fuzzer"
|
293
|
+
)
|
294
|
+
|
295
|
+
add_executable(snappy_uncompress_fuzzer "")
|
296
|
+
target_sources(snappy_uncompress_fuzzer
|
297
|
+
PRIVATE "snappy_uncompress_fuzzer.cc"
|
298
|
+
)
|
299
|
+
target_link_libraries(snappy_uncompress_fuzzer snappy)
|
300
|
+
set_target_properties(snappy_uncompress_fuzzer
|
301
|
+
PROPERTIES LINK_FLAGS "-fsanitize=fuzzer"
|
302
|
+
)
|
303
|
+
endif(SNAPPY_FUZZING_BUILD)
|
304
|
+
|
305
|
+
# Must be included before CMAKE_INSTALL_INCLUDEDIR is used.
|
306
|
+
include(GNUInstallDirs)
|
307
|
+
|
308
|
+
if(SNAPPY_INSTALL)
|
309
|
+
install(TARGETS snappy
|
310
|
+
EXPORT SnappyTargets
|
311
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
312
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
313
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
314
|
+
)
|
315
|
+
install(
|
316
|
+
FILES
|
317
|
+
"snappy-c.h"
|
318
|
+
"snappy-sinksource.h"
|
319
|
+
"snappy.h"
|
320
|
+
"${PROJECT_BINARY_DIR}/snappy-stubs-public.h"
|
321
|
+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
322
|
+
)
|
323
|
+
|
324
|
+
include(CMakePackageConfigHelpers)
|
325
|
+
configure_package_config_file(
|
326
|
+
"cmake/${PROJECT_NAME}Config.cmake.in"
|
327
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
|
328
|
+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
329
|
+
)
|
330
|
+
write_basic_package_version_file(
|
331
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
|
332
|
+
COMPATIBILITY SameMajorVersion
|
333
|
+
)
|
334
|
+
install(
|
335
|
+
EXPORT SnappyTargets
|
336
|
+
NAMESPACE Snappy::
|
337
|
+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
338
|
+
)
|
339
|
+
install(
|
340
|
+
FILES
|
341
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
|
342
|
+
"${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
|
343
|
+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
344
|
+
)
|
345
|
+
endif(SNAPPY_INSTALL)
|