rake-compiler 1.2.0 → 1.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 168f62a83a0e87ed5dd8ddc21151082d826a18af8baa3319be221704fd559e1b
4
- data.tar.gz: 62247a212ea5dce5803ef33d4490d3a6a982e5bf78716a5da0339e1c980b467a
3
+ metadata.gz: 530d28062d0a6bc7601e7aec15adba736048594ad4e0026dff17594f4462a2ca
4
+ data.tar.gz: 94dea28437dd1dedaef5a48f7eb13672102bc11d43a371e755d593126cac20b7
5
5
  SHA512:
6
- metadata.gz: 5857be6b32518649261bb405df56b6986083e019f38621801323aea374544a9771c30bca2f7cc539c7fc8cd4f0cc44b8861f93bab4877ff4bfc45aecbb6e5d44
7
- data.tar.gz: 61c4b8db10ff10e4b8ec45a7688241689981bc3c70f2a2b7eb2eebf877e9ca623844f70e70858daf899812a7ef8deb7c13c77b9fc0570d3bdcff7d367b445e07
6
+ metadata.gz: 8c4066120b1718f19299eacfee717a8efd7ca381078124e38107b372f3925791b9016aa6048bd773c6aebf6875e94937cb5eff38365e759c665102e6f55e8b1f
7
+ data.tar.gz: 804376554f6efa4c5b4e62b28b2d18cbffb0273c0de6e0bbc3fb7674dc4669a1bab83e121c3dd2bb1f5c1a1cffc89b5977ca96410c7599b589affbe075c0abd9
data/History.md CHANGED
@@ -1,3 +1,17 @@
1
+ ### 1.2.1 / 2022-12-16
2
+
3
+ * Enhancements:
4
+ * GH-209: Added support for RubyGems 3.3.21 or later.
5
+ [Patch by Mike Dalessio]
6
+
7
+ * Fixes:
8
+ * GH-208: Fixed a typo in documentation.
9
+ [Patch by Garen Torikian]
10
+
11
+ * Thanks:
12
+ * Garen Torikian
13
+ * Mike Dalessio
14
+
1
15
  ### 1.2.0 / 2022-04-15
2
16
 
3
17
  * Enhancements:
data/README.md CHANGED
@@ -241,7 +241,7 @@ several settings for `Rake::ExtensionTask`:
241
241
  | no_native | ExtensionTask (CRuby) | [Optional] Set to true to prevent non-CRuby platforms from defining native tasks. Default: `false`. |
242
242
  | config_includes | ExtensionTask (CRuby) | [Optional] Specify an Array of paths to include as `-I...:...` includes during compilation. Default: `['.']`. |
243
243
  | classpath | JavaExtensionTask | [Optional] Specify additional classpath paths as an Array. Default: _Uses the current CLASSPATH._ |
244
- | debug | JavaExtensionTask | [Optional] Whether to set the debug flag during complication. Default: `false`. |
244
+ | debug | JavaExtensionTask | [Optional] Whether to set the debug flag during compilation. Default: `false`. |
245
245
  | source_version | JavaExtensionTask | [Optional] The JRE version that your source code requires to compile. Default: `1.6`. |
246
246
  | target_version | JavaExtensionTask | [Optional] The oldest JRE version you want to support. Default: `1.6`. |
247
247
  | encoding | JavaExtensionTask | [Optional] Specify an -encoding option to provide to the compiler. Default: `nil`. |
@@ -5,6 +5,8 @@ require 'rbconfig'
5
5
 
6
6
  require 'pathname'
7
7
 
8
+ require_relative "compiler_config"
9
+
8
10
  module Rake
9
11
  class BaseExtensionTask < TaskLib
10
12
 
@@ -0,0 +1,38 @@
1
+ module Rake
2
+ class CompilerConfig
3
+ def initialize(config_path)
4
+ require "yaml"
5
+ @config = YAML.load_file(config_path)
6
+ end
7
+
8
+ def find(ruby_version, gem_platform)
9
+ gem_platform = Gem::Platform.new(gem_platform)
10
+
11
+ @config.each do |config_name, config_location|
12
+ # There are two variations we might find in the rake-compiler config.yml
13
+ #
14
+ # 1. config_name: rbconfig-x86_64-linux-3.0.0
15
+ # runtime_platform_name: x86_64-linux
16
+ # runtime_version: 3.0.0
17
+ #
18
+ # 2. config_name: rbconfig-x86_64-linux-gnu-3.0.0
19
+ # runtime_platform_name: x86_64-linux-gnu
20
+ # runtime_version: 3.0.0
21
+ #
22
+ # With rubygems < 3.3.21, both variations will be present (two entries pointing at the same
23
+ # installation).
24
+ #
25
+ # With rubygems >= 3.3.21, only the second variation will be present.
26
+ runtime_platform_name = config_name.split("-")[1..-2].join("-")
27
+ runtime_version = config_name.split("-").last
28
+ runtime_platform = Gem::Platform.new(runtime_platform_name)
29
+
30
+ if (ruby_version == runtime_version) && (gem_platform =~ runtime_platform)
31
+ return config_location
32
+ end
33
+ end
34
+
35
+ nil
36
+ end
37
+ end
38
+ end
@@ -393,8 +393,11 @@ Java extension should be preferred.
393
393
  return
394
394
  end
395
395
 
396
- require "yaml"
397
- config_file = YAML.load_file(config_path)
396
+ rbconfig_file = Rake::CompilerConfig.new(config_path).find(ruby_ver, for_platform)
397
+ unless rbconfig_file
398
+ warn "no configuration section for specified version of Ruby (rbconfig-#{for_platform}-#{ruby_ver})"
399
+ return
400
+ end
398
401
 
399
402
  # tmp_path
400
403
  tmp_path = "#{@tmp_dir}/#{for_platform}/#{@name}/#{ruby_ver}"
@@ -405,11 +408,6 @@ Java extension should be preferred.
405
408
  # lib_binary_path
406
409
  lib_binary_path = "#{lib_path}/#{File.basename(binary(for_platform))}"
407
410
 
408
- unless rbconfig_file = config_file["rbconfig-#{for_platform}-#{ruby_ver}"] then
409
- warn "no configuration section for specified version of Ruby (rbconfig-#{for_platform}-#{ruby_ver})"
410
- return
411
- end
412
-
413
411
  # mkmf
414
412
  mkmf_file = File.expand_path(File.join(File.dirname(rbconfig_file), '..', 'mkmf.rb'))
415
413
 
@@ -0,0 +1,54 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ require 'rake/extensiontask'
4
+ require 'rbconfig'
5
+ require 'tempfile'
6
+
7
+ describe Rake::CompilerConfig do
8
+ def config_file(contents)
9
+ Tempfile.new.tap do |tf|
10
+ tf.write(contents)
11
+ tf.close
12
+ end
13
+ end
14
+
15
+ it "returns the matching config for exact platform match" do
16
+ cc = Rake::CompilerConfig.new(config_file(<<~CONFIG))
17
+ ---
18
+ rbconfig-x86_64-linux-3.0.0: "/path/to/aaa/rbconfig.rb"
19
+ rbconfig-x86_64-darwin-3.1.0: "/path/to/bbb/rbconfig.rb"
20
+ rbconfig-x86_64-linux-3.1.0: "/path/to/ccc/rbconfig.rb"
21
+ CONFIG
22
+
23
+ expect(cc.find("3.0.0", "x86_64-linux")).to eq("/path/to/aaa/rbconfig.rb")
24
+ expect(cc.find("3.1.0", "x86_64-darwin")).to eq("/path/to/bbb/rbconfig.rb")
25
+ expect(cc.find("3.1.0", "x86_64-linux")).to eq("/path/to/ccc/rbconfig.rb")
26
+
27
+ expect(cc.find("2.7.0", "x86_64-linux")).to be_nil
28
+ expect(cc.find("3.1.0", "arm64-linux")).to be_nil
29
+ end
30
+
31
+ it "returns the matching config for inexact platform match" do
32
+ cc = Rake::CompilerConfig.new(config_file(<<~CONFIG))
33
+ ---
34
+ rbconfig-x86_64-linux-gnu-3.0.0: "/path/to/aaa/rbconfig.rb"
35
+ rbconfig-x86_64-linux-musl-3.1.0: "/path/to/bbb/rbconfig.rb"
36
+ CONFIG
37
+
38
+ expect(cc.find("3.0.0", "x86_64-linux")).to eq("/path/to/aaa/rbconfig.rb")
39
+ expect(cc.find("3.1.0", "x86_64-linux")).to eq("/path/to/bbb/rbconfig.rb")
40
+ end
41
+
42
+ it "does not match the other way around" do
43
+ if Gem::Version.new(Gem::VERSION) < Gem::Version.new("3.3.21")
44
+ skip "rubygems 3.3.21+ only"
45
+ end
46
+
47
+ cc = Rake::CompilerConfig.new(config_file(<<~CONFIG))
48
+ ---
49
+ rbconfig-x86_64-linux-3.1.0: "/path/to/bbb/rbconfig.rb"
50
+ CONFIG
51
+
52
+ expect(cc.find("3.1.0", "x86_64-linux-musl")).to be_nil
53
+ end
54
+ end
@@ -381,9 +381,10 @@ describe Rake::ExtensionTask do
381
381
  end
382
382
 
383
383
  it 'should warn if no section of config file defines running version of ruby' do
384
- config = Hash.new
385
- expect(config).to receive(:[]).with("rbconfig-#{@platform}-#{@ruby_ver}").and_return(nil)
386
- allow(YAML).to receive(:load_file).and_return(config)
384
+ allow_any_instance_of(Rake::CompilerConfig).to(
385
+ receive(:find).with(@ruby_ver, @platform).and_return(nil)
386
+ )
387
+
387
388
  out, err = capture_output do
388
389
  Rake::ExtensionTask.new('extension_one') do |ext|
389
390
  ext.cross_compile = true
@@ -403,9 +404,9 @@ describe Rake::ExtensionTask do
403
404
  end
404
405
 
405
406
  it 'should generate additional rake tasks if files are added when cross compiling' do
406
- config = Hash.new
407
- allow(config).to receive(:[]).and_return('/rubies/1.9.1/rbconfig.rb')
408
- allow(YAML).to receive(:load_file).and_return(config)
407
+ allow_any_instance_of(Rake::CompilerConfig).to(
408
+ receive(:find).and_return("/rubies/1.9.1/rbconfig.rb")
409
+ )
409
410
 
410
411
  # Use a real spec instead of a mock because define_native_tasks dups and
411
412
  # calls methods on Gem::Specification, which is more than mock can do.
@@ -433,9 +434,11 @@ describe Rake::ExtensionTask do
433
434
  end
434
435
 
435
436
  it 'should allow usage of RUBY_CC_VERSION to indicate a different version of ruby' do
436
- config = Hash.new
437
- expect(config).to receive(:[]).with("rbconfig-i386-mingw32-1.9.1").and_return('/rubies/1.9.1/rbconfig.rb')
438
- allow(YAML).to receive(:load_file).and_return(config)
437
+ allow_any_instance_of(Rake::CompilerConfig).to(
438
+ receive(:find)
439
+ .with("1.9.1", "i386-mingw32")
440
+ .and_return("/rubies/1.9.1/rbconfig.rb")
441
+ )
439
442
 
440
443
  ENV['RUBY_CC_VERSION'] = '1.9.1'
441
444
  Rake::ExtensionTask.new('extension_one') do |ext|
@@ -444,10 +447,16 @@ describe Rake::ExtensionTask do
444
447
  end
445
448
 
446
449
  it 'should allow multiple versions be supplied to RUBY_CC_VERSION' do
447
- config = Hash.new
448
- expect(config).to receive(:[]).once.with("rbconfig-i386-mingw32-1.8.6").and_return('/rubies/1.8.6/rbconfig.rb')
449
- expect(config).to receive(:[]).once.with("rbconfig-i386-mingw32-1.9.1").and_return('/rubies/1.9.1/rbconfig.rb')
450
- allow(YAML).to receive(:load_file).and_return(config)
450
+ allow_any_instance_of(Rake::CompilerConfig).to(
451
+ receive(:find)
452
+ .with("1.8.6", "i386-mingw32")
453
+ .and_return("/rubies/1.8.6/rbconfig.rb")
454
+ )
455
+ allow_any_instance_of(Rake::CompilerConfig).to(
456
+ receive(:find)
457
+ .with("1.9.1", "i386-mingw32")
458
+ .and_return("/rubies/1.9.1/rbconfig.rb")
459
+ )
451
460
 
452
461
  ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
453
462
  Rake::ExtensionTask.new('extension_one') do |ext|
@@ -459,18 +468,19 @@ describe Rake::ExtensionTask do
459
468
  platforms = ["x86-mingw32", "x64-mingw32"]
460
469
  ruby_cc_versions = ["1.8.6", "2.1.10", "2.2.6", "2.3.3", "2.10.1", "2.11.0"]
461
470
  ENV["RUBY_CC_VERSION"] = ruby_cc_versions.join(":")
462
- config = Hash.new
471
+
463
472
  ruby_cc_versions.each do |ruby_cc_version|
464
473
  platforms.each do |platform|
465
474
  unless platform == "x64-mingw32" && ruby_cc_version == "2.11.0"
466
475
  rbconf = "/rubies/#{ruby_cc_version}/rbconfig.rb"
467
476
  end
468
- allow(config).to receive(:[]).
469
- with("rbconfig-#{platform}-#{ruby_cc_version}").
470
- and_return(rbconf)
477
+ allow_any_instance_of(Rake::CompilerConfig).to(
478
+ receive(:find)
479
+ .with(ruby_cc_version, platform)
480
+ .and_return(rbconf)
481
+ )
471
482
  end
472
483
  end
473
- allow(YAML).to receive(:load_file).and_return(config)
474
484
 
475
485
  allow(Gem).to receive_message_chain(:configuration, :verbose=).and_return(true)
476
486
 
@@ -515,9 +525,16 @@ describe Rake::ExtensionTask do
515
525
 
516
526
  context "(cross compile for multiple versions)" do
517
527
  before :each do
518
- config = Hash.new
519
- allow(config).to receive(:[]).and_return('/rubies/1.8.6/rbconfig.rb', '/rubies/1.9.1/rbconfig.rb')
520
- allow(YAML).to receive(:load_file).and_return(config)
528
+ allow_any_instance_of(Rake::CompilerConfig).to(
529
+ receive(:find)
530
+ .with("1.8.6", "universal-unknown")
531
+ .and_return("/rubies/1.8.6/rbconfig.rb")
532
+ )
533
+ allow_any_instance_of(Rake::CompilerConfig).to(
534
+ receive(:find)
535
+ .with("1.9.1", "universal-unknown")
536
+ .and_return("/rubies/1.9.1/rbconfig.rb")
537
+ )
521
538
 
522
539
  ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
523
540
  @ext = Rake::ExtensionTask.new('extension_one') do |ext|
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  - Luis Lavena
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-04-15 00:00:00.000000000 Z
12
+ date: 2022-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -108,9 +108,11 @@ files:
108
108
  - features/support/generator_helpers.rb
109
109
  - features/support/platform_extension_helpers.rb
110
110
  - lib/rake/baseextensiontask.rb
111
+ - lib/rake/compiler_config.rb
111
112
  - lib/rake/extensioncompiler.rb
112
113
  - lib/rake/extensiontask.rb
113
114
  - lib/rake/javaextensiontask.rb
115
+ - spec/lib/rake/compiler_config_spec.rb
114
116
  - spec/lib/rake/extensiontask_spec.rb
115
117
  - spec/lib/rake/javaextensiontask_spec.rb
116
118
  - spec/spec.opts
@@ -126,7 +128,7 @@ homepage: https://github.com/rake-compiler/rake-compiler
126
128
  licenses:
127
129
  - MIT
128
130
  metadata: {}
129
- post_install_message:
131
+ post_install_message:
130
132
  rdoc_options:
131
133
  - "--main"
132
134
  - README.md
@@ -146,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
148
  version: 1.8.23
147
149
  requirements: []
148
150
  rubygems_version: 3.4.0.dev
149
- signing_key:
151
+ signing_key:
150
152
  specification_version: 4
151
153
  summary: Rake-based Ruby Extension (C, Java) task generator.
152
154
  test_files: []