Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 101 lines (79 sloc) 2.951 kb
a4a3468 @luislavena Initial cleanup of Rakefile
luislavena authored
1 require "hoe"
2 require "rake/extensiontask"
9cb0d94 @luislavena Compile extensions
luislavena authored
3 require "rake/javaextensiontask"
a4a3468 @luislavena Initial cleanup of Rakefile
luislavena authored
4
474ba70 @luislavena Build extensions
luislavena authored
5 IS_JRUBY = defined?(RUBY_ENGINE) ? RUBY_ENGINE == "jruby" : false
6
2f794b9 @evanphx Use the Hoe git plugin
evanphx authored
7 Hoe.plugin :git
8
a4a3468 @luislavena Initial cleanup of Rakefile
luislavena authored
9 HOE = Hoe.spec "puma" do
10 self.rubyforge_name = 'puma'
11 self.readme_file = "README.md"
6767859 @jc00ke Fix homepage url in gemspec
jc00ke authored
12 self.urls = %w!http://puma.io https://github.com/puma/puma!
a4a3468 @luislavena Initial cleanup of Rakefile
luislavena authored
13
14 developer 'Evan Phoenix', 'evan@phx.io'
15
16 spec_extras[:extensions] = ["ext/puma_http11/extconf.rb"]
17 spec_extras[:executables] = ['puma', 'pumactl']
6767859 @jc00ke Fix homepage url in gemspec
jc00ke authored
18 spec_extras[:homepage] = self.urls.first
a4a3468 @luislavena Initial cleanup of Rakefile
luislavena authored
19
0fee5c8 @luislavena Change YAML.load trick to use File.read instead
luislavena authored
20 require_ruby_version ">= 1.8.7"
21
dac074d @evanphx Go back to approx, I'm a silly goose
evanphx authored
22 dependency "rack", "~> 1.2"
a4a3468 @luislavena Initial cleanup of Rakefile
luislavena authored
23
24 extra_dev_deps << ["rake-compiler", "~> 0.8.0"]
25 end
26
474ba70 @luislavena Build extensions
luislavena authored
27 # hoe/test and rake-compiler don't seem to play well together, so disable
28 # hoe/test's .gemtest touch file thingy for now
29 HOE.spec.files -= [".gemtest"]
30
a4a3468 @luislavena Initial cleanup of Rakefile
luislavena authored
31 # puma.gemspec
3e98339 @luislavena Make 'ragel' task actually work
luislavena authored
32
e8f4bcf @evanphx Regen gemspec properly
evanphx authored
33 file "#{HOE.spec.name}.gemspec" => ['Rakefile', "lib/puma/const.rb"] do |t|
a4a3468 @luislavena Initial cleanup of Rakefile
luislavena authored
34 puts "Generating #{t.name}"
35 File.open(t.name, 'wb') { |f| f.write HOE.spec.to_ruby }
36 end
37
38 desc "Generate or update the standalone gemspec file for the project"
39 task :gemspec => ["#{HOE.spec.name}.gemspec"]
40
3e98339 @luislavena Make 'ragel' task actually work
luislavena authored
41 # generate extension code using Ragel (C and Java)
42 desc "Generate extension code (C and Java) using Ragel"
43 task :ragel
44
45 file 'ext/puma_http11/http11_parser.c' => ['ext/puma_http11/http11_parser.rl'] do |t|
46 begin
47 sh "ragel #{t.prerequisites.last} -C -G2 -I ext/puma_http11 -o #{t.name}"
48 rescue
49 fail "Could not build wrapper using Ragel (it failed or not installed?)"
50 end
51 end
52 task :ragel => ['ext/puma_http11/http11_parser.c']
53
54 file 'ext/puma_http11/org/jruby/puma/Http11Parser.java' => ['ext/puma_http11/http11_parser.java.rl'] do |t|
55 begin
56 sh "ragel #{t.prerequisites.last} -J -G2 -I ext/puma_http11 -o #{t.name}"
57 rescue
58 fail "Could not build wrapper using Ragel (it failed or not installed?)"
59 end
60 end
61 task :ragel => ['ext/puma_http11/org/jruby/puma/Http11Parser.java']
62
9cb0d94 @luislavena Compile extensions
luislavena authored
63 # compile extensions using rake-compiler
64 # C (MRI, Rubinius)
65 Rake::ExtensionTask.new("puma_http11", HOE.spec) do |ext|
474ba70 @luislavena Build extensions
luislavena authored
66 # place extension inside namespace
67 ext.lib_dir = "lib/puma"
942c1ad @luislavena Enable cross-compilation of C extension
luislavena authored
68
a47cc0e @evanphx Remove cross reporting workarounds since rack-compiler 0.8.0 fixes them
evanphx authored
69 ext.cross_compile = true
942c1ad @luislavena Enable cross-compilation of C extension
luislavena authored
70 ext.cross_platform = ['i386-mswin32-60', 'i386-mingw32']
21327ca @luislavena Add fat-binary stub when cross compiling
luislavena authored
71 ext.cross_compiling do |spec|
72 # add fat-binary stub only when cross compiling
73 spec.files << "lib/puma/puma_http11.rb"
74 end
942c1ad @luislavena Enable cross-compilation of C extension
luislavena authored
75
76 CLEAN.include "lib/puma/{1.8,1.9}"
21327ca @luislavena Add fat-binary stub when cross compiling
luislavena authored
77 CLEAN.include "lib/puma/puma_http11.rb"
9cb0d94 @luislavena Compile extensions
luislavena authored
78 end
79
80 # Java (JRuby)
a47cc0e @evanphx Remove cross reporting workarounds since rack-compiler 0.8.0 fixes them
evanphx authored
81 Rake::JavaExtensionTask.new("puma_http11", HOE.spec) do |ext|
82 ext.lib_dir = "lib/puma"
9cb0d94 @luislavena Compile extensions
luislavena authored
83 end
84
21327ca @luislavena Add fat-binary stub when cross compiling
luislavena authored
85 # the following is a fat-binary stub that will be used when
86 # require 'puma/puma_http11' and will use either 1.8 or 1.9 version depending
87 # on RUBY_VERSION
88 file "lib/puma/puma_http11.rb" do |t|
89 File.open(t.name, "w") do |f|
90 f.puts "RUBY_VERSION =~ /(\d+.\d+)/"
91 f.puts 'require "puma/#{$1}/puma_http11"'
92 end
93 end
94
474ba70 @luislavena Build extensions
luislavena authored
95 # tests require extension be compiled, but depend on the platform
96 if IS_JRUBY
97 task :test => [:java]
98 else
99 task :test => [:compile]
100 end
Something went wrong with that request. Please try again.