"Jim Weirich" <jim@weirichhouse.org> wrote in message
news:200501190718.30178.jim@weirichhouse.org...
>> - How should I handle native ruby extensions (building them at install
>> time
>> is not an option here). Part of the library is implemented natively
>> (Win32
>> for now).
>
> I released my first binary gem yesterday. What I did: I compiled the gem
> software locally on my own machine. Then used the same gemspec I used
> for the source distribution with the following changes:
>
> (1) removed the extension
From what? It might be obvious, but please treat me like a total beginner.
Just to be clear, I had a gemspec for the project (x10-cm17a) that created a
non-binary gem. I started with that gemspec and made the following changes..
(1) The gemspec has an extension field that is filled out if you have
extensions to build. Because the extension is already built when you
distribute an binary gem, you shouldn't set the extension field.
(2) The "arch" directory is a directory that contains the .so files for a
particular architecture. The directory is usually named something like
i386-mswin32 or i686-linux. You can get the name of the arch directory from
the ruby config, e.g.
require 'rbconfig'
ARCH = Config::CONFIG['arch']
The 'lib' field of the gemspec is a list if directories to be added to the
load path when the gem is loaded. You need to add the arch directory to that
list. The resulting line will look like this:
s.require_paths << 'lib' << "lib/#{ARCH}"
(3) The list of files to be included with the gem need to be updated to
include the .so file. I added the following line to append the .so file to
the list of files:
s.files += ["lib/#{ARCH}/cm17a_api.so"]
(4) Forget to mention this earlier, but I changed the gemspec platform from
the default of 'RUBY' to ARCH (see the definition of ARCH in step 2 above.
s.platform = ARCH
I've included the modified Rakefile that I used to build the gemspec as an
attachment. That will give the complete details.
> There is a requirements field in the gemspec that where you can list the
> dependencies. This is for comment purposes only, we don't do
> autodetection
> of non-gem dependencies.
Could you expand on that a bit - do you mean that:
- The user would him/herself manually have to install such dependencies
- It's not possible to submit them as part of the gem?
Essentially, yes.
Rakefile (4.63 KB)
···
On Friday 21 January 2005 03:00 am, Johan Nilsson wrote:
> On Wednesday 19 January 2005 03:41 am, Johan Nilsson wrote:
--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)