Replace object_id for equal? in Matrix specs
[rbx.git] / Rakefile
blobaf3b8d8208b05dc3229727aca642f8907c5671fe
1 # NOTE! When updating this file, also update INSTALL, if necessary.
2 # NOTE! Please keep your tasks grouped together.
4 $VERBOSE = true
5 $verbose = Rake.application.options.trace
6 $dlext = Config::CONFIG["DLEXT"]
7 $compiler = nil
9 RUBINIUS_BASE = File.dirname(__FILE__)
11 require 'tsort'
12 require 'rakelib/rubinius'
13 require 'rakelib/struct_generator'
14 require 'rakelib/const_generator'
15 require 'rakelib/types_generator'
17 task :default => :build
19 # BUILD TASKS
21 desc "Build everything that needs to be built"
22 task :build => 'build:all'
24 task :stable_compiler do
25   if ENV['USE_CURRENT']
26     puts "Use current versions, not stable."
27   else
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"
32   end
33 end
35 rule ".rbc" => %w[.rb] do |t|
36   compile t.source, t.name
37 end
39 files = FileList['kernel/core/*.rb']
41 unless files.include?("kernel/core/dir.rb")
42   files.add("kernel/core/dir.rb")
43 end
45 Core      = CodeGroup.new(files, 'runtime/core', 'core')
47 Bootstrap = CodeGroup.new 'kernel/bootstrap/*.rb', 'runtime/bootstrap',
48                           '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'
53 end
55 file 'runtime/stable/loader.rbc' => 'runtime/loader.rbc' do
56   cp 'runtime/loader.rbc', 'runtime/stable', :verbose => $verbose
57 end
59 file 'runtime/stable/compiler.rba' => 'build:compiler' do |t|
60   #sh "cd lib; zip -r ../runtime/stable/compiler.rba compiler -x \\*.rb"
61   rm_f t.name
62   rbc_files = Rake::FileList['compiler/**/*.rbc']
64   Dir.chdir 'lib' do
65     rbc_files.each do |rbc_file|
66       ar_add "../#{t.name}", rbc_file
67     end
68   end
69 end
71 Rake::StructGeneratorTask.new do |t|
72   t.dest = "lib/etc.rb"
73 end
75 Rake::StructGeneratorTask.new do |t|
76   t.dest = 'lib/zlib.rb'
77 end
79 AllPreCompiled = Core.output + Bootstrap.output + PlatformFiles.output
80 AllPreCompiled << "runtime/loader.rbc"
82 namespace :build do
84   task :all => %w[
85     build:shotgun
86     build:platform
87     build:rbc
88     compiler
89     lib/etc.rb
90     lib/rbconfig.rb
91     extensions
92   ]
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.
97   rule '^shotgun/.+'
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.
103   exclude_source = [
104     /auto/,
105     /instruction_names/,
106     /node_types/,
107     /grammar.c/,
108     'primitive_indexes.h',
109     'primitive_util.h'
110   ]
112   c_source = FileList[
113     "shotgun/config.h",
114     "shotgun/lib/*.[chy]",
115     "shotgun/lib/*.rb",
116     "shotgun/lib/subtend/*.[chS]",
117     "shotgun/main.c",
118   ].exclude(*exclude_source)
120   file "shotgun/rubinius.bin" => c_source do
121     sh make('vm')
122   end
123   
124   file "shotgun/rubinius.local.bin" => c_source do
125     sh make('vm')
126   end
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"
137   end
139   desc "Rebuild runtime/stable/*.  If you don't know why you're running this, don't."
140   task :stable => %w[
141     build:all
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
147   ]
149   desc "Rebuild the .load_order.txt files"
150   task "load_order" do
151     # Note: Steps to rebuild load_order were defined above
152   end
154   namespace :vm do
155     task "clean" do
156       sh "cd shotgun/lib; #{make "clean"}"
157     end
159     task "dev" do
160       sh "cd shotgun/lib; #{make "DEV=1"}"
161     end
162   end
164   task :platform => 'runtime/platform.conf'
167 # INSTALL TASKS
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     sh File.join(BINPATH, 'rbx'), 'compile', rb_file, :verbose => true
190   end
193 desc "Uninstall rubinius and libraries. Helps with build problems."
194 task :uninstall => :config_env do
195   rm Dir[File.join(BINPATH, 'rbx*')]
196   rm_r Dir[File.join(LIBPATH, '*rubinius*')]
199 task :compiledir => :stable_compiler do
200   dir = ENV['DIR']
201   raise "Use DIR= to set which directory" if !dir or dir.empty?
202   compile_dir(dir)
205 # CLEAN TASKS
207 desc "Recompile all ruby system files"
208 task :rebuild => %w[clean build:all]
210 desc "Alias for clean:all"
211 task :clean => "clean:all"
213 desc "Alias for clean:distclean"
214 task :distclean => "clean:distclean"
216 namespace :clean do
217   desc "Clean everything but third-party libs"
218   task :all => %w[clean:rbc clean:extensions clean:shotgun clean:generated clean:crap clean:config]
220   desc "Clean everything including third-party libs"
221   task :distclean => %w[clean:all clean:external]
223   desc "Remove all compile system ruby files"
224   task :rbc do
225     files_to_delete = []
226     files_to_delete += Dir["*.rbc"] + Dir["**/*.rbc"] + Dir["**/.*.rbc"]
227     files_to_delete += Dir["**/.load_order.txt"]
228     files_to_delete += ["runtime/platform.conf"]
229     files_to_delete -= ["runtime/stable/loader.rbc"] # never ever delete this
231     files_to_delete.each do |f|
232       rm_f f, :verbose => $verbose
233     end
234   end
236   desc "Cleans all compiled extension files (lib/ext)"
237   task :extensions do
238     Dir["lib/ext/**/*#{$dlext}"].each do |f|
239       rm_f f, :verbose => $verbose
240     end
241   end
243   desc "Cleans up VM building site"
244   task :shotgun do
245     sh make('clean')
246   end
248   desc "Cleans up generated files"
249   task :generated do
250     rm_f Dir["shotgun/lib/grammar.c"], :verbose => $verbose
251   end
253   desc "Cleans up VM and external libs"
254   task :external do
255     sh "cd shotgun; #{make('distclean')}"
256   end
258   desc "Cleans up editor files and other misc crap"
259   task :crap do
260     rm_f Dir["*~"] + Dir["**/*~"], :verbose => $verbose
261   end
262   
263   desc "Cleans up config files (so they can be regenerated when you change PREFIX)"
264   task :config do
265     rm "shotgun/config.h", :verbose => $verbose
266     rm "shotgun/config.mk", :verbose => $verbose
267   end
270 # SPEC TASKS
271 desc "Run all 'known good' specs (task alias for spec:ci)"
272 task :spec => 'spec:ci'
274 namespace :spec do
275   namespace :setup do
276     # Setup for 'Subtend' specs. No need to call this yourself.
277     task :subtend do
278       Dir["spec/subtend/**/Rakefile"].each do |rakefile|
279         sh "rake -f #{rakefile}"
280       end
281     end
282   end
284   desc "Run continuous integration examples"
285   task :ci => :build do
286     clear_compiler
288     target = ENV['SPEC_TARGET'] || 'rubinius'
289     system %(shotgun/rubinius -e 'puts "rubinius build: \#{Rubinius::BUILDREV}"') if target == 'rubinius'
290     sh "bin/mspec ci -t #{target}"
291   end
293   spec_targets = %w(compiler core language library parser rubinius)
294   # Build a spec:<task_name> for each group of Rubinius specs
295   spec_targets.each do |group|
296     desc "Run #{group} examples"
297     task group do
298       sh "bin/mspec spec/#{group}"
299     end
300   end
302   desc "Run subtend (Rubinius C API) examples"
303   task :subtend => "spec:setup:subtend" do
304     sh "bin/mspec spec/rubinius/subtend"
305   end
307   # Specdiffs to make it easier to see what your changes have affected :)
308   desc 'Run specs and produce a diff against current base'
309   task :diff => 'diff:run'
311   namespace :diff do
312     desc 'Run specs and produce a diff against current base'
313     task :run do
314       system 'bin/mspec -f ci -o spec/reports/specdiff.txt spec'
315       system 'diff -u spec/reports/base.txt spec/reports/specdiff.txt'
316       system 'rm spec/reports/specdiff.txt'
317     end
319     desc 'Replace the base spec file with a new one'
320     task :replace do
321       system 'bin/mspec -f ci -o spec/reports/base.txt spec'
322     end
323   end
325   desc "Run the rspec specs for mspec"
326   task :mspec do
327     # Use the rspec spec runner (see mspec/README; gem install rspec)
328     sh 'spec ./mspec/spec'
329   end
331   task :r2r do
332     puts ARGV.inspect
333   end
336 # MISC TASKS
338 desc "Build task for CruiseControl"
339 task :ccrb => [:build, 'spec:ci']