2016-11-22 10:05:49 -05:00
|
|
|
require "bundler/setup"
|
2017-08-16 14:56:29 -04:00
|
|
|
require "rake/testtask"
|
2012-01-08 12:06:50 -05:00
|
|
|
require "rake/extensiontask"
|
2012-01-08 13:59:23 -05:00
|
|
|
require "rake/javaextensiontask"
|
2017-06-04 16:21:05 -04:00
|
|
|
require "rubocop/rake_task"
|
2019-07-08 15:49:45 -04:00
|
|
|
require_relative 'lib/puma/detect'
|
2017-08-17 15:14:24 -04:00
|
|
|
require 'rubygems/package_task'
|
|
|
|
require 'bundler/gem_tasks'
|
|
|
|
|
2019-07-16 16:28:44 -04:00
|
|
|
gemspec = Gem::Specification.load("puma.gemspec")
|
2017-08-17 15:14:24 -04:00
|
|
|
Gem::PackageTask.new(gemspec).define
|
2017-06-04 16:21:05 -04:00
|
|
|
|
|
|
|
# Add rubocop task
|
|
|
|
RuboCop::RakeTask.new
|
2012-01-08 12:06:50 -05:00
|
|
|
|
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']
|
|
|
|
|
2017-08-16 18:07:15 -04:00
|
|
|
if !Puma.jruby?
|
|
|
|
# compile extensions using rake-compiler
|
|
|
|
# C (MRI, Rubinius)
|
2019-07-16 16:28:44 -04:00
|
|
|
Rake::ExtensionTask.new("puma_http11", gemspec) do |ext|
|
2017-08-16 18:07:15 -04:00
|
|
|
# place extension inside namespace
|
|
|
|
ext.lib_dir = "lib/puma"
|
2012-01-08 13:59:23 -05:00
|
|
|
|
2019-07-16 16:28:44 -04:00
|
|
|
CLEAN.include "lib/puma/{1.8,1.9}"
|
|
|
|
CLEAN.include "lib/puma/puma_http11.rb"
|
|
|
|
end
|
2012-08-23 19:56:37 -04:00
|
|
|
else
|
2017-08-16 18:07:15 -04:00
|
|
|
# Java (JRuby)
|
2019-07-16 16:28:44 -04:00
|
|
|
Rake::JavaExtensionTask.new("puma_http11", gemspec) do |ext|
|
2017-08-16 18:07:15 -04:00
|
|
|
ext.lib_dir = "lib/puma"
|
|
|
|
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
|
|
|
|
|
2017-08-16 14:56:29 -04:00
|
|
|
Rake::TestTask.new(:test)
|
|
|
|
|
2012-01-08 14:32:32 -05:00
|
|
|
# tests require extension be compiled, but depend on the platform
|
2017-08-16 18:07:15 -04:00
|
|
|
if Puma.jruby?
|
2012-01-08 14:32:32 -05:00
|
|
|
task :test => [:java]
|
|
|
|
else
|
|
|
|
task :test => [:compile]
|
|
|
|
end
|
2012-10-13 13:15:59 -04:00
|
|
|
|
|
|
|
namespace :test do
|
|
|
|
desc "Run the integration tests"
|
2019-07-16 16:28:44 -04:00
|
|
|
|
2012-10-13 13:15:59 -04:00
|
|
|
task :integration do
|
2017-08-16 18:07:15 -04:00
|
|
|
sh "ruby test/shell/run.rb"
|
2012-10-13 13:15:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Run all tests"
|
2017-08-16 18:07:15 -04:00
|
|
|
if (Puma.jruby? && ENV['TRAVIS']) || Puma.windows?
|
2012-11-29 15:28:16 -05:00
|
|
|
task :all => :test
|
|
|
|
else
|
|
|
|
task :all => [:test, "test:integration"]
|
|
|
|
end
|
2012-10-13 13:15:59 -04:00
|
|
|
end
|
2017-06-04 16:21:05 -04:00
|
|
|
|
2017-08-16 18:07:15 -04:00
|
|
|
task :default => [:rubocop, "test:all"]
|