rake-compiler 1.0.3 → 1.0.4
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/Gemfile +2 -2
- data/History.txt +11 -0
- data/lib/rake/baseextensiontask.rb +1 -1
- data/lib/rake/extensiontask.rb +17 -18
- data/spec/lib/rake/extensiontask_spec.rb +69 -58
- data/spec/lib/rake/javaextensiontask_spec.rb +6 -6
- data/tasks/gem.rake +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd44b9624dc0fb5e6f727017cb9a1c9ac9865672
|
4
|
+
data.tar.gz: 35d69b334abd18af368c1d2f4f0c4c33a8aaf54f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ff91d807ddec5ce9815c07c228d26f0a7cdb83e0a76ed86d0bb66b16e29fee6fec06ab161ac3377d32f512e9e45114557150c4b4adff1104da22beee24c3027
|
7
|
+
data.tar.gz: 75047010d54066c4d961cf97aea7931e351d05e2a9a77747a1897e76cf0e812147913b05ca49aed701c1d86cd7d8f286515e413d10de8a3bc2226e1832ac5cd1
|
data/Gemfile
CHANGED
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 1.0.4 / 2017-05-27
|
2
|
+
|
3
|
+
* Enhancements:
|
4
|
+
* Migrate to RSpec 3 from RSpec 2.
|
5
|
+
* Add more tests.
|
6
|
+
#140 [Patch by Lars Kanis]
|
7
|
+
* Support C++ source files by default.
|
8
|
+
#141 [Patch by Takashi Kokubun]
|
9
|
+
* Suppress warnings.
|
10
|
+
#142 [Patch by Akira Matsuda]
|
11
|
+
|
1
12
|
=== 1.0.3 / 2016-12-02
|
2
13
|
|
3
14
|
* Enhancements:
|
@@ -19,10 +19,10 @@ module Rake
|
|
19
19
|
attr_accessor :tmp_dir
|
20
20
|
attr_accessor :ext_dir
|
21
21
|
attr_accessor :lib_dir
|
22
|
-
attr_accessor :platform
|
23
22
|
attr_accessor :config_options
|
24
23
|
attr_accessor :source_pattern
|
25
24
|
attr_accessor :extra_options
|
25
|
+
attr_writer :platform
|
26
26
|
|
27
27
|
def platform
|
28
28
|
@platform ||= RUBY_PLATFORM
|
data/lib/rake/extensiontask.rb
CHANGED
@@ -10,7 +10,7 @@ module Rake
|
|
10
10
|
class ExtensionTask < BaseExtensionTask
|
11
11
|
attr_accessor :config_script
|
12
12
|
attr_accessor :cross_compile
|
13
|
-
|
13
|
+
attr_writer :cross_platform
|
14
14
|
attr_writer :cross_config_options
|
15
15
|
attr_accessor :no_native
|
16
16
|
attr_accessor :config_includes
|
@@ -18,14 +18,14 @@ module Rake
|
|
18
18
|
def init(name = nil, gem_spec = nil)
|
19
19
|
super
|
20
20
|
@config_script = 'extconf.rb'
|
21
|
-
@source_pattern = "*.c"
|
21
|
+
@source_pattern = "*.{c,cc,cpp}"
|
22
22
|
@compiled_pattern = "*.{o,obj,so,bundle,dSYM}"
|
23
23
|
@cross_compile = false
|
24
24
|
@cross_config_options = []
|
25
25
|
@cross_compiling = nil
|
26
26
|
@no_native = false
|
27
27
|
@config_includes = []
|
28
|
-
@ruby_versions_per_platform =
|
28
|
+
@ruby_versions_per_platform = {}
|
29
29
|
end
|
30
30
|
|
31
31
|
def cross_platform
|
@@ -237,7 +237,6 @@ Java extension should be preferred.
|
|
237
237
|
platf = for_platform || platform
|
238
238
|
|
239
239
|
# tmp_path
|
240
|
-
tmp_path = "#{@tmp_dir}/#{platf}/#{@name}/#{ruby_ver}"
|
241
240
|
stage_path = "#{@tmp_dir}/#{platf}/stage"
|
242
241
|
|
243
242
|
# lib_path
|
@@ -255,10 +254,13 @@ Java extension should be preferred.
|
|
255
254
|
spec.platform = Gem::Platform.new(platf)
|
256
255
|
|
257
256
|
# set ruby version constraints
|
258
|
-
|
257
|
+
ruby_versions = @ruby_versions_per_platform[platf] || []
|
258
|
+
sorted_ruby_versions = ruby_versions.sort_by do |ruby_version|
|
259
|
+
ruby_version.split(".").collect(&:to_i)
|
260
|
+
end
|
259
261
|
spec.required_ruby_version = [
|
260
|
-
">= #{
|
261
|
-
"< #{
|
262
|
+
">= #{ruby_api_version(sorted_ruby_versions.first)}",
|
263
|
+
"< #{ruby_api_version(sorted_ruby_versions.last).succ}"
|
262
264
|
]
|
263
265
|
|
264
266
|
# clear the extensions defined in the specs
|
@@ -280,12 +282,12 @@ Java extension should be preferred.
|
|
280
282
|
callback.call(spec) if callback
|
281
283
|
|
282
284
|
# Generate a package for this gem
|
283
|
-
pkg = Gem::PackageTask.new(spec) do |
|
284
|
-
|
285
|
-
|
285
|
+
pkg = Gem::PackageTask.new(spec) do |p|
|
286
|
+
p.need_zip = false
|
287
|
+
p.need_tar = false
|
286
288
|
# Do not copy any files per PackageTask, because
|
287
289
|
# we need the files from the staging directory
|
288
|
-
|
290
|
+
p.package_files.clear
|
289
291
|
end
|
290
292
|
|
291
293
|
# copy other gem files to staging directory if added by the callback
|
@@ -355,7 +357,8 @@ Java extension should be preferred.
|
|
355
357
|
end
|
356
358
|
|
357
359
|
# Update cross compiled platform/version combinations
|
358
|
-
@ruby_versions_per_platform[for_platform]
|
360
|
+
ruby_versions = (@ruby_versions_per_platform[for_platform] ||= [])
|
361
|
+
ruby_versions << version
|
359
362
|
|
360
363
|
define_cross_platform_tasks_with_version(for_platform, version)
|
361
364
|
|
@@ -508,12 +511,8 @@ Java extension should be preferred.
|
|
508
511
|
[*@cross_platform].map { |p| "native:#{p}" }
|
509
512
|
end
|
510
513
|
|
511
|
-
def
|
512
|
-
|
513
|
-
end
|
514
|
-
|
515
|
-
def version_ary2str(version_ary)
|
516
|
-
version_ary.unpack("C*").join(".")
|
514
|
+
def ruby_api_version(ruby_version)
|
515
|
+
ruby_version.split(".")[0, 2].join(".")
|
517
516
|
end
|
518
517
|
|
519
518
|
def fake_rb(platform, version)
|
@@ -77,8 +77,8 @@ describe Rake::ExtensionTask do
|
|
77
77
|
@ext.lib_dir.should == 'lib'
|
78
78
|
end
|
79
79
|
|
80
|
-
it 'should look for C files pattern (.c)' do
|
81
|
-
@ext.source_pattern.should == "*.c"
|
80
|
+
it 'should look for C/C++ files pattern (.c,.cc,.cpp)' do
|
81
|
+
@ext.source_pattern.should == "*.{c,cc,cpp}"
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'should have no configuration options preset to delegate' do
|
@@ -94,7 +94,7 @@ describe Rake::ExtensionTask do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'should default to no cross compilation' do
|
97
|
-
@ext.cross_compile.should
|
97
|
+
@ext.cross_compile.should == false
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'should have no configuration options for cross compilation' do
|
@@ -115,7 +115,7 @@ describe Rake::ExtensionTask do
|
|
115
115
|
|
116
116
|
context '(one extension)' do
|
117
117
|
before :each do
|
118
|
-
Rake::FileList.
|
118
|
+
allow(Rake::FileList).to receive(:[]).and_return(["ext/extension_one/source.c"], [])
|
119
119
|
@ext = Rake::ExtensionTask.new('extension_one')
|
120
120
|
@ext_bin = ext_bin('extension_one')
|
121
121
|
@platform = RUBY_PLATFORM
|
@@ -124,7 +124,7 @@ describe Rake::ExtensionTask do
|
|
124
124
|
|
125
125
|
context 'compile' do
|
126
126
|
it 'should define as task' do
|
127
|
-
Rake::Task.task_defined?('compile').should
|
127
|
+
Rake::Task.task_defined?('compile').should == true
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should depend on 'compile:{platform}'" do
|
@@ -134,7 +134,7 @@ describe Rake::ExtensionTask do
|
|
134
134
|
|
135
135
|
context 'compile:extension_one' do
|
136
136
|
it 'should define as task' do
|
137
|
-
Rake::Task.task_defined?('compile:extension_one').should
|
137
|
+
Rake::Task.task_defined?('compile:extension_one').should == true
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should depend on 'compile:extension_one:{platform}'" do
|
@@ -144,7 +144,7 @@ describe Rake::ExtensionTask do
|
|
144
144
|
|
145
145
|
context 'lib/extension_one.{so,bundle}' do
|
146
146
|
it 'should define as task' do
|
147
|
-
Rake::Task.task_defined?("lib/#{@ext_bin}").should
|
147
|
+
Rake::Task.task_defined?("lib/#{@ext_bin}").should == true
|
148
148
|
end
|
149
149
|
|
150
150
|
it "should depend on 'copy:extension_one:{platform}:{ruby_ver}'" do
|
@@ -154,7 +154,7 @@ describe Rake::ExtensionTask do
|
|
154
154
|
|
155
155
|
context 'tmp/{platform}/extension_one/{ruby_ver}/extension_one.{so,bundle}' do
|
156
156
|
it 'should define as task' do
|
157
|
-
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ruby_ver}/#{@ext_bin}").should
|
157
|
+
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ruby_ver}/#{@ext_bin}").should == true
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should depend on 'tmp/{platform}/extension_one/{ruby_ver}/Makefile'" do
|
@@ -172,7 +172,7 @@ describe Rake::ExtensionTask do
|
|
172
172
|
|
173
173
|
context 'tmp/{platform}/extension_one/{ruby_ver}/Makefile' do
|
174
174
|
it 'should define as task' do
|
175
|
-
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ruby_ver}/Makefile").should
|
175
|
+
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ruby_ver}/Makefile").should == true
|
176
176
|
end
|
177
177
|
|
178
178
|
it "should depend on 'tmp/{platform}/extension_one/{ruby_ver}'" do
|
@@ -201,7 +201,7 @@ describe Rake::ExtensionTask do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
it "should warn when pre-compiled files exist in extension directory" do
|
204
|
-
Rake::FileList.
|
204
|
+
allow(Rake::FileList).to receive(:[]).
|
205
205
|
and_return(["ext/extension_one/source.c"],
|
206
206
|
["ext/extension_one/source.o"])
|
207
207
|
|
@@ -214,7 +214,7 @@ describe Rake::ExtensionTask do
|
|
214
214
|
|
215
215
|
context '(extension in custom location)' do
|
216
216
|
before :each do
|
217
|
-
Rake::FileList.
|
217
|
+
allow(Rake::FileList).to receive(:[]).and_return(["ext/extension_one/source.c"], [])
|
218
218
|
@ext = Rake::ExtensionTask.new('extension_one') do |ext|
|
219
219
|
ext.ext_dir = 'custom/ext/foo'
|
220
220
|
end
|
@@ -232,7 +232,7 @@ describe Rake::ExtensionTask do
|
|
232
232
|
|
233
233
|
context '(native tasks)' do
|
234
234
|
before :each do
|
235
|
-
Rake::FileList.
|
235
|
+
allow(Rake::FileList).to receive(:[]).and_return(["ext/extension_one/source.c"], [])
|
236
236
|
@spec = mock_gem_spec
|
237
237
|
@ext_bin = ext_bin('extension_one')
|
238
238
|
@platform = RUBY_PLATFORM
|
@@ -241,24 +241,24 @@ describe Rake::ExtensionTask do
|
|
241
241
|
|
242
242
|
context 'native' do
|
243
243
|
before :each do
|
244
|
-
@spec.
|
244
|
+
allow(@spec).to receive(:platform=).and_return('ruby')
|
245
245
|
end
|
246
246
|
|
247
247
|
it 'should define a task for building the supplied gem' do
|
248
248
|
Rake::ExtensionTask.new('extension_one', @spec)
|
249
|
-
Rake::Task.task_defined?('native:my_gem').should
|
249
|
+
Rake::Task.task_defined?('native:my_gem').should == true
|
250
250
|
end
|
251
251
|
|
252
252
|
it 'should define as task for pure ruby gems' do
|
253
|
-
Rake::Task.task_defined?('native').should
|
253
|
+
Rake::Task.task_defined?('native').should == false
|
254
254
|
Rake::ExtensionTask.new('extension_one', @spec)
|
255
|
-
Rake::Task.task_defined?('native').should
|
255
|
+
Rake::Task.task_defined?('native').should == true
|
256
256
|
end
|
257
257
|
|
258
258
|
it 'should not define a task for already native gems' do
|
259
|
-
@spec.
|
259
|
+
allow(@spec).to receive(:platform).and_return('current')
|
260
260
|
Rake::ExtensionTask.new('extension_one', @spec)
|
261
|
-
Rake::Task.task_defined?('native').should
|
261
|
+
Rake::Task.task_defined?('native').should == false
|
262
262
|
end
|
263
263
|
|
264
264
|
it 'should depend on platform specific native tasks' do
|
@@ -277,7 +277,7 @@ describe Rake::ExtensionTask do
|
|
277
277
|
|
278
278
|
context '(one extension whose name with directory prefixes)' do
|
279
279
|
before :each do
|
280
|
-
Rake::FileList.
|
280
|
+
allow(Rake::FileList).to receive(:[]).and_return(["ext/prefix1/prefix2/extension_one/source.c"], [])
|
281
281
|
@ext = Rake::ExtensionTask.new('prefix1/prefix2/extension_one')
|
282
282
|
@ext_bin = ext_bin('extension_one')
|
283
283
|
@platform = RUBY_PLATFORM
|
@@ -286,7 +286,7 @@ describe Rake::ExtensionTask do
|
|
286
286
|
|
287
287
|
context 'compile' do
|
288
288
|
it 'should define as task' do
|
289
|
-
Rake::Task.task_defined?('compile').should
|
289
|
+
Rake::Task.task_defined?('compile').should == true
|
290
290
|
end
|
291
291
|
|
292
292
|
it "should depend on 'compile:{platform}'" do
|
@@ -296,7 +296,7 @@ describe Rake::ExtensionTask do
|
|
296
296
|
|
297
297
|
context 'compile:prefix1/prefix2/extension_one' do
|
298
298
|
it 'should define as task' do
|
299
|
-
Rake::Task.task_defined?('compile:prefix1/prefix2/extension_one').should
|
299
|
+
Rake::Task.task_defined?('compile:prefix1/prefix2/extension_one').should == true
|
300
300
|
end
|
301
301
|
|
302
302
|
it "should depend on 'compile:prefix1/prefix2/extension_one:{platform}'" do
|
@@ -306,7 +306,7 @@ describe Rake::ExtensionTask do
|
|
306
306
|
|
307
307
|
context 'lib/prefix1/prefix2/extension_one.{so,bundle}' do
|
308
308
|
it 'should define as task' do
|
309
|
-
Rake::Task.task_defined?("lib/prefix1/prefix2/#{@ext_bin}").should
|
309
|
+
Rake::Task.task_defined?("lib/prefix1/prefix2/#{@ext_bin}").should == true
|
310
310
|
end
|
311
311
|
|
312
312
|
it "should depend on 'copy:prefix1/prefix2/extension_one:{platform}:{ruby_ver}'" do
|
@@ -316,7 +316,7 @@ describe Rake::ExtensionTask do
|
|
316
316
|
|
317
317
|
context 'tmp/{platform}/prefix1/prefix2/extension_one/{ruby_ver}/prefix1/prefix2/extension_one.{so,bundle}' do
|
318
318
|
it 'should define as task' do
|
319
|
-
Rake::Task.task_defined?("tmp/#{@platform}/prefix1/prefix2/extension_one/#{@ruby_ver}/prefix1/prefix2/#{@ext_bin}").should
|
319
|
+
Rake::Task.task_defined?("tmp/#{@platform}/prefix1/prefix2/extension_one/#{@ruby_ver}/prefix1/prefix2/#{@ext_bin}").should == true
|
320
320
|
end
|
321
321
|
|
322
322
|
it "should depend on 'tmp/{platform}/prefix1/prefix2/extension_one/{ruby_ver}/Makefile'" do
|
@@ -335,21 +335,21 @@ describe Rake::ExtensionTask do
|
|
335
335
|
|
336
336
|
context '(cross platform tasks)' do
|
337
337
|
before :each do
|
338
|
-
File.
|
339
|
-
YAML.
|
340
|
-
Rake::FileList.
|
338
|
+
allow(File).to receive(:exist?).and_return(true)
|
339
|
+
allow(YAML).to receive(:load_file).and_return(mock_config_yml)
|
340
|
+
allow(Rake::FileList).to receive(:[]).and_return(["ext/extension_one/source.c"], [])
|
341
341
|
@spec = mock_gem_spec
|
342
342
|
@config_file = File.expand_path("~/.rake-compiler/config.yml")
|
343
343
|
@ruby_ver = RUBY_VERSION
|
344
344
|
@platform = 'i386-mingw32'
|
345
345
|
@config_path = mock_config_yml["rbconfig-#{@platform}-#{@ruby_ver}"]
|
346
346
|
|
347
|
-
File.
|
347
|
+
allow(File).to receive(:open).and_yield(mock_fake_rb)
|
348
348
|
end
|
349
349
|
|
350
350
|
context 'if no rake-compiler configuration exists' do
|
351
351
|
before :each do
|
352
|
-
File.
|
352
|
+
expect(File).to receive(:exist?).with(@config_file).and_return(false)
|
353
353
|
|
354
354
|
_, @err = capture_output do
|
355
355
|
Rake::ExtensionTask.new('extension_one') do |ext|
|
@@ -373,16 +373,16 @@ describe Rake::ExtensionTask do
|
|
373
373
|
end
|
374
374
|
|
375
375
|
it 'should parse the config file using YAML' do
|
376
|
-
YAML.
|
376
|
+
expect(YAML).to receive(:load_file).with(@config_file).and_return(mock_config_yml)
|
377
377
|
Rake::ExtensionTask.new('extension_one') do |ext|
|
378
378
|
ext.cross_compile = true
|
379
379
|
end
|
380
380
|
end
|
381
381
|
|
382
382
|
it 'should warn if no section of config file defines running version of ruby' do
|
383
|
-
config =
|
384
|
-
config.
|
385
|
-
YAML.
|
383
|
+
config = Hash.new
|
384
|
+
expect(config).to receive(:[]).with("rbconfig-#{@platform}-#{@ruby_ver}").and_return(nil)
|
385
|
+
allow(YAML).to receive(:load_file).and_return(config)
|
386
386
|
out, err = capture_output do
|
387
387
|
Rake::ExtensionTask.new('extension_one') do |ext|
|
388
388
|
ext.cross_compile = true
|
@@ -402,9 +402,9 @@ describe Rake::ExtensionTask do
|
|
402
402
|
end
|
403
403
|
|
404
404
|
it 'should generate additional rake tasks if files are added when cross compiling' do
|
405
|
-
config =
|
406
|
-
config.
|
407
|
-
YAML.
|
405
|
+
config = Hash.new
|
406
|
+
allow(config).to receive(:[]).and_return('/rubies/1.9.1/rbconfig.rb')
|
407
|
+
allow(YAML).to receive(:load_file).and_return(config)
|
408
408
|
|
409
409
|
# Use a real spec instead of a mock because define_native_tasks dups and
|
410
410
|
# calls methods on Gem::Specification, which is more than mock can do.
|
@@ -416,7 +416,7 @@ describe Rake::ExtensionTask do
|
|
416
416
|
# Gem::PackageTask calls Rake::PackageTask which sets Gem.configuration.verbose,
|
417
417
|
# which initializes Gem::ConfigFile,
|
418
418
|
# which gets mad if it cannot find `sysconfdir`/gemrc
|
419
|
-
Gem.
|
419
|
+
allow(Gem).to receive_message_chain(:configuration, :verbose=).and_return(true)
|
420
420
|
|
421
421
|
ENV['RUBY_CC_VERSION'] = '1.9.1'
|
422
422
|
Rake::ExtensionTask.new('extension_one', spec) do |ext|
|
@@ -432,9 +432,9 @@ describe Rake::ExtensionTask do
|
|
432
432
|
end
|
433
433
|
|
434
434
|
it 'should allow usage of RUBY_CC_VERSION to indicate a different version of ruby' do
|
435
|
-
config =
|
436
|
-
config.
|
437
|
-
YAML.
|
435
|
+
config = Hash.new
|
436
|
+
expect(config).to receive(:[]).with("rbconfig-i386-mingw32-1.9.1").and_return('/rubies/1.9.1/rbconfig.rb')
|
437
|
+
allow(YAML).to receive(:load_file).and_return(config)
|
438
438
|
|
439
439
|
ENV['RUBY_CC_VERSION'] = '1.9.1'
|
440
440
|
Rake::ExtensionTask.new('extension_one') do |ext|
|
@@ -443,10 +443,10 @@ describe Rake::ExtensionTask do
|
|
443
443
|
end
|
444
444
|
|
445
445
|
it 'should allow multiple versions be supplied to RUBY_CC_VERSION' do
|
446
|
-
config =
|
447
|
-
config.
|
448
|
-
config.
|
449
|
-
YAML.
|
446
|
+
config = Hash.new
|
447
|
+
expect(config).to receive(:[]).once.with("rbconfig-i386-mingw32-1.8.6").and_return('/rubies/1.8.6/rbconfig.rb')
|
448
|
+
expect(config).to receive(:[]).once.with("rbconfig-i386-mingw32-1.9.1").and_return('/rubies/1.9.1/rbconfig.rb')
|
449
|
+
allow(YAML).to receive(:load_file).and_return(config)
|
450
450
|
|
451
451
|
ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
|
452
452
|
Rake::ExtensionTask.new('extension_one') do |ext|
|
@@ -454,25 +454,27 @@ describe Rake::ExtensionTask do
|
|
454
454
|
end
|
455
455
|
end
|
456
456
|
|
457
|
-
it "should set required_ruby_version from RUBY_CC_VERSION" do
|
457
|
+
it "should set required_ruby_version from RUBY_CC_VERSION, set platform, clear extensions but keep metadata" do
|
458
458
|
platforms = ["x86-mingw32", "x64-mingw32"]
|
459
|
-
ruby_cc_versions = ["2.1.10", "2.2.6", "2.3.3"]
|
459
|
+
ruby_cc_versions = ["1.8.6", "2.1.10", "2.2.6", "2.3.3", "2.10.1"]
|
460
460
|
ENV["RUBY_CC_VERSION"] = ruby_cc_versions.join(":")
|
461
|
-
config =
|
461
|
+
config = Hash.new
|
462
462
|
ruby_cc_versions.each do |ruby_cc_version|
|
463
463
|
platforms.each do |platform|
|
464
|
-
config.
|
464
|
+
allow(config).to receive(:[]).
|
465
465
|
with("rbconfig-#{platform}-#{ruby_cc_version}").
|
466
466
|
and_return("/rubies/#{ruby_cc_version}/rbconfig.rb")
|
467
467
|
end
|
468
468
|
end
|
469
|
-
YAML.
|
469
|
+
allow(YAML).to receive(:load_file).and_return(config)
|
470
470
|
|
471
|
-
Gem.
|
471
|
+
allow(Gem).to receive_message_chain(:configuration, :verbose=).and_return(true)
|
472
472
|
|
473
473
|
spec = Gem::Specification.new do |s|
|
474
474
|
s.name = 'my_gem'
|
475
475
|
s.platform = Gem::Platform::RUBY
|
476
|
+
s.extensions = ['ext/somegem/extconf.rb']
|
477
|
+
s.metadata['allowed_push_host'] = 'http://test'
|
476
478
|
end
|
477
479
|
|
478
480
|
cross_specs = []
|
@@ -488,10 +490,19 @@ describe Rake::ExtensionTask do
|
|
488
490
|
end
|
489
491
|
|
490
492
|
expected_required_ruby_versions = [
|
491
|
-
Gem::Requirement.new([">=
|
492
|
-
Gem::Requirement.new([">=
|
493
|
+
Gem::Requirement.new([">= 1.8", "< 2.11"]),
|
494
|
+
Gem::Requirement.new([">= 1.8", "< 2.11"]),
|
493
495
|
]
|
494
496
|
cross_specs.collect(&:required_ruby_version).should == expected_required_ruby_versions
|
497
|
+
cross_specs.collect(&:extensions).should == [[], []]
|
498
|
+
cross_specs.collect(&:platform).collect(&:to_s).should == platforms
|
499
|
+
cross_specs.collect{|s| s.metadata['allowed_push_host']}.should == ['http://test', 'http://test']
|
500
|
+
|
501
|
+
# original gemspec should keep unchanged
|
502
|
+
spec.required_ruby_version.should == Gem::Requirement.new([">= 0"])
|
503
|
+
spec.platform.should == Gem::Platform::RUBY
|
504
|
+
spec.extensions.should == ['ext/somegem/extconf.rb']
|
505
|
+
spec.metadata['allowed_push_host'].should == 'http://test'
|
495
506
|
end
|
496
507
|
|
497
508
|
after :each do
|
@@ -500,9 +511,9 @@ describe Rake::ExtensionTask do
|
|
500
511
|
|
501
512
|
context "(cross compile for multiple versions)" do
|
502
513
|
before :each do
|
503
|
-
config =
|
504
|
-
config.
|
505
|
-
YAML.
|
514
|
+
config = Hash.new
|
515
|
+
allow(config).to receive(:[]).and_return('/rubies/1.8.6/rbconfig.rb', '/rubies/1.9.1/rbconfig.rb')
|
516
|
+
allow(YAML).to receive(:load_file).and_return(config)
|
506
517
|
|
507
518
|
ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
|
508
519
|
@ext = Rake::ExtensionTask.new('extension_one') do |ext|
|
@@ -548,7 +559,7 @@ describe Rake::ExtensionTask do
|
|
548
559
|
|
549
560
|
context 'compile:universal-unknown' do
|
550
561
|
it "should be defined" do
|
551
|
-
Rake::Task.task_defined?('compile:universal-unknown').should
|
562
|
+
Rake::Task.task_defined?('compile:universal-unknown').should == true
|
552
563
|
end
|
553
564
|
|
554
565
|
it "should depend on 'compile:extension_one:universal-unknown'" do
|
@@ -558,7 +569,7 @@ describe Rake::ExtensionTask do
|
|
558
569
|
|
559
570
|
context 'native:universal-unknown' do
|
560
571
|
it "should be defined" do
|
561
|
-
Rake::Task.task_defined?('native:universal-unknown').should
|
572
|
+
Rake::Task.task_defined?('native:universal-unknown').should == true
|
562
573
|
end
|
563
574
|
|
564
575
|
it "should depend on 'native:my_gem:universal-unknown'" do
|
@@ -596,7 +607,7 @@ describe Rake::ExtensionTask do
|
|
596
607
|
end
|
597
608
|
|
598
609
|
def mock_gem_spec(stubs = {})
|
599
|
-
|
610
|
+
double(Gem::Specification,
|
600
611
|
{ :name => 'my_gem', :platform => 'ruby', :files => [] }.merge(stubs)
|
601
612
|
)
|
602
613
|
end
|
@@ -633,6 +644,6 @@ describe Rake::ExtensionTask do
|
|
633
644
|
end
|
634
645
|
|
635
646
|
def mock_fake_rb
|
636
|
-
|
647
|
+
double(File, :write => 45)
|
637
648
|
end
|
638
649
|
end
|
@@ -89,7 +89,7 @@ describe Rake::JavaExtensionTask do
|
|
89
89
|
|
90
90
|
context '(one extension)' do
|
91
91
|
before :each do
|
92
|
-
Rake::FileList.
|
92
|
+
allow(Rake::FileList).to receive(:[]).and_return(["ext/extension_one/source.java"])
|
93
93
|
@ext = Rake::JavaExtensionTask.new('extension_one')
|
94
94
|
@ext_bin = ext_bin('extension_one')
|
95
95
|
@platform = 'java'
|
@@ -97,7 +97,7 @@ describe Rake::JavaExtensionTask do
|
|
97
97
|
|
98
98
|
context 'compile' do
|
99
99
|
it 'should define as task' do
|
100
|
-
Rake::Task.task_defined?('compile').should
|
100
|
+
Rake::Task.task_defined?('compile').should == true
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should depend on 'compile:{platform}'" do
|
@@ -108,7 +108,7 @@ describe Rake::JavaExtensionTask do
|
|
108
108
|
|
109
109
|
context 'compile:extension_one' do
|
110
110
|
it 'should define as task' do
|
111
|
-
Rake::Task.task_defined?('compile:extension_one').should
|
111
|
+
Rake::Task.task_defined?('compile:extension_one').should == true
|
112
112
|
end
|
113
113
|
|
114
114
|
it "should depend on 'compile:extension_one:{platform}'" do
|
@@ -131,7 +131,7 @@ describe Rake::JavaExtensionTask do
|
|
131
131
|
|
132
132
|
context 'tmp/{platform}/extension_one/extension_one.jar' do
|
133
133
|
it 'should define as task' do
|
134
|
-
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ext_bin}").should
|
134
|
+
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ext_bin}").should == true
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should depend on checkpoint file" do
|
@@ -141,7 +141,7 @@ describe Rake::JavaExtensionTask do
|
|
141
141
|
|
142
142
|
context 'tmp/{platform}/extension_one/.build' do
|
143
143
|
it 'should define as task' do
|
144
|
-
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/.build").should
|
144
|
+
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/.build").should == true
|
145
145
|
end
|
146
146
|
|
147
147
|
it 'should depend on source files' do
|
@@ -174,7 +174,7 @@ describe Rake::JavaExtensionTask do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def mock_gem_spec(stubs = {})
|
177
|
-
|
177
|
+
double(Gem::Specification,
|
178
178
|
{ :name => 'my_gem', :platform => 'ruby' }.merge(stubs)
|
179
179
|
)
|
180
180
|
end
|
data/tasks/gem.rake
CHANGED
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.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-05-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|