Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 342 lines (269 sloc) 8.138 kb
da5f9e6 @brixen Added load-order dependency generation to rake build:(core|platform) tas...
brixen authored
1 require 'tsort'
2
d630d96 Rakefile now supports rake report:all which runs all of the reports. All...
Ryantm authored
3 task :default => :tasks
4
5 task :tasks do
6 puts `rake -T`
7 end
8dd2b6b @evanphx r43@vatu: evan | 2006-08-24 16:34:21 -0700
evanphx authored
8
da5f9e6 @brixen Added load-order dependency generation to rake build:(core|platform) tas...
brixen authored
9 class Hash
10 include TSort
11
12 alias tsort_each_node each_key
13
14 def tsort_each_child(node, &block)
15 fetch(node).each(&block)
16 end
17 end
18
dc16b49 @wilson * Near-total rewrite of the Rakefile. Tasks that use rcompile are in the...
wilson authored
19 def newer?(file, cmp)
20 File.exists?(cmp) and File.mtime(cmp) >= File.mtime(file)
21 end
939f9ac @evanphx Revert array changes back to r1088. r1089 is busted bigtime.
evanphx authored
22
8634917 @evanphx Load order files are now in alphabetical order if there are no other dep...
evanphx authored
23 @setup_stable = false
24
329ec45 @evanphx Loading directly from directory structure
evanphx authored
25 def setup_stable
8634917 @evanphx Load order files are now in alphabetical order if there are no other dep...
evanphx authored
26 return if @setup_stable
27 @setup_stable = true
28
329ec45 @evanphx Loading directly from directory structure
evanphx authored
29 @pb = "runtime/stable/bootstrap.rba"
30 @pp = "runtime/stable/platform.rba"
31 @pc = "runtime/stable/core.rba"
32 @pl = "runtime/stable/loader.rbc"
33 @pr = "runtime/stable/compiler.rba"
34
35 if ENV['USE_CURRENT']
36 puts "Use current versions, not stable."
37 else
38 ENV['BOOTSTRAP'] = @pb
39 ENV['CORE'] = @pc
40 ENV['LOADER'] = @pl
41 ENV['PLATFORM'] = @pp
42 ENV['COMPILER'] = @pr
43 end
54cae11 @evanphx Added more IO stuff and platform methods.
evanphx authored
44
329ec45 @evanphx Loading directly from directory structure
evanphx authored
45 @compiler = ENV['COMPILER']
be1a8ed @wilson Include compiler archive in list of files managed by 'dev:setup'
wilson authored
46 end
47
da5f9e6 @brixen Added load-order dependency generation to rake build:(core|platform) tas...
brixen authored
48 def source_name(compiled)
49 File.basename(compiled, '.*') + '.rb'
50 end
51
52 def compiled_name(source, dir)
53 File.join(dir, File.basename(source, '.*') + '.rbc')
54 end
55
56 # Some files have load order dependencies. To specify a load order
57 # dependency, include a comment in the file that has the dependency.
58 # For example, assume files a.rb and b.rb, where a.rb requires that
59 # b.rb is loaded first. In a.rb, include a comment
60 # # depends on: b.rb
61 #
62 # The 'depends on:' declaration takes a space separated list of file.
63 # When the '.load_order.txt' file is created, a topological sort
64 # (see name caveat in TSort) of the dependencies is performed
65 # so files that are depended on are loaded first.
66 #
67 # If there is a 'depends on:' declarations for a non-existent file,
68 # or if there are cyclic dependencies, this method will not create
69 # the '.load_order.txt' file.
70
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
71 def create_load_order(files, output=".load_order.txt")
da5f9e6 @brixen Added load-order dependency generation to rake build:(core|platform) tas...
brixen authored
72 d = Hash.new { |h,k| h[k] = [] }
73
74 # assume all the files are in the same directory
75 dir = File.dirname(files.first)
76 files.each do |fname|
77 name = source_name(fname)
78 File.open(File.join(dir, name), "r") do |f|
79 f.each do |line|
80 if m = /#\s*depends on:\s*(.*)/.match(line)
81 m[1].split.each { |dep| d[name] << dep }
82 end
83 end
84 end
85 end
86
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
87 File.open(output, "w") do |f|
da5f9e6 @brixen Added load-order dependency generation to rake build:(core|platform) tas...
brixen authored
88 begin
8634917 @evanphx Load order files are now in alphabetical order if there are no other dep...
evanphx authored
89 if d.empty?
90 list = files.sort
91 else
92 list = d.tsort
93 end
94
95 f.puts list.collect { |n| compiled_name(n, dir) }.join("\n")
da5f9e6 @brixen Added load-order dependency generation to rake build:(core|platform) tas...
brixen authored
96 rescue IndexError
97 puts "Unable to generate '.load_order.txt'"
98 puts "Most likely, a file includes a 'depends on:' declaration for a non-existent file"
99 exit 1
100 rescue TSort::Cyclic => e
101 puts "Unable to generate '.load_order.txt' due to a cyclic dependency\n (#{e.message})"
102 exit 1
103 end
104 end
105 end
106
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
107 def compile(name, output)
8634917 @evanphx Load order files are now in alphabetical order if there are no other dep...
evanphx authored
108 setup_stable
109
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
110 dir = File.dirname(output)
111 unless File.exists?(dir)
112 FileUtils.mkdir_p dir
113 end
329ec45 @evanphx Loading directly from directory structure
evanphx authored
114
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
115 if @compiler
116 sh "shotgun/rubinius -I#{@compiler} compile #{name} #{output}", :verbose => false
117 else
118 sh "shotgun/rubinius compile #{name} #{output}", :verbose => false
329ec45 @evanphx Loading directly from directory structure
evanphx authored
119 end
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
120 end
329ec45 @evanphx Loading directly from directory structure
evanphx authored
121
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
122 rule ".rbc" => ".rb" do |t|
123 compile(t.source, t.name)
329ec45 @evanphx Loading directly from directory structure
evanphx authored
124 end
125
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
126 #file 'runtime/core/kernel/core/proc.rbc' => 'kernel/core/proc.rb' do |t|
127 # p t.prerequisites
128 # p t.name
129 #end
130
131 class CodeGroup
132 def initialize(files, dir, load_order=true)
133 @files = FileList[files]
134 @output = nil
135 @directory = dir
136 map(dir, load_order)
137 end
138
139 attr_reader :output
140
141 def map(dir, load_order)
142
143 unless File.exists?(dir)
144 Dir.mkdir dir
145 end
146
147 prc = proc do |t|
148 compile(t.prerequisites.first, t.name)
149 end
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
150
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
151 @output = []
329ec45 @evanphx Loading directly from directory structure
evanphx authored
152
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
153 @files.each do |source|
154 runtime = File.join(dir, source.ext("rbc"))
155 @output << runtime
156 file(runtime => source, &prc)
157 end
158
159 if load_order
160
161 lo = File.join(dir, '.load_order.txt')
162
163 file lo => @files do
164 create_load_order(@files, lo)
567d4f7 @evanphx Stack allocated lvars, GC fixes, compiler changes, oh my!
evanphx authored
165 end
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
166
167 @output << lo
6b9c27b Complete rspec coverage of subtend string compat to date.
Kev authored
168 end
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
169
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
170 return @output
cdfdc27 Added my idea of a sanity check against MRI for compatibility purposes
Mae authored
171 end
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
172
173 def clean
174 sh "find #{@directory} -name '*.rbc' -delete"
086f889 * bin/specrunner is a small bash kludge for running mini_rspec over
Eero Saynatkari authored
175 end
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
176 end
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
177
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
178 Core = CodeGroup.new 'kernel/core/*.rb', 'runtime/core'
179 Bootstrap = CodeGroup.new 'kernel/bootstrap/*.rb', 'runtime/bootstrap'
180 Platform = CodeGroup.new 'kernel/platform/*.rb', 'runtime/platform'
181 Compiler = CodeGroup.new 'compiler/**/*.rb', 'runtime', false
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
182
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
183 file 'runtime/loader.rbc' => 'kernel/loader.rb' do
184 compile 'kernel/loader.rb', 'runtime/loader.rbc'
4d4f6fa @brixen Added namespaces to the Rakefile with aliases to the old tasks.
brixen authored
185 end
186
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
187 AllPreCompiled = Core.output + Bootstrap.output + Platform.output + Compiler.output
188 AllPreCompiled << "runtime/loader.rbc"
189
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
190 # spec tasks
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
191 desc "Run all 'known good' specs (task alias for spec:ci)"
8b118bf Removed legacy rake tasks
Brian Ford authored
192 task :spec => 'spec:ci'
d0e6b65 @brixen changes to support better CI specs
brixen authored
193
03dfae6 @brixen Added rake task spec:ci. added svn:executable for bin/mspec. enhanced re...
brixen authored
194 namespace :spec do
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
195 namespace :setup do
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
196 # Setup for 'Subtend' specs. No need to call this yourself.
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
197 task :subtend do
ed682b8 @mkhl Fix rake spec:subtend:setup.
mkhl authored
198 Dir["spec/subtend/**/Rakefile"].each do |rakefile|
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
199 sh "rake -f #{rakefile}"
200 end
201 end
202 end
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
203
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
204 desc "Run continuous integration examples"
03dfae6 @brixen Added rake task spec:ci. added svn:executable for bin/mspec. enhanced re...
brixen authored
205 task :ci do
c7d623e @brixen enhanced spec:ci to take a target on the command line, invoke like: SPEC...
brixen authored
206 target = ENV['SPEC_TARGET'] || 'rbx'
207 system %(shotgun/rubinius -e 'puts "rbx build: \#{Rubinius::BUILDREV}"') if target == 'rbx'
4ef0b9f @brixen Updated exclusion list for CI specs.
brixen authored
208 sh "bin/ci -t #{target}"
03dfae6 @brixen Added rake task spec:ci. added svn:executable for bin/mspec. enhanced re...
brixen authored
209 end
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
210
8b118bf Removed legacy rake tasks
Brian Ford authored
211 spec_targets = %w(compiler core language library parser rubinius)
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
212 # Build a spec:<task_name> for each group of Rubinius specs
213 spec_targets.each do |group|
214 desc "Run #{group} examples"
d08e789 @brixen fixed typo. bad typo. that's a no.
brixen authored
215 task group do
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
216 sh "bin/mspec spec/#{group}"
217 end
218 end
219
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
220 desc "Run subtend (Rubinius C API) examples"
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
221 task :subtend => "spec:setup:subtend" do
d0e6b65 @brixen changes to support better CI specs
brixen authored
222 sh "bin/mspec spec/rubinius/subtend"
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
223 end
224
225 # Specdiffs to make it easier to see what your changes have affected :)
226 desc 'Run specs and produce a diff against current base'
227 task :diff => 'diff:run'
228
229 namespace :diff do
230 desc 'Run specs and produce a diff against current base'
231 task :run do
d0e6b65 @brixen changes to support better CI specs
brixen authored
232 system 'bin/mspec -f ci -o spec/reports/specdiff.txt spec'
233 system 'diff -u spec/reports/base.txt spec/reports/specdiff.txt'
234 system 'rm spec/reports/specdiff.txt'
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
235 end
236
237 desc 'Replace the base spec file with a new one'
238 task :replace do
d0e6b65 @brixen changes to support better CI specs
brixen authored
239 system 'bin/mspec -f ci -o spec/reports/base.txt spec'
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
240 end
241 end
d630d96 Rakefile now supports rake report:all which runs all of the reports. All...
Ryantm authored
242
243 task :r2r do
244 puts ARGV.inspect
245 end
03dfae6 @brixen Added rake task spec:ci. added svn:executable for bin/mspec. enhanced re...
brixen authored
246 end
247
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
248 desc "Build everything that needs to be built"
249 task :build => ['build:all']
6e51eee @brixen put guards on imcompatible specs to prevent ruby, jruby from running the...
brixen authored
250
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
251 desc "Recompile all ruby system files"
252 task :rebuild => ['clean:rbc', 'clean:shotgun', 'build:all']
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
253
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
254 desc "Remove all ruby system files"
255 task :distclean => 'clean:rbc'
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
256
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
257 desc "Remove all stray compiled Ruby files"
258 task :pristine do
259 FileList['**/*.rbc'].each do |fn|
260 next if /^runtime/.match(fn)
261 FileUtils.rm fn rescue nil
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
262 end
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
263 end
5468980 @evanphx kernel/ reorg! New functionality goes in kernel/core only. kernel.rba ha...
evanphx authored
264
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
265 namespace :clean do
266
267 desc "Remove all compile system ruby files (runtime/)"
268 task :rbc do
269 AllPreCompiled.each do |f|
270 File.unlink f rescue nil
dc16b49 @wilson * Near-total rewrite of the Rakefile. Tasks that use rcompile are in the...
wilson authored
271 end
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
272 end
5468980 @evanphx kernel/ reorg! New functionality goes in kernel/core only. kernel.rba ha...
evanphx authored
273
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
274 desc "Cleans up VM building site"
275 task :shotgun do
276 sh "make clean"
277 end
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
278 end
404f8ab Don't call configure on build:shotgun everytime.
Tilman authored
279
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
280 namespace :build do
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
281
282 task :all => ["build:shotgun", "build:rbc"]
283
284 # This nobody rule lets use use all the shotgun files as
285 # prereqs. This rule is run for all those prereqs and just
286 # (obviously) does nothing, but it makes rake happy.
287 rule '^shotgun/.+' do
288 end
289
290 c_source = FileList["shotgun/lib/*.[ch]", "shotgun/main.c",
291 "shotgun/lib/*.rb", "shotgun/lib/subtend/*.[chS]"]
292
293 file "shotgun/rubinius.bin" => c_source do
294 sh "make vm"
295 end
296
297 task :extensions do
298 sh "make exts"
299 end
300
404f8ab Don't call configure on build:shotgun everytime.
Tilman authored
301 file "shotgun/config.h" do
dc16b49 @wilson * Near-total rewrite of the Rakefile. Tasks that use rcompile are in the...
wilson authored
302 sh "./configure"
303 raise 'Failed to configure Rubinius' unless $?.success?
3751f33 @evanphx * Reworked the Rakefile to build the compiler by detection, like bootstr...
evanphx authored
304 end
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
305
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
306 task :configure => ["shotgun/config.h"]
970dca2 @wilson Rakefile cleanup. Removed some tasks, renamed others. rake -T for detail...
wilson authored
307
dc16b49 @wilson * Near-total rewrite of the Rakefile. Tasks that use rcompile are in the...
wilson authored
308 desc "Compiles shotgun (the C-code VM)"
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
309 task :shotgun => [:configure, "shotgun/rubinius.bin"]
310
311 task :setup_rbc do
329ec45 @evanphx Loading directly from directory structure
evanphx authored
312 setup_stable
34ad791 * Disabled Lightning's dissembler on amd64
Eero Saynatkari authored
313 end
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
314
315 task :rbc => ([:setup_rbc] + AllPreCompiled)
316
317 task :core => :rbc do
318 puts "OBSOLETE. Use 'rake build'"
6001be6 @evanphx loader.rb is now seperated from bootstrap and core.
evanphx authored
319 end
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
320
321 task :bootstrap => :rbc do
322 puts "OBSOLETE. Use 'rake build'"
e8b73c6 @wilson * Added build:delete_rbc task to clean up all rbc files, everywhere.
wilson authored
323 end
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
324
325 task :platform => :rbc do
326 puts "OBSOLETE. Use 'rake build'"
541bcb5 @evanphx Complete reorganization of bootstrap. Addition of kernel/platform. FFI f...
evanphx authored
327 end
4638b74 @evanphx Vast rework of the Rakefile and build process
evanphx authored
328
329 task :loader => :rbc do
330 puts "OBSOLETE. Use 'rake build'"
9e24421 @wilson * Use a random pivot point for better worst-case Array#sort performance
wilson authored
331 end
332 end
333
121d2bb @evanphx A little magic for a more bulletproof process. Run rake dev:setup after ...
evanphx authored
334 # dev tasks
335 namespace :dev do
b4e6651 @wilson Give rake dev:setup a better description
wilson authored
336 desc "Make a snapshot of the runtime files for your own safety"
121d2bb @evanphx A little magic for a more bulletproof process. Run rake dev:setup after ...
evanphx authored
337 task :setup do
329ec45 @evanphx Loading directly from directory structure
evanphx authored
338 puts "OBSOLETE. You no longer need to do this."
121d2bb @evanphx A little magic for a more bulletproof process. Run rake dev:setup after ...
evanphx authored
339 end
340 end
341
Something went wrong with that request. Please try again.