This repository has been archived by the owner on Aug 9, 2021. It is now read-only.
forked from MacRuby/ControlTower
/
Rakefile
102 lines (87 loc) · 3.11 KB
/
Rakefile
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
require 'rubygems'
require 'rubygems/package_task'
CT_VERSION = '1.1.0'
GEM_SPEC = Gem::Specification.new do |spec|
spec.name = 'control_tower'
spec.summary = 'A Rack-based HTTP server for MacRuby'
spec.description = <<-DESCRIPTION
Control Tower is a Rack-based HTTP server designed to work with MacRuby. It can
be used by calling to its Rack::Handler class, or by running the control_tower
executable with a Rackup configuration file (see the control tower help for more
details).
DESCRIPTION
spec.author = 'MacRuby Team'
spec.email = 'macruby-devel@lists.macosforge.org'
spec.homepage = 'http://www.macruby.org'
spec.version = CT_VERSION
spec.files = %w( lib/control_tower.rb
lib/control_tower/rack_socket.rb
lib/control_tower/server.rb
lib/rack/handler/control_tower.rb
lib/rack/session/gcd.rb
bin/control_tower
ext/CTParser/http11_parser.h
ext/CTParser/http11_parser.c
ext/CTParser/CTParser.h
ext/CTParser/CTParser.m
ext/CTParser/extconf.rb )
spec.extensions << 'ext/CTParser/extconf.rb'
spec.executable = 'control_tower'
spec.add_dependency('rack', '~> 1.4.0')
end
verbose(true)
desc 'Same as all'
task :default => :all
desc 'Build everything'
task :all => ['build', 'gem']
desc 'Build CTParser'
task :build do
gcc = RbConfig::CONFIG['CC']
cflags = RbConfig::CONFIG['CFLAGS'] + ' ' + RbConfig::CONFIG['ARCH_FLAG']
cflags.sub!(/-O./, '-O3')
cflags << ' -Wall'
Dir.chdir('ext/CTParser') do
sh "#{gcc} #{cflags} -fobjc-gc CTParser.m -c -o CTParser.o"
sh "#{gcc} #{cflags} http11_parser.c -c -o http11_parser.o"
sh "#{RbConfig::CONFIG['LDSHARED']} CTParser.o http11_parser.o -o CTParser.bundle"
end
end
desc 'Clean packages and extensions'
task :clean do
sh 'rm -rf pkg ext/CTParser/*.o ext/CTParser/*.bundle lib/*.bundle'
end
desc 'Install as a standard library'
task :stdlib_install => [:build] do
prefix = (ENV['DESTDIR'] || '')
dest = File.join(prefix, RbConfig::CONFIG['sitelibdir'])
mkdir_p(dest)
sh "ditto lib \"#{dest}\""
dest = File.join(prefix, RbConfig::CONFIG['sitearchdir'])
mkdir_p(dest)
sh "cp ext/CTParser/CTParser.bundle \"#{dest}\""
end
desc "Install as a ruby gem"
task :install => [:gem, :install_runtime_dependencies] do
require 'rubygems/installer'
Gem::Installer.new("pkg/#{GEM_SPEC.file_name}").install
end
desc "Install runtime dependencies"
task :install_runtime_dependencies do
require 'rubygems/dependency_installer'
GEM_SPEC.runtime_dependencies.each do |dep|
puts "Installing #{dep.name} (#{dep.requirement})"
Gem::DependencyInstaller.new.install(dep.name, dep.requirement)
end
end
file 'ext/CTParser/CTParser.bundle' => 'build'
file 'lib/CTParser.bundle' => ['ext/CTParser/CTParser.bundle'] do
FileUtils.cp('ext/CTParser/CTParser.bundle', 'lib/CTParser.bundle')
end
Gem::PackageTask.new(GEM_SPEC) do |pkg|
pkg.need_zip = false
pkg.need_tar = true
end
desc 'Run Control Tower'
task :run do
sh 'macruby -I./lib -I./ext/CTParser bin/control_tower'
end