2012-01-08 12:06:50 -05:00
|
|
|
require "hoe"
|
|
|
|
require "rake/extensiontask"
|
2012-01-08 13:59:23 -05:00
|
|
|
require "rake/javaextensiontask"
|
2012-01-08 12:06:50 -05:00
|
|
|
|
2012-01-08 14:32:32 -05:00
|
|
|
IS_JRUBY = defined?(RUBY_ENGINE) ? RUBY_ENGINE == "jruby" : false
|
|
|
|
|
2012-03-29 18:47:48 -04:00
|
|
|
Hoe.plugin :git
|
2013-07-06 16:48:35 -04:00
|
|
|
Hoe.plugin :ignore
|
2012-03-29 18:47:48 -04:00
|
|
|
|
2012-01-08 12:06:50 -05:00
|
|
|
HOE = Hoe.spec "puma" do
|
|
|
|
self.rubyforge_name = 'puma'
|
|
|
|
self.readme_file = "README.md"
|
2012-04-30 13:45:32 -04:00
|
|
|
self.urls = %w!http://puma.io https://github.com/puma/puma!
|
2012-01-08 12:06:50 -05:00
|
|
|
|
2014-01-25 15:50:23 -05:00
|
|
|
license "BSD"
|
2012-01-08 12:06:50 -05:00
|
|
|
developer 'Evan Phoenix', 'evan@phx.io'
|
|
|
|
|
|
|
|
spec_extras[:extensions] = ["ext/puma_http11/extconf.rb"]
|
|
|
|
spec_extras[:executables] = ['puma', 'pumactl']
|
2012-04-30 13:45:32 -04:00
|
|
|
spec_extras[:homepage] = self.urls.first
|
2012-01-08 12:06:50 -05:00
|
|
|
|
2012-01-08 15:46:10 -05:00
|
|
|
require_ruby_version ">= 1.8.7"
|
|
|
|
|
2013-02-06 01:46:07 -05:00
|
|
|
dependency "rack", [">= 1.1", "< 2.0"]
|
2012-01-08 12:06:50 -05:00
|
|
|
|
|
|
|
extra_dev_deps << ["rake-compiler", "~> 0.8.0"]
|
|
|
|
end
|
|
|
|
|
2013-07-06 16:48:35 -04:00
|
|
|
task :prerelease => [:clobber, :check_manifest, :test]
|
|
|
|
|
2012-01-08 14:32:32 -05:00
|
|
|
# hoe/test and rake-compiler don't seem to play well together, so disable
|
|
|
|
# hoe/test's .gemtest touch file thingy for now
|
|
|
|
HOE.spec.files -= [".gemtest"]
|
|
|
|
|
2013-07-01 20:51:11 -04:00
|
|
|
include Hoe::Git
|
|
|
|
|
|
|
|
desc "Print the current changelog."
|
|
|
|
task "changelog" do
|
|
|
|
tag = ENV["FROM"] || git_tags.last
|
|
|
|
range = [tag, "HEAD"].compact.join ".."
|
|
|
|
cmd = "git log #{range} '--format=tformat:%B|||%aN|||%aE|||'"
|
|
|
|
now = Time.new.strftime "%Y-%m-%d"
|
|
|
|
|
|
|
|
changes = `#{cmd}`.split(/\|\|\|/).each_slice(3).map { |msg, author, email|
|
|
|
|
msg.split(/\n/).reject { |s| s.empty? }.first
|
|
|
|
}.flatten.compact
|
|
|
|
|
|
|
|
$changes = Hash.new { |h,k| h[k] = [] }
|
|
|
|
|
|
|
|
codes = {
|
|
|
|
"!" => :major,
|
|
|
|
"+" => :minor,
|
|
|
|
"*" => :minor,
|
|
|
|
"-" => :bug,
|
|
|
|
"?" => :unknown,
|
|
|
|
}
|
|
|
|
|
|
|
|
codes_re = Regexp.escape codes.keys.join
|
|
|
|
|
|
|
|
changes.each do |change|
|
|
|
|
if change =~ /^\s*([#{codes_re}])\s*(.*)/ then
|
|
|
|
code, line = codes[$1], $2
|
|
|
|
else
|
|
|
|
code, line = codes["?"], change.chomp
|
|
|
|
end
|
|
|
|
|
|
|
|
$changes[code] << line
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "=== #{ENV['VERSION'] || 'NEXT'} / #{now}"
|
|
|
|
puts
|
|
|
|
changelog_section :major
|
|
|
|
changelog_section :minor
|
|
|
|
changelog_section :bug
|
|
|
|
changelog_section :unknown
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
|
2012-01-08 13:53:28 -05:00
|
|
|
# generate extension code using Ragel (C and Java)
|
|
|
|
desc "Generate extension code (C and Java) using Ragel"
|
|
|
|
task :ragel
|
|
|
|
|
|
|
|
file 'ext/puma_http11/http11_parser.c' => ['ext/puma_http11/http11_parser.rl'] do |t|
|
|
|
|
begin
|
|
|
|
sh "ragel #{t.prerequisites.last} -C -G2 -I ext/puma_http11 -o #{t.name}"
|
|
|
|
rescue
|
|
|
|
fail "Could not build wrapper using Ragel (it failed or not installed?)"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
task :ragel => ['ext/puma_http11/http11_parser.c']
|
|
|
|
|
|
|
|
file 'ext/puma_http11/org/jruby/puma/Http11Parser.java' => ['ext/puma_http11/http11_parser.java.rl'] do |t|
|
|
|
|
begin
|
|
|
|
sh "ragel #{t.prerequisites.last} -J -G2 -I ext/puma_http11 -o #{t.name}"
|
|
|
|
rescue
|
|
|
|
fail "Could not build wrapper using Ragel (it failed or not installed?)"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
task :ragel => ['ext/puma_http11/org/jruby/puma/Http11Parser.java']
|
|
|
|
|
2012-08-23 19:56:37 -04:00
|
|
|
if !IS_JRUBY
|
|
|
|
|
2012-01-08 13:59:23 -05:00
|
|
|
# compile extensions using rake-compiler
|
|
|
|
# C (MRI, Rubinius)
|
|
|
|
Rake::ExtensionTask.new("puma_http11", HOE.spec) do |ext|
|
2012-01-08 14:32:32 -05:00
|
|
|
# place extension inside namespace
|
|
|
|
ext.lib_dir = "lib/puma"
|
2012-01-08 14:42:07 -05:00
|
|
|
|
2012-01-08 20:53:15 -05:00
|
|
|
ext.cross_compile = true
|
2012-01-08 14:42:07 -05:00
|
|
|
ext.cross_platform = ['i386-mswin32-60', 'i386-mingw32']
|
2012-01-08 15:23:37 -05:00
|
|
|
ext.cross_compiling do |spec|
|
|
|
|
# add fat-binary stub only when cross compiling
|
|
|
|
spec.files << "lib/puma/puma_http11.rb"
|
|
|
|
end
|
2012-01-08 14:42:07 -05:00
|
|
|
|
|
|
|
CLEAN.include "lib/puma/{1.8,1.9}"
|
2012-01-08 15:23:37 -05:00
|
|
|
CLEAN.include "lib/puma/puma_http11.rb"
|
2012-01-08 13:59:23 -05:00
|
|
|
end
|
|
|
|
|
2012-08-23 19:56:37 -04:00
|
|
|
else
|
|
|
|
|
2012-01-08 13:59:23 -05:00
|
|
|
# Java (JRuby)
|
2012-01-08 20:53:15 -05:00
|
|
|
Rake::JavaExtensionTask.new("puma_http11", HOE.spec) do |ext|
|
|
|
|
ext.lib_dir = "lib/puma"
|
2012-01-08 13:59:23 -05:00
|
|
|
end
|
|
|
|
|
2012-08-23 19:56:37 -04:00
|
|
|
end
|
|
|
|
|
2012-01-08 15:23:37 -05:00
|
|
|
# the following is a fat-binary stub that will be used when
|
|
|
|
# require 'puma/puma_http11' and will use either 1.8 or 1.9 version depending
|
|
|
|
# on RUBY_VERSION
|
|
|
|
file "lib/puma/puma_http11.rb" do |t|
|
|
|
|
File.open(t.name, "w") do |f|
|
|
|
|
f.puts "RUBY_VERSION =~ /(\d+.\d+)/"
|
|
|
|
f.puts 'require "puma/#{$1}/puma_http11"'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-08 14:32:32 -05:00
|
|
|
# tests require extension be compiled, but depend on the platform
|
|
|
|
if IS_JRUBY
|
|
|
|
task :test => [:java]
|
|
|
|
else
|
|
|
|
task :test => [:compile]
|
|
|
|
end
|
2012-10-13 13:15:59 -04:00
|
|
|
|
|
|
|
namespace :test do
|
|
|
|
desc "Run the integration tests"
|
|
|
|
task :integration do
|
|
|
|
sh "cd test/shell; sh run.sh"
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Run all tests"
|
2012-11-29 15:28:16 -05:00
|
|
|
if defined?(JRUBY_VERSION) and ENV['TRAVIS']
|
|
|
|
task :all => :test
|
|
|
|
else
|
|
|
|
task :all => [:test, "test:integration"]
|
|
|
|
end
|
2012-10-13 13:15:59 -04:00
|
|
|
end
|
|
|
|
|