forked from rubinius/rapa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
56 lines (47 loc) · 1.63 KB
/
Rakefile
File metadata and controls
56 lines (47 loc) · 1.63 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
DIR = File.expand_path "../", __FILE__
if dir = ENV["DIR"]
OUT_DIR = File.expand_path ENV["DIR"]
else
OUT_DIR = File.expand_path "../", __FILE__
end
def machines(version)
DIR + "/machines/#{version}"
end
def rubinius(version)
DIR + "/actions/rubinius/#{version}"
end
def rubinius_ragel(version)
"ragel -C -G1 -I #{machines(version)} -I #{rubinius(version)}"
end
# The Ragel generated line info is a mess. This just strips the
# info so that any compile errors are reported directly from the
# generated code. This may be confusing. Other solutions welcome.
# BTW, the -L option just puts the #line directives into comments,
# which just clutters the generated code needlessly.
def remove_line_references(name, file)
source = IO.readlines name
source.reject! { |line| line =~ /^#line\s(\d+)\s"[^"]+"/ }
File.open(name, "w") { |f| f.puts source }
end
namespace :build do
desc "Generate Array#pack, String#unpack primitives for Rubinius"
task :rbx => ["rbx:pack", "rbx:unpack"]
namespace :rbx do
task :pack do
["18", "19"].each do |version|
input = "#{rubinius(version)}/pack_code.rl"
output = "#{OUT_DIR}/pack#{version}.cpp"
sh "#{rubinius_ragel(version)} -o #{output} #{input}"
remove_line_references output, "vm/builtin/pack#{version}.cpp"
end
end
task :unpack do
["18", "19"].each do |version|
input = "#{rubinius(version)}/unpack_code.rl"
output = "#{OUT_DIR}/unpack#{version}.cpp"
sh "#{rubinius_ragel(version)} -o #{output} #{input}"
remove_line_references output, "vm/builtin/unpack#{version}.cpp"
end
end
end
end