forked from rubinius/rubinius
/
Rakefile
283 lines (235 loc) · 6.88 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
task :default => :tasks
task :tasks do
puts `rake -T`
end
def newer?(file, cmp)
File.exists?(cmp) and File.mtime(cmp) >= File.mtime(file)
end
@pb = "runtime/pristine_bootstrap.rba"
@pc = "runtime/pristine_core.rba"
if File.exists?(@pb)
puts "Using #{@pb} for bootstrap."
ENV['BOOTSTRAP'] = @pb
end
if File.exists?(@pc)
puts "Using #{@pc} for core."
ENV['CORE'] = @pc
end
@compiler = ENV['COMPILER']
def update_archive(files, archive, dir=nil)
archive = File.expand_path(ENV['OUTPUT'] || archive)
changed = []
files.each do |file|
cmp = "#{file}c"
if !newer?(file, cmp)
changed << cmp
if @compiler
system "shotgun/rubinius -I#{@compiler} compile #{file}"
else
system "shotgun/rubinius compile #{file}"
end
elsif !File.exists?(archive)
changed << cmp
end
file << "c"
end
curdir = Dir.getwd
if dir
Dir.chdir(dir)
changed.map! { |f| f.gsub(%r!^#{dir}/!, "") }
end
File.open(".load_order.txt","w") do |f|
f.puts files.join("\n")
end
if File.exists? archive
if changed.empty?
puts "No files to update."
else
system "zip -u #{archive} .load_order.txt #{changed.join(' ')}"
end
else
system "zip #{archive} .load_order.txt #{changed.join(' ')}"
end
Dir.chdir(curdir) if dir
end
# spec tasks
desc "Run continuous integration examples"
task :spec => 'spec:ci'
namespace :spec do
namespace :setup do
desc "Setup for subtend examples"
task :subtend do
Dir[File.join(ROOT,"spec/subtend/**/Rakefile")].each do |rakefile|
sh "rake -f #{rakefile}"
end
end
end
desc "Run continuous integration examples"
task :ci do
begin
stat = File.stat("CI-specs")
if stat.file?
raise "CI-specs is a file. Remove it to run CI specs"
elsif stat.directory?
sh "svn up CI-specs"
end
rescue
sh("svn co http://code.fallingsnow.net/svn/rubinius/branches/CI-specs")
end
target = ENV['SPEC_TARGET'] || 'rbx'
system %(shotgun/rubinius -e 'puts "rbx build: \#{Rubinius::BUILDREV}"') if target == 'rbx'
sh "bin/mspec -t #{target} -f ci CI-specs"
end
spec_targets = %w(compiler core language library parser rubinius)
# Build a spec:<task_name> for each group of Rubinius specs
spec_targets.each do |group|
desc "Run #{group} examples"
task group do
sh "bin/mspec spec/#{group}"
end
end
desc "Run subtend examples"
task :subtend => "spec:setup:subtend" do
sh "bin/mspec spec/subtend"
end
# Specdiffs to make it easier to see what your changes have affected :)
desc 'Run specs and produce a diff against current base'
task :diff => 'diff:run'
namespace :diff do
desc 'Run specs and produce a diff against current base'
task :run do
system 'bin/mspec spec > /tmp/rbs_specdiff'
system 'diff -u spec/diffs/base.txt /tmp/rbs_specdiff'
system 'rm /tmp/rbs_specdiff'
end
desc 'Replace the base spec file with a new one'
task :replace do
system 'bin/mspec spec > spec/diffs/base.txt'
end
end
task :r2r do
puts ARGV.inspect
end
end
# build tasks
desc "Completely rebuild everything"
task :rebuild => ['build:clean', 'build:shotgun', 'build:compiler', 'build:bootstrap', 'build:core', 'build:library']
desc "Build shotgun (the C-code VM)"
task :build => ['build:shotgun']
namespace :build do
desc "Removes build by-products for shotgun, compiler, and library"
task :clean => ['clean:shotgun', 'clean:compiler', 'clean:bootstrap', 'clean:core', 'clean:library']
namespace :clean do
desc "Removes build by-products for shotgun"
task :shotgun do
sh "make -C shotgun clean || true"
end
desc "Removes build by-products for compiler"
task :compiler do
FileList['native/**/*.rbc', '/tmp/*.rbc'].each do |fn|
FileUtils.rm fn rescue nil
end
end
desc "Removes build by-products for library"
task :library do
FileList['library/**/*.rbc'].each do |fn|
FileUtils.rm fn rescue nil
end
end
desc "Removes build by-products for bootstrap"
task :bootstrap do
FileList['kernel/bootstrap/**/*.rbc'].each do |fn|
FileUtils.rm fn rescue nil
end
end
desc "Removes build by-products for core"
task :core do
FileList['kernel/core/**/*.rbc'].each do |fn|
FileUtils.rm fn rescue nil
end
end
end
file "shotgun/config.h" do
sh "./configure"
raise 'Failed to configure Rubinius' unless $?.success?
end
task :configure => ["shotgun/config.h"] do
end
desc "Compiles shotgun (the C-code VM)"
task :shotgun => :configure do
sh "make"
raise 'Failed to build shotgun' unless $?.success?
end
desc "Compiles the Rubinius bootstrap archive"
task :bootstrap do
files = Dir["kernel/bootstrap/*.rb"].sort
update_archive files, 'runtime/bootstrap.rba'
end
desc "Compiles the Rubinius core archive"
task :core do
files = Dir["kernel/core/*.rb"].sort
update_archive files, 'runtime/core.rba'
end
task :loader do
i = "kernel/loader.rb"
o = ENV['OUTPUT'] || "runtime/loader.rbc"
if @compiler
system "shotgun/rubinius -I#{@compiler} compile #{i} #{o}"
else
system "shotgun/rubinius compile #{i} #{o}"
end
end
desc "Compiles the Rubinius library archive"
task :library do
files = Dir["library/**/*.rb"].sort
update_archive files, 'runtime/library.rba'
end
desc "Compiles the Rubinius compiler archive"
task :compiler do
files = %w! bytecode/compiler bytecode/assembler bytecode/encoder
sexp/simple_processor translation/normalize translation/local_scoping
sexp/composite_processor translation/states sexp/exceptions
bytecode/primitive_names !
paths = []
files.each do |name|
file = "#{name}.rb"
dir = File.dirname(file)
dest_dir = File.join("native", dir)
path = File.expand_path File.join("lib", file)
dest = File.join("native", file)
FileUtils.mkdir_p dest_dir
FileUtils.symlink path, dest rescue nil
paths << dest
end
paths += %w!native/bytecode/rubinius.rb
native/bytecode/system_hints.rb
native/bytecode/plugins.rb!
update_archive paths, 'runtime/compiler.rba', "native"
end
end
desc "Remove all .rbc files from the project"
task :pristine do
FileList['**/*.rbc'].each do |fn|
next if fn == 'runtime/loader.rbc'
FileUtils.rm fn rescue nil
end
end
# svn tasks
desc "Remove runtime/*.rba then svn up"
task :svn => 'svn:up'
namespace :svn do
desc "Revert runtime/*.rba then svn up"
task :up do
sh "svn revert reports/*.html"
sh "svn revert runtime/*.rba"
puts `svn up`
end
end
# dev tasks
namespace :dev do
desc "Make a few changes to support easier development"
task :setup do
sh "cp runtime/core.rba #{@pc}"
sh "cp runtime/bootstrap.rba #{@pb}"
end
end