-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
83 lines (67 loc) · 1.76 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
# -*- mode: ruby -*-
task :default => :test
require 'rubygems'
require 'rake/testtask'
require 'rubygems/package_task'
FILES = FileList['README', 'ChangeLog', '{lib,ext,doc,test}/**/*', 'ext/yylex.c', 'lib/cast/c.tab.rb']
# cast_ext
file 'ext/cast/cast_ext.so' =>
FileList['ext/cast/*.c', 'ext/cast/yylex.c'] do |t|
cd 'ext/cast' do
ruby 'extconf.rb'
sh 'make'
end
end
# lexer
file 'ext/cast/yylex.c' => 'ext/cast/yylex.re' do |t|
sh "re2c #{t.prerequisites[0]} > #{t.name}"
end
# parser
file 'lib/cast/c.tab.rb' => 'lib/cast/c.y' do |t|
sh "racc #{t.prerequisites[0]}"
end
desc "Build."
task :lib =>
FileList['lib/cast/*.rb',
'lib/cast/c.tab.rb',
'ext/cast/cast_ext.so']
desc "Run unit tests."
Rake::TestTask.new(:test => :lib) do |t|
t.libs << 'ext' << 'test'
t.test_files = FileList['test/*_test.rb']
t.verbose = true
end
desc "Run irb with cast loaded."
task :irb => :lib do
sh 'irb -Ilib:ext -rcast'
end
spec = Gem::Specification.new do |s|
s.name = 'cast'
s.summary = "C parser and AST constructor."
s.version = '0.1.0'
s.author = 'George Ogata'
s.email = '[email protected]'
s.homepage = 'http://cast.rubyforge.org'
s.rubyforge_project = 'cast'
s.platform = Gem::Platform::RUBY
s.extensions << 'ext/extconf.rb'
s.files = FILES.to_a
s.autorequire = 'cast'
s.test_file = 'test/run.rb'
s.has_rdoc = false
s.add_development_dependency 'racc'
s.requirements << 're2c'
end
Gem::PackageTask.new spec
desc "Remove temporary files in build process"
task :clean do
rm_f 'ext/cast/*.o'
end
desc "Remove all files built from initial source files"
task :clobber => [:clean] do
rm_f 'ext/cast/Makefile'
rm_f 'ext/cast/cast_ext.so'
rm_f 'ext/cast/yylex.c'
rm_f 'lib/cast/c.tab.rb'
rm_f 'pkg'
end