Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions lib/rubygems/ext/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ def initialize(spec, build_args = spec.build_args, target_rbconfig = Gem.target_
@gem_dir = spec.full_gem_path
@target_rbconfig = target_rbconfig
@build_jobs = build_jobs

@ran_rake = false
end

##
Expand All @@ -177,7 +175,6 @@ def builder_for(extension) # :nodoc:
when /configure/ then
Gem::Ext::ConfigureBuilder
when /rakefile/i, /mkrf_conf/i then
@ran_rake = true
Gem::Ext::RakeBuilder
when /CMakeLists.txt/ then
Gem::Ext::CmakeBuilder.new
Expand Down Expand Up @@ -250,8 +247,6 @@ def build_extensions
FileUtils.rm_f @spec.gem_build_complete_path

@spec.extensions.each do |extension|
break if @ran_rake

build_extension extension, dest_path
end

Expand Down
53 changes: 52 additions & 1 deletion test/rubygems/test_gem_ext_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setup

@spec = util_spec "a"

@builder = Gem::Ext::Builder.new @spec, ""
@builder = Gem::Ext::Builder.new @spec
end

def teardown
Expand Down Expand Up @@ -201,6 +201,57 @@ def test_build_extensions_install_ext_only
Gem.configuration.install_extension_in_lib = @orig_install_extension_in_lib
end

def test_build_multiple_extensions
pend if RUBY_ENGINE == "truffleruby"
pend "terminates on ruby/ruby" if ruby_repo?

extension_in_lib do
@spec.extensions << "ext/Rakefile"
@spec.extensions << "ext/extconf.rb"

ext_dir = File.join @spec.gem_dir, "ext"

FileUtils.mkdir_p ext_dir

extconf_rb = File.join ext_dir, "extconf.rb"
rakefile = File.join ext_dir, "Rakefile"

File.open extconf_rb, "w" do |f|
f.write <<-'RUBY'
require 'mkmf'

create_makefile 'a'
RUBY
end

File.open rakefile, "w" do |f|
f.write <<-RUBY
task :default do
FileUtils.touch File.join "#{ext_dir}", 'foo'
end
RUBY
end

ext_lib_dir = File.join ext_dir, "lib"
FileUtils.mkdir ext_lib_dir
FileUtils.touch File.join ext_lib_dir, "a.rb"
FileUtils.mkdir File.join ext_lib_dir, "a"
FileUtils.touch File.join ext_lib_dir, "a", "b.rb"

use_ui @ui do
@builder.build_extensions
end

assert_path_exist @spec.extension_dir
assert_path_exist @spec.gem_build_complete_path
assert_path_exist File.join @spec.gem_dir, "ext", "foo"
assert_path_exist File.join @spec.extension_dir, "gem_make.out"
assert_path_exist File.join @spec.extension_dir, "a.rb"
assert_path_exist File.join @spec.gem_dir, "lib", "a.rb"
assert_path_exist File.join @spec.gem_dir, "lib", "a", "b.rb"
end
end

def test_build_extensions_none
use_ui @ui do
@builder.build_extensions
Expand Down