zrip 0.1.1 → 0.2.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 +4 -4
- data/CHANGELOG.md +16 -0
- data/Cargo.lock +38 -74
- data/README.md +13 -40
- data/ext/zrip/Cargo.toml +3 -3
- data/ext/zrip/build.rs +23 -0
- data/ext/zrip/src/lib.rs +697 -300
- data/ext/zrip/src/rb.rs +615 -0
- data/lib/zrip/block_codec.rb +49 -0
- data/lib/zrip/dict_trainer.rb +32 -0
- data/lib/zrip/dictionary.rb +10 -0
- data/lib/zrip/frame_codec.rb +58 -0
- data/lib/zrip/version.rb +1 -1
- data/lib/zrip.rb +14 -0
- metadata +7 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 50caa1679bd74290e01032b2564ab2ac083633f00ad7070f2e3e597572ffe22b
|
|
4
|
+
data.tar.gz: d89a94b7221aba11a0084f8ffeab771428f682ddf19908a647c2bce862b43ffe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 74bc8d13edae353144da41a66e80d41440157dc11c9555726c2c01659d88a02c8ffd0a7410b0157fb011a45677c54448a808ed463a1f9b1d99bd9a2769e42926
|
|
7
|
+
data.tar.gz: 91c282a2f5275e2e0cd72a9a2cf089a0582e47d256acce3c9bf67be6f494ab89a046bfece175d23f9543e7162b90b8bf66cc0dd97e5ebd5c9a695c3462e23d01
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.2.0] - 2026-08-07
|
|
6
|
+
|
|
7
|
+
- Release the Ruby GVL around large frame/block compression and frame
|
|
8
|
+
decompression calls.
|
|
9
|
+
- Update the `zrip` crate dependency to 0.8.5.
|
|
10
|
+
- Replace Magnus with direct `rb-sys` bindings, add TruffleRuby build support,
|
|
11
|
+
and lower the Ruby requirement to 3.4.
|
|
12
|
+
- Apply `max_output_size:` to the total decompressed output of concatenated
|
|
13
|
+
Zstandard frames.
|
|
14
|
+
- Add RubyDoc metadata and move API reference details from `README.md` into
|
|
15
|
+
YARD comments.
|
|
16
|
+
|
|
17
|
+
## [0.1.2] - 2026-08-05
|
|
18
|
+
|
|
19
|
+
- Update `zrip` crate dependency from 0.8.3 to 0.8.4.
|
|
20
|
+
|
|
5
21
|
## [0.1.1] - 2026-06-29
|
|
6
22
|
|
|
7
23
|
- Update `zrip` crate dependency from 0.3 to 0.8.
|
data/Cargo.lock
CHANGED
|
@@ -4,9 +4,9 @@ version = 4
|
|
|
4
4
|
|
|
5
5
|
[[package]]
|
|
6
6
|
name = "aho-corasick"
|
|
7
|
-
version = "1.1.
|
|
7
|
+
version = "1.1.5"
|
|
8
8
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
-
checksum = "
|
|
9
|
+
checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
|
|
10
10
|
dependencies = [
|
|
11
11
|
"memchr",
|
|
12
12
|
]
|
|
@@ -31,9 +31,9 @@ dependencies = [
|
|
|
31
31
|
|
|
32
32
|
[[package]]
|
|
33
33
|
name = "bitflags"
|
|
34
|
-
version = "2.13.
|
|
34
|
+
version = "2.13.1"
|
|
35
35
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
36
|
-
checksum = "
|
|
36
|
+
checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
|
|
37
37
|
|
|
38
38
|
[[package]]
|
|
39
39
|
name = "cexpr"
|
|
@@ -52,9 +52,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
|
52
52
|
|
|
53
53
|
[[package]]
|
|
54
54
|
name = "clang-sys"
|
|
55
|
-
version = "1.
|
|
55
|
+
version = "1.9.1"
|
|
56
56
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
57
|
-
checksum = "
|
|
57
|
+
checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a"
|
|
58
58
|
dependencies = [
|
|
59
59
|
"glob",
|
|
60
60
|
"libc",
|
|
@@ -63,21 +63,21 @@ dependencies = [
|
|
|
63
63
|
|
|
64
64
|
[[package]]
|
|
65
65
|
name = "either"
|
|
66
|
-
version = "1.
|
|
66
|
+
version = "1.17.0"
|
|
67
67
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
68
|
-
checksum = "
|
|
68
|
+
checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d"
|
|
69
69
|
|
|
70
70
|
[[package]]
|
|
71
71
|
name = "fearless_simd"
|
|
72
|
-
version = "0.
|
|
72
|
+
version = "0.6.0"
|
|
73
73
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
74
|
-
checksum = "
|
|
74
|
+
checksum = "e0f5f895dac0865bc235f1364793899569a7db538137f1024dccea56bf41c78d"
|
|
75
75
|
|
|
76
76
|
[[package]]
|
|
77
77
|
name = "glob"
|
|
78
|
-
version = "0.3.
|
|
78
|
+
version = "0.3.4"
|
|
79
79
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
80
|
-
checksum = "
|
|
80
|
+
checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
|
|
81
81
|
|
|
82
82
|
[[package]]
|
|
83
83
|
name = "itertools"
|
|
@@ -96,9 +96,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
|
|
96
96
|
|
|
97
97
|
[[package]]
|
|
98
98
|
name = "libc"
|
|
99
|
-
version = "0.2.
|
|
99
|
+
version = "0.2.189"
|
|
100
100
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
101
|
-
checksum = "
|
|
101
|
+
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
|
102
102
|
|
|
103
103
|
[[package]]
|
|
104
104
|
name = "libloading"
|
|
@@ -110,34 +110,11 @@ dependencies = [
|
|
|
110
110
|
"windows-link",
|
|
111
111
|
]
|
|
112
112
|
|
|
113
|
-
[[package]]
|
|
114
|
-
name = "magnus"
|
|
115
|
-
version = "0.8.2"
|
|
116
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
117
|
-
checksum = "3b36a5b126bbe97eb0d02d07acfeb327036c6319fd816139a49824a83b7f9012"
|
|
118
|
-
dependencies = [
|
|
119
|
-
"magnus-macros",
|
|
120
|
-
"rb-sys",
|
|
121
|
-
"rb-sys-env",
|
|
122
|
-
"seq-macro",
|
|
123
|
-
]
|
|
124
|
-
|
|
125
|
-
[[package]]
|
|
126
|
-
name = "magnus-macros"
|
|
127
|
-
version = "0.8.0"
|
|
128
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
129
|
-
checksum = "47607461fd8e1513cb4f2076c197d8092d921a1ea75bd08af97398f593751892"
|
|
130
|
-
dependencies = [
|
|
131
|
-
"proc-macro2",
|
|
132
|
-
"quote",
|
|
133
|
-
"syn",
|
|
134
|
-
]
|
|
135
|
-
|
|
136
113
|
[[package]]
|
|
137
114
|
name = "memchr"
|
|
138
|
-
version = "2.8.
|
|
115
|
+
version = "2.8.3"
|
|
139
116
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
140
|
-
checksum = "
|
|
117
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
141
118
|
|
|
142
119
|
[[package]]
|
|
143
120
|
name = "minimal-lexical"
|
|
@@ -157,18 +134,18 @@ dependencies = [
|
|
|
157
134
|
|
|
158
135
|
[[package]]
|
|
159
136
|
name = "proc-macro2"
|
|
160
|
-
version = "1.0.
|
|
137
|
+
version = "1.0.107"
|
|
161
138
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
162
|
-
checksum = "
|
|
139
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
163
140
|
dependencies = [
|
|
164
141
|
"unicode-ident",
|
|
165
142
|
]
|
|
166
143
|
|
|
167
144
|
[[package]]
|
|
168
145
|
name = "quote"
|
|
169
|
-
version = "1.0.
|
|
146
|
+
version = "1.0.47"
|
|
170
147
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
171
|
-
checksum = "
|
|
148
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
172
149
|
dependencies = [
|
|
173
150
|
"proc-macro2",
|
|
174
151
|
]
|
|
@@ -197,17 +174,11 @@ dependencies = [
|
|
|
197
174
|
"syn",
|
|
198
175
|
]
|
|
199
176
|
|
|
200
|
-
[[package]]
|
|
201
|
-
name = "rb-sys-env"
|
|
202
|
-
version = "0.2.3"
|
|
203
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
204
|
-
checksum = "cca7ad6a7e21e72151d56fe2495a259b5670e204c3adac41ee7ef676ea08117a"
|
|
205
|
-
|
|
206
177
|
[[package]]
|
|
207
178
|
name = "regex"
|
|
208
|
-
version = "1.
|
|
179
|
+
version = "1.13.1"
|
|
209
180
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
210
|
-
checksum = "
|
|
181
|
+
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
|
|
211
182
|
dependencies = [
|
|
212
183
|
"aho-corasick",
|
|
213
184
|
"memchr",
|
|
@@ -217,9 +188,9 @@ dependencies = [
|
|
|
217
188
|
|
|
218
189
|
[[package]]
|
|
219
190
|
name = "regex-automata"
|
|
220
|
-
version = "0.4.
|
|
191
|
+
version = "0.4.18"
|
|
221
192
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
222
|
-
checksum = "
|
|
193
|
+
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
|
|
223
194
|
dependencies = [
|
|
224
195
|
"aho-corasick",
|
|
225
196
|
"memchr",
|
|
@@ -234,15 +205,9 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|
|
234
205
|
|
|
235
206
|
[[package]]
|
|
236
207
|
name = "rustc-hash"
|
|
237
|
-
version = "2.1.
|
|
238
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
239
|
-
checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe"
|
|
240
|
-
|
|
241
|
-
[[package]]
|
|
242
|
-
name = "seq-macro"
|
|
243
|
-
version = "0.3.6"
|
|
208
|
+
version = "2.1.3"
|
|
244
209
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
245
|
-
checksum = "
|
|
210
|
+
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
|
246
211
|
|
|
247
212
|
[[package]]
|
|
248
213
|
name = "shell-words"
|
|
@@ -258,9 +223,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
|
258
223
|
|
|
259
224
|
[[package]]
|
|
260
225
|
name = "syn"
|
|
261
|
-
version = "2.0.
|
|
226
|
+
version = "2.0.119"
|
|
262
227
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
263
|
-
checksum = "
|
|
228
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
264
229
|
dependencies = [
|
|
265
230
|
"proc-macro2",
|
|
266
231
|
"quote",
|
|
@@ -281,18 +246,17 @@ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
|
|
281
246
|
|
|
282
247
|
[[package]]
|
|
283
248
|
name = "zrip"
|
|
284
|
-
version = "0.1.
|
|
249
|
+
version = "0.1.2"
|
|
285
250
|
dependencies = [
|
|
286
|
-
"magnus",
|
|
287
251
|
"rb-sys",
|
|
288
|
-
"zrip 0.8.
|
|
252
|
+
"zrip 0.8.5",
|
|
289
253
|
]
|
|
290
254
|
|
|
291
255
|
[[package]]
|
|
292
256
|
name = "zrip"
|
|
293
|
-
version = "0.8.
|
|
257
|
+
version = "0.8.5"
|
|
294
258
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
295
|
-
checksum = "
|
|
259
|
+
checksum = "fa05c09787b3aaaaa57870dca9fd9f3b4934018cbb5dde1b112017e2e70ec491"
|
|
296
260
|
dependencies = [
|
|
297
261
|
"zrip-core",
|
|
298
262
|
"zrip-decode",
|
|
@@ -301,15 +265,15 @@ dependencies = [
|
|
|
301
265
|
|
|
302
266
|
[[package]]
|
|
303
267
|
name = "zrip-core"
|
|
304
|
-
version = "0.
|
|
268
|
+
version = "0.9.1"
|
|
305
269
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
306
|
-
checksum = "
|
|
270
|
+
checksum = "9335acd94c1f09f729178fc339f9d49790254c1e98ba076f88df3a3f534c4e7d"
|
|
307
271
|
|
|
308
272
|
[[package]]
|
|
309
273
|
name = "zrip-decode"
|
|
310
|
-
version = "0.8.
|
|
274
|
+
version = "0.8.5"
|
|
311
275
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
312
|
-
checksum = "
|
|
276
|
+
checksum = "1801cd8b5d374e2bc31cd8a231182dd47e621492fa0bf68ca7d3033e001cd06b"
|
|
313
277
|
dependencies = [
|
|
314
278
|
"fearless_simd",
|
|
315
279
|
"zrip-core",
|
|
@@ -317,9 +281,9 @@ dependencies = [
|
|
|
317
281
|
|
|
318
282
|
[[package]]
|
|
319
283
|
name = "zrip-encode"
|
|
320
|
-
version = "0.8.
|
|
284
|
+
version = "0.8.4"
|
|
321
285
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
322
|
-
checksum = "
|
|
286
|
+
checksum = "38e7e22b665b947f0240b44805713e87a15c34e86d0891cbe2856c575c5cda1d"
|
|
323
287
|
dependencies = [
|
|
324
288
|
"zrip-core",
|
|
325
289
|
]
|
data/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# zrip
|
|
1
|
+
# zrip: Ractor-safe Zstandard for Ruby
|
|
2
2
|
|
|
3
3
|
[](https://github.com/paddor/zrip-rb/actions/workflows/ci.yml)
|
|
4
4
|
[](https://rubygems.org/gems/zrip)
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](https://www.ruby-lang.org)
|
|
7
7
|
|
|
8
8
|
Ruby bindings for [zrip](https://crates.io/crates/zrip), a pure-Rust Zstandard
|
|
9
|
-
implementation. Built
|
|
10
|
-
|
|
9
|
+
implementation. Built as an `rb-sys` native extension and declared Ractor-safe
|
|
10
|
+
so you can compress from any Ractor without a global lock.
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
@@ -22,7 +22,7 @@ declared Ractor-safe so you can compress from any Ractor without a global lock.
|
|
|
22
22
|
|
|
23
23
|
## Install
|
|
24
24
|
|
|
25
|
-
Requires Ruby >= 4
|
|
25
|
+
Requires Ruby >= 3.4 and a Rust toolchain (for building the native extension):
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
28
|
gem install zrip
|
|
@@ -66,8 +66,8 @@ strong = Zrip::FrameCodec.new(level: 19) # higher = smaller output
|
|
|
66
66
|
```ruby
|
|
67
67
|
codec = Zrip::FrameCodec.new
|
|
68
68
|
|
|
69
|
-
# Limit output size to 1 MiB
|
|
70
|
-
codec.decompress(compressed, max_output_size:
|
|
69
|
+
# Limit total output size to 1 MiB
|
|
70
|
+
codec.decompress(compressed, max_output_size: 1024 * 1024)
|
|
71
71
|
|
|
72
72
|
# Read frame content size from header (without decompressing)
|
|
73
73
|
Zrip::FrameCodec.get_frame_content_size(compressed) #=> 12000
|
|
@@ -96,6 +96,9 @@ codec = Zrip::FrameCodec.new(dict: dict)
|
|
|
96
96
|
|
|
97
97
|
### Ractor safety
|
|
98
98
|
|
|
99
|
+
On Ruby VMs without Ractor support, the codecs still work normally; the
|
|
100
|
+
Ractor-specific guarantees and examples do not apply.
|
|
101
|
+
|
|
99
102
|
```ruby
|
|
100
103
|
codec = Zrip::FrameCodec.new
|
|
101
104
|
|
|
@@ -111,39 +114,9 @@ end
|
|
|
111
114
|
ractors.each { |r| p r.value } # => :ok, :ok, :ok, :ok
|
|
112
115
|
```
|
|
113
116
|
|
|
114
|
-
##
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|---|---|---|
|
|
118
|
-
| `Zrip::FrameCodec` | `.new(dict: nil, level: 1)` | Create a frame codec, optionally with a `Dictionary`, raw `String` dict, or compression level |
|
|
119
|
-
| | `.get_frame_content_size(string)` | Read Frame_Content_Size from a Zstd frame header |
|
|
120
|
-
| | `#compress(string)` | Compress to Zstd frame |
|
|
121
|
-
| | `#decompress(string, max_output_size: nil)` | Decompress a Zstd frame, optionally bounded |
|
|
122
|
-
| | `#has_dict?` | Whether a dictionary is loaded |
|
|
123
|
-
| | `#id` | Dictionary ID (nil without dict) |
|
|
124
|
-
| | `#size` | Dictionary size in bytes (0 without dict) |
|
|
125
|
-
| | `#level` | Compression level |
|
|
126
|
-
| `Zrip::BlockCodec` | `.new(dict: nil, level: 1)` | Create a block codec, optionally with a dict |
|
|
127
|
-
| | `#compress(string)` | Compress to Zstd block |
|
|
128
|
-
| | `#decompress(string, max_output_size: nil)` | Decompress a Zstd block, optionally bounded |
|
|
129
|
-
| | `#has_dict?` | Whether a dictionary is loaded |
|
|
130
|
-
| | `#size` | Dictionary size in bytes (0 without dict) |
|
|
131
|
-
| | `#level` | Compression level |
|
|
132
|
-
| `Zrip::Dictionary` | `.new(bytes:, id: nil)` | Immutable dictionary value object (`Data.define`) |
|
|
133
|
-
| | `#bytes` | Frozen binary dict bytes |
|
|
134
|
-
| | `#id` | 32-bit dictionary ID (auto-detected from ZDICT header or SHA-256) |
|
|
135
|
-
| | `#size` | Dictionary size in bytes |
|
|
136
|
-
| `Zrip::DictTrainer` | `.new(max_dict_size)` | Create a trainer |
|
|
137
|
-
| | `#add_sample(string)` | Feed a training sample (skips < 4 bytes) |
|
|
138
|
-
| | `#train` | Consume the trainer, return dict bytes |
|
|
139
|
-
| | `#sample_count` | Number of accepted samples |
|
|
140
|
-
| | `#total_bytes` | Total bytes of accepted samples |
|
|
141
|
-
| | `#trained?` | Whether `#train` has been called |
|
|
142
|
-
| | `#max_dict_size` | Configured max dict size |
|
|
143
|
-
| `Zrip::DecompressError` | | Raised on decompression failure |
|
|
144
|
-
| `Zrip::CompressError` | | Raised on compression failure |
|
|
145
|
-
| `Zrip::MissingContentSizeError` | | Raised when Frame_Content_Size is absent (subclass of `DecompressError`) |
|
|
146
|
-
| `Zrip::OutputSizeLimitError` | | Raised when declared content size exceeds limit (subclass of `DecompressError`) |
|
|
117
|
+
## Documentation
|
|
118
|
+
|
|
119
|
+
Reference: <https://rubydoc.info/gems/zrip>
|
|
147
120
|
|
|
148
121
|
## License
|
|
149
122
|
|
data/ext/zrip/Cargo.toml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "zrip"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.2"
|
|
4
4
|
edition = "2021"
|
|
5
|
+
build = "build.rs"
|
|
5
6
|
|
|
6
7
|
[lib]
|
|
7
8
|
name = "zrip"
|
|
8
9
|
crate-type = ["cdylib", "rlib"]
|
|
9
10
|
|
|
10
11
|
[dependencies]
|
|
11
|
-
zstd = { version = "0.8", package = "zrip", features = ["frame", "dict_builder"] }
|
|
12
|
-
magnus = "0.8"
|
|
12
|
+
zstd = { version = "0.8.5", package = "zrip", features = ["frame", "dict_builder"] }
|
|
13
13
|
rb-sys = "0.9"
|
|
14
14
|
|
|
15
15
|
[build-dependencies]
|
data/ext/zrip/build.rs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
use std::process::Command;
|
|
2
|
+
|
|
3
|
+
fn main() {
|
|
4
|
+
println!("cargo:rerun-if-env-changed=RUBY");
|
|
5
|
+
println!("cargo:rustc-check-cfg=cfg(ruby_engine, values(\"mri\", \"truffleruby\"))");
|
|
6
|
+
|
|
7
|
+
let ruby = std::env::var("RUBY").unwrap_or_else(|_| "ruby".to_string());
|
|
8
|
+
let output = Command::new(&ruby)
|
|
9
|
+
.arg("-rrbconfig")
|
|
10
|
+
.arg("-e")
|
|
11
|
+
.arg("print RbConfig::CONFIG.fetch('ruby_install_name')")
|
|
12
|
+
.output()
|
|
13
|
+
.unwrap_or_else(|err| panic!("failed to run {ruby}: {err}"));
|
|
14
|
+
|
|
15
|
+
if !output.status.success() {
|
|
16
|
+
panic!("failed to query Ruby engine with {ruby}");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
match String::from_utf8_lossy(&output.stdout).trim() {
|
|
20
|
+
"truffleruby" => println!("cargo:rustc-cfg=ruby_engine=\"truffleruby\""),
|
|
21
|
+
_ => println!("cargo:rustc-cfg=ruby_engine=\"mri\""),
|
|
22
|
+
}
|
|
23
|
+
}
|