[Rubygems-developers] pure-ruby vs. compile-on-intsall

Trans transfire at gmail.com
Wed Nov 7 22:50:45 EST 2007


Well, here's my final hack. Now I path RubyGems to handle this the right way.


require 'mkmf'
require 'rbconfig'

FailedMessage.replace("Compilation of native extension failed.
Check mkmf.log for details. You may need configuration options.
This Gem has a pure-ruby fall back option, so you can still use it.
To do so, export the environment variable to NORUBYEXT='true'
and gem install again.\n\n")

extension_name = 'scanner_c'

arch = Config::CONFIG['arch']

windows = (/mswin/ =~ arch) #RUBY_PLATFORM

if (ENV['NORUBYEXT'] == 'true') || windows  # TEMPORARILY ADD WINDOWS HERE
  # LETS TRY FAKING IT OUT.
  if windows
    File.open('make.bat', 'w') do |f|
      f << 'echo Native extension will be omitted.'
    end
    File.open('nmake.bat', 'w') do |f|
      f << 'echo Native extension will be omitted.'
    end
  end
  File.open('Makefile', 'w') do |f|
    f << "all:\n"
    f << "install:\n"
  end
else
  if windows && ENV['make'].nil?
    $LIBS += " msvcprt.lib"
    #dir_config(extension_name)
    #create_makefile(extension_name, "tmail")
    create_makefile(extension_name, "tmail/#{arch}")
  else
    $CFLAGS += " -D_FILE_OFFSET_BITS=64"  #???
    #dir_config(extension_name)
    #create_makefile(extension_name, "tmail")
    create_makefile(extension_name, "tmail/#{arch}")
  end
end


More information about the Rubygems-developers mailing list