Class: Shoe::Tasks::Compile
Overview
Defines `rake compile`
to build your C extensions.
Uses {Gem::Ext::ExtConfBuilder}[http://rubygems.rubyforge.org/rubygems-update/Gem/Ext/ExtConfBuilder.html]
, so extensions are compiled locally just as they will be with `gem install`
. Your users will thank you.
To enable and configure, add extensions[http://docs.rubygems.org/read/chapter/20#extensions]
to your gemspec.
Instance Attribute Summary
Attributes inherited from Task
Instance Method Summary collapse
Methods inherited from Task
Constructor Details
This class inherits a constructor from Shoe::Tasks::Task
Instance Method Details
#active? ⇒ Boolean
17 18 19 |
# File 'lib/shoe/tasks/compile.rb', line 17 def active? !spec.extensions.empty? end |
#define ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/shoe/tasks/compile.rb', line 21 def define desc <<-END.gsub(/^ */, '') Compile C extensions. Configure via the `extensions` field in #{spec.name}.gemspec. END task :compile do top_level_path = File.('.') destination_path = File.join(top_level_path, spec.require_paths.first) spec.extensions.each do |extension| Dir.chdir File.dirname(extension) do Gem::Ext::ExtConfBuilder.build( extension, top_level_path, destination_path, results = [] ) end end end task :prepare => :compile end |