[Rubygems-developers] Initial capability to build native (source) gems

Richard Kilmer rich at infoether.com
Tue Mar 30 02:31:58 EST 2004


I have added the ability to build native extension gems from source.  
This will not (yet) work on win32 using nmake (tomorrow).

To use this...

example gemspec:

require 'rubygems'

spec = Gem::Specification.new do |s|

   s.name = 'semitar'
   s.version = "0.1.0"
   s.platform = Gem::Platform::RUBY
   s.summary = "Semitar is a pure Ruby Semantic Web library 
   s.requirements << 'raptorlib rdf parser'
   s.files = Dir.glob("{lib,ext}/**/*").delete_if {|item| 
   s.require_path = 'lib'
   s.extensions << 'ext/raptor/extconf.rb'
   s.autorequire = 'semitar'


   s.author = "Richard Kilmer"
   s.email = "rich at infoether.com"
   s.homepage = "http://semitar.semwebcentral.org"

if $0==__FILE__


The key is having the:

s.extensions << 'ext/raptor/extconf.rb'

This will instruct the system to execute that extconf.rb file, then (if 
the Makefile is created) do a 'make' and 'make install'.  I do a little 
trick to make sure the 'make install' installs the shared 
library/dll/bundle in the first 'require_path' for your gem.  This way 
we do not have to have an additional path for the native library.

If you need to pass parameters to the extconf.rb:

ruby blah.gem --force -- --with-raptor-dir=/usr/local

everything past the -- is sent to the extconf.rb file.

This is rough, but it does work for my gem!

Will work on it more soon (must sleep...)



More information about the Rubygems-developers mailing list