1 # NOTE! When updating this file, also update INSTALL, if necessary.
2 # NOTE! Please keep your tasks grouped together.
5 $verbose = Rake.application.options.trace
6 $dlext = Config::CONFIG["DLEXT"]
9 RUBINIUS_BASE = File.dirname(__FILE__)
12 require 'rakelib/rubinius'
13 require 'rakelib/struct_generator'
14 require 'rakelib/const_generator'
15 require 'rakelib/types_generator'
17 task :default => :build
21 desc "Build everything that needs to be built"
22 task :build => 'build:all'
24 task :stable_compiler do
26 puts "Use current versions, not stable."
28 ENV['RBX_BOOTSTRAP'] = "runtime/stable/bootstrap.rba"
29 ENV['RBX_CORE'] = "runtime/stable/core.rba"
30 ENV['RBX_LOADER'] = "runtime/stable/loader.rbc"
31 ENV['RBX_PLATFORM'] = "runtime/stable/platform.rba"
35 rule ".rbc" => %w[.rb] do |t|
36 compile t.source, t.name
39 files = FileList['kernel/core/*.rb']
41 unless files.include?("kernel/core/dir.rb")
42 files.add("kernel/core/dir.rb")
45 Core = CodeGroup.new(files, 'runtime/core', 'core')
47 Bootstrap = CodeGroup.new 'kernel/bootstrap/*.rb', 'runtime/bootstrap',
49 PlatformFiles = CodeGroup.new 'kernel/platform/*.rb', 'runtime/platform', 'platform'
51 file 'runtime/loader.rbc' => 'kernel/loader.rb' do
52 compile 'kernel/loader.rb', 'runtime/loader.rbc'
55 file 'runtime/stable/loader.rbc' => 'runtime/loader.rbc' do
56 cp 'runtime/loader.rbc', 'runtime/stable', :verbose => $verbose
59 file 'runtime/stable/compiler.rba' => 'build:compiler' do |t|
60 #sh "cd lib; zip -r ../runtime/stable/compiler.rba compiler -x \\*.rb"
62 rbc_files = Rake::FileList['compiler/**/*.rbc']
65 rbc_files.each do |rbc_file|
66 ar_add "../#{t.name}", rbc_file
71 Rake::StructGeneratorTask.new do |t|
75 Rake::StructGeneratorTask.new do |t|
76 t.dest = 'lib/zlib.rb'
79 AllPreCompiled = Core.output + Bootstrap.output + PlatformFiles.output
80 AllPreCompiled << "runtime/loader.rbc"
94 # This nobody rule lets use use all the shotgun files as
95 # prereqs. This rule is run for all those prereqs and just
96 # (obviously) does nothing, but it makes rake happy.
99 # These files must be excluded from the c_source FileList
100 # because they are build products (i.e. there is no rule
101 # to build them, they will be built) and the c_source list
102 # list gets created before they are deleted by the clean task.
108 'primitive_indexes.h',
114 "shotgun/lib/*.[chy]",
116 "shotgun/lib/subtend/*.[chS]",
118 ].exclude(*exclude_source)
120 file "shotgun/rubinius.bin" => c_source do
124 file "shotgun/rubinius.local.bin" => c_source do
128 desc "Compiles shotgun (the C-code VM)"
129 task :shotgun => %w[configure shotgun/rubinius.bin shotgun/rubinius.local.bin]
131 task :setup_rbc => :stable_compiler
133 task :rbc => ([:setup_rbc] + AllPreCompiled)
135 task :compiler => :stable_compiler do
136 compile_dir "lib/compiler"
139 desc "Rebuild runtime/stable/*. If you don't know why you're running this, don't."
142 runtime/stable/bootstrap.rba
143 runtime/stable/core.rba
144 runtime/stable/compiler.rba
145 runtime/stable/loader.rbc
146 runtime/stable/platform.rba
149 desc "Rebuild the .load_order.txt files"
151 # Note: Steps to rebuild load_order were defined above
156 sh "cd shotgun/lib; #{make "clean"}"
160 sh "cd shotgun/lib; #{make "DEV=1"}"
164 task :platform => 'runtime/platform.conf'
169 desc "Install rubinius as rbx"
170 task :install => :config_env do
171 sh "cd shotgun; #{make "install"}"
173 mkdir_p RBAPATH, :verbose => true
174 mkdir_p CODEPATH, :verbose => true
176 rba_files = Rake::FileList.new('runtime/platform.conf',
177 'runtime/**/*.rb{a,c}',
178 'runtime/**/.load_order.txt')
180 install_files rba_files, RBAPATH
182 lib_files = Rake::FileList.new 'lib/**/*'
184 install_files lib_files, CODEPATH
186 mkdir_p File.join(CODEPATH, 'bin'), :verbose => true
188 Rake::FileList.new("#{CODEPATH}/**/*.rb").sort.each do |rb_file|
189 if File.exists? "#{rb_file}c"
190 next if File.mtime("#{rb_file}c") > File.mtime(rb_file)
192 sh File.join(BINPATH, 'rbx'), 'compile', rb_file, :verbose => true
196 desc "Uninstall rubinius and libraries. Helps with build problems."
197 task :uninstall => :config_env do
198 rm Dir[File.join(BINPATH, 'rbx*')]
199 rm_r Dir[File.join(LIBPATH, '*rubinius*')]
202 task :compiledir => :stable_compiler do
204 raise "Use DIR= to set which directory" if !dir or dir.empty?
210 desc "Recompile all ruby system files"
211 task :rebuild => %w[clean build:all]
213 desc "Alias for clean:all"
214 task :clean => "clean:all"
216 desc "Alias for clean:distclean"
217 task :distclean => "clean:distclean"
220 desc "Clean everything but third-party libs"
221 task :all => %w[clean:rbc clean:extensions clean:shotgun clean:generated clean:crap clean:config]
223 desc "Clean everything including third-party libs"
224 task :distclean => %w[clean:all clean:external]
226 desc "Remove all compile system ruby files"
229 files_to_delete += Dir["*.rbc"] + Dir["**/*.rbc"] + Dir["**/.*.rbc"]
230 files_to_delete += Dir["**/.load_order.txt"]
231 files_to_delete += ["runtime/platform.conf"]
232 files_to_delete -= ["runtime/stable/loader.rbc"] # never ever delete this
234 files_to_delete.each do |f|
235 rm_f f, :verbose => $verbose
239 desc "Cleans all compiled extension files (lib/ext)"
241 Dir["lib/ext/**/*#{$dlext}"].each do |f|
242 rm_f f, :verbose => $verbose
246 desc "Cleans up VM building site"
251 desc "Cleans up generated files"
253 rm_f Dir["shotgun/lib/grammar.c"], :verbose => $verbose
256 desc "Cleans up VM and external libs"
258 sh "cd shotgun; #{make('distclean')}"
261 desc "Cleans up editor files and other misc crap"
263 rm_f Dir["*~"] + Dir["**/*~"], :verbose => $verbose
266 desc "Cleans up config files (so they can be regenerated when you change PREFIX)"
268 rm "shotgun/config.h", :verbose => $verbose
269 rm "shotgun/config.mk", :verbose => $verbose
274 desc "Run all 'known good' specs (task alias for spec:ci)"
275 task :spec => 'spec:ci'
279 # Setup for 'Subtend' specs. No need to call this yourself.
281 Dir["spec/subtend/**/Rakefile"].each do |rakefile|
282 sh "rake -f #{rakefile}"
287 desc "Initialize git submodules for mspec and rubyspec"
288 task :init => 'mspec:init'
290 desc "Run continuous integration examples"
291 task :ci => :build do
294 target = ENV['SPEC_TARGET'] || 'rubinius'
295 system %(shotgun/rubinius -e 'puts "rubinius build: \#{Rubinius::BUILDREV}"') if target == 'rubinius'
296 sh "bin/mspec ci -t #{target}"
299 spec_targets = %w(compiler core language library parser rubinius)
300 # Build a spec:<task_name> for each group of Rubinius specs
301 spec_targets.each do |group|
302 desc "Run #{group} examples"
304 sh "bin/mspec spec/#{group}"
308 desc "Run subtend (Rubinius C API) examples"
309 task :subtend => "spec:setup:subtend" do
310 sh "bin/mspec spec/rubinius/subtend"
313 # Specdiffs to make it easier to see what your changes have affected :)
314 desc 'Run specs and produce a diff against current base'
315 task :diff => 'diff:run'
318 desc 'Run specs and produce a diff against current base'
320 system 'bin/mspec -f ci -o spec/reports/specdiff.txt spec'
321 system 'diff -u spec/reports/base.txt spec/reports/specdiff.txt'
322 system 'rm spec/reports/specdiff.txt'
325 desc 'Replace the base spec file with a new one'
327 system 'bin/mspec -f ci -o spec/reports/base.txt spec'
331 desc "Run the rspec specs for mspec"
333 # Use the rspec spec runner (see mspec/README; gem install rspec)
334 sh 'spec ./mspec/spec'
343 desc "Initialize git submodule for mspec"
345 sh "git submodule init mspec"
346 sh "git submodule update mspec"
349 desc "Synchronize mspec submodule to current remote version"
353 sh "git rebase origin"
355 version = `git log --pretty=oneline -1 mspec`[0..7]
357 sh "git commit -m 'Updated MSpec submodule to #{version}'"
360 desc "Update mspec sources to current submodule version"
362 sh "git submodule update mspec"
365 task :pull => :update
370 desc "Build task for CruiseControl"
371 task :ccrb => [:build, 'spec:ci']
374 desc "Run CI client daemon in incremental mode."
376 sh "tools/cluster_test/ci.rb -i"
379 desc "Run CI client daemon in full build mode."
381 sh "tools/cluster_test/ci.rb"