Bug #7698 ยป 0001-ext_conf_builder.rb-build-in-separate-dir.patch
lib/rubygems/ext/builder.rb | ||
---|---|---|
mf = Gem.read_binary 'Makefile'
|
||
mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
|
||
mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}")
|
||
mf = mf.gsub(/\s*\S+\.time$/, "")
|
||
File.open('Makefile', 'wb') {|f| f.print mf}
|
||
lib/rubygems/ext/ext_conf_builder.rb | ||
---|---|---|
require 'rubygems/ext/builder'
|
||
require 'rubygems/command'
|
||
require 'fileutils'
|
||
require 'tmpdir'
|
||
class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
|
||
def self.build(extension, directory, dest_path, results, args=[])
|
||
cmd = "#{Gem.ruby} #{File.basename extension}"
|
||
pwd = Dir.pwd
|
||
cmd = "#{Gem.ruby} #{File.join pwd, File.basename(extension)}"
|
||
cmd << " #{args.join ' '}" unless args.empty?
|
||
run cmd, results
|
||
Dir.chdir(Dir.mktmpdir("gem-install.")) do
|
||
begin
|
||
run cmd, results
|
||
make dest_path, results
|
||
make dest_path, results
|
||
ensure
|
||
FileUtils.mv("mkmf.log", pwd) if $! and File.exist?("mkmf.log")
|
||
end
|
||
end
|
||
results
|
||
end
|
test/rubygems/test_gem_ext_ext_conf_builder.rb | ||
---|---|---|
Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
|
||
end
|
||
assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
|
||
assert_match(/^#{Gem.ruby} .*extconf.rb/, output[0])
|
||
assert_equal "creating Makefile\n", output[1]
|
||
case RUBY_PLATFORM
|
||
when /mswin/ then
|
||
... | ... | |
assert_match(/\Aextconf failed:
|
||
#{Gem.ruby} extconf.rb.*
|
||
#{Gem.ruby} .*extconf.rb.*
|
||
checking for main\(\) in .*?nonexistent/m, error.message)
|
||
assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
|
||
assert_match(/^#{Gem.ruby} .*extconf.rb/, output[0])
|
||
end
|
||
def test_class_make
|
test/rubygems/test_gem_installer.rb | ||
---|---|---|
gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out'
|
||
assert_match %r%#{Regexp.escape Gem.ruby} extconf\.rb%,
|
||
assert_match %r%#{Regexp.escape Gem.ruby} .*extconf\.rb%,
|
||
File.read(gem_make_out)
|
||
assert_match %r%#{Regexp.escape Gem.ruby}: No such file%,
|
||
File.read(gem_make_out)
|
||
... | ... | |
File.open File.join(@spec.gem_dir, "extconf.rb"), "w" do |f|
|
||
f.write <<-'RUBY'
|
||
puts "IN EXTCONF"
|
||
File.open 'extconf_args', 'w' do |f|
|
||
extconf_args = File.join File.dirname(__FILE__), 'extconf_args'
|
||
File.open extconf_args, 'w' do |f|
|
||
f.puts ARGV.inspect
|
||
end
|
||