[Rubygems-developers] Gem build process for C extension
jeremy at hinegardner.org
Fri Jan 4 22:31:52 EST 2008
On Fri, Jan 04, 2008 at 06:54:15PM -0800, Kevin Clark wrote:
> > (a) How do I tell rubygems to invoke "rake" rather than "make" during
> > the build process? I assume I just need to put something in
> > the .gemspec, but I don't know what.
> If you have a Rakefile or a mkrf_config in the ext directory, it
> should use those instead of an extconf.
This only works with rubygems 0.9.5 or higher, before that rubygems did not
support mkrf extensions.
> > (b) How do I tell rubygems that my gem now has a dependency on the
> > "mkrf" gem?
> Just add mkrf as a dependency like you would with other gems.
> > Are there documents or examples showing how to properly use gems in
> > conjunction with a C extension and its build process? How do other
> > people make sure path names are quoted properly? Should I use mkmf or
> > mkrf?
> There's an example in the Pickaxe, and one here
You can also look at the ruby-libtommath gem. Its a pretty simple
example of using gems and mkrf to package an extension.
> I can't speak to quoting pathnames. I'd say mkrf is probably a better
> starting point if _any_ hacking is to be done. I've quarantined the
> part of my brain that understood mkmf for fear the disease would
> spread. It isn't as widely used though, so there may be things
> missing. Please _do_ file bug reports if that's the case.
> > Is there comprehensive documentation for a .gemspec file?
> Probably, but honestly at this point I end up going to the source or
> to my other gems.
The rubygems GemSpec references is online
http://rubygems.org/read/chapter/20#page85 It is not completely
comprehensive, but I've found it invaluable.
Jeremy Hinegardner jeremy at hinegardner.org
More information about the Rubygems-developers