public
Description: Rubinius, the Ruby VM
Homepage: http://rubini.us
Clone URL: git://github.com/evanphx/rubinius.git
brixen (author)
Wed Jul 16 19:26:30 -0700 2008
commit  b0a7ffa7b6aa1f50d8c6bc295537a7f6abfdb332
tree    c492d83836710d664f1a8b9028dbcdc42ac6afc8
parent  2fe0593f6a9722ee312f6f258e19fcd588e4a10c
rubinius / Rakefile
100644 312 lines (239 sloc) 7.817 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# NOTE! When updating this file, also update INSTALL, if necessary.
# NOTE! Please keep your tasks grouped together.
 
$VERBOSE = true
$verbose = Rake.application.options.trace
$dlext = Config::CONFIG["DLEXT"]
$compiler = nil
 
RUBINIUS_BASE = File.expand_path(File.dirname(__FILE__))
 
require 'tsort'
require 'rakelib/rubinius'
require 'rakelib/git'
 
task :default => :build
 
# BUILD TASKS
 
desc "Build everything that needs to be built"
task :build => 'build:all'
 
task :stable_compiler do
  if ENV['USE_CURRENT']
    puts "Use current versions, not stable."
  else
    ENV['RBX_BOOTSTRAP'] = "runtime/stable/bootstrap.rba"
    ENV['RBX_CORE'] = "runtime/stable/core.rba"
    ENV['RBX_LOADER'] = "runtime/stable/loader.rbc"
    ENV['RBX_PLATFORM'] = "runtime/stable/platform.rba"
  end
end
 
rule ".rbc" => %w[.rb] do |t|
  compile t.source, t.name
end
 
files = FileList['kernel/core/*.rb']
 
unless files.include?("kernel/core/dir.rb")
  files.add("kernel/core/dir.rb")
end
 
Core = CodeGroup.new(files, 'runtime/core', 'core')
 
Bootstrap = CodeGroup.new 'kernel/bootstrap/*.rb', 'runtime/bootstrap',
                          'bootstrap'
PlatformFiles = CodeGroup.new 'kernel/platform/*.rb', 'runtime/platform', 'platform'
 
file 'runtime/loader.rbc' => 'kernel/loader.rb' do
  compile 'kernel/loader.rb', 'runtime/loader.rbc'
end
 
file 'runtime/stable/loader.rbc' => 'runtime/loader.rbc' do
  cp 'runtime/loader.rbc', 'runtime/stable', :verbose => $verbose
end
 
file 'runtime/stable/compiler.rba' => 'build:compiler' do |t|
  #sh "cd lib; zip -r ../runtime/stable/compiler.rba compiler -x \\*.rb"
  rm_f t.name
  rbc_files = Rake::FileList['compiler/**/*.rbc']
 
  Dir.chdir 'lib' do
    rbc_files.each do |rbc_file|
      ar_add "../#{t.name}", rbc_file
    end
  end
end
 
AllPreCompiled = Core.output + Bootstrap.output + PlatformFiles.output
AllPreCompiled << "runtime/loader.rbc"
 
namespace :build do
 
  task :all => %w[
build:system
 
compiler
 
lib/etc.rb
lib/rbconfig.rb
 
extensions
 
gems:install_development
]
 
  desc "Builds the core components for running rbx"
  task :system => %w[
build:shotgun
build:platform
build:rbc
]
 
  # This nobody rule lets use use all the shotgun files as
  # prereqs. This rule is run for all those prereqs and just
  # (obviously) does nothing, but it makes rake happy.
  rule '^shotgun/.+'
 
  # These files must be excluded from the c_source FileList
  # because they are build products (i.e. there is no rule
  # to build them, they will be built) and the c_source list
  # list gets created before they are deleted by the clean task.
  exclude_source = [
/auto/,
/instruction_names/,
/node_types/,
/grammar.c/,
    'primitive_indexes.h',
    'primitive_util.h'
  ]
 
  c_source = FileList[
    "shotgun/config.h",
    "shotgun/lib/*.[chy]",
    "shotgun/lib/*.rb",
    "shotgun/lib/subtend/*.[chS]",
    "shotgun/main.c"
  ].exclude(*exclude_source)
 
  file "shotgun/rubinius.bin" => c_source do
    sh make('vm')
  end
 
  file "shotgun/dev-tramp" => "shotgun/dev-tramp.c" do
    sh "cc -DBUILDDIR=\\\"#{Dir.pwd}/shotgun\\\" -o shotgun/dev-tramp shotgun/dev-tramp.c"
  end
 
  file "shotgun/rubinius.local.bin" => c_source + ["shotgun/dev-tramp"] do
    sh make('vm')
  end
 
  desc "Compiles shotgun (the C-code VM)"
  task :shotgun => %w[configure shotgun/rubinius.bin shotgun/rubinius.local.bin]
 
  task :setup_rbc => :stable_compiler
 
  task :rbc => ([:setup_rbc] + AllPreCompiled)
 
  task :compiler => :stable_compiler do
    compile_dir "lib/compiler"
  end
 
  desc "Rebuild runtime/stable/*. If you don't know why you're running this, don't."
  task :stable => %w[
build:all
runtime/stable/bootstrap.rba
runtime/stable/core.rba
runtime/stable/compiler.rba
runtime/stable/loader.rbc
runtime/stable/platform.rba
]
 
  desc "Rebuild the .load_order.txt files"
  task "load_order" do
    # Note: Steps to rebuild load_order were defined above
  end
 
  namespace :vm do
    task "clean" do
      sh "cd shotgun/lib; #{make "clean"}"
    end
 
    task "dev" do
      sh "cd shotgun/lib; #{make "DEV=1"}"
    end
  end
 
  task :platform => 'runtime/platform.conf'
end
 
# INSTALL TASKS
 
desc "Install rubinius as rbx"
task :install do
  sh "cd shotgun; #{make "install"}"
 
  mkdir_p RBAPATH, :verbose => true
  mkdir_p CODEPATH, :verbose => true
 
  # Install the subtend headers.
  mkdir_p EXTPATH, :verbose => true
 
  Rake::FileList.new('shotgun/lib/subtend/*.h').each do |file|
    install file, File.join(EXTPATH, File.basename(file)), :mode => 0644, :verbose => true
  end
 
  install "shotgun/config.h", File.join(EXTPATH, "config.h"),
    :mode => 0644, :verbose => true
 
  File.open File.join(EXTPATH, "defines.h"), "w" do |f|
    f.puts "// This file left empty"
  end
 
  File.open File.join(EXTPATH, "missing.h"), "w" do |f|
    f.puts "// This file left empty"
  end
 
  rba_files = Rake::FileList.new('runtime/platform.conf',
                                 'runtime/**/*.rb{a,c}',
                                 'runtime/**/.load_order.txt')
 
  install_files rba_files, RBAPATH
 
  lib_files = Rake::FileList.new 'lib/**/*'
 
  install_files lib_files, CODEPATH
 
  mkdir_p File.join(CODEPATH, 'bin'), :verbose => true
 
  Rake::FileList.new("#{CODEPATH}/**/*.rb").sort.each do |rb_file|
    if File.exists? "#{rb_file}c"
      next if File.mtime("#{rb_file}c") > File.mtime(rb_file)
    end
    sh File.join(BINPATH, 'rbx'), 'compile', rb_file, :verbose => true
  end
 
  Rake::Task['gems:install'].invoke
end
 
desc "Uninstall rubinius and libraries. Helps with build problems."
task :uninstall do
  rm Dir[File.join(BINPATH, 'rbx*')]
  rm_r Dir[File.join(LIBPATH, '*rubinius*')]
end
 
task :compiledir => :stable_compiler do
  dir = ENV['DIR']
  raise "Use DIR= to set which directory" if !dir or dir.empty?
  compile_dir(dir)
end
 
# CLEAN TASKS
 
desc "Recompile all ruby system files"
task :rebuild => %w[clean build:all]
 
desc "Alias for clean:all"
task :clean => "clean:all"
 
desc "Alias for clean:distclean"
task :distclean => "clean:distclean"
 
namespace :clean do
  desc "Clean everything but third-party libs"
  task :all => %w[
clean:rbc
clean:extensions
clean:shotgun
clean:generated
clean:crap
clean:config
gems:clean
]
 
  desc "Clean everything including third-party libs"
  task :distclean => %w[clean:all clean:external]
 
  desc "Remove all compile system ruby files"
  task :rbc do
    files_to_delete = []
    files_to_delete += Dir["*.rbc"] + Dir["**/*.rbc"] + Dir["**/.*.rbc"]
    files_to_delete += Dir["**/.load_order.txt"]
    files_to_delete += ["runtime/platform.conf"]
    files_to_delete -= ["runtime/stable/loader.rbc"] # never ever delete this
 
    files_to_delete.each do |f|
      rm_f f, :verbose => $verbose
    end
  end
 
  desc "Cleans all compiled extension files (lib/ext)"
  task :extensions do
    Dir["lib/ext/**/*#{$dlext}"].each do |f|
      rm_f f, :verbose => $verbose
    end
  end
 
  desc "Cleans up VM building site"
  task :shotgun do
    sh make('clean')
    rm_f "shotgun/dev-tramp"
  end
 
  desc "Cleans up generated files"
  task :generated do
    rm_f Dir["shotgun/lib/grammar.c"], :verbose => $verbose
  end
 
  desc "Cleans up VM and external libs"
  task :external do
    sh "cd shotgun; #{make('distclean')}"
  end
 
  desc "Cleans up editor files and other misc crap"
  task :crap do
    rm_f Dir["*~"] + Dir["**/*~"], :verbose => $verbose
  end
 
  desc "Cleans up config files (so they can be regenerated when you change PREFIX)"
  task :config do
    files = %w(shotgun/config.h shotgun/config.mk lib/rbconfig.rb)
    files.each do |file|
      rm file, :verbose => $verbose if File.exist?(file)
    end
  end
end
 
# MISC TASKS
 
desc "Build task for CruiseControl"
task :ccrb => [:build, 'spec:ci']