Module: Hoe::Compiler
- Defined in:
- lib/hoe/compiler.rb
Overview
rake-compiler plugin for hoe c-extensions.
This plugin is for extconf.rb based projects that want to use rake-compiler to deal with packaging binary gems. It expects a standard extconf setup, namely that your extconf.rb and c source is located in: ext/project-name.
Look at nokogiri for a good example of how to use this.
Tasks Provided:
- compile
-
Compile your c-extension.
Instance Attribute Summary collapse
-
#compile_tasks ⇒ Object
Optional: Defines what tasks need to be compile first.
Instance Method Summary collapse
-
#activate_compiler_deps ⇒ Object
Activate the rake-compiler dependencies.
-
#define_compiler_tasks ⇒ Object
Define tasks for compiler plugin.
-
#extension(name) ⇒ Object
Declare a compiler extension, expecting ext/NAME/extconf.rb to exist.
-
#initialize_compiler ⇒ Object
Initialize variables for compiler plugin.
Instance Attribute Details
#compile_tasks ⇒ Object
Optional: Defines what tasks need to be compile first. [default: test]
20 21 22 |
# File 'lib/hoe/compiler.rb', line 20 def compile_tasks @compile_tasks end |
Instance Method Details
#activate_compiler_deps ⇒ Object
Activate the rake-compiler dependencies.
32 33 34 35 36 37 38 |
# File 'lib/hoe/compiler.rb', line 32 def activate_compiler_deps dependency "rake-compiler", "~> 1.0", :development gem "rake-compiler", "~> 1.0" rescue LoadError warn "Couldn't load rake-compiler. Skipping. Run `rake newb` to fix." end |
#define_compiler_tasks ⇒ Object
Define tasks for compiler plugin.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/hoe/compiler.rb', line 53 def define_compiler_tasks require "rake/extensiontask" @extensions.each do |name| clean_globs << "lib/#{name}/*.{so,bundle,dll}" Rake::ExtensionTask.new name, spec do |ext| ext.lib_dir = File.join(*["lib", name.to_s, ENV["FAT_DIR"]].compact) end end compile_tasks.each do |t| task t => :compile end rescue LoadError warn "Couldn't load rake-compiler. Skipping. Run `rake newb` to fix." end |
#extension(name) ⇒ Object
Declare a compiler extension, expecting ext/NAME/extconf.rb to exist.
44 45 46 47 48 |
# File 'lib/hoe/compiler.rb', line 44 def extension name @extensions ||= [] @extensions << name spec_extras[:extensions] = @extensions.map { |n| "ext/#{n}/extconf.rb" } end |
#initialize_compiler ⇒ Object
Initialize variables for compiler plugin.
25 26 27 |
# File 'lib/hoe/compiler.rb', line 25 def initialize_compiler self.compile_tasks = [:multi, :test, :check_manifest] end |