From: Timothy Hunter Date: 2005-06-24T08:40:37+09:00 Subject: Re: setup.rb question Bill Kelly wrote: > Hi, > > I'm packaging a ruby extension, and want setup.rb to perform > a particular part of the install only on a particular platform. > > I figure others may have dealt with this with their own > extensions, and I was wondering how it's usually done. > > On win32, I'm including a pre-built .dll that my extension > requires, because it's kind of a pain to build on windows. > I've put the .dll in the bin/ directory - and setup.rb does > the right thing (for windows) and installs the .dll alongside > the ruby.exe binary, wherever that may be on the system. > > However, on Linux, the shared library .so's needed by the > extension a) are easy to build, so I see no need to include > pre-built ones, and b) don't belong next to the ruby > executable anyway... and c) I certainly don't want the > win32 .dll copied into /usr/bin or wherever on Linux. :) > > So my question is how to have setup.rb do the right thing > on windows with the files in ./bin (which it currently is)... > and basically ignore the files in ./bin on Linux. > > Is it typical to just hack setup.rb to add the desired > behavior? Just wondering how it's usually done. > setup.rb support a set of 8 "hooks" that you might be able to leverage. You can create a hook to run before or after each of setup's config, setup, install, and clean steps. Each hook is just a fragment of Ruby code that setup runs if it's present. Setup defines a few APIs that the hook code can use to find out about the configuration. (http://i.loveruby.net/en/man/setup/hookapi.html) Just thinking out loud, maybe you could put the .dll somewhere other than bin (to keep setup from automatically installing it) and then create a post-install hook that copied the .dll only for Windows installs. There's probably a better way but still I don't think you should have to hack setup.rb itself.