macournoyer / thin

A very fast & simple Ruby web server

commit  fd7b9498ccebe32f0fb3b444ed16d7ef10eb2d77
tree    3bdc6a7cb8e3789467450ed59037c69c88515161
parent  cf117fd94d9543b767b61c755c8b0c773a0614c5
thin / Rakefile
100644 38 lines (32 sloc) 0.965 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
JRUBY = RUBY_PLATFORM =~ /java/
WIN = (RUBY_PLATFORM =~ /mswin|cygwin/)
SUDO = (WIN ? "" : "sudo")
 
require 'rake'
require 'rake/clean'
require 'lib/thin'
 
Dir['tasks/**/*.rake'].each { |rake| load rake }
 
task :default => :spec
 
if JRUBY
  jruby_ext_task :thin_parser_jruby, "lib/thin_parser.jar"
else
  ext_task :thin_parser
end
 
desc "Compile the Ragel state machines"
task :ragel do
  Dir.chdir 'ext/thin_parser' do
    # C ext
    target = "parser.c"
    File.unlink target if File.exist? target
    sh "ragel -G2 parser.c.rl -o #{target}"
    raise "Failed to compile Ragel state machine" unless File.exist? target
  end
  Dir.chdir 'ext/thin_parser_jruby' do
    # JRuby
    target = "org/thin/HttpParser.java"
    mkdir_p File.dirname(target)
    File.unlink target if File.exist? target
    sh "ragel -J parser.java.rl -o #{target}"
    raise "Failed to build Java source" unless File.exist? target
  end
end