zstdlib 0.9.0-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +6 -0
- data/CHANGES.md +78 -0
- data/Gemfile +3 -0
- data/README.md +107 -0
- data/Rakefile +59 -0
- data/ext/zstdlib_c/extconf.rb +54 -0
- data/ext/zstdlib_c/ruby/zlib-2.2/zstdlib.c +4675 -0
- data/ext/zstdlib_c/ruby/zlib-2.3/zstdlib.c +4702 -0
- data/ext/zstdlib_c/ruby/zlib-2.4/zstdlib.c +4859 -0
- data/ext/zstdlib_c/ruby/zlib-2.5/zstdlib.c +4864 -0
- data/ext/zstdlib_c/ruby/zlib-2.6/zstdlib.c +4906 -0
- data/ext/zstdlib_c/ruby/zlib-2.7/zstdlib.c +4895 -0
- data/ext/zstdlib_c/ruby/zlib-3.0/zstdlib.c +4994 -0
- data/ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c +5076 -0
- data/ext/zstdlib_c/zlib-1.2.11/adler32.c +186 -0
- data/ext/zstdlib_c/zlib-1.2.11/compress.c +86 -0
- data/ext/zstdlib_c/zlib-1.2.11/crc32.c +442 -0
- data/ext/zstdlib_c/zlib-1.2.11/crc32.h +441 -0
- data/ext/zstdlib_c/zlib-1.2.11/deflate.c +2163 -0
- data/ext/zstdlib_c/zlib-1.2.11/deflate.h +349 -0
- data/ext/zstdlib_c/zlib-1.2.11/gzclose.c +25 -0
- data/ext/zstdlib_c/zlib-1.2.11/gzguts.h +218 -0
- data/ext/zstdlib_c/zlib-1.2.11/gzlib.c +637 -0
- data/ext/zstdlib_c/zlib-1.2.11/gzread.c +654 -0
- data/ext/zstdlib_c/zlib-1.2.11/gzwrite.c +665 -0
- data/ext/zstdlib_c/zlib-1.2.11/infback.c +640 -0
- data/ext/zstdlib_c/zlib-1.2.11/inffast.c +323 -0
- data/ext/zstdlib_c/zlib-1.2.11/inffast.h +11 -0
- data/ext/zstdlib_c/zlib-1.2.11/inffixed.h +94 -0
- data/ext/zstdlib_c/zlib-1.2.11/inflate.c +1561 -0
- data/ext/zstdlib_c/zlib-1.2.11/inflate.h +125 -0
- data/ext/zstdlib_c/zlib-1.2.11/inftrees.c +304 -0
- data/ext/zstdlib_c/zlib-1.2.11/inftrees.h +62 -0
- data/ext/zstdlib_c/zlib-1.2.11/trees.c +1203 -0
- data/ext/zstdlib_c/zlib-1.2.11/trees.h +128 -0
- data/ext/zstdlib_c/zlib-1.2.11/uncompr.c +93 -0
- data/ext/zstdlib_c/zlib-1.2.11/zconf.h +534 -0
- data/ext/zstdlib_c/zlib-1.2.11/zlib.h +1912 -0
- data/ext/zstdlib_c/zlib-1.2.11/zutil.c +325 -0
- data/ext/zstdlib_c/zlib-1.2.11/zutil.h +271 -0
- data/ext/zstdlib_c/zlib.mk +14 -0
- data/ext/zstdlib_c/zlibwrapper/zlibwrapper.c +10 -0
- data/ext/zstdlib_c/zlibwrapper.mk +14 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/bitstream.h +478 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/compiler.h +335 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/cpu.h +213 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/debug.c +24 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/debug.h +107 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/entropy_common.c +368 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/error_private.c +56 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/error_private.h +159 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/fse.h +717 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/fse_decompress.c +403 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/huf.h +364 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/mem.h +442 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/pool.c +355 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/pool.h +84 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/portability_macros.h +137 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/threading.c +122 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/threading.h +155 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.c +24 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/xxhash.h +5686 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_common.c +83 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_deps.h +111 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_internal.h +493 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/common/zstd_trace.h +163 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/clevels.h +134 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/fse_compress.c +741 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/hist.c +181 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/hist.h +75 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/huf_compress.c +1370 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress.c +6327 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_internal.h +1458 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_literals.c +159 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_literals.h +31 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_sequences.c +442 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_sequences.h +54 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_superblock.c +573 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_compress_superblock.h +32 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_cwksp.h +676 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_double_fast.c +696 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_double_fast.h +38 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_fast.c +675 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_fast.h +37 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.c +2104 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_lazy.h +125 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_ldm.c +724 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_ldm.h +117 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_ldm_geartab.h +106 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_opt.c +1446 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstd_opt.h +56 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstdmt_compress.c +1859 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/compress/zstdmt_compress.h +113 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress.c +1889 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/huf_decompress_amd64.S +585 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_ddict.c +244 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_ddict.h +44 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_decompress.c +2230 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_decompress_block.c +2072 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_decompress_block.h +68 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/decompress/zstd_decompress_internal.h +236 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/zdict.h +452 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/zstd.h +2575 -0
- data/ext/zstdlib_c/zstd-1.5.2/lib/zstd_errors.h +95 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzclose.c +28 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzcompatibility.h +68 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzguts.h +229 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzlib.c +640 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzread.c +678 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/gzwrite.c +671 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/zstd_zlibwrapper.c +1198 -0
- data/ext/zstdlib_c/zstd-1.5.2/zlibWrapper/zstd_zlibwrapper.h +88 -0
- data/ext/zstdlib_c/zstd.mk +15 -0
- data/lib/2.4/zstdlib_c.bundle +0 -0
- data/lib/2.5/zstdlib_c.bundle +0 -0
- data/lib/2.6/zstdlib_c.bundle +0 -0
- data/lib/2.7/zstdlib_c.bundle +0 -0
- data/lib/3.0/zstdlib_c.bundle +0 -0
- data/lib/3.1/zstdlib_c.bundle +0 -0
- data/lib/zstdlib.rb +6 -0
- data/test/zstdlib_test.rb +21 -0
- metadata +237 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 848f850eaee90f5efc1dd1635a38d2f273ce08c33c724cabf2dd5137714cb3b9
|
4
|
+
data.tar.gz: 282bb69a9497f75e64bab66ec5ce75f030713c4c3f0b1470adf4e46a60d7875d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d3b1f93759785514a257490e289a5960e18588eecb81f7033bc8e37280266f9f71df99b006b07359ee13acf3eb9007e9e0e83ae7b6b2a5ecd812d719bb8d0bff
|
7
|
+
data.tar.gz: a0113d785fa57cb1c0a1eced1da9f2401fa1420108278fdf76b242ff4d20fc473f412347fc47b2e3a18b6d078d9947c2e63bd6bc7a203f4c187c28f92fc734be
|
data/.yardopts
ADDED
data/CHANGES.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# 0.9.0
|
2
|
+
|
3
|
+
Updated Zstd to `1.5.2`
|
4
|
+
|
5
|
+
Added support for MRI Ruby versions `3.0-3.1`
|
6
|
+
|
7
|
+
Upgraded rake-compiler-dock to `1.2.0`
|
8
|
+
|
9
|
+
Implemented deployment of system-specific compiled gems for for x32/x64 Windows and x64/ARM64 MacOS platforms
|
10
|
+
|
11
|
+
# 0.8.0
|
12
|
+
|
13
|
+
Zstd version update to `1.5.0`
|
14
|
+
|
15
|
+
|
16
|
+
# 0.7.0
|
17
|
+
|
18
|
+
Zstd version update to `1.4.5`
|
19
|
+
|
20
|
+
|
21
|
+
# 0.6.0
|
22
|
+
|
23
|
+
Added support for MRI Ruby version `2.7`
|
24
|
+
|
25
|
+
Upgraded rake-compiler-dock to `1.0.0`
|
26
|
+
|
27
|
+
|
28
|
+
# 0.5.0
|
29
|
+
|
30
|
+
Zstd version update to `1.4.4`
|
31
|
+
|
32
|
+
|
33
|
+
# 0.4.0
|
34
|
+
|
35
|
+
Zstd version update to `1.4.3`
|
36
|
+
|
37
|
+
Relocated to GitHub.
|
38
|
+
|
39
|
+
|
40
|
+
# 0.3.0
|
41
|
+
|
42
|
+
Zstd version update to `1.4.2`
|
43
|
+
|
44
|
+
|
45
|
+
# 0.2.0
|
46
|
+
|
47
|
+
Zstd version update to `1.4.0`
|
48
|
+
|
49
|
+
Documentation updates.
|
50
|
+
|
51
|
+
|
52
|
+
# 0.1.2
|
53
|
+
|
54
|
+
Implemented `Zstdlib::ZSTD_VERSION` constant and `Zstdlib.zstd_version` module method for Zstd version retrieval.
|
55
|
+
|
56
|
+
Documentation updates.
|
57
|
+
|
58
|
+
|
59
|
+
# 0.1.1
|
60
|
+
|
61
|
+
Pick up the most recent compatible source for _zstdlib_ Ruby extension module instead of target Ruby version.
|
62
|
+
|
63
|
+
Replaced (most) references to `Zlib` with `Zstdlib` within extractable documentation.
|
64
|
+
|
65
|
+
Fixed a few missing methods on Ruby side.
|
66
|
+
|
67
|
+
Documentation updates.
|
68
|
+
|
69
|
+
|
70
|
+
# 0.1.0
|
71
|
+
|
72
|
+
Initial release.
|
73
|
+
|
74
|
+
Zstd version: `1.3.8`
|
75
|
+
|
76
|
+
Zlib version: `1.2.11`
|
77
|
+
|
78
|
+
Supported MRI Ruby versions: `2.2-2.6`
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# [Zstdlib](https://github.com/okhlybov/zstdlib) - a Zstandard data compression library binding for Ruby
|
2
|
+
|
3
|
+
_zstdlib_ is native Ruby extension for [Zstandard](https://facebook.github.io/zstd/) data compression library.
|
4
|
+
|
5
|
+
_zstdlib_ is currently available for the [MRI Ruby](https://www.ruby-lang.org/) platform.
|
6
|
+
|
7
|
+
## Why bother?
|
8
|
+
|
9
|
+
Unlike the other Zstd bindings available for Ruby, *Zstdlib* utilizes Zstd's native *Zlib* compatibility layer.
|
10
|
+
|
11
|
+
This specifically means that `Zstdlib` module is and will be (mostly) API-compatible with standard Ruby `Zlib` module and thus _zstdlib_ can be used as a drop-in replacement for _zlib_: just replace `Zlib` with `Zstdlib` throughout the source code and you're in!
|
12
|
+
|
13
|
+
Streams produced by `Zstdlib::Deflate` class can be decompressed with standard _zstd_ utility and hence can be written to _.zst_ or _.zstd_ files.
|
14
|
+
Conversely, the `Zstdlib::Inflate` class can handle data from such files.
|
15
|
+
|
16
|
+
## Use cases
|
17
|
+
|
18
|
+
### Simple string compression
|
19
|
+
````ruby
|
20
|
+
require 'zstdlib'
|
21
|
+
data = Zstdlib.deflate('Hello Zstd')
|
22
|
+
````
|
23
|
+
|
24
|
+
### Incremental data compression
|
25
|
+
````ruby
|
26
|
+
require 'zstdlib'
|
27
|
+
zstd = Zstdlib::Deflate.new
|
28
|
+
data = String.new
|
29
|
+
data << zstd.deflate('Hello')
|
30
|
+
data << zstd.deflate('Zstd')
|
31
|
+
data << zstd.finish
|
32
|
+
````
|
33
|
+
|
34
|
+
### Simple string decompression
|
35
|
+
````ruby
|
36
|
+
require 'zstdlib'
|
37
|
+
data = Zstdlib.inflate(compressed_data)
|
38
|
+
````
|
39
|
+
|
40
|
+
## Technical notes
|
41
|
+
|
42
|
+
_zstdlib_ covers the following parts of _zlib_:
|
43
|
+
|
44
|
+
- `ZStream`, `Inflate` and `Deflate` classes
|
45
|
+
- Various `Zlib::` constants (`DEFAULT_COMPRESSION` etc.)
|
46
|
+
- `Zlib::` exception classes (`Error` and its descendants)
|
47
|
+
|
48
|
+
Note that _zstdlib_ currently omits Gzip file support with its `GzipFile`, `GzipReader` and `GzipWriter` classes
|
49
|
+
and associated constants although this may be changed in future.
|
50
|
+
|
51
|
+
There exist `Zstdlib::ZSTD_VERSION` constant and `Zstdlib.zstd_version` module method which can be used to obtain shipped Zstd library version.
|
52
|
+
|
53
|
+
|
54
|
+
### General guidelines
|
55
|
+
|
56
|
+
In order to enable Zstd (de)compression capability in existing code, simply replace _zlib_ with _zstdlib_ in require statements and
|
57
|
+
`Zlib` with `Zstdlib` module references throughout the code.
|
58
|
+
|
59
|
+
The rest of the _zlib_-aware code should work unchanged.
|
60
|
+
|
61
|
+
For further information refer to documentation on _zlib_ .
|
62
|
+
|
63
|
+
|
64
|
+
### Notes on compression levels
|
65
|
+
|
66
|
+
If unsure do not pass anything to constructor in order to use `DEFAULT_COMPRESSION` level which works for both _zlib_ ans _zstdlib_.
|
67
|
+
|
68
|
+
Contrary to _zlib_ the `NO_COMPRESSION` constant in _zstdlib_ is an equivalent to `BEST_SPEED` as Zstd always compresses data.
|
69
|
+
|
70
|
+
The `BEST_COMPRESSION` constant is adjusted to reflect Zstd-specific compression level range.
|
71
|
+
Anyways this level is recommended against due to abysmal performance not to be expected from the *fast* state-of-the-art compression algorithm.
|
72
|
+
The Zstd documentation (currently) recommends using *19* as the level for optimal *best* compression.
|
73
|
+
|
74
|
+
The `BEST_SPEED` constant remains unchanged.
|
75
|
+
|
76
|
+
## Availability
|
77
|
+
|
78
|
+
_zstdlib_ home page on [GitHub](https://github.com/okhlybov/zstdlib).
|
79
|
+
|
80
|
+
Source code and system-specific compiled gems can be obtained from [rubygems.org](https://rubygems.org/gems/zstdlib).
|
81
|
+
|
82
|
+
The system-specific gems are currently provided for x32/x64 Windows and x64/ARM64 MacOS platforms.
|
83
|
+
|
84
|
+
Note that these gems are built with the [rake-compiler-dock](https://github.com/rake-compiler/rake-compiler-dock)
|
85
|
+
infrastructure the minimum supported Ruby version is raised to 2.4.
|
86
|
+
All other installations including Linux will use the source gem and hence require the compilation step with locally installed development tools.
|
87
|
+
|
88
|
+
## Release history
|
89
|
+
|
90
|
+
For user-visible changes refer to [change log](CHANGES.md).
|
91
|
+
|
92
|
+
## Caveats
|
93
|
+
|
94
|
+
This module is in testing phase so things beyond basic interface might not work as expected.
|
95
|
+
|
96
|
+
Documentation extracted from _zstdlib_ still contains traces of old zlib-related pieces.
|
97
|
+
Just keep this in mind and substitute *zlib* with *zstdlib* upon browsing.
|
98
|
+
|
99
|
+
Gzip _.gz_ file support, although available in Zstd's Zlib compatibility layer, is currently disabled.
|
100
|
+
|
101
|
+
Zstd's external compression dictionaries capability is not (yet) implemented.
|
102
|
+
|
103
|
+
# The end
|
104
|
+
|
105
|
+
Cheers,
|
106
|
+
|
107
|
+
Oleg A. Khlybov <[fougas@mail.ru](mailto:fougas@mail.ru)>
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rake/extensiontask'
|
4
|
+
require 'rake_compiler_dock'
|
5
|
+
|
6
|
+
|
7
|
+
spec = Gem::Specification.load('zstdlib.gemspec')
|
8
|
+
|
9
|
+
|
10
|
+
platforms = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32 x86_64-darwin arm64-darwin]
|
11
|
+
|
12
|
+
|
13
|
+
Rake::ExtensionTask.new('zstdlib_c', spec) do |t|
|
14
|
+
t.cross_compile = true
|
15
|
+
t.cross_platform = platforms
|
16
|
+
t.cross_config_options << '--enable-cross-build'
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
namespace "gem" do
|
21
|
+
platforms.each do |platform|
|
22
|
+
desc "build native gem for #{platform}"
|
23
|
+
# This runs on a host
|
24
|
+
task platform do
|
25
|
+
RakeCompilerDock.sh(<<~EOF, platform: platform)
|
26
|
+
gem install bundler --no-document &&
|
27
|
+
bundle &&
|
28
|
+
bundle exec rake gem:#{platform}:buildit
|
29
|
+
EOF
|
30
|
+
end
|
31
|
+
|
32
|
+
namespace platform do
|
33
|
+
# This runs in the rake-compiler-dock docker container
|
34
|
+
task "buildit" do
|
35
|
+
# Use Task#invoke because the pkg/*gem task is defined at runtime
|
36
|
+
Rake::Task["native:#{platform}"].invoke
|
37
|
+
Rake::Task["pkg/#{spec.full_name}-#{Gem::Platform.new(platform)}.gem"].invoke
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
desc "build native gem for all platforms"
|
44
|
+
multitask 'all' => platforms
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
Rake::TestTask.new(:test) do |t|
|
50
|
+
t.libs << 'test'
|
51
|
+
t.libs << 'lib'
|
52
|
+
t.test_files = FileList['test/*_test.rb']
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
Gem::PackageTask.new(spec)
|
57
|
+
|
58
|
+
|
59
|
+
# Build system explained: https://github.com/flavorjones/ruby-c-extensions-explained/tree/main/precompiled
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'mkmf'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
include RbConfig
|
7
|
+
include FileUtils
|
8
|
+
|
9
|
+
ZSTD_VERSION = '1.5.2'
|
10
|
+
ZLIB_VERSION = '1.2.11'
|
11
|
+
|
12
|
+
RB_VERSION = CONFIG['MAJOR']+'.'+CONFIG['MINOR']
|
13
|
+
ZMOD_VERSION = RB_VERSION >= '2.3' ? '3.1' : RB_VERSION # Review requirements with every new zlib module release!
|
14
|
+
|
15
|
+
# For cross compiling
|
16
|
+
ENV['CC'] = RbConfig::CONFIG['CC']
|
17
|
+
ENV['LD'] = RbConfig::CONFIG['LD']
|
18
|
+
|
19
|
+
root = File.dirname(__FILE__)
|
20
|
+
|
21
|
+
zmod = File.expand_path "ruby/zlib-#{ZMOD_VERSION}", root
|
22
|
+
zlib = File.expand_path "zlib-#{ZLIB_VERSION}", root
|
23
|
+
zstd = File.expand_path "zstd-#{ZSTD_VERSION}/lib", root
|
24
|
+
zlibwrapper = File.expand_path "zstd-#{ZSTD_VERSION}/zlibWrapper", root
|
25
|
+
|
26
|
+
cp "#{zmod}/zstdlib.c", 'zstdlib.c'
|
27
|
+
|
28
|
+
$srcs = ['zstdlib.c']
|
29
|
+
|
30
|
+
$CFLAGS += ' -fomit-frame-pointer -ffast-math -O3'
|
31
|
+
$CPPFLAGS += " -I#{zlib} -I#{zlibwrapper} -I#{zstd} -DZWRAP_USE_ZSTD=1 -DGZIP_SUPPORT=1"
|
32
|
+
$LDFLAGS += ' -s'
|
33
|
+
$LOCAL_LIBS += ' libzlibwrapper.a libz.a libzstd.a'
|
34
|
+
|
35
|
+
create_makefile('zstdlib_c')
|
36
|
+
|
37
|
+
File.open('Makefile', 'a') do |file|
|
38
|
+
file << %~
|
39
|
+
|
40
|
+
export CC LD AR CFLAGS CPPFLAGS
|
41
|
+
|
42
|
+
$(DLLIB) : libz.a libzstd.a libzlibwrapper.a
|
43
|
+
|
44
|
+
libzstd.a :
|
45
|
+
\texport SRCDIR=#{zstd} && mkdir -p zstd && $(MAKE) -C zstd -f #{File.expand_path root}/zstd.mk
|
46
|
+
|
47
|
+
libz.a :
|
48
|
+
\texport SRCDIR=#{zlib} && mkdir -p zlib && $(MAKE) -C zlib -f #{File.expand_path root}/zlib.mk
|
49
|
+
|
50
|
+
libzlibwrapper.a :
|
51
|
+
\texport SRCDIR=#{zlibwrapper} && mkdir -p zlibwrapper && $(MAKE) -C zlibwrapper -f #{File.expand_path root}/zlibwrapper.mk
|
52
|
+
|
53
|
+
~
|
54
|
+
end
|