Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rake-compiler/rake-compiler
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.3
Choose a base ref
...
head repository: rake-compiler/rake-compiler
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.0.4
Choose a head ref
  • 12 commits
  • 7 files changed
  • 5 contributors

Commits on Dec 2, 2016

  1. Bump version

    kou committed Dec 2, 2016

    Verified

    This commit was signed with the committer’s verified signature.
    lforst Luca Forstner
    Copy the full SHA
    2549964 View commit details

Commits on Mar 24, 2017

  1. Use RSpec 3

    kou committed Mar 24, 2017

    Verified

    This commit was signed with the committer’s verified signature.
    lforst Luca Forstner
    Copy the full SHA
    0c78747 View commit details

Commits on Apr 20, 2017

  1. Copy the full SHA
    2c97eaa View commit details

Commits on Apr 21, 2017

  1. Merge pull request #140 from larskanis/test-gemspec-mutation

    Add more tests for gemspec mutation of native gems
    
    Patch by Lars Kanis. Thanks!!!
    kou authored Apr 21, 2017
    Copy the full SHA
    2573c0e View commit details

Commits on Apr 26, 2017

  1. Copy the full SHA
    8e132f5 View commit details
  2. Merge pull request #141 from k0kubun/cxx-source-files

    Regard C++ sources as source_files
    
    Patch by Takashi Kokubun. Thanks!!!
    kou authored Apr 26, 2017
    Copy the full SHA
    f7c8723 View commit details

Commits on May 19, 2017

  1. Copy the full SHA
    9a1ec74 View commit details
  2. Copy the full SHA
    d0a20e1 View commit details
  3. ⚠️ method redefined

    amatsuda committed May 19, 2017
    Copy the full SHA
    98948ce View commit details
  4. ⚠️ method redefined

    amatsuda committed May 19, 2017
    Copy the full SHA
    00bf2e7 View commit details

Commits on May 20, 2017

  1. Merge pull request #142 from amatsuda/warnings

    Warnings
    
    Patch by Akira Matsuda. Thanks!!!
    kou authored May 20, 2017
    Copy the full SHA
    b00d1ce View commit details

Commits on May 26, 2017

  1. Add 1.0.4 entry

    kou committed May 26, 2017
    Copy the full SHA
    5656ea9 View commit details
Showing with 93 additions and 72 deletions.
  1. +2 −2 Gemfile
  2. +11 −0 History.txt
  3. +1 −1 lib/rake/baseextensiontask.rb
  4. +6 −7 lib/rake/extensiontask.rb
  5. +66 −55 spec/lib/rake/extensiontask_spec.rb
  6. +6 −6 spec/lib/rake/javaextensiontask_spec.rb
  7. +1 −1 tasks/gem.rake
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -3,6 +3,6 @@ source "https://rubygems.org"
gem "rake"

group :development do
gem "rspec", "~> 2.8.0"
gem "cucumber", "~> 1.1.4"
gem "rspec", "~> 3.0"
gem "cucumber", "~> 2.0"
end
11 changes: 11 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
=== 1.0.4 / 2017-05-27

* Enhancements:
* Migrate to RSpec 3 from RSpec 2.
* Add more tests.
#140 [Patch by Lars Kanis]
* Support C++ source files by default.
#141 [Patch by Takashi Kokubun]
* Suppress warnings.
#142 [Patch by Akira Matsuda]

=== 1.0.3 / 2016-12-02

* Enhancements:
2 changes: 1 addition & 1 deletion lib/rake/baseextensiontask.rb
Original file line number Diff line number Diff line change
@@ -19,10 +19,10 @@ class BaseExtensionTask < TaskLib
attr_accessor :tmp_dir
attr_accessor :ext_dir
attr_accessor :lib_dir
attr_accessor :platform
attr_accessor :config_options
attr_accessor :source_pattern
attr_accessor :extra_options
attr_writer :platform

def platform
@platform ||= RUBY_PLATFORM
13 changes: 6 additions & 7 deletions lib/rake/extensiontask.rb
Original file line number Diff line number Diff line change
@@ -10,15 +10,15 @@ module Rake
class ExtensionTask < BaseExtensionTask
attr_accessor :config_script
attr_accessor :cross_compile
attr_accessor :cross_platform
attr_writer :cross_platform
attr_writer :cross_config_options
attr_accessor :no_native
attr_accessor :config_includes

def init(name = nil, gem_spec = nil)
super
@config_script = 'extconf.rb'
@source_pattern = "*.c"
@source_pattern = "*.{c,cc,cpp}"
@compiled_pattern = "*.{o,obj,so,bundle,dSYM}"
@cross_compile = false
@cross_config_options = []
@@ -237,7 +237,6 @@ def define_native_tasks(for_platform = nil, ruby_ver = RUBY_VERSION, callback =
platf = for_platform || platform

# tmp_path
tmp_path = "#{@tmp_dir}/#{platf}/#{@name}/#{ruby_ver}"
stage_path = "#{@tmp_dir}/#{platf}/stage"

# lib_path
@@ -283,12 +282,12 @@ def define_native_tasks(for_platform = nil, ruby_ver = RUBY_VERSION, callback =
callback.call(spec) if callback

# Generate a package for this gem
pkg = Gem::PackageTask.new(spec) do |pkg|
pkg.need_zip = false
pkg.need_tar = false
pkg = Gem::PackageTask.new(spec) do |p|
p.need_zip = false
p.need_tar = false
# Do not copy any files per PackageTask, because
# we need the files from the staging directory
pkg.package_files.clear
p.package_files.clear
end

# copy other gem files to staging directory if added by the callback
121 changes: 66 additions & 55 deletions spec/lib/rake/extensiontask_spec.rb
Original file line number Diff line number Diff line change
@@ -77,8 +77,8 @@
@ext.lib_dir.should == 'lib'
end

it 'should look for C files pattern (.c)' do
@ext.source_pattern.should == "*.c"
it 'should look for C/C++ files pattern (.c,.cc,.cpp)' do
@ext.source_pattern.should == "*.{c,cc,cpp}"
end

it 'should have no configuration options preset to delegate' do
@@ -94,7 +94,7 @@
end

it 'should default to no cross compilation' do
@ext.cross_compile.should be_false
@ext.cross_compile.should == false
end

it 'should have no configuration options for cross compilation' do
@@ -115,7 +115,7 @@

context '(one extension)' do
before :each do
Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"], [])
allow(Rake::FileList).to receive(:[]).and_return(["ext/extension_one/source.c"], [])
@ext = Rake::ExtensionTask.new('extension_one')
@ext_bin = ext_bin('extension_one')
@platform = RUBY_PLATFORM
@@ -124,7 +124,7 @@

context 'compile' do
it 'should define as task' do
Rake::Task.task_defined?('compile').should be_true
Rake::Task.task_defined?('compile').should == true
end

it "should depend on 'compile:{platform}'" do
@@ -134,7 +134,7 @@

context 'compile:extension_one' do
it 'should define as task' do
Rake::Task.task_defined?('compile:extension_one').should be_true
Rake::Task.task_defined?('compile:extension_one').should == true
end

it "should depend on 'compile:extension_one:{platform}'" do
@@ -144,7 +144,7 @@

context 'lib/extension_one.{so,bundle}' do
it 'should define as task' do
Rake::Task.task_defined?("lib/#{@ext_bin}").should be_true
Rake::Task.task_defined?("lib/#{@ext_bin}").should == true
end

it "should depend on 'copy:extension_one:{platform}:{ruby_ver}'" do
@@ -154,7 +154,7 @@

context 'tmp/{platform}/extension_one/{ruby_ver}/extension_one.{so,bundle}' do
it 'should define as task' do
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ruby_ver}/#{@ext_bin}").should be_true
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ruby_ver}/#{@ext_bin}").should == true
end

it "should depend on 'tmp/{platform}/extension_one/{ruby_ver}/Makefile'" do
@@ -172,7 +172,7 @@

context 'tmp/{platform}/extension_one/{ruby_ver}/Makefile' do
it 'should define as task' do
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ruby_ver}/Makefile").should be_true
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ruby_ver}/Makefile").should == true
end

it "should depend on 'tmp/{platform}/extension_one/{ruby_ver}'" do
@@ -201,7 +201,7 @@
end

it "should warn when pre-compiled files exist in extension directory" do
Rake::FileList.stub!(:[]).
allow(Rake::FileList).to receive(:[]).
and_return(["ext/extension_one/source.c"],
["ext/extension_one/source.o"])

@@ -214,7 +214,7 @@

context '(extension in custom location)' do
before :each do
Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"], [])
allow(Rake::FileList).to receive(:[]).and_return(["ext/extension_one/source.c"], [])
@ext = Rake::ExtensionTask.new('extension_one') do |ext|
ext.ext_dir = 'custom/ext/foo'
end
@@ -232,7 +232,7 @@

context '(native tasks)' do
before :each do
Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"], [])
allow(Rake::FileList).to receive(:[]).and_return(["ext/extension_one/source.c"], [])
@spec = mock_gem_spec
@ext_bin = ext_bin('extension_one')
@platform = RUBY_PLATFORM
@@ -241,24 +241,24 @@

context 'native' do
before :each do
@spec.stub!(:platform=).and_return('ruby')
allow(@spec).to receive(:platform=).and_return('ruby')
end

it 'should define a task for building the supplied gem' do
Rake::ExtensionTask.new('extension_one', @spec)
Rake::Task.task_defined?('native:my_gem').should be_true
Rake::Task.task_defined?('native:my_gem').should == true
end

it 'should define as task for pure ruby gems' do
Rake::Task.task_defined?('native').should be_false
Rake::Task.task_defined?('native').should == false
Rake::ExtensionTask.new('extension_one', @spec)
Rake::Task.task_defined?('native').should be_true
Rake::Task.task_defined?('native').should == true
end

it 'should not define a task for already native gems' do
@spec.stub!(:platform).and_return('current')
allow(@spec).to receive(:platform).and_return('current')
Rake::ExtensionTask.new('extension_one', @spec)
Rake::Task.task_defined?('native').should be_false
Rake::Task.task_defined?('native').should == false
end

it 'should depend on platform specific native tasks' do
@@ -277,7 +277,7 @@

context '(one extension whose name with directory prefixes)' do
before :each do
Rake::FileList.stub!(:[]).and_return(["ext/prefix1/prefix2/extension_one/source.c"], [])
allow(Rake::FileList).to receive(:[]).and_return(["ext/prefix1/prefix2/extension_one/source.c"], [])
@ext = Rake::ExtensionTask.new('prefix1/prefix2/extension_one')
@ext_bin = ext_bin('extension_one')
@platform = RUBY_PLATFORM
@@ -286,7 +286,7 @@

context 'compile' do
it 'should define as task' do
Rake::Task.task_defined?('compile').should be_true
Rake::Task.task_defined?('compile').should == true
end

it "should depend on 'compile:{platform}'" do
@@ -296,7 +296,7 @@

context 'compile:prefix1/prefix2/extension_one' do
it 'should define as task' do
Rake::Task.task_defined?('compile:prefix1/prefix2/extension_one').should be_true
Rake::Task.task_defined?('compile:prefix1/prefix2/extension_one').should == true
end

it "should depend on 'compile:prefix1/prefix2/extension_one:{platform}'" do
@@ -306,7 +306,7 @@

context 'lib/prefix1/prefix2/extension_one.{so,bundle}' do
it 'should define as task' do
Rake::Task.task_defined?("lib/prefix1/prefix2/#{@ext_bin}").should be_true
Rake::Task.task_defined?("lib/prefix1/prefix2/#{@ext_bin}").should == true
end

it "should depend on 'copy:prefix1/prefix2/extension_one:{platform}:{ruby_ver}'" do
@@ -316,7 +316,7 @@

context 'tmp/{platform}/prefix1/prefix2/extension_one/{ruby_ver}/prefix1/prefix2/extension_one.{so,bundle}' do
it 'should define as task' do
Rake::Task.task_defined?("tmp/#{@platform}/prefix1/prefix2/extension_one/#{@ruby_ver}/prefix1/prefix2/#{@ext_bin}").should be_true
Rake::Task.task_defined?("tmp/#{@platform}/prefix1/prefix2/extension_one/#{@ruby_ver}/prefix1/prefix2/#{@ext_bin}").should == true
end

it "should depend on 'tmp/{platform}/prefix1/prefix2/extension_one/{ruby_ver}/Makefile'" do
@@ -335,21 +335,21 @@

context '(cross platform tasks)' do
before :each do
File.stub!(:exist?).and_return(true)
YAML.stub!(:load_file).and_return(mock_config_yml)
Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.c"], [])
allow(File).to receive(:exist?).and_return(true)
allow(YAML).to receive(:load_file).and_return(mock_config_yml)
allow(Rake::FileList).to receive(:[]).and_return(["ext/extension_one/source.c"], [])
@spec = mock_gem_spec
@config_file = File.expand_path("~/.rake-compiler/config.yml")
@ruby_ver = RUBY_VERSION
@platform = 'i386-mingw32'
@config_path = mock_config_yml["rbconfig-#{@platform}-#{@ruby_ver}"]

File.stub!(:open).and_yield(mock_fake_rb)
allow(File).to receive(:open).and_yield(mock_fake_rb)
end

context 'if no rake-compiler configuration exists' do
before :each do
File.should_receive(:exist?).with(@config_file).and_return(false)
expect(File).to receive(:exist?).with(@config_file).and_return(false)

_, @err = capture_output do
Rake::ExtensionTask.new('extension_one') do |ext|
@@ -373,16 +373,16 @@
end

it 'should parse the config file using YAML' do
YAML.should_receive(:load_file).with(@config_file).and_return(mock_config_yml)
expect(YAML).to receive(:load_file).with(@config_file).and_return(mock_config_yml)
Rake::ExtensionTask.new('extension_one') do |ext|
ext.cross_compile = true
end
end

it 'should warn if no section of config file defines running version of ruby' do
config = mock(Hash)
config.should_receive(:[]).with("rbconfig-#{@platform}-#{@ruby_ver}").and_return(nil)
YAML.stub!(:load_file).and_return(config)
config = Hash.new
expect(config).to receive(:[]).with("rbconfig-#{@platform}-#{@ruby_ver}").and_return(nil)
allow(YAML).to receive(:load_file).and_return(config)
out, err = capture_output do
Rake::ExtensionTask.new('extension_one') do |ext|
ext.cross_compile = true
@@ -402,9 +402,9 @@
end

it 'should generate additional rake tasks if files are added when cross compiling' do
config = mock(Hash)
config.stub!(:[]).and_return('/rubies/1.9.1/rbconfig.rb')
YAML.stub!(:load_file).and_return(config)
config = Hash.new
allow(config).to receive(:[]).and_return('/rubies/1.9.1/rbconfig.rb')
allow(YAML).to receive(:load_file).and_return(config)

# Use a real spec instead of a mock because define_native_tasks dups and
# calls methods on Gem::Specification, which is more than mock can do.
@@ -416,7 +416,7 @@
# Gem::PackageTask calls Rake::PackageTask which sets Gem.configuration.verbose,
# which initializes Gem::ConfigFile,
# which gets mad if it cannot find `sysconfdir`/gemrc
Gem.stub_chain(:configuration, :verbose=).and_return(true)
allow(Gem).to receive_message_chain(:configuration, :verbose=).and_return(true)

ENV['RUBY_CC_VERSION'] = '1.9.1'
Rake::ExtensionTask.new('extension_one', spec) do |ext|
@@ -432,9 +432,9 @@
end

it 'should allow usage of RUBY_CC_VERSION to indicate a different version of ruby' do
config = mock(Hash)
config.should_receive(:[]).with("rbconfig-i386-mingw32-1.9.1").and_return('/rubies/1.9.1/rbconfig.rb')
YAML.stub!(:load_file).and_return(config)
config = Hash.new
expect(config).to receive(:[]).with("rbconfig-i386-mingw32-1.9.1").and_return('/rubies/1.9.1/rbconfig.rb')
allow(YAML).to receive(:load_file).and_return(config)

ENV['RUBY_CC_VERSION'] = '1.9.1'
Rake::ExtensionTask.new('extension_one') do |ext|
@@ -443,36 +443,38 @@
end

it 'should allow multiple versions be supplied to RUBY_CC_VERSION' do
config = mock(Hash)
config.should_receive(:[]).once.with("rbconfig-i386-mingw32-1.8.6").and_return('/rubies/1.8.6/rbconfig.rb')
config.should_receive(:[]).once.with("rbconfig-i386-mingw32-1.9.1").and_return('/rubies/1.9.1/rbconfig.rb')
YAML.stub!(:load_file).and_return(config)
config = Hash.new
expect(config).to receive(:[]).once.with("rbconfig-i386-mingw32-1.8.6").and_return('/rubies/1.8.6/rbconfig.rb')
expect(config).to receive(:[]).once.with("rbconfig-i386-mingw32-1.9.1").and_return('/rubies/1.9.1/rbconfig.rb')
allow(YAML).to receive(:load_file).and_return(config)

ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
Rake::ExtensionTask.new('extension_one') do |ext|
ext.cross_compile = true
end
end

it "should set required_ruby_version from RUBY_CC_VERSION" do
it "should set required_ruby_version from RUBY_CC_VERSION, set platform, clear extensions but keep metadata" do
platforms = ["x86-mingw32", "x64-mingw32"]
ruby_cc_versions = ["1.8.6", "2.1.10", "2.2.6", "2.3.3", "2.10.1"]
ENV["RUBY_CC_VERSION"] = ruby_cc_versions.join(":")
config = mock(Hash)
config = Hash.new
ruby_cc_versions.each do |ruby_cc_version|
platforms.each do |platform|
config.stub!(:[]).
allow(config).to receive(:[]).
with("rbconfig-#{platform}-#{ruby_cc_version}").
and_return("/rubies/#{ruby_cc_version}/rbconfig.rb")
end
end
YAML.stub!(:load_file).and_return(config)
allow(YAML).to receive(:load_file).and_return(config)

Gem.stub_chain(:configuration, :verbose=).and_return(true)
allow(Gem).to receive_message_chain(:configuration, :verbose=).and_return(true)

spec = Gem::Specification.new do |s|
s.name = 'my_gem'
s.platform = Gem::Platform::RUBY
s.extensions = ['ext/somegem/extconf.rb']
s.metadata['allowed_push_host'] = 'http://test'
end

cross_specs = []
@@ -492,6 +494,15 @@
Gem::Requirement.new([">= 1.8", "< 2.11"]),
]
cross_specs.collect(&:required_ruby_version).should == expected_required_ruby_versions
cross_specs.collect(&:extensions).should == [[], []]
cross_specs.collect(&:platform).collect(&:to_s).should == platforms
cross_specs.collect{|s| s.metadata['allowed_push_host']}.should == ['http://test', 'http://test']

# original gemspec should keep unchanged
spec.required_ruby_version.should == Gem::Requirement.new([">= 0"])
spec.platform.should == Gem::Platform::RUBY
spec.extensions.should == ['ext/somegem/extconf.rb']
spec.metadata['allowed_push_host'].should == 'http://test'
end

after :each do
@@ -500,9 +511,9 @@

context "(cross compile for multiple versions)" do
before :each do
config = mock(Hash)
config.stub!(:[]).and_return('/rubies/1.8.6/rbconfig.rb', '/rubies/1.9.1/rbconfig.rb')
YAML.stub!(:load_file).and_return(config)
config = Hash.new
allow(config).to receive(:[]).and_return('/rubies/1.8.6/rbconfig.rb', '/rubies/1.9.1/rbconfig.rb')
allow(YAML).to receive(:load_file).and_return(config)

ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
@ext = Rake::ExtensionTask.new('extension_one') do |ext|
@@ -548,7 +559,7 @@

context 'compile:universal-unknown' do
it "should be defined" do
Rake::Task.task_defined?('compile:universal-unknown').should be_true
Rake::Task.task_defined?('compile:universal-unknown').should == true
end

it "should depend on 'compile:extension_one:universal-unknown'" do
@@ -558,7 +569,7 @@

context 'native:universal-unknown' do
it "should be defined" do
Rake::Task.task_defined?('native:universal-unknown').should be_true
Rake::Task.task_defined?('native:universal-unknown').should == true
end

it "should depend on 'native:my_gem:universal-unknown'" do
@@ -596,7 +607,7 @@ def ext_bin(extension_name)
end

def mock_gem_spec(stubs = {})
mock(Gem::Specification,
double(Gem::Specification,
{ :name => 'my_gem', :platform => 'ruby', :files => [] }.merge(stubs)
)
end
@@ -633,6 +644,6 @@ def mock_config_yml
end

def mock_fake_rb
mock(File, :write => 45)
double(File, :write => 45)
end
end
12 changes: 6 additions & 6 deletions spec/lib/rake/javaextensiontask_spec.rb
Original file line number Diff line number Diff line change
@@ -89,15 +89,15 @@

context '(one extension)' do
before :each do
Rake::FileList.stub!(:[]).and_return(["ext/extension_one/source.java"])
allow(Rake::FileList).to receive(:[]).and_return(["ext/extension_one/source.java"])
@ext = Rake::JavaExtensionTask.new('extension_one')
@ext_bin = ext_bin('extension_one')
@platform = 'java'
end

context 'compile' do
it 'should define as task' do
Rake::Task.task_defined?('compile').should be_true
Rake::Task.task_defined?('compile').should == true
end

it "should depend on 'compile:{platform}'" do
@@ -108,7 +108,7 @@

context 'compile:extension_one' do
it 'should define as task' do
Rake::Task.task_defined?('compile:extension_one').should be_true
Rake::Task.task_defined?('compile:extension_one').should == true
end

it "should depend on 'compile:extension_one:{platform}'" do
@@ -131,7 +131,7 @@

context 'tmp/{platform}/extension_one/extension_one.jar' do
it 'should define as task' do
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ext_bin}").should be_true
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/#{@ext_bin}").should == true
end

it "should depend on checkpoint file" do
@@ -141,7 +141,7 @@

context 'tmp/{platform}/extension_one/.build' do
it 'should define as task' do
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/.build").should be_true
Rake::Task.task_defined?("tmp/#{@platform}/extension_one/.build").should == true
end

it 'should depend on source files' do
@@ -174,7 +174,7 @@ def ext_bin(extension_name)
end

def mock_gem_spec(stubs = {})
mock(Gem::Specification,
double(Gem::Specification,
{ :name => 'my_gem', :platform => 'ruby' }.merge(stubs)
)
end
2 changes: 1 addition & 1 deletion tasks/gem.rake
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ require 'rubygems/package_task'
GEM_SPEC = Gem::Specification.new do |s|
# basic information
s.name = "rake-compiler"
s.version = "1.0.3"
s.version = "1.0.4"
s.platform = Gem::Platform::RUBY

# description and details