Permalink
Browse files

Add precompile task

  • Loading branch information...
1 parent d4db544 commit 46b6e4d915ae3fb8ae74621af2786ec1fa2cea81 @drbrain drbrain committed Oct 6, 2008
Showing with 21 additions and 6 deletions.
  1. +17 −1 Rakefile
  2. +4 −5 rakelib/kernel.rake
View
@@ -24,7 +24,7 @@ task :compile_ruby, :file do |task, args|
end
task :compile_ruby => 'kernel:build' # HACK argument + dependency is broken
-desc "Run the given ruby fil ewith the vm"
+desc "Run the given ruby file with the vm"
task :run_ruby, :file do |task, args|
file = args[:file]
raise ArgumentError, 'compile_ruby requires a file name' if file.nil?
@@ -40,6 +40,22 @@ task :run_ruby, :file do |task, args|
end
task :run_ruby => %w[kernel:build vm/vm] # HACK argument + dependency is broken
+desc "Compile files with MRI because vm takes forever to do it"
+task :precompile => %w[extensions] do
+ FileList['lib/**/*.rb'].each do |rb|
+ next unless File.file? rb
+
+ rbc = "#{rb}c"
+
+ if File.exist? rbc then
+ rbc_mtime = File.mtime rbc
+ next if rbc_mtime >= COMPILER_MTIME or rbc_mtime >= File.mtime(rb)
+ end
+
+ mri_compile rb, rbc
+ end
+end
+
# BUILD TASKS
# task :stable_compiler do
View
@@ -126,10 +126,11 @@ rule ".rbc" do |t|
compile_ruby src, rbc
end
-compiler_sources = Dir["lib/compiler/*.rb"] + %w(lib/strscan.rb lib/stringio.rb lib/racc/parser.rb)
+COMPILER_SOURCES = Dir["lib/compiler/*.rb"] + %w(lib/strscan.rb lib/stringio.rb lib/racc/parser.rb)
+COMPILER_MTIME = COMPILER_SOURCES.map { |f| File::Stat.new(f).mtime }.max
compiler = []
-compiler_sources.each do |rb|
+COMPILER_SOURCES.each do |rb|
compiler << "#{rb}c"
file "#{rb}c" => rb do
compile_ruby rb, "#{rb}c"
@@ -141,15 +142,13 @@ task :kernel => 'kernel:build'
namespace :kernel do
task :check_compiler do
- compiler_mtime = compiler_sources.map { |f| File::Stat.new(f).mtime }.max
-
kernel_mtime = all_kernel.select do |f|
f =~ /rbc$/ and File.exist? f
end.map do |f|
File::Stat.new(f).mtime
end.min
- Rake::Task['kernel:clean'].invoke if !kernel_mtime or compiler_mtime > kernel_mtime
+ Rake::Task['kernel:clean'].invoke if !kernel_mtime or COMPILER_MTIME > kernel_mtime
end
task :show do

0 comments on commit 46b6e4d

Please sign in to comment.