forked from drbrain/cast
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
57 lines (45 loc) · 1.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
# -*- mode: ruby -*-
task :default => :test
require 'rake/testtask'
dlext = RbConfig::CONFIG['DLEXT']
# cast_ext
file "ext/cast/cast_ext.#{dlext}" =>
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/c.tab.rb',
"ext/cast/cast_ext.#{dlext}"]
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
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 Dir['ext/cast/*.{bundle,dll,o,so}']
rm_f 'ext/cast/yylex.c'
rm_f 'lib/cast/c.tab.rb'
end