rake-compiler 1.3.1 → 1.3.3
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/History.md +22 -0
- data/README.md +29 -0
- data/lib/rake/extensiontask.rb +42 -12
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3397eb9f08bac5f0a8c4cc98e7eebc192f73243c5b8e4cf31811a49591e143bf
|
|
4
|
+
data.tar.gz: 820a5d04f528f0ff98bf215b60203237e4bd2811aa414e9df8d8ae420f9e7692
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9130791a2c7c76d514ddeae980a96c94e9f8be95e4e974d70ab00a197b078523269dc756a89c5c1fc38037d070249d9415d65bc6700f88bb3261aa07cbb80d91
|
|
7
|
+
data.tar.gz: 3a4ede3bd9e9a7f883b22438c2ae90f0ac1135fad53a207b01322858e35b57e6cdc10acf6cb33ec5ef757ed4b4e51c585967872168d83e725dec6494c9a6a8ad
|
data/History.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
### 1.3.3 / 2026-11-04
|
|
2
|
+
|
|
3
|
+
* Improvements:
|
|
4
|
+
* GH-260 GH-261: Add support for Ruby 2.1 and 2.2 again.
|
|
5
|
+
* Patch by Felix Bünemann
|
|
6
|
+
|
|
7
|
+
* Thanks:
|
|
8
|
+
* Felix Bünemann
|
|
9
|
+
|
|
10
|
+
### 1.3.2 / 2026-10-08
|
|
11
|
+
|
|
12
|
+
* Improvements:
|
|
13
|
+
* GH-257: Add support for content addressable gem.
|
|
14
|
+
* Patch by Harriet Oughton
|
|
15
|
+
* Patch by Jenny Shen
|
|
16
|
+
* Patch by Gira Chawda
|
|
17
|
+
|
|
18
|
+
* Thanks:
|
|
19
|
+
* Harriet Oughton
|
|
20
|
+
* Jenny Shen
|
|
21
|
+
* Gira Chawda
|
|
22
|
+
|
|
1
23
|
### 1.3.1 / 2025-05-06
|
|
2
24
|
|
|
3
25
|
* Improvements:
|
data/README.md
CHANGED
|
@@ -247,6 +247,7 @@ end
|
|
|
247
247
|
| cross_config_options | ExtensionTask (CRuby) | [Optional] See [Cross compilation - the future is now.](#cross-compilation---the-future-is-now) Default: `[]`. |
|
|
248
248
|
| no_native | ExtensionTask (CRuby) | [Optional] Set to true to prevent non-CRuby platforms from defining native tasks. Default: `false`. |
|
|
249
249
|
| config_includes | ExtensionTask (CRuby) | [Optional] Specify an Array of paths to include as `-I...:...` includes during compilation. Default: `['.']`. |
|
|
250
|
+
| content_addressable | ExtensionTask (CRuby) | [Optional] Set to true to also build a content addressable gem per Ruby ABI. See [Building content addressable gems](#building-content-addressable-gems). Default: `false`. |
|
|
250
251
|
| classpath | JavaExtensionTask | [Optional] Specify additional classpath paths as an Array. Default: _Uses the current CLASSPATH._ |
|
|
251
252
|
| debug | JavaExtensionTask | [Optional] Whether to set the debug flag during compilation. Default: `false`. |
|
|
252
253
|
| source_version | JavaExtensionTask | [Optional] The JRE version that your source code requires to compile. Default: `1.6`. |
|
|
@@ -444,6 +445,34 @@ This approach catch the cases of provided fat binaries or gems compiled by the
|
|
|
444
445
|
end user installing the gem. It has also been implemented successfully in
|
|
445
446
|
several projects.
|
|
446
447
|
|
|
448
|
+
#### Building content addressable gems
|
|
449
|
+
|
|
450
|
+
RubyGems 4.1.0 or later can build gems that target a single Ruby ABI and are
|
|
451
|
+
named by the hash of their contents instead of by platform. If you enable
|
|
452
|
+
`content_addressable`, rake-compiler builds one of these gems for each Ruby
|
|
453
|
+
version in `RUBY_CC_VERSION`, in addition to the multi ABI gem:
|
|
454
|
+
|
|
455
|
+
```ruby
|
|
456
|
+
Rake::ExtensionTask.new('my_extension', gem_spec) do |ext|
|
|
457
|
+
ext.cross_compile = true
|
|
458
|
+
ext.cross_platform = ['x86_64-linux', 'arm64-darwin']
|
|
459
|
+
ext.content_addressable = true
|
|
460
|
+
end
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
rake cross native gem RUBY_CC_VERSION=3.3.11:3.4.9
|
|
464
|
+
|
|
465
|
+
This produces, in `pkg/`, the usual multi ABI gem plus one gem per Ruby ABI whose
|
|
466
|
+
`required_ruby_version` is pinned to that ABI:
|
|
467
|
+
|
|
468
|
+
pkg/my_gem-1.0.0-x86_64-linux.gem # multi ABI gem, Ruby >= 3.3, < 3.5.dev
|
|
469
|
+
pkg/my_gem-1.0.0-<hash>.gem # Ruby ~> 3.3.0
|
|
470
|
+
pkg/my_gem-1.0.0-<hash>.gem # Ruby ~> 3.4.0
|
|
471
|
+
|
|
472
|
+
`rake native` and `rake native:<platform>` build the multi ABI gem and all of
|
|
473
|
+
the single ABI gems. To build only the gem for one Ruby ABI, run
|
|
474
|
+
`rake native:<gem name>:<platform>:<ruby abi>`.
|
|
475
|
+
|
|
447
476
|
## What are you talking about? (Give me examples)
|
|
448
477
|
|
|
449
478
|
I know all the above sounds like a complete foreign language (it does even for me!).
|
data/lib/rake/extensiontask.rb
CHANGED
|
@@ -15,6 +15,7 @@ module Rake
|
|
|
15
15
|
attr_writer :cross_config_options
|
|
16
16
|
attr_accessor :no_native
|
|
17
17
|
attr_accessor :config_includes
|
|
18
|
+
attr_accessor :content_addressable
|
|
18
19
|
|
|
19
20
|
def init(name = nil, gem_spec = nil)
|
|
20
21
|
super
|
|
@@ -26,6 +27,7 @@ module Rake
|
|
|
26
27
|
@cross_compiling = nil
|
|
27
28
|
@no_native = (ENV["RAKE_EXTENSION_TASK_NO_NATIVE"] == "true")
|
|
28
29
|
@config_includes = []
|
|
30
|
+
@content_addressable = false
|
|
29
31
|
# Default to an empty list of ruby versions for each platform
|
|
30
32
|
@ruby_versions_per_platform = Hash.new { |h, k| h[k] = [] }
|
|
31
33
|
@make = nil
|
|
@@ -54,6 +56,11 @@ module Rake
|
|
|
54
56
|
warn "WARNING: rake-compiler found compiled files in '#{@ext_dir}' directory. Please remove them."
|
|
55
57
|
end
|
|
56
58
|
|
|
59
|
+
if @content_addressable && !Gem::PackageTask.method_defined?(:content_addressable=)
|
|
60
|
+
warn "WARNING: content_addressable is enabled but RubyGems #{Gem::VERSION} does not support content addressable gems.\n" \
|
|
61
|
+
" Only the multi-ABI gem will be built. Upgrade RubyGems with `gem update --system`."
|
|
62
|
+
end
|
|
63
|
+
|
|
57
64
|
# only gems with 'ruby' platforms are allowed to define native tasks
|
|
58
65
|
define_native_tasks if !@no_native && (@gem_spec && @gem_spec.platform == 'ruby')
|
|
59
66
|
|
|
@@ -257,9 +264,22 @@ Java extension should be preferred.
|
|
|
257
264
|
# Update compiled platform/version combinations
|
|
258
265
|
@ruby_versions_per_platform[platf] << ruby_ver
|
|
259
266
|
|
|
267
|
+
native_task_name = "native:#{@gem_spec.name}:#{platf}"
|
|
268
|
+
|
|
269
|
+
# packaging tasks to define: task name => Ruby ABI (nil for the multi-ABI gem)
|
|
270
|
+
package_tasks = { native_task_name => nil }
|
|
271
|
+
|
|
272
|
+
# when content addressable, also build a single Ruby ABI gem per Ruby version
|
|
273
|
+
if content_addressable && Gem::PackageTask.method_defined?(:content_addressable=)
|
|
274
|
+
abi = ruby_api_version(ruby_ver)
|
|
275
|
+
package_tasks["#{native_task_name}:#{abi}"] = abi
|
|
276
|
+
end
|
|
277
|
+
|
|
260
278
|
# create 'native:gem_name' and chain it to 'native' task
|
|
261
|
-
|
|
262
|
-
|
|
279
|
+
package_tasks.each do |task_name, ruby_abi|
|
|
280
|
+
next if Rake::Task.task_defined?(task_name)
|
|
281
|
+
|
|
282
|
+
task task_name do |t|
|
|
263
283
|
# FIXME: workaround Gem::Specification limitation around cache_file:
|
|
264
284
|
# http://github.com/rubygems/rubygems/issues/78
|
|
265
285
|
spec = gem_spec.dup
|
|
@@ -269,14 +289,19 @@ Java extension should be preferred.
|
|
|
269
289
|
spec.platform = Gem::Platform.new(platf)
|
|
270
290
|
|
|
271
291
|
# set ruby version constraints
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
292
|
+
if ruby_abi
|
|
293
|
+
# pessimistic version requirement for a single Ruby ABI gem
|
|
294
|
+
spec.required_ruby_version = "~> #{ruby_abi}.0"
|
|
295
|
+
else
|
|
296
|
+
ruby_versions = @ruby_versions_per_platform[platf]
|
|
297
|
+
sorted_ruby_versions = ruby_versions.sort_by do |ruby_version|
|
|
298
|
+
ruby_version.split(".").collect(&:to_i)
|
|
299
|
+
end
|
|
300
|
+
spec.required_ruby_version = [
|
|
301
|
+
">= #{ruby_api_version(sorted_ruby_versions.first)}",
|
|
302
|
+
"< #{ruby_api_version(sorted_ruby_versions.last).succ}.dev"
|
|
303
|
+
]
|
|
275
304
|
end
|
|
276
|
-
spec.required_ruby_version = [
|
|
277
|
-
">= #{ruby_api_version(sorted_ruby_versions.first)}",
|
|
278
|
-
"< #{ruby_api_version(sorted_ruby_versions.last).succ}.dev"
|
|
279
|
-
]
|
|
280
305
|
|
|
281
306
|
# set rubygems version constraints
|
|
282
307
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.22") &&
|
|
@@ -313,6 +338,9 @@ Java extension should be preferred.
|
|
|
313
338
|
# Do not copy any files per PackageTask, because
|
|
314
339
|
# we need the files from the staging directory
|
|
315
340
|
p.package_files.clear
|
|
341
|
+
# Gem::PackageTask scopes its staging directory by Ruby ABI when
|
|
342
|
+
# content_addressable is set, so every gem still lands in `pkg/`.
|
|
343
|
+
p.content_addressable = true if ruby_abi
|
|
316
344
|
end
|
|
317
345
|
|
|
318
346
|
# copy other gem files to staging directory if added by the callback
|
|
@@ -343,7 +371,9 @@ Java extension should be preferred.
|
|
|
343
371
|
end
|
|
344
372
|
|
|
345
373
|
# add binaries to the dependency chain
|
|
346
|
-
|
|
374
|
+
package_tasks.each_key do |task_name|
|
|
375
|
+
task task_name => ["#{stage_path}/#{lib_binary_path}"]
|
|
376
|
+
end
|
|
347
377
|
|
|
348
378
|
# ensure the extension get copied
|
|
349
379
|
unless Rake::Task.task_defined?(lib_binary_path) then
|
|
@@ -352,12 +382,12 @@ Java extension should be preferred.
|
|
|
352
382
|
file "#{stage_path}/#{lib_binary_path}" => ["copy:#{@name}:#{platf}:#{ruby_ver}"]
|
|
353
383
|
|
|
354
384
|
# Allow segmented packaging by platform (open door for 'cross compile')
|
|
355
|
-
task "native:#{platf}" =>
|
|
385
|
+
task "native:#{platf}" => package_tasks.keys
|
|
356
386
|
|
|
357
387
|
# Only add this extension to the compile chain if current
|
|
358
388
|
# platform matches the indicated one.
|
|
359
389
|
if platf == RUBY_PLATFORM then
|
|
360
|
-
task "native:#{@gem_spec.name}" =>
|
|
390
|
+
task "native:#{@gem_spec.name}" => package_tasks.keys
|
|
361
391
|
task "native" => ["native:#{platf}"]
|
|
362
392
|
end
|
|
363
393
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rake-compiler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kouhei Sutou
|
|
@@ -135,14 +135,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
135
135
|
requirements:
|
|
136
136
|
- - ">="
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: 1
|
|
138
|
+
version: '2.1'
|
|
139
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
requirements:
|
|
141
141
|
- - ">="
|
|
142
142
|
- !ruby/object:Gem::Version
|
|
143
143
|
version: 1.8.23
|
|
144
144
|
requirements: []
|
|
145
|
-
rubygems_version:
|
|
145
|
+
rubygems_version: 4.0.20
|
|
146
146
|
specification_version: 4
|
|
147
147
|
summary: Rake-based Ruby Extension (C, Java) task generator.
|
|
148
148
|
test_files: []
|