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
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1ffcdc64cf93afdef43c64bfac7cce36f1461621f605f9663cd1e004edafc1ec
|
|
4
|
+
data.tar.gz: 83e7a4f8b1e29a476a94c9d68b317029c640b3e5c5b3d681eaf22eebe5d939f1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3b0d9a931fcb349f1afc70726123cb06039ddf35c40ab711d2d2b32d9b6c6e986f047af1c0e928f357ef59c523d85df6eb082272ae8a41fb0a36c6144dae8561
|
|
7
|
+
data.tar.gz: e98f7b827e8884dcbac00dcdd6cc96cbf02924962eee69bb767b2b18c7b4f8dfd6a7b88dfd8effaa9b1f78ad1b6200663dfa37a50bad7e36a39be9867a8fc4b1
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 snappy-ruby
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Snappy Ruby Bindings
|
|
2
|
+
|
|
3
|
+
Ruby bindings for Google's Snappy compression library (https://github.com/google/snappy) with **bundled libsnappy source** - no system dependencies required!
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Fast compression and decompression using Snappy
|
|
8
|
+
- **Bundled Snappy library** - no need to install libsnappy separately
|
|
9
|
+
- File-based compression/decompression with input and output filename support
|
|
10
|
+
- Compression level support (compatible with Snappy's range: 1-9)
|
|
11
|
+
- Compatible with Ruby 3.0+
|
|
12
|
+
- Works on Linux, macOS, and Windows
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Add this line to your application's Gemfile:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
gem 'snappy-ruby'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
And then execute:
|
|
23
|
+
|
|
24
|
+
$ bundle install
|
|
25
|
+
|
|
26
|
+
Or install it yourself as:
|
|
27
|
+
|
|
28
|
+
$ gem install snappy-ruby
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
require 'snappy'
|
|
34
|
+
|
|
35
|
+
# Compress data from a file
|
|
36
|
+
Snappy.compress_file('input.txt', 'output.snappy', level: 6)
|
|
37
|
+
|
|
38
|
+
# Decompress data to a file
|
|
39
|
+
Snappy.decompress_file('output.snappy', 'decompressed.txt')
|
|
40
|
+
|
|
41
|
+
# In-memory compression/decompression
|
|
42
|
+
compressed = Snappy.compress('Hello, World!', level: 6)
|
|
43
|
+
decompressed = Snappy.decompress(compressed)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Development
|
|
47
|
+
|
|
48
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
|
|
49
|
+
|
|
50
|
+
## Requirements
|
|
51
|
+
|
|
52
|
+
- Ruby 3.0 or higher
|
|
53
|
+
- Ruby development headers (ruby-dev)
|
|
54
|
+
- C++ compiler with C++11 support
|
|
55
|
+
|
|
56
|
+
**Note:** The Snappy library is bundled with this gem, so you don't need to install libsnappy separately!
|
|
57
|
+
|
|
58
|
+
### Installing Build Dependencies
|
|
59
|
+
|
|
60
|
+
On Ubuntu/Debian:
|
|
61
|
+
```bash
|
|
62
|
+
sudo apt-get install ruby-dev build-essential
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
On macOS (requires Xcode Command Line Tools):
|
|
66
|
+
```bash
|
|
67
|
+
xcode-select --install
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
On Fedora/RHEL:
|
|
71
|
+
```bash
|
|
72
|
+
sudo dnf install ruby-devel gcc-c++ make
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
The gem is available as open source under the terms of the MIT License.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rspec/core/rake_task"
|
|
3
|
+
require "rake/extensiontask"
|
|
4
|
+
|
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
6
|
+
|
|
7
|
+
Rake::ExtensionTask.new("snappy") do |ext|
|
|
8
|
+
ext.lib_dir = "lib/snappy"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
task default: [:compile, :spec]
|
|
12
|
+
task spec: :compile
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require "mkmf"
|
|
2
|
+
|
|
3
|
+
# Configuration for bundled Snappy library
|
|
4
|
+
SNAPPY_DIR = File.expand_path("snappy-src", __dir__)
|
|
5
|
+
|
|
6
|
+
unless File.directory?(SNAPPY_DIR)
|
|
7
|
+
abort <<-ERROR
|
|
8
|
+
|
|
9
|
+
ERROR: Snappy source directory not found at #{SNAPPY_DIR}
|
|
10
|
+
|
|
11
|
+
The Snappy library source should be bundled with this gem.
|
|
12
|
+
Please ensure the gem was installed correctly.
|
|
13
|
+
|
|
14
|
+
ERROR
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Add Snappy source directory to include path
|
|
18
|
+
$INCFLAGS << " -I#{SNAPPY_DIR}"
|
|
19
|
+
|
|
20
|
+
# Add C++11 support (required by Snappy)
|
|
21
|
+
$CXXFLAGS << " -std=c++11 -fno-exceptions -fno-rtti"
|
|
22
|
+
|
|
23
|
+
# Link against C++ standard library
|
|
24
|
+
$LIBS << " -lstdc++"
|
|
25
|
+
|
|
26
|
+
# Define HAVE_CONFIG_H to use our config.h
|
|
27
|
+
$CPPFLAGS << " -DHAVE_CONFIG_H"
|
|
28
|
+
|
|
29
|
+
# Disable some warnings for cleaner output
|
|
30
|
+
$CXXFLAGS << " -Wno-sign-compare"
|
|
31
|
+
|
|
32
|
+
# Create a symlink for snappy.cc with a different name to avoid conflict with snappy.c
|
|
33
|
+
# The Ruby binding (snappy.c) will compile to snappy.o
|
|
34
|
+
# The Snappy library (snappy-lib.cc) will compile to snappy-lib.o
|
|
35
|
+
snappy_lib_link = File.join(SNAPPY_DIR, "snappy-lib.cc")
|
|
36
|
+
snappy_lib_src = File.join(SNAPPY_DIR, "snappy.cc")
|
|
37
|
+
|
|
38
|
+
# Remove old symlink if it exists, then create new one
|
|
39
|
+
File.delete(snappy_lib_link) if File.exist?(snappy_lib_link) || File.symlink?(snappy_lib_link)
|
|
40
|
+
File.symlink("snappy.cc", snappy_lib_link)
|
|
41
|
+
|
|
42
|
+
# List of Snappy source files to compile
|
|
43
|
+
snappy_sources = %w[
|
|
44
|
+
snappy-lib.cc
|
|
45
|
+
snappy-c.cc
|
|
46
|
+
snappy-sinksource.cc
|
|
47
|
+
snappy-stubs-internal.cc
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
# Add VPATH to tell make where to find the source files
|
|
51
|
+
$VPATH ||= []
|
|
52
|
+
$VPATH << SNAPPY_DIR
|
|
53
|
+
|
|
54
|
+
# Initialize $objs if it's not already initialized
|
|
55
|
+
$objs ||= []
|
|
56
|
+
|
|
57
|
+
# First, add the main Ruby binding (snappy.c -> snappy.o)
|
|
58
|
+
# This file is in ext/snappy/, not in snappy-src/
|
|
59
|
+
$objs << "snappy.o"
|
|
60
|
+
|
|
61
|
+
# Add Snappy library source files
|
|
62
|
+
snappy_sources.each do |src|
|
|
63
|
+
$objs << src.sub(/\.cc$/, ".o")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Verify all required source files exist
|
|
67
|
+
missing_files = snappy_sources.reject { |src| File.exist?(File.join(SNAPPY_DIR, src)) || File.symlink?(File.join(SNAPPY_DIR, src)) }
|
|
68
|
+
unless missing_files.empty?
|
|
69
|
+
abort "ERROR: Missing Snappy source files:\n #{missing_files.join("\n ")}"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
puts "=" * 70
|
|
73
|
+
puts "Building snappy-ruby with bundled Snappy library"
|
|
74
|
+
puts "=" * 70
|
|
75
|
+
puts "Snappy source: #{SNAPPY_DIR}"
|
|
76
|
+
puts "Include flags: #{$INCFLAGS}"
|
|
77
|
+
puts "C++ flags: #{$CXXFLAGS}"
|
|
78
|
+
puts "Main Ruby binding: snappy.c"
|
|
79
|
+
puts "Compiling Snappy sources:"
|
|
80
|
+
snappy_sources.each { |src| puts " - #{src}" }
|
|
81
|
+
puts "=" * 70
|
|
82
|
+
|
|
83
|
+
create_makefile("snappy/snappy")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
opensource@google.com
|
|
@@ -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
|
+
)
|