Class: Gem::ExtBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygems/installer.rb

Overview

class Uninstaller

Class Method Summary collapse

Class Method Details

.class_nameObject



575
576
577
578
# File 'lib/rubygems/installer.rb', line 575

def self.class_name
  name =~ /Ext(.*)Builder/
  $1.downcase
end

.make(dest_path, results) ⇒ Object



580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
# File 'lib/rubygems/installer.rb', line 580

def self.make(dest_path, results)
  unless File.exist? 'Makefile' then
    raise Gem::InstallError, "Makefile not found:\n\n#{results.join "\n"}" 
  end

  mf = File.read('Makefile')
  mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
  mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}")

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

  make_program = ENV['make']
  unless make_program then
    make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
  end

  ['', ' install'].each do |target|
    cmd = "#{make_program}#{target}"
    results << cmd
    results << `#{cmd} #{redirector}`

    raise Gem::InstallError, "make#{target} failed:\n\n#{results}" unless
      $?.exitstatus.zero?
  end
end

.redirectorObject



606
607
608
# File 'lib/rubygems/installer.rb', line 606

def self.redirector
  '2>&1'
end

.run(command, results) ⇒ Object



610
611
612
613
614
615
616
617
# File 'lib/rubygems/installer.rb', line 610

def self.run(command, results)
  results << command
  results << `#{command} #{redirector}`

  unless $?.exitstatus.zero? then
    raise Gem::InstallError, "#{class_name} failed:\n\n#{results.join "\n"}"
  end
end