-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
63 lines (44 loc) · 1.06 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
require 'tools/red'
KERNEL_SRC = FileList["kernel/*.rb"]
EXEC = "build/rbv8"
task :build => [EXEC, 'kernel:build', 'codegen:build']
task :default => :build
task :clean do
sh "cd vm/v8 && scons -c"
rm_rf "vm/v8/obj"
rm_rf "build"
end
task :spec do
sh "mspec/bin/mspec ci spec"
end
# == VM
file "vm/v8/libv8.a" do
sh "cd vm/v8 && scons mode=release"
end
file EXEC => "vm/v8/libv8.a" do |f|
mkdir_for EXEC
sh "g++ -o #{f.name} -Ivm/v8/include -Lvm/v8 -lv8 -lpthread vm/shell.cc"
end
# == Kernel
namespace :kernel do
desc "Compile kernel Ruby files to JavaScript"
task :build => KERNEL_SRC.ext("js").sub(/^/, "build/")
KERNEL_SRC.each do |rb|
js = "build/kernel/" + File.basename(rb).ext('js')
file js => rb do |t|
mkdir_for js
File.open(js, 'w') { |f| f << Red.compile(File.read(rb)) }
end
end
end
# == CodeGen
namespace :codegen do
task :build => "codegen/ruby_parser.rb"
end
rule '.rb' => '.y' do |t|
sh "racc -l -t -E -o #{t.name} #{t.source}"
end
# == Utils
def mkdir_for(file)
mkdir_p File.dirname(file)
end