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.expand_path(File.dirname(__FILE__))
12 require 'rakelib/rubinius'
14 require 'rakelib/struct_generator'
15 require 'rakelib/const_generator'
16 require 'rakelib/types_generator'
18 task :default => :build
22 desc "Build everything that needs to be built"
23 task :build => 'build:all'
25 task :stable_compiler do
27 puts "Use current versions, not stable."
29 ENV['RBX_BOOTSTRAP'] = "runtime/stable/bootstrap.rba"
30 ENV['RBX_CORE'] = "runtime/stable/core.rba"
31 ENV['RBX_LOADER'] = "runtime/stable/loader.rbc"
32 ENV['RBX_PLATFORM'] = "runtime/stable/platform.rba"
36 rule ".rbc" => %w[.rb] do |t|
37 compile t.source, t.name
40 files = FileList['kernel/core/*.rb']
42 unless files.include?("kernel/core/dir.rb")
43 files.add("kernel/core/dir.rb")
46 Core = CodeGroup.new(files, 'runtime/core', 'core')
48 Bootstrap = CodeGroup.new 'kernel/bootstrap/*.rb', 'runtime/bootstrap',
50 PlatformFiles = CodeGroup.new 'kernel/platform/*.rb', 'runtime/platform', 'platform'
52 file 'runtime/loader.rbc' => 'kernel/loader.rb' do
53 compile 'kernel/loader.rb', 'runtime/loader.rbc'
56 file 'runtime/stable/loader.rbc' => 'runtime/loader.rbc' do
57 cp 'runtime/loader.rbc', 'runtime/stable', :verbose => $verbose
60 file 'runtime/stable/compiler.rba' => 'build:compiler' do |t|
61 #sh "cd lib; zip -r ../runtime/stable/compiler.rba compiler -x \\*.rb"
63 rbc_files = Rake::FileList['compiler/**/*.rbc']
66 rbc_files.each do |rbc_file|
67 ar_add "../#{t.name}", rbc_file
72 Rake::StructGeneratorTask.new do |t|
76 Rake::StructGeneratorTask.new do |t|
77 t.dest = 'lib/zlib.rb'
80 AllPreCompiled = Core.output + Bootstrap.output + PlatformFiles.output
81 AllPreCompiled << "runtime/loader.rbc"
95 # This nobody rule lets use use all the shotgun files as
96 # prereqs. This rule is run for all those prereqs and just
97 # (obviously) does nothing, but it makes rake happy.
100 # These files must be excluded from the c_source FileList
101 # because they are build products (i.e. there is no rule
102 # to build them, they will be built) and the c_source list
103 # list gets created before they are deleted by the clean task.
109 'primitive_indexes.h',
115 "shotgun/lib/*.[chy]",
117 "shotgun/lib/subtend/*.[chS]",
119 ].exclude(*exclude_source)
121 file "shotgun/rubinius.bin" => c_source do
125 file "shotgun/rubinius.local.bin" => c_source do
129 desc "Compiles shotgun (the C-code VM)"
130 task :shotgun => %w[configure shotgun/rubinius.bin shotgun/rubinius.local.bin]
132 task :setup_rbc => :stable_compiler
134 task :rbc => ([:setup_rbc] + AllPreCompiled)
136 task :compiler => :stable_compiler do
137 compile_dir "lib/compiler"
140 desc "Rebuild runtime/stable/*. If you don't know why you're running this, don't."
143 runtime/stable/bootstrap.rba
144 runtime/stable/core.rba
145 runtime/stable/compiler.rba
146 runtime/stable/loader.rbc
147 runtime/stable/platform.rba
150 desc "Rebuild the .load_order.txt files"
152 # Note: Steps to rebuild load_order were defined above
157 sh "cd shotgun/lib; #{make "clean"}"
161 sh "cd shotgun/lib; #{make "DEV=1"}"
165 task :platform => 'runtime/platform.conf'
170 desc "Install rubinius as rbx"
171 task :install => :config_env do
172 sh "cd shotgun; #{make "install"}"
174 mkdir_p RBAPATH, :verbose => true
175 mkdir_p CODEPATH, :verbose => true
177 rba_files = Rake::FileList.new('runtime/platform.conf',
178 'runtime/**/*.rb{a,c}',
179 'runtime/**/.load_order.txt')
181 install_files rba_files, RBAPATH
183 lib_files = Rake::FileList.new 'lib/**/*'
185 install_files lib_files, CODEPATH
187 mkdir_p File.join(CODEPATH, 'bin'), :verbose => true
189 Rake::FileList.new("#{CODEPATH}/**/*.rb").sort.each do |rb_file|
190 if File.exists? "#{rb_file}c"
191 next if File.mtime("#{rb_file}c") > File.mtime(rb_file)
193 sh File.join(BINPATH, 'rbx'), 'compile', rb_file, :verbose => true
197 desc "Uninstall rubinius and libraries. Helps with build problems."
198 task :uninstall => :config_env do
199 rm Dir[File.join(BINPATH, 'rbx*')]
200 rm_r Dir[File.join(LIBPATH, '*rubinius*')]
203 task :compiledir => :stable_compiler do
205 raise "Use DIR= to set which directory" if !dir or dir.empty?
211 desc "Recompile all ruby system files"
212 task :rebuild => %w[clean build:all]
214 desc "Alias for clean:all"
215 task :clean => "clean:all"
217 desc "Alias for clean:distclean"
218 task :distclean => "clean:distclean"
221 desc "Clean everything but third-party libs"
222 task :all => %w[clean:rbc clean:extensions clean:shotgun clean:generated clean:crap clean:config]
224 desc "Clean everything including third-party libs"
225 task :distclean => %w[clean:all clean:external]
227 desc "Remove all compile system ruby files"
230 files_to_delete += Dir["*.rbc"] + Dir["**/*.rbc"] + Dir["**/.*.rbc"]
231 files_to_delete += Dir["**/.load_order.txt"]
232 files_to_delete += ["runtime/platform.conf"]
233 files_to_delete -= ["runtime/stable/loader.rbc"] # never ever delete this
235 files_to_delete.each do |f|
236 rm_f f, :verbose => $verbose
240 desc "Cleans all compiled extension files (lib/ext)"
242 Dir["lib/ext/**/*#{$dlext}"].each do |f|
243 rm_f f, :verbose => $verbose
247 desc "Cleans up VM building site"
252 desc "Cleans up generated files"
254 rm_f Dir["shotgun/lib/grammar.c"], :verbose => $verbose
257 desc "Cleans up VM and external libs"
259 sh "cd shotgun; #{make('distclean')}"
262 desc "Cleans up editor files and other misc crap"
264 rm_f Dir["*~"] + Dir["**/*~"], :verbose => $verbose
267 desc "Cleans up config files (so they can be regenerated when you change PREFIX)"
269 rm "shotgun/config.h", :verbose => $verbose
270 rm "shotgun/config.mk", :verbose => $verbose
276 desc "Build task for CruiseControl"
277 task :ccrb => [:build, 'spec:ci']
280 desc "Run CI client daemon in incremental mode."
282 sh "tools/cluster_test/ci.rb -i"
285 desc "Run CI client daemon in full build mode."
287 sh "tools/cluster_test/ci.rb"