views:

70

answers:

1

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script?

Background: I've a project with two extension modules, foo.so and bar.so which currently live in their own subdirectories like so:

myproject/ext/foo/extconf.rb
myproject/ext/foo/foo.c
myproject/ext/foo/foo.h

myproject/ext/bar/extconf.rb
myproject/ext/bar/bar.c
myproject/ext/bar/bar.h

I'd prefer that all .c and .h sources simply reside under ext/ under the control of a single extconf.rb file, but I don't know how to get mkmf play along.

+1  A: 

With mkmf, you will need to use separate directories; it's not designed for putting multiple extensions in the same directory.

You may be able to use one of the mkmf alternatives (e.g. mkrf) to put the extensions in the same directory; I don't know whether or not this will work. I once wanted to do the same thing, but eventually discovered that as my library grew, having multiple directories for my extensions became desirable for keeping the project organized.

Paul Brannan