[Rubygems-developers] Gem::Ext::RakeBuilder ignores custom Rakefile name

Yaohan Chen yaohan.chen at gmail.com
Wed Jun 18 23:59:59 EDT 2008


I'm working on a project which compiles and uses some platform dependent 
files, but they are not built from C files. The method to generate those 
files is already in the project's Rakefile as a task, so I wanted to use 
gem's Rakefile extension builder. I have

  spec.extensions << "Rakefile.ext"

But the extension building phase fails saying Rakefile cannot be found. 
Looking lib/rubygems/ext/rake_builder.rb lines 11-21,

  def self.build(extension, directory, dest_path, results)
    if File.basename(extension) =~ /mkrf_conf/i then
      cmd = "#{Gem.ruby} #{File.basename extension}"
      cmd << " #{ARGV.join " "}" unless ARGV.empty?
      run cmd, results

    cmd = ENV['rake'] || 'rake'
    cmd << " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}

    run cmd, results

It seems that if the Rakefile contains mkrf_conf in the basename (btw I see 
some mkrf_conf.rb files on the web, but none with both Rakefile and mkmf_conf 
in its name) then it is treated as a "configure script", it is executed and 
afterwards a Rakefile is expected to be created. Otherwise, the file must be 
named Rakefile. If this is by design, there is a usability problem in 
accepting any filename containing Rakefile in spec.extensions.

There is also a problem with requiring the file to be called Rakefile. The 
project already has a Rakefile containing various tasks such as gem, and a 
task for building the extension. It doesn't make sense to have the default 
rule build the extension, which is why I am trying to use a different 
Rakefile. But if it's possible to name the task to execute, along with the 
Rakefile in specification.extensions, I would have no problem.

Finally, is the Rakefile expected to both build and install the extensions in 
its default task?

Thank you in advance.

Yaohan Chen

More information about the Rubygems-developers mailing list