super() block pass bug, String#[] bug, singleton_method_added
[rbx.git] / Rakefile
blobc707ce7e35430b31ceedeb5a5296ddb17c91a95f
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.expand_path(File.dirname(__FILE__))
11 require 'tsort'
12 require 'rakelib/rubinius'
13 require 'rakelib/git'
14 require 'rakelib/struct_generator'
15 require 'rakelib/const_generator'
16 require 'rakelib/types_generator'
18 task :default => :build
20 # BUILD TASKS
22 desc "Build everything that needs to be built"
23 task :build => 'build:all'
25 task :stable_compiler do
26   if ENV['USE_CURRENT']
27     puts "Use current versions, not stable."
28   else
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"
33   end
34 end
36 rule ".rbc" => %w[.rb] do |t|
37   compile t.source, t.name
38 end
40 files = FileList['kernel/core/*.rb']
42 unless files.include?("kernel/core/dir.rb")
43   files.add("kernel/core/dir.rb")
44 end
46 Core      = CodeGroup.new(files, 'runtime/core', 'core')
48 Bootstrap = CodeGroup.new 'kernel/bootstrap/*.rb', 'runtime/bootstrap',
49                           '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'
54 end
56 file 'runtime/stable/loader.rbc' => 'runtime/loader.rbc' do
57   cp 'runtime/loader.rbc', 'runtime/stable', :verbose => $verbose
58 end
60 file 'runtime/stable/compiler.rba' => 'build:compiler' do |t|
61   #sh "cd lib; zip -r ../runtime/stable/compiler.rba compiler -x \\*.rb"
62   rm_f t.name
63   rbc_files = Rake::FileList['compiler/**/*.rbc']
65   Dir.chdir 'lib' do
66     rbc_files.each do |rbc_file|
67       ar_add "../#{t.name}", rbc_file
68     end
69   end
70 end
72 Rake::StructGeneratorTask.new do |t|
73   t.dest = "lib/etc.rb"
74 end
76 Rake::StructGeneratorTask.new do |t|
77   t.dest = 'lib/zlib.rb'
78 end
80 AllPreCompiled = Core.output + Bootstrap.output + PlatformFiles.output
81 AllPreCompiled << "runtime/loader.rbc"
83 namespace :build do
85   task :all => %w[
86     spec:init
87     build:shotgun
88     build:platform
89     build:rbc
90     compiler
91     lib/etc.rb
92     lib/rbconfig.rb
93     extensions
94   ]
96   # This nobody rule lets use use all the shotgun files as
97   # prereqs. This rule is run for all those prereqs and just
98   # (obviously) does nothing, but it makes rake happy.
99   rule '^shotgun/.+'
101   # These files must be excluded from the c_source FileList
102   # because they are build products (i.e. there is no rule
103   # to build them, they will be built) and the c_source list
104   # list gets created before they are deleted by the clean task.
105   exclude_source = [
106     /auto/,
107     /instruction_names/,
108     /node_types/,
109     /grammar.c/,
110     'primitive_indexes.h',
111     'primitive_util.h'
112   ]
114   c_source = FileList[
115     "shotgun/config.h",
116     "shotgun/lib/*.[chy]",
117     "shotgun/lib/*.rb",
118     "shotgun/lib/subtend/*.[chS]",
119     "shotgun/main.c",
120   ].exclude(*exclude_source)
122   file "shotgun/rubinius.bin" => c_source do
123     sh make('vm')
124   end
125   
126   file "shotgun/rubinius.local.bin" => c_source do
127     sh make('vm')
128   end
130   desc "Compiles shotgun (the C-code VM)"
131   task :shotgun => %w[configure shotgun/rubinius.bin shotgun/rubinius.local.bin]
133   task :setup_rbc => :stable_compiler
135   task :rbc => ([:setup_rbc] + AllPreCompiled)
137   task :compiler => :stable_compiler do
138     compile_dir "lib/compiler"
139   end
141   desc "Rebuild runtime/stable/*.  If you don't know why you're running this, don't."
142   task :stable => %w[
143     build:all
144     runtime/stable/bootstrap.rba
145     runtime/stable/core.rba
146     runtime/stable/compiler.rba
147     runtime/stable/loader.rbc
148     runtime/stable/platform.rba
149   ]
151   desc "Rebuild the .load_order.txt files"
152   task "load_order" do
153     # Note: Steps to rebuild load_order were defined above
154   end
156   namespace :vm do
157     task "clean" do
158       sh "cd shotgun/lib; #{make "clean"}"
159     end
161     task "dev" do
162       sh "cd shotgun/lib; #{make "DEV=1"}"
163     end
164   end
166   task :platform => 'runtime/platform.conf'
169 # INSTALL TASKS
171 desc "Install rubinius as rbx"
172 task :install => :config_env do
173   sh "cd shotgun; #{make "install"}"
175   mkdir_p RBAPATH, :verbose => true
176   mkdir_p CODEPATH, :verbose => true
178   rba_files = Rake::FileList.new('runtime/platform.conf',
179                                  'runtime/**/*.rb{a,c}',
180                                  'runtime/**/.load_order.txt')
182   install_files rba_files, RBAPATH
184   lib_files = Rake::FileList.new 'lib/**/*'
186   install_files lib_files, CODEPATH
188   mkdir_p File.join(CODEPATH, 'bin'), :verbose => true
190   Rake::FileList.new("#{CODEPATH}/**/*.rb").sort.each do |rb_file|
191     if File.exists? "#{rb_file}c"
192       next if File.mtime("#{rb_file}c") > File.mtime(rb_file)
193     end
194     sh File.join(BINPATH, 'rbx'), 'compile', rb_file, :verbose => true
195   end
198 desc "Uninstall rubinius and libraries. Helps with build problems."
199 task :uninstall => :config_env do
200   rm Dir[File.join(BINPATH, 'rbx*')]
201   rm_r Dir[File.join(LIBPATH, '*rubinius*')]
204 task :compiledir => :stable_compiler do
205   dir = ENV['DIR']
206   raise "Use DIR= to set which directory" if !dir or dir.empty?
207   compile_dir(dir)
210 # CLEAN TASKS
212 desc "Recompile all ruby system files"
213 task :rebuild => %w[clean build:all]
215 desc "Alias for clean:all"
216 task :clean => "clean:all"
218 desc "Alias for clean:distclean"
219 task :distclean => "clean:distclean"
221 namespace :clean do
222   desc "Clean everything but third-party libs"
223   task :all => %w[clean:rbc clean:extensions clean:shotgun clean:generated clean:crap clean:config]
225   desc "Clean everything including third-party libs"
226   task :distclean => %w[clean:all clean:external]
228   desc "Remove all compile system ruby files"
229   task :rbc do
230     files_to_delete = []
231     files_to_delete += Dir["*.rbc"] + Dir["**/*.rbc"] + Dir["**/.*.rbc"]
232     files_to_delete += Dir["**/.load_order.txt"]
233     files_to_delete += ["runtime/platform.conf"]
234     files_to_delete -= ["runtime/stable/loader.rbc"] # never ever delete this
236     files_to_delete.each do |f|
237       rm_f f, :verbose => $verbose
238     end
239   end
241   desc "Cleans all compiled extension files (lib/ext)"
242   task :extensions do
243     Dir["lib/ext/**/*#{$dlext}"].each do |f|
244       rm_f f, :verbose => $verbose
245     end
246   end
248   desc "Cleans up VM building site"
249   task :shotgun do
250     sh make('clean')
251   end
253   desc "Cleans up generated files"
254   task :generated do
255     rm_f Dir["shotgun/lib/grammar.c"], :verbose => $verbose
256   end
258   desc "Cleans up VM and external libs"
259   task :external do
260     sh "cd shotgun; #{make('distclean')}"
261   end
263   desc "Cleans up editor files and other misc crap"
264   task :crap do
265     rm_f Dir["*~"] + Dir["**/*~"], :verbose => $verbose
266   end
267   
268   desc "Cleans up config files (so they can be regenerated when you change PREFIX)"
269   task :config do
270     rm "shotgun/config.h", :verbose => $verbose
271     rm "shotgun/config.mk", :verbose => $verbose
272   end
275 # MISC TASKS
277 desc "Build task for CruiseControl"
278 task :ccrb => [:build, 'spec:ci']
280 namespace :test do
281   desc "Run CI client daemon in incremental mode."
282   task :daemon do
283     sh "tools/cluster_test/ci.rb -i"
284   end
286   desc "Run CI client daemon in full build mode."
287   task :daemon_full do
288     sh "tools/cluster_test/ci.rb"
289   end