0001-ext_conf_builder.rb-build-in-separate-dir.patch

Nobuyoshi Nakada, 02/27/2013 06:08 PM

Download (4.03 KB)

View differences:

lib/rubygems/ext/builder.rb
19 19
    mf = Gem.read_binary 'Makefile'
20 20
    mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
21 21
    mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}")
22
    mf = mf.gsub(/\s*\S+\.time$/, "")
23 22

  
24 23
    File.open('Makefile', 'wb') {|f| f.print mf}
25 24

  
lib/rubygems/ext/ext_conf_builder.rb
6 6

  
7 7
require 'rubygems/ext/builder'
8 8
require 'rubygems/command'
9
require 'fileutils'
10
require 'tmpdir'
9 11

  
10 12
class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
11 13

  
12 14
  def self.build(extension, directory, dest_path, results, args=[])
13
    cmd = "#{Gem.ruby} #{File.basename extension}"
15
    pwd = Dir.pwd
16
    cmd = "#{Gem.ruby} #{File.join pwd, File.basename(extension)}"
14 17
    cmd << " #{args.join ' '}" unless args.empty?
15 18

  
16
    run cmd, results
19
    Dir.chdir(Dir.mktmpdir("gem-install.")) do
20
      begin
21
        run cmd, results
17 22

  
18
    make dest_path, results
23
        make dest_path, results
24
      ensure
25
        FileUtils.mv("mkmf.log", pwd) if $! and File.exist?("mkmf.log")
26
      end
27
    end
19 28

  
20 29
    results
21 30
  end
test/rubygems/test_gem_ext_ext_conf_builder.rb
30 30
      Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
31 31
    end
32 32

  
33
    assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
33
    assert_match(/^#{Gem.ruby} .*extconf.rb/, output[0])
34 34
    assert_equal "creating Makefile\n", output[1]
35 35
    case RUBY_PLATFORM
36 36
    when /mswin/ then
......
107 107

  
108 108
    assert_match(/\Aextconf failed:
109 109

  
110
#{Gem.ruby} extconf.rb.*
110
#{Gem.ruby} .*extconf.rb.*
111 111
checking for main\(\) in .*?nonexistent/m, error.message)
112 112

  
113
    assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
113
    assert_match(/^#{Gem.ruby} .*extconf.rb/, output[0])
114 114
  end
115 115

  
116 116
  def test_class_make
test/rubygems/test_gem_installer.rb
81 81

  
82 82
    gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out'
83 83

  
84
    assert_match %r%#{Regexp.escape Gem.ruby} extconf\.rb%,
84
    assert_match %r%#{Regexp.escape Gem.ruby} .*extconf\.rb%,
85 85
                 File.read(gem_make_out)
86 86
    assert_match %r%#{Regexp.escape Gem.ruby}: No such file%,
87 87
                 File.read(gem_make_out)
......
119 119
    File.open File.join(@spec.gem_dir, "extconf.rb"), "w" do |f|
120 120
      f.write <<-'RUBY'
121 121
        puts "IN EXTCONF"
122
        File.open 'extconf_args', 'w' do |f|
122
        extconf_args = File.join File.dirname(__FILE__), 'extconf_args'
123
        File.open extconf_args, 'w' do |f|
123 124
          f.puts ARGV.inspect
124 125
        end
125 126

  
126
-