zstdlib 0.13.0-x86-linux
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 +107 -0
- data/Gemfile +3 -0
- data/README.md +107 -0
- data/Rakefile +59 -0
- data/ext/zstdlib_c/extconf.rb +59 -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/ruby/zlib-3.2/zstdlib.c +5090 -0
- data/ext/zstdlib_c/ruby/zlib-3.3/zstdlib.c +5090 -0
- data/ext/zstdlib_c/zlib-1.3.1/adler32.c +164 -0
- data/ext/zstdlib_c/zlib-1.3.1/compress.c +75 -0
- data/ext/zstdlib_c/zlib-1.3.1/crc32.c +1049 -0
- data/ext/zstdlib_c/zlib-1.3.1/crc32.h +9446 -0
- data/ext/zstdlib_c/zlib-1.3.1/deflate.c +2139 -0
- data/ext/zstdlib_c/zlib-1.3.1/deflate.h +377 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzclose.c +23 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzguts.h +214 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzlib.c +582 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzread.c +602 -0
- data/ext/zstdlib_c/zlib-1.3.1/gzwrite.c +631 -0
- data/ext/zstdlib_c/zlib-1.3.1/infback.c +628 -0
- data/ext/zstdlib_c/zlib-1.3.1/inffast.c +320 -0
- data/ext/zstdlib_c/zlib-1.3.1/inffast.h +11 -0
- data/ext/zstdlib_c/zlib-1.3.1/inffixed.h +94 -0
- data/ext/zstdlib_c/zlib-1.3.1/inflate.c +1526 -0
- data/ext/zstdlib_c/zlib-1.3.1/inflate.h +126 -0
- data/ext/zstdlib_c/zlib-1.3.1/inftrees.c +299 -0
- data/ext/zstdlib_c/zlib-1.3.1/inftrees.h +62 -0
- data/ext/zstdlib_c/zlib-1.3.1/trees.c +1117 -0
- data/ext/zstdlib_c/zlib-1.3.1/trees.h +128 -0
- data/ext/zstdlib_c/zlib-1.3.1/uncompr.c +85 -0
- data/ext/zstdlib_c/zlib-1.3.1/zconf.h +543 -0
- data/ext/zstdlib_c/zlib-1.3.1/zlib.h +1938 -0
- data/ext/zstdlib_c/zlib-1.3.1/zutil.c +299 -0
- data/ext/zstdlib_c/zlib-1.3.1/zutil.h +254 -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.6/lib/common/allocations.h +55 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/bits.h +200 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/bitstream.h +457 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/compiler.h +450 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/cpu.h +249 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/debug.c +30 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/debug.h +116 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/entropy_common.c +340 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/error_private.c +63 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/error_private.h +168 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/fse.h +640 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/fse_decompress.c +313 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/huf.h +286 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/mem.h +426 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/pool.c +371 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/pool.h +90 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/portability_macros.h +158 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/threading.c +182 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/threading.h +150 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/xxhash.c +18 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/xxhash.h +7020 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_common.c +48 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_deps.h +111 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_internal.h +392 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/common/zstd_trace.h +163 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/clevels.h +134 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/fse_compress.c +625 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/hist.c +181 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/hist.h +75 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/huf_compress.c +1464 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress.c +7153 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_internal.h +1534 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_literals.c +235 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_literals.h +39 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_sequences.c +442 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_sequences.h +54 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_superblock.c +688 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_compress_superblock.h +32 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_cwksp.h +748 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_double_fast.c +770 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_double_fast.h +50 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_fast.c +968 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_fast.h +38 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_lazy.c +2199 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_lazy.h +202 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_ldm.c +730 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_ldm.h +117 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_ldm_geartab.h +106 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_opt.c +1576 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstd_opt.h +80 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstdmt_compress.c +1882 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/compress/zstdmt_compress.h +113 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/huf_decompress.c +1944 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/huf_decompress_amd64.S +595 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_ddict.c +244 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_ddict.h +44 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress.c +2407 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress_block.c +2215 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress_block.h +73 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/decompress/zstd_decompress_internal.h +240 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/zdict.h +474 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/zstd.h +3089 -0
- data/ext/zstdlib_c/zstd-1.5.6/lib/zstd_errors.h +114 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzclose.c +26 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzcompatibility.h +68 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzguts.h +229 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzlib.c +587 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzread.c +637 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/gzwrite.c +631 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/zstd_zlibwrapper.c +1200 -0
- data/ext/zstdlib_c/zstd-1.5.6/zlibWrapper/zstd_zlibwrapper.h +91 -0
- data/ext/zstdlib_c/zstd.mk +15 -0
- data/lib/2.4/zstdlib_c.so +0 -0
- data/lib/2.5/zstdlib_c.so +0 -0
- data/lib/2.6/zstdlib_c.so +0 -0
- data/lib/2.7/zstdlib_c.so +0 -0
- data/lib/3.0/zstdlib_c.so +0 -0
- data/lib/3.1/zstdlib_c.so +0 -0
- data/lib/3.2/zstdlib_c.so +0 -0
- data/lib/3.3/zstdlib_c.so +0 -0
- data/lib/zstdlib.rb +6 -0
- data/test/zstdlib_test.rb +21 -0
- metadata +243 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2fb52ee73594a2ce8766f1974754e68454c30c07684cc7f4272350add6b90427
|
4
|
+
data.tar.gz: 90b580f359534445b8cfcdabfc63c38e1795b1f8b551514a6ced1fe6b8d950cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 02d9a4103d519b739781d9148fdc5face963753c02ea4d1411ae1695a6f00420a9796192fca01934e47f1f133bbee98f1aa5b4798dade17953ddc99866a211d4
|
7
|
+
data.tar.gz: cb6e4d70dc53e94111e416d6043c1df8a0204176b1e42873ebc754222ffc15705dbff59302df4776a0ba5f8061ab230db4bfe551f3408df6ec74191ed54efdd4
|
data/.yardopts
ADDED
data/CHANGES.md
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# 0.13.0
|
2
|
+
|
3
|
+
Updated Zstd to `1.5.6`
|
4
|
+
|
5
|
+
Upgraded rake-compiler-dock to `1.5.0`
|
6
|
+
|
7
|
+
|
8
|
+
# 0.12.0
|
9
|
+
|
10
|
+
Updated Zlib to `1.3.1`
|
11
|
+
|
12
|
+
Added support for MRI Ruby version `3.3`
|
13
|
+
|
14
|
+
Upgraded rake-compiler-dock to `1.4.0`
|
15
|
+
|
16
|
+
|
17
|
+
# 0.11.0
|
18
|
+
|
19
|
+
Updated Zstd to `1.5.5`
|
20
|
+
|
21
|
+
Added support for MRI Ruby version `3.2`
|
22
|
+
|
23
|
+
|
24
|
+
# 0.10.0
|
25
|
+
|
26
|
+
Updated Zlib to `1.2.12`
|
27
|
+
|
28
|
+
|
29
|
+
# 0.9.0
|
30
|
+
|
31
|
+
Updated Zstd to `1.5.2`
|
32
|
+
|
33
|
+
Added support for MRI Ruby versions `3.0-3.1`
|
34
|
+
|
35
|
+
Upgraded rake-compiler-dock to `1.2.0`
|
36
|
+
|
37
|
+
Implemented deployment of system-specific compiled gems for for x32/x64 Windows and x64/ARM64 MacOS platforms
|
38
|
+
|
39
|
+
|
40
|
+
# 0.8.0
|
41
|
+
|
42
|
+
Zstd version update to `1.5.0`
|
43
|
+
|
44
|
+
|
45
|
+
# 0.7.0
|
46
|
+
|
47
|
+
Zstd version update to `1.4.5`
|
48
|
+
|
49
|
+
|
50
|
+
# 0.6.0
|
51
|
+
|
52
|
+
Added support for MRI Ruby version `2.7`
|
53
|
+
|
54
|
+
Upgraded rake-compiler-dock to `1.0.0`
|
55
|
+
|
56
|
+
|
57
|
+
# 0.5.0
|
58
|
+
|
59
|
+
Zstd version update to `1.4.4`
|
60
|
+
|
61
|
+
|
62
|
+
# 0.4.0
|
63
|
+
|
64
|
+
Zstd version update to `1.4.3`
|
65
|
+
|
66
|
+
Relocated to GitHub.
|
67
|
+
|
68
|
+
|
69
|
+
# 0.3.0
|
70
|
+
|
71
|
+
Zstd version update to `1.4.2`
|
72
|
+
|
73
|
+
|
74
|
+
# 0.2.0
|
75
|
+
|
76
|
+
Zstd version update to `1.4.0`
|
77
|
+
|
78
|
+
Documentation updates.
|
79
|
+
|
80
|
+
|
81
|
+
# 0.1.2
|
82
|
+
|
83
|
+
Implemented `Zstdlib::ZSTD_VERSION` constant and `Zstdlib.zstd_version` module method for Zstd version retrieval.
|
84
|
+
|
85
|
+
Documentation updates.
|
86
|
+
|
87
|
+
|
88
|
+
# 0.1.1
|
89
|
+
|
90
|
+
Pick up the most recent compatible source for _zstdlib_ Ruby extension module instead of target Ruby version.
|
91
|
+
|
92
|
+
Replaced (most) references to `Zlib` with `Zstdlib` within extractable documentation.
|
93
|
+
|
94
|
+
Fixed a few missing methods on Ruby side.
|
95
|
+
|
96
|
+
Documentation updates.
|
97
|
+
|
98
|
+
|
99
|
+
# 0.1.0
|
100
|
+
|
101
|
+
Initial release.
|
102
|
+
|
103
|
+
Zstd version: `1.3.8`
|
104
|
+
|
105
|
+
Zlib version: `1.2.11`
|
106
|
+
|
107
|
+
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-linux x86_64-linux 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,59 @@
|
|
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.6'
|
10
|
+
ZLIB_VERSION = '1.3.1'
|
11
|
+
|
12
|
+
RB_VERSION = CONFIG['MAJOR']+'.'+CONFIG['MINOR']
|
13
|
+
|
14
|
+
# Review requirements with every new zlib module release!
|
15
|
+
ZMOD_VERSION = if RB_VERSION >= '2.5' then '3.3'
|
16
|
+
elsif RB_VERSION >= '2.3' then '3.2'
|
17
|
+
else RB_VERSION
|
18
|
+
end
|
19
|
+
|
20
|
+
# For cross compiling
|
21
|
+
ENV['CC'] = RbConfig::CONFIG['CC']
|
22
|
+
ENV['LD'] = RbConfig::CONFIG['LD']
|
23
|
+
|
24
|
+
root = File.dirname(__FILE__)
|
25
|
+
|
26
|
+
zmod = File.expand_path "ruby/zlib-#{ZMOD_VERSION}", root
|
27
|
+
zlib = File.expand_path "zlib-#{ZLIB_VERSION}", root
|
28
|
+
zstd = File.expand_path "zstd-#{ZSTD_VERSION}/lib", root
|
29
|
+
zlibwrapper = File.expand_path "zstd-#{ZSTD_VERSION}/zlibWrapper", root
|
30
|
+
|
31
|
+
cp "#{zmod}/zstdlib.c", 'zstdlib.c'
|
32
|
+
|
33
|
+
$srcs = ['zstdlib.c']
|
34
|
+
|
35
|
+
$CFLAGS += ' -fomit-frame-pointer -ffast-math -O3'
|
36
|
+
$CPPFLAGS += " -I#{zlib} -I#{zlibwrapper} -I#{zstd} -DZWRAP_USE_ZSTD=1 -DGZIP_SUPPORT=1"
|
37
|
+
$LDFLAGS += ' -s'
|
38
|
+
$LOCAL_LIBS += ' libzlibwrapper.a libz.a libzstd.a'
|
39
|
+
|
40
|
+
create_makefile('zstdlib_c')
|
41
|
+
|
42
|
+
File.open('Makefile', 'a') do |file|
|
43
|
+
file << %~
|
44
|
+
|
45
|
+
export CC LD AR CFLAGS CPPFLAGS
|
46
|
+
|
47
|
+
$(DLLIB) : libz.a libzstd.a libzlibwrapper.a
|
48
|
+
|
49
|
+
libzstd.a :
|
50
|
+
\texport SRCDIR=#{zstd} && mkdir -p zstd && $(MAKE) -C zstd -f #{File.expand_path root}/zstd.mk
|
51
|
+
|
52
|
+
libz.a :
|
53
|
+
\texport SRCDIR=#{zlib} && mkdir -p zlib && $(MAKE) -C zlib -f #{File.expand_path root}/zlib.mk
|
54
|
+
|
55
|
+
libzlibwrapper.a :
|
56
|
+
\texport SRCDIR=#{zlibwrapper} && mkdir -p zlibwrapper && $(MAKE) -C zlibwrapper -f #{File.expand_path root}/zlibwrapper.mk
|
57
|
+
|
58
|
+
~
|
59
|
+
end
|