Skip to content

Commit

Permalink
Added namespaces to the Rakefile with aliases to the old tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Dec 14, 2006
1 parent befcaac commit 4d4f6fa
Showing 1 changed file with 233 additions and 85 deletions.
318 changes: 233 additions & 85 deletions Rakefile
@@ -1,128 +1,276 @@
desc "Rebuild shotgun from scratch" task :default => :spec
task :build => [:clean, :ensure_syd, :shotgun, :bk]


desc "Run shotgun's core tests" desc "Run all specs and tests."
task :test_shotgun => [:code_cache] do task :spec do
system("ruby test/tc_all.rb shotgun-tests") Rake::Task['spec:all'].invoke rescue got_error = true

raise "Spec or test failures." if got_error
end end


desc "Run rubinius's 1.8.* tests" namespace :spec do
desc "Run all specs and tests."
task :all do
Rake::Task['spec:lang'].invoke rescue got_error = true
Rake::Task['test:all'].invoke rescue got_error = true

raise "Spec or test failures." if got_error
end

desc "Run the language specs."
task :lang do
end

desc "Run the shotgun specs."
task :shotgun do
end

end

namespace :test do
desc "Run all tests."
task :all do
Rake::Task['test:core'].invoke rescue got_error = true
Rake::Task['test:shotgun'].invoke rescue got_error = true

raise "Test failures." if got_error
end

desc "Run rubinius's 1.8.* tests"
task :core do
system("ruby -Ilib test/tc_all.rb")
end

desc "Run shotgun's core tests."
task :shotgun => ['test:setup:code_cache'] do
system("ruby test/tc_all.rb shotgun-tests")
end

namespace :setup do
desc "Prepare the code-cache directory"
task :code_cache do
Dir.mkdir "code-cache" unless File.exists?("code-cache")
FileUtils.rm Dir.glob("code-cache/*")
end
end
end

"Rebuild the whole project"
task :build => 'build:all'

namespace :build do
desc "Rebuild shotgun from scratch"
task :all => ['build:clean', 'setup:syd', 'build:shotgun', 'build:bk']

desc "Cleanup build files."
task :clean do
FileUtils.rm_rf 'code-cache'
FileUtils.rm Dir.glob('lib/kernel.rb*')
`cd shotgun;make clean;cd ..`
end

task :setup do
sh "ruby bin/rcc"
end

namespace :setup do
desc "Ensure that the correct version of the sydparse gem is installed."
task :syd do
require 'rubygems'
begin
require_gem 'sydparse', '>= 1.2.1'
rescue Gem::LoadError
puts "\nYour system does not have the required sysparse gem installed...\n"
Rake::Task['syd'].invoke
raise "Gem 'sydparse' must be installed from externals/syd-parser/pkg directory. Then re-run 'rake build'."
end
end

# Combine the separate .rb files in lib into a single kernel.rb
task :kernel do
fd = File.open("lib/kernel.rb", "w")
Dir["kernel/*.rb"].sort.each do |path|
next if File.basename(path) == "__loader.rb"
puts path
cur = File.open(path)
fd << cur.read
cur.close
fd << "\n"
end

Dir["kernel/core/*.rb"].each do |path|
puts path
fd << File.read(path)
fd << "\n"
end

fd << File.read("kernel/__loader.rb")
fd.close
end
end

task :fields do
$:.unshift "lib"
require 'types'
fd = File.open("kernel/00auto_fields.rb", "w")
Rubinius::Types.each do |name, mod|
next if mod::TotalFields.size == 0
sname = mod.name.split("::").last
fd.puts "class #{sname}"
idx = 0
str = []
mod::TotalFields.each do |fel|
if fel == :instance_variables
fel = :__ivars__
end
str << [":#{fel} => #{idx}"]
# fd.puts "index_accessor :#{fel}, #{idx}"
fd.puts " def #{fel}; Ruby.asm \"push self\\npush #{idx}\\nfetch_field\"; end"
idx += 1
end
fd.puts " ivar_as_index #{str.join(", ")}"
fd.puts "end"
end
fd.close
end

desc "Build shotgun C components."
task :shotgun => 'build:setup' do
system("make -C shotgun rubinius")
end

desc "Build the kernel."
task :kernel => 'build:setup:kernel' do
puts "Compiling kernel.rb..."
`bin/rcompile lib/kernel.rb`
end

desc "Build the kernel."
task :bk => 'build:kernel'

desc "Build syd-parser."
task :syd do
puts "Building externals/syd-parser gem...\n"
system("cd externals/syd-parser; rake gem")
puts "\nNow do 'gem install externals/syd-parser/pkg/*.gem' as your gem superuser.\n\n"
end
end

namespace :doc do
desc "Learn how to contribute."
task :contrib => 'doc:contrib:easy'

namespace :contrib do
desc "Find out about easy ways to contribute."
task :easy do
puts <<-EOM
The Rubinius team welcomes contributions, bug reports, test cases, and monetary support.
One possible way to help is:
1. Add a test for a Ruby core method.
2. Go to the appropriately-named file in the 'kernel' directory.
3. Implement that method in Ruby.
4. Run the tests until they pass. :)
The 'ri' command is a rich source of examples and test cases.
EOM
end

desc "Find out about ways to contribute that may require a lot of knowledge or work."
task :hard do
puts "More to come. For now, just make everything work faster than anything else in the world."
end
end
end

namespace :svk do
task :push do
sh 'svk push --verbatim'
end
end

# Deprecated rake tasks
def deprecate(msg)
puts "Deprecated. Please use #{msg}."
end

desc "DEPRECATED: Run shotgun's core tests"
task :test_shotgun do
deprecate 'test:shotgun'
Rake::Task['test:shotgun'].invoke
end

desc "DEPRECATED: Run rubinius's 1.8.* tests"
task :test do task :test do
system("ruby -Ilib test/tc_all.rb") deprecate 'test:core'
Rake::Task['test:core'].invoke
end end


desc "Run all the tests" desc "DEPRECATED: Run all the tests"
task :test_all => [:test, :test_shotgun] task :test_all do
deprecate 'test:all'
Rake::Task['test:all'].invoke
end


# This forces ruby inline to build everything in the # This forces ruby inline to build everything in the
# right place. # right place.
task :setup do task :setup do
sh "ruby bin/rcc" deprecate 'build:setup'
Rake::Task['build:setup'].invoke
end end


desc "Build shotgun C components" desc "DEPRECATED: Build shotgun C components"
task :shotgun => [:setup] do task :shotgun do
system("make -C shotgun rubinius") deprecate 'build:shotgun'
Rake::Task['build:shotgun'].invoke
end end


desc "Prepare the code-cache directory" desc "DEPRECATED: Prepare the code-cache directory"
task :code_cache do task :code_cache do
Dir.mkdir "code-cache" unless File.exists?("code-cache") deprecate 'test:setup:code-cache'
FileUtils.rm Dir.glob("code-cache/*") Rake::Task['test:setup:code-cache'].invoke
end end


desc "Ensure that the correct version of the sydparse gem is installed." desc "DEPRECATED: Ensure that the correct version of the sydparse gem is installed."
task :ensure_syd do task :ensure_syd do
require 'rubygems' deprecate 'build:setup:syd'
begin Rake::Task['build:setup:syd'].invoke
require_gem 'sydparse', '>= 1.2.1'
rescue Gem::LoadError
puts "\nYour system does not have the required sysparse gem installed...\n"
Rake::Task['syd'].invoke
raise "Gem 'sydparse' must be installed from externals/syd-parser/pkg directory. Then re-run 'rake build'."
end
end end


desc "Build syd-parser." desc "DEPRECATED: Build syd-parser."
task :syd do task :syd do
puts "Building externals/syd-parser gem...\n" deprecate 'build:syd'
system("cd externals/syd-parser; rake gem") Rake::Task['build:syd'].invoke
puts "\nNow do 'gem install externals/syd-parser/pkg/*.gem' as your gem superuser.\n\n"
end end


task :fields do task :fields do
$:.unshift "lib" deprecate 'build:fields'
require 'types' Rake::Task['build:fields'].invoke
fd = File.open("kernel/00auto_fields.rb", "w")
Rubinius::Types.each do |name, mod|
next if mod::TotalFields.size == 0
sname = mod.name.split("::").last
fd.puts "class #{sname}"
idx = 0
str = []
mod::TotalFields.each do |fel|
if fel == :instance_variables
fel = :__ivars__
end
str << [":#{fel} => #{idx}"]
# fd.puts "index_accessor :#{fel}, #{idx}"
fd.puts " def #{fel}; Ruby.asm \"push self\\npush #{idx}\\nfetch_field\"; end"
idx += 1
end
fd.puts " ivar_as_index #{str.join(", ")}"
fd.puts "end"
end
fd.close
end end


# Combine the separate .rb files in lib into a single kernel.rb # Combine the separate .rb files in lib into a single kernel.rb
task :kernel do task :kernel do
fd = File.open("lib/kernel.rb", "w") deprecate 'build:setup:kernel'
Dir["kernel/*.rb"].sort.each do |path| Rake::Task['build:setup:kernel'].invoke
next if File.basename(path) == "__loader.rb"
puts path
cur = File.open(path)
fd << cur.read
cur.close
fd << "\n"
end

Dir["kernel/core/*.rb"].each do |path|
puts path
fd << File.read(path)
fd << "\n"
end

fd << File.read("kernel/__loader.rb")
fd.close
end end


# Build the kernel # Build the kernel
task :bk => [:kernel] do task :bk do
puts "Compiling kernel.rb..." deprecate 'build:bk'
`bin/rcompile lib/kernel.rb` Rake::Task['build:kernel'].invoke
end end


task :clean do task :clean do
FileUtils.rm_rf 'code-cache' deprecate 'build:clean'
FileUtils.rm Dir.glob('lib/kernel.rb*') Rake::Task['build:clean'].invoke
`cd shotgun;make clean;cd ..`
end end


task :push do task :push do
sh 'svk push --verbatim' deprecate 'svk:push'
Rake::Task['svk:push'].invoke
end end


desc "DEPRECATED: Alias for doc:contrib:easy."
task :find_low_hanging_fruit do task :find_low_hanging_fruit do
puts <<-EOM deprecate 'doc:contrib:easy'
The Rubinius team welcomes contributions, bug reports, test cases, and monetary support. Rake::Task['doc:contrib:easy'].invoke
One possible way to help is:
1. Add a test for a Ruby core method.
2. Go to the appropriately-named file in the 'kernel' directory.
3. Implement that method in Ruby.
4. Run the tests until they pass. :)
The 'ri' command is a rich source of examples and test cases.
EOM
end end


# vim: syntax=ruby # vim: syntax=ruby

0 comments on commit 4d4f6fa

Please sign in to comment.