snappy 0.3.0-java → 0.5.0-java
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 +4 -4
- data/.github/workflows/main.yml +2 -2
- data/.github/workflows/publish.yml +7 -13
- data/Dockerfile +1 -1
- data/Gemfile +1 -0
- data/README.md +20 -1
- data/Rakefile +1 -1
- data/ext/extconf.rb +13 -11
- data/lib/snappy/shim.rb +3 -23
- data/lib/snappy/version.rb +1 -1
- data/lib/snappy/writer.rb +1 -1
- data/lib/snappy_ext.jar +0 -0
- data/snappy.gemspec +1 -0
- data/test/snappy_test.rb +29 -4
- data/vendor/snappy/BUILD.bazel +211 -0
- data/vendor/snappy/CMakeLists.txt +176 -31
- data/vendor/snappy/CONTRIBUTING.md +9 -4
- data/vendor/snappy/MODULE.bazel +23 -0
- data/vendor/snappy/NEWS +27 -0
- data/vendor/snappy/README.md +52 -35
- data/vendor/snappy/WORKSPACE +27 -0
- data/vendor/snappy/WORKSPACE.bzlmod +0 -0
- data/vendor/snappy/cmake/config.h.in +30 -23
- data/vendor/snappy/snappy-internal.h +218 -25
- data/vendor/snappy/snappy-sinksource.cc +26 -9
- data/vendor/snappy/snappy-sinksource.h +11 -11
- data/vendor/snappy/snappy-stubs-internal.cc +1 -1
- data/vendor/snappy/snappy-stubs-internal.h +231 -306
- data/vendor/snappy/snappy-stubs-public.h.in +0 -11
- data/vendor/snappy/snappy-test.cc +88 -198
- data/vendor/snappy/snappy-test.h +102 -285
- data/vendor/snappy/snappy.cc +1412 -425
- data/vendor/snappy/snappy.h +60 -10
- data/vendor/snappy/snappy_benchmark.cc +398 -0
- data/vendor/snappy/snappy_compress_fuzzer.cc +21 -16
- data/vendor/snappy/snappy_test_data.cc +57 -0
- data/vendor/snappy/snappy_test_data.h +68 -0
- data/vendor/snappy/snappy_test_tool.cc +471 -0
- data/vendor/snappy/snappy_uncompress_fuzzer.cc +3 -2
- data/vendor/snappy/snappy_unittest.cc +183 -666
- metadata +13 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3a62e55dcd9b5df9f78b9cd0ecd24b5aac02e4905c08eefc0f023cd8f8d6c19e
|
|
4
|
+
data.tar.gz: 501fbd93edca8aecc762e39788e23323ccdd5a7a84be24f51b85c5d3d61e1e6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44a906dd1caa7caf4831640a2c1d659e789df8d50b61c5ef024113f70f30b91a0359f5e312c8037f3591b4147c6ef9c56160b87aff056324760a16aec0a39ac9
|
|
7
|
+
data.tar.gz: 25b779a716a13967be79a0c8e7e715a98569c2e2dfe6b7d46152874f06348f780943d739181caca2e4409d9ef056df477b2e49831e22fd9970344160db46f29b
|
data/.github/workflows/main.yml
CHANGED
|
@@ -7,10 +7,10 @@ jobs:
|
|
|
7
7
|
strategy:
|
|
8
8
|
fail-fast: false
|
|
9
9
|
matrix:
|
|
10
|
-
ruby: [2.
|
|
10
|
+
ruby: [2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 4.0, jruby]
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
steps:
|
|
13
|
-
- uses: actions/checkout@
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
14
|
with:
|
|
15
15
|
submodules: true
|
|
16
16
|
- name: Set up Ruby
|
|
@@ -10,10 +10,14 @@ jobs:
|
|
|
10
10
|
strategy:
|
|
11
11
|
fail-fast: false
|
|
12
12
|
matrix:
|
|
13
|
-
ruby: [
|
|
13
|
+
ruby: [4.0, jruby]
|
|
14
|
+
if: github.repository == 'miyucy/snappy'
|
|
14
15
|
runs-on: ubuntu-latest
|
|
16
|
+
permissions:
|
|
17
|
+
contents: write
|
|
18
|
+
id-token: write
|
|
15
19
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
20
|
+
- uses: actions/checkout@v4
|
|
17
21
|
with:
|
|
18
22
|
submodules: true
|
|
19
23
|
- name: Set up Ruby
|
|
@@ -21,14 +25,4 @@ jobs:
|
|
|
21
25
|
with:
|
|
22
26
|
ruby-version: ${{ matrix.ruby }}
|
|
23
27
|
bundler-cache: true
|
|
24
|
-
-
|
|
25
|
-
run: |
|
|
26
|
-
mkdir -p ~/.gem
|
|
27
|
-
cat << EOF > ~/.gem/credentials
|
|
28
|
-
---
|
|
29
|
-
:github: Bearer ${{secrets.GITHUB_TOKEN}}
|
|
30
|
-
:rubygems_api_key: ${{secrets.RUBYGEMS_API_KEY}}
|
|
31
|
-
EOF
|
|
32
|
-
chmod 600 ~/.gem/credentials
|
|
33
|
-
bundle exec rake release[remote]
|
|
34
|
-
rm -f ~/.gem/credentials
|
|
28
|
+
- uses: rubygems/release-gem@v1
|
data/Dockerfile
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -9,7 +9,10 @@ see https://github.com/google/snappy
|
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
11
|
$ brew install snappy
|
|
12
|
-
$ brew install autoconf automake libtool
|
|
12
|
+
$ brew install autoconf automake cmake libtool
|
|
13
|
+
|
|
14
|
+
# This step may be needed if gem installation fails
|
|
15
|
+
bundle config build.snappy --with-snappy-dir=/opt/homebrew/opt/snappy
|
|
13
16
|
```
|
|
14
17
|
|
|
15
18
|
### Ubuntu
|
|
@@ -26,6 +29,22 @@ $ apk install snappy
|
|
|
26
29
|
$ apk install build-base libexecinfo automake autoconf libtool
|
|
27
30
|
```
|
|
28
31
|
|
|
32
|
+
### Windows
|
|
33
|
+
|
|
34
|
+
[Ruby Installer](https://rubyinstaller.org/) 3.0 and earlier:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
(in MSYS2 shell)
|
|
38
|
+
$ pacman -S mingw-w64-x86_64-snappy
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Ruby Installer 3.1 and later:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
(in MSYS2 shell)
|
|
45
|
+
pacman -S mingw-w64-ucrt-x86_64-snappy
|
|
46
|
+
```
|
|
47
|
+
|
|
29
48
|
## Installation
|
|
30
49
|
|
|
31
50
|
Add this line to your application's Gemfile:
|
data/Rakefile
CHANGED
|
@@ -31,7 +31,7 @@ if defined?(JRUBY_VERSION)
|
|
|
31
31
|
|
|
32
32
|
desc "Compile the extension"
|
|
33
33
|
task compile: :setup do
|
|
34
|
-
ant.javac destdir: "${build.dir}", includeantruntime: "no", target: "1.
|
|
34
|
+
ant.javac destdir: "${build.dir}", includeantruntime: "no", target: "1.8", source: "1.8", debug: "on" do
|
|
35
35
|
classpath refid: "compile.class.path"
|
|
36
36
|
src { pathelement location: "${src.dir}" }
|
|
37
37
|
end
|
data/ext/extconf.rb
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "mkmf"
|
|
2
|
+
require "fileutils"
|
|
3
3
|
|
|
4
4
|
$CXXFLAGS += " -std=c++11 "
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
have_libsnappy = pkg_config("libsnappy") || have_library("snappy")
|
|
7
|
+
unless have_libsnappy
|
|
7
8
|
# build vendor/snappy
|
|
8
9
|
pwd = File.dirname File.expand_path __FILE__
|
|
9
|
-
dir = File.join pwd,
|
|
10
|
+
dir = File.join pwd, "..", "vendor", "snappy"
|
|
10
11
|
|
|
11
12
|
Dir.chdir(dir) do
|
|
12
|
-
FileUtils.
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
FileUtils.rm_rf "build"
|
|
14
|
+
FileUtils.mkdir_p "build"
|
|
15
|
+
Dir.chdir(File.join(dir, "build")) do
|
|
16
|
+
`cmake .. -DCMAKE_BUILD_TYPE=Release -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_BUILD_BENCHMARKS=OFF`
|
|
15
17
|
end
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
src = %w[
|
|
19
21
|
config.h
|
|
20
22
|
snappy-stubs-public.h
|
|
21
|
-
].map { |e| File.join dir,
|
|
22
|
-
FileUtils.cp src, pwd, :
|
|
23
|
+
].map { |e| File.join dir, "build", e }
|
|
24
|
+
FileUtils.cp src, pwd, verbose: true
|
|
23
25
|
src = %w[
|
|
24
26
|
snappy-c.cc
|
|
25
27
|
snappy-c.h
|
|
@@ -31,7 +33,7 @@ unless pkg_config('libsnappy') || have_library('snappy')
|
|
|
31
33
|
snappy-stubs-internal.cc
|
|
32
34
|
snappy-stubs-internal.h
|
|
33
35
|
].map { |e| File.join dir, e }
|
|
34
|
-
FileUtils.cp src, pwd, :
|
|
36
|
+
FileUtils.cp src, pwd, verbose: true
|
|
35
37
|
end
|
|
36
38
|
|
|
37
|
-
create_makefile
|
|
39
|
+
create_makefile "snappy_ext"
|
data/lib/snappy/shim.rb
CHANGED
|
@@ -3,28 +3,8 @@
|
|
|
3
3
|
module Snappy
|
|
4
4
|
module_function
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def b(str)
|
|
12
|
-
str
|
|
13
|
-
end
|
|
14
|
-
else
|
|
15
|
-
def set_encoding(io)
|
|
16
|
-
io.set_encoding Encoding::ASCII_8BIT
|
|
17
|
-
io
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
if ::String.instance_methods.include? :b
|
|
21
|
-
def b(str)
|
|
22
|
-
str.b
|
|
23
|
-
end
|
|
24
|
-
else
|
|
25
|
-
def b(str)
|
|
26
|
-
str.force_encoding Encoding::ASCII_8BIT
|
|
27
|
-
end
|
|
28
|
-
end
|
|
6
|
+
def set_encoding(io)
|
|
7
|
+
io.set_encoding Encoding::ASCII_8BIT
|
|
8
|
+
io
|
|
29
9
|
end
|
|
30
10
|
end
|
data/lib/snappy/version.rb
CHANGED
data/lib/snappy/writer.rb
CHANGED
data/lib/snappy_ext.jar
CHANGED
|
Binary file
|
data/snappy.gemspec
CHANGED
data/test/snappy_test.rb
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "test_helper"
|
|
4
|
+
require "securerandom"
|
|
4
5
|
|
|
5
6
|
class SnappyTest < Test::Unit::TestCase
|
|
6
|
-
T = [*"a".."z", *"A".."Z", *"0".."9"].freeze
|
|
7
|
-
|
|
8
7
|
def random_data(length = 1024)
|
|
9
|
-
|
|
8
|
+
SecureRandom.alphanumeric(length)
|
|
10
9
|
end
|
|
11
10
|
|
|
12
11
|
test "VERSION" do
|
|
@@ -20,6 +19,11 @@ class SnappyTest < Test::Unit::TestCase
|
|
|
20
19
|
assert_equal s, Snappy.inflate(Snappy.deflate(s))
|
|
21
20
|
end
|
|
22
21
|
|
|
22
|
+
test "binary data" do
|
|
23
|
+
s = SecureRandom.random_bytes(1024)
|
|
24
|
+
assert_equal s, Snappy.inflate(Snappy.deflate(s))
|
|
25
|
+
end
|
|
26
|
+
|
|
23
27
|
test "well done (pair)" do
|
|
24
28
|
s = random_data
|
|
25
29
|
[
|
|
@@ -83,13 +87,34 @@ class SnappyTest < Test::Unit::TestCase
|
|
|
83
87
|
notify "Ractor not defined"
|
|
84
88
|
omit
|
|
85
89
|
end
|
|
90
|
+
unless RUBY_VERSION.start_with?("4")
|
|
91
|
+
omit
|
|
92
|
+
end
|
|
86
93
|
s = random_data
|
|
87
94
|
a = Array.new(2) do
|
|
88
95
|
Ractor.new(s) do |s|
|
|
89
96
|
Snappy.inflate(Snappy.deflate(s)) == s
|
|
90
97
|
end
|
|
91
98
|
end
|
|
92
|
-
assert_equal [true, true], a.map(&:
|
|
99
|
+
assert_equal [true, true], a.map(&:value)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
test "take2" do
|
|
103
|
+
unless defined? ::Ractor
|
|
104
|
+
notify "Ractor not defined"
|
|
105
|
+
omit
|
|
106
|
+
end
|
|
107
|
+
unless RUBY_VERSION.start_with?("4")
|
|
108
|
+
omit
|
|
109
|
+
end
|
|
110
|
+
s = random_data
|
|
111
|
+
i = Ractor.new(s) do |s|
|
|
112
|
+
Snappy.deflate(s)
|
|
113
|
+
end.value
|
|
114
|
+
j = Ractor.new(i) do |i|
|
|
115
|
+
Snappy.inflate(i)
|
|
116
|
+
end.value
|
|
117
|
+
assert_equal s, j
|
|
93
118
|
end
|
|
94
119
|
end
|
|
95
120
|
end
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Copyright 2023 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
|
+
package(default_visibility = ["//visibility:public"])
|
|
30
|
+
|
|
31
|
+
licenses(["notice"])
|
|
32
|
+
|
|
33
|
+
SNAPPY_VERSION = (1, 2, 2)
|
|
34
|
+
|
|
35
|
+
config_setting(
|
|
36
|
+
name = "windows",
|
|
37
|
+
constraint_values = ["@platforms//os:windows"],
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
cc_library(
|
|
41
|
+
name = "config",
|
|
42
|
+
hdrs = ["config.h"],
|
|
43
|
+
defines = ["HAVE_CONFIG_H"],
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
cc_library(
|
|
47
|
+
name = "snappy-stubs-public",
|
|
48
|
+
hdrs = [":snappy-stubs-public.h"],
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
cc_library(
|
|
52
|
+
name = "snappy-stubs-internal",
|
|
53
|
+
srcs = ["snappy-stubs-internal.cc"],
|
|
54
|
+
hdrs = ["snappy-stubs-internal.h"],
|
|
55
|
+
deps = [
|
|
56
|
+
":config",
|
|
57
|
+
":snappy-stubs-public",
|
|
58
|
+
],
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
cc_library(
|
|
62
|
+
name = "snappy",
|
|
63
|
+
srcs = [
|
|
64
|
+
"snappy.cc",
|
|
65
|
+
"snappy-internal.h",
|
|
66
|
+
"snappy-sinksource.cc",
|
|
67
|
+
],
|
|
68
|
+
hdrs = [
|
|
69
|
+
"snappy.h",
|
|
70
|
+
"snappy-sinksource.h",
|
|
71
|
+
],
|
|
72
|
+
copts = select({
|
|
73
|
+
":windows": [],
|
|
74
|
+
"//conditions:default": [
|
|
75
|
+
"-Wno-sign-compare",
|
|
76
|
+
],
|
|
77
|
+
}),
|
|
78
|
+
deps = [
|
|
79
|
+
":config",
|
|
80
|
+
":snappy-stubs-internal",
|
|
81
|
+
":snappy-stubs-public",
|
|
82
|
+
],
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
cc_library(
|
|
86
|
+
name = "snappy-c",
|
|
87
|
+
srcs = ["snappy-c.cc"],
|
|
88
|
+
hdrs = ["snappy-c.h"],
|
|
89
|
+
deps = [":snappy"],
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
filegroup(
|
|
93
|
+
name = "testdata",
|
|
94
|
+
srcs = glob(["testdata/*"]),
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
cc_library(
|
|
98
|
+
name = "snappy-test",
|
|
99
|
+
testonly = True,
|
|
100
|
+
srcs = [
|
|
101
|
+
"snappy-test.cc",
|
|
102
|
+
"snappy_test_data.cc",
|
|
103
|
+
],
|
|
104
|
+
hdrs = [
|
|
105
|
+
"snappy-test.h",
|
|
106
|
+
"snappy_test_data.h",
|
|
107
|
+
],
|
|
108
|
+
deps = [":snappy-stubs-internal"],
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
cc_test(
|
|
112
|
+
name = "snappy_benchmark",
|
|
113
|
+
srcs = ["snappy_benchmark.cc"],
|
|
114
|
+
data = [":testdata"],
|
|
115
|
+
deps = [
|
|
116
|
+
":snappy",
|
|
117
|
+
":snappy-test",
|
|
118
|
+
"@com_google_benchmark//:benchmark_main",
|
|
119
|
+
],
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
cc_test(
|
|
123
|
+
name = "snappy_unittest",
|
|
124
|
+
srcs = [
|
|
125
|
+
"snappy_unittest.cc",
|
|
126
|
+
],
|
|
127
|
+
data = [":testdata"],
|
|
128
|
+
deps = [
|
|
129
|
+
":snappy",
|
|
130
|
+
":snappy-test",
|
|
131
|
+
"@com_google_googletest//:gtest_main",
|
|
132
|
+
],
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Generate a config.h similar to what cmake would produce.
|
|
136
|
+
genrule(
|
|
137
|
+
name = "config_h",
|
|
138
|
+
outs = ["config.h"],
|
|
139
|
+
cmd = """cat <<EOF >$@
|
|
140
|
+
#define HAVE_STDDEF_H 1
|
|
141
|
+
#define HAVE_STDINT_H 1
|
|
142
|
+
#ifdef __has_builtin
|
|
143
|
+
# if !defined(HAVE_BUILTIN_EXPECT) && __has_builtin(__builtin_expect)
|
|
144
|
+
# define HAVE_BUILTIN_EXPECT 1
|
|
145
|
+
# endif
|
|
146
|
+
# if !defined(HAVE_BUILTIN_CTZ) && __has_builtin(__builtin_ctzll)
|
|
147
|
+
# define HAVE_BUILTIN_CTZ 1
|
|
148
|
+
# endif
|
|
149
|
+
# if !defined(HAVE_BUILTIN_PREFETCH) && __has_builtin(__builtin_prefetech)
|
|
150
|
+
# define HAVE_BUILTIN_PREFETCH 1
|
|
151
|
+
# endif
|
|
152
|
+
#elif defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
|
153
|
+
# ifndef HAVE_BUILTIN_EXPECT
|
|
154
|
+
# define HAVE_BUILTIN_EXPECT 1
|
|
155
|
+
# endif
|
|
156
|
+
# ifndef HAVE_BUILTIN_CTZ
|
|
157
|
+
# define HAVE_BUILTIN_CTZ 1
|
|
158
|
+
# endif
|
|
159
|
+
# ifndef HAVE_BUILTIN_PREFETCH
|
|
160
|
+
# define HAVE_BUILTIN_PREFETCH 1
|
|
161
|
+
# endif
|
|
162
|
+
#endif
|
|
163
|
+
|
|
164
|
+
#if defined(_WIN32) && !defined(HAVE_WINDOWS_H)
|
|
165
|
+
#define HAVE_WINDOWS_H 1
|
|
166
|
+
#endif
|
|
167
|
+
|
|
168
|
+
#ifdef __has_include
|
|
169
|
+
# if !defined(HAVE_BYTESWAP_H) && __has_include(<byteswap.h>)
|
|
170
|
+
# define HAVE_BYTESWAP_H 1
|
|
171
|
+
# endif
|
|
172
|
+
# if !defined(HAVE_UNISTD_H) && __has_include(<unistd.h>)
|
|
173
|
+
# define HAVE_UNISTD_H 1
|
|
174
|
+
# endif
|
|
175
|
+
# if !defined(HAVE_SYS_ENDIAN_H) && __has_include(<sys/endian.h>)
|
|
176
|
+
# define HAVE_SYS_ENDIAN_H 1
|
|
177
|
+
# endif
|
|
178
|
+
# if !defined(HAVE_SYS_MMAN_H) && __has_include(<sys/mman.h>)
|
|
179
|
+
# define HAVE_SYS_MMAN_H 1
|
|
180
|
+
# endif
|
|
181
|
+
# if !defined(HAVE_SYS_UIO_H) && __has_include(<sys/uio.h>)
|
|
182
|
+
# define HAVE_SYS_UIO_H 1
|
|
183
|
+
# endif
|
|
184
|
+
# if !defined(HAVE_SYS_TIME_H) && __has_include(<sys/time.h>)
|
|
185
|
+
# define HAVE_SYS_TIME_H 1
|
|
186
|
+
# endif
|
|
187
|
+
#endif
|
|
188
|
+
|
|
189
|
+
#ifndef SNAPPY_IS_BIG_ENDIAN
|
|
190
|
+
# ifdef __s390x__
|
|
191
|
+
# define SNAPPY_IS_BIG_ENDIAN 1
|
|
192
|
+
# elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
193
|
+
# define SNAPPY_IS_BIG_ENDIAN 1
|
|
194
|
+
# endif
|
|
195
|
+
#endif
|
|
196
|
+
EOF
|
|
197
|
+
""",
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
genrule(
|
|
201
|
+
name = "snappy_stubs_public_h",
|
|
202
|
+
srcs = ["snappy-stubs-public.h.in"],
|
|
203
|
+
outs = ["snappy-stubs-public.h"],
|
|
204
|
+
# Assume sys/uio.h is available on non-Windows.
|
|
205
|
+
# Set the version numbers.
|
|
206
|
+
cmd = ("""sed -e 's/$${HAVE_SYS_UIO_H_01}/!_WIN32/g' \
|
|
207
|
+
-e 's/$${PROJECT_VERSION_MAJOR}/%d/g' \
|
|
208
|
+
-e 's/$${PROJECT_VERSION_MINOR}/%d/g' \
|
|
209
|
+
-e 's/$${PROJECT_VERSION_PATCH}/%d/g' \
|
|
210
|
+
$< >$@""" % SNAPPY_VERSION),
|
|
211
|
+
)
|