Sha256: 86e356fc0c38eba7ea81213aecd6d1685404608945ff7c845105c584d52364db

Contents?: true

Size: 1.83 KB

Versions: 3

Compression:

Stored size: 1.83 KB

Contents

require 'rake'
require 'rake/clean'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'fileutils'
include FileUtils

# Load Rev Gemspec
load 'rev.gemspec'

# Default Rake task is compile
task :default => %w(compile spec)

# RDoc
Rake::RDocTask.new(:rdoc) do |task|
  task.rdoc_dir = 'doc'
  task.title    = 'Rev'
  task.options = %w(--title Revactor --main README.textile --line-numbers)
  task.rdoc_files.include(['ext/rev/*.c', 'lib/**/*.rb'])
  task.rdoc_files.include(['README.textile', 'LICENSE'])
end

# Rebuild parser Ragel
task :ragel do
  Dir.chdir "ext/http11_client" do
    target = "http11_parser.c"
    File.unlink target if File.exist? target
    sh "ragel http11_parser.rl | rlgen-cd -G2 -o #{target}"
    raise "Failed to build C source" unless File.exist? target
  end
end

# Gem
Rake::GemPackageTask.new(GEMSPEC) do |pkg|
  pkg.need_tar = true
end

def make(makedir)
  Dir.chdir(makedir) { sh 'make' }
end

def extconf(dir)
  Dir.chdir(dir) { ruby "extconf.rb" }
end

def setup_extension(dir, extension)
  ext = "ext/#{dir}"
  ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
  ext_files = FileList[
    "#{ext}/*.c",
    "#{ext}/*.h",
    "#{ext}/extconf.rb",
    "#{ext}/Makefile",
    "lib"
  ] 
  
  task "lib" do
    directory "lib"
  end

  desc "Builds just the #{extension} extension"
  task extension.to_sym => ["#{ext}/Makefile", ext_so ]

  file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
    extconf "#{ext}"
  end

  file ext_so => ext_files do
    make "#{ext}"
    cp ext_so, "lib"
  end
end

setup_extension("rev", "rev_ext")
setup_extension("http11_client", "http11_client")

task :compile => [:rev_ext, :http11_client]

CLEAN.include ["build/*", "**/*.o", "**/*.so", "**/*.a", "**/*.log", "pkg"]
CLEAN.include ["ext/**/Makefile", "lib/rev_ext.*", "lib/http11_client.*", "ext/**/*.#{Config::CONFIG["DLEXT"]}"]

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rev-0.3.2 Rakefile
rev-0.3.1 Rakefile
rev-0.3.0 Rakefile