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'
15 task :default => :build
19 desc "Build everything that needs to be built"
20 task :build => 'build:all'
22 task :stable_compiler do
24 puts "Use current versions, not stable."
26 ENV['RBX_BOOTSTRAP'] = "runtime/stable/bootstrap.rba"
27 ENV['RBX_CORE'] = "runtime/stable/core.rba"
28 ENV['RBX_LOADER'] = "runtime/stable/loader.rbc"
29 ENV['RBX_PLATFORM'] = "runtime/stable/platform.rba"
33 rule ".rbc" => %w[.rb] do |t|
34 compile t.source, t.name
37 files = FileList['kernel/core/*.rb']
39 unless files.include?("kernel/core/dir.rb")
40 files.add("kernel/core/dir.rb")
43 Core = CodeGroup.new(files, 'runtime/core', 'core')
45 Bootstrap = CodeGroup.new 'kernel/bootstrap/*.rb', 'runtime/bootstrap',
47 PlatformFiles = CodeGroup.new 'kernel/platform/*.rb', 'runtime/platform', 'platform'
49 file 'runtime/loader.rbc' => 'kernel/loader.rb' do
50 compile 'kernel/loader.rb', 'runtime/loader.rbc'
53 file 'runtime/stable/loader.rbc' => 'runtime/loader.rbc' do
54 cp 'runtime/loader.rbc', 'runtime/stable', :verbose => $verbose
57 file 'runtime/stable/compiler.rba' => 'build:compiler' do |t|
58 #sh "cd lib; zip -r ../runtime/stable/compiler.rba compiler -x \\*.rb"
60 rbc_files = Rake::FileList['compiler/**/*.rbc']
63 rbc_files.each do |rbc_file|
64 ar_add "../#{t.name}", rbc_file
69 AllPreCompiled = Core.output + Bootstrap.output + PlatformFiles.output
70 AllPreCompiled << "runtime/loader.rbc"
84 gems:install_development
87 desc "Builds the core components for running rbx"
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/dev-tramp" => "shotgun/dev-tramp.c" do
125 sh "cc -DBUILDDIR=\\\"#{Dir.pwd}/shotgun\\\" -o shotgun/dev-tramp shotgun/dev-tramp.c"
128 file "shotgun/rubinius.local.bin" => c_source + ["shotgun/dev-tramp"] do
132 desc "Compiles shotgun (the C-code VM)"
133 task :shotgun => %w[configure shotgun/rubinius.bin shotgun/rubinius.local.bin]
135 task :setup_rbc => :stable_compiler
137 task :rbc => ([:setup_rbc] + AllPreCompiled)
139 task :compiler => :stable_compiler do
140 compile_dir "lib/compiler"
143 desc "Rebuild runtime/stable/*. If you don't know why you're running this, don't."
146 runtime/stable/bootstrap.rba
147 runtime/stable/core.rba
148 runtime/stable/compiler.rba
149 runtime/stable/loader.rbc
150 runtime/stable/platform.rba
153 desc "Rebuild the .load_order.txt files"
155 # Note: Steps to rebuild load_order were defined above
160 sh "cd shotgun/lib; #{make "clean"}"
164 sh "cd shotgun/lib; #{make "DEV=1"}"
168 task :platform => 'runtime/platform.conf'
173 desc "Install rubinius as rbx"
175 sh "cd shotgun; #{make "install"}"
177 mkdir_p RBAPATH, :verbose => true
178 mkdir_p CODEPATH, :verbose => true
180 # Install the subtend headers.
181 mkdir_p EXTPATH, :verbose => true
183 Rake::FileList.new('shotgun/lib/subtend/*.h').each do |file|
184 install file, File.join(EXTPATH, File.basename(file)), :mode => 0644, :verbose => true
187 install "shotgun/config.h", File.join(EXTPATH, "config.h"),
188 :mode => 0644, :verbose => true
190 File.open File.join(EXTPATH, "defines.h"), "w" do |f|
191 f.puts "// This file left empty"
194 File.open File.join(EXTPATH, "missing.h"), "w" do |f|
195 f.puts "// This file left empty"
198 rba_files = Rake::FileList.new('runtime/platform.conf',
199 'runtime/**/*.rb{a,c}',
200 'runtime/**/.load_order.txt')
202 install_files rba_files, RBAPATH
204 lib_files = Rake::FileList.new 'lib/**/*'
206 install_files lib_files, CODEPATH
208 mkdir_p File.join(CODEPATH, 'bin'), :verbose => true
210 Rake::FileList.new("#{CODEPATH}/**/*.rb").sort.each do |rb_file|
211 if File.exists? "#{rb_file}c"
212 next if File.mtime("#{rb_file}c") > File.mtime(rb_file)
214 sh File.join(BINPATH, 'rbx'), 'compile', rb_file, :verbose => true
217 Rake::Task['gems:install'].invoke
220 desc "Uninstall rubinius and libraries. Helps with build problems."
222 rm Dir[File.join(BINPATH, 'rbx*')]
223 rm_r Dir[File.join(LIBPATH, '*rubinius*')]
226 task :compiledir => :stable_compiler do
228 raise "Use DIR= to set which directory" if !dir or dir.empty?
234 desc "Recompile all ruby system files"
235 task :rebuild => %w[clean build:all]
237 desc "Alias for clean:all"
238 task :clean => "clean:all"
240 desc "Alias for clean:distclean"
241 task :distclean => "clean:distclean"
244 desc "Clean everything but third-party libs"
255 desc "Clean everything including third-party libs"
256 task :distclean => %w[clean:all clean:external]
258 desc "Remove all compile system ruby files"
261 files_to_delete += Dir["*.rbc"] + Dir["**/*.rbc"] + Dir["**/.*.rbc"]
262 files_to_delete += Dir["**/.load_order.txt"]
263 files_to_delete += ["runtime/platform.conf"]
264 files_to_delete -= ["runtime/stable/loader.rbc"] # never ever delete this
266 files_to_delete.each do |f|
267 rm_f f, :verbose => $verbose
271 desc "Cleans all compiled extension files (lib/ext)"
273 Dir["lib/ext/**/*#{$dlext}"].each do |f|
274 rm_f f, :verbose => $verbose
278 desc "Cleans up VM building site"
281 rm_f "shotgun/dev-tramp"
284 desc "Cleans up generated files"
286 rm_f Dir["shotgun/lib/grammar.c"], :verbose => $verbose
289 desc "Cleans up VM and external libs"
291 sh "cd shotgun; #{make('distclean')}"
294 desc "Cleans up editor files and other misc crap"
296 rm_f Dir["*~"] + Dir["**/*~"], :verbose => $verbose
299 desc "Cleans up config files (so they can be regenerated when you change PREFIX)"
301 files = %w(shotgun/config.h shotgun/config.mk lib/rbconfig.rb)
303 rm file, :verbose => $verbose if File.exist?(file)
310 desc "Build task for CruiseControl"
311 task :ccrb => [:build, 'spec:ci']