Permalink
Browse files

Added rake install and rake uninstall tasks.

  • Loading branch information...
1 parent 773527d commit 0e1df2fedd06ba80f69dbf8fe1f0ec868e228770 Brian Ford committed Nov 28, 2008
Showing with 92 additions and 18 deletions.
  1. +71 −6 Rakefile
  2. +1 −1 kernel/delta/string.rb
  3. +6 −1 kernel/loader.rb
  4. +6 −2 rakelib/configuration.rb
  5. +2 −0 rakelib/configure.rake
  6. +6 −8 rakelib/vm.rake
View
@@ -11,9 +11,6 @@ RUBINIUS_BASE = File.expand_path(File.dirname(__FILE__))
$: << "lib"
-# require 'tsort'
-# require 'rakelib/rubinius'
-
task :default => %w[build vm:test spec:sydney]
desc "Compile the given ruby file into a .rbc file"
@@ -81,6 +78,74 @@ task :distclean => %w[
vm:distclean
]
+def install_bin
+ File.join RBX_BINPATH, 'rbx'
+end
+
+desc "Uninstall Rubinius"
+task :uninstall do
+ rm_rf install_bin
+ rm_rf RBX_BASE_PATH
+end
+
+desc "Install Rubinius"
+task :install => %w[
+ clean
+ install:build
+ install:files
+] do
+ sh "rake clean"
+ puts "Install complete."
+ puts "The install versions of files have been cleaned."
+ puts "Run 'rake build' to rebuild development versions."
+end
+
+namespace :install do
+ # Internal task, not documented with desc. Shells out
+ # to perform the build. See reason in doc/build_system.txt.
+ task :build do
+ ENV['RBX_RUNTIME'] = File.join(Dir.pwd, 'runtime')
+ sh "rake build"
+ end
+
+ # Internal task, not documented with desc. Performs the
+ # actual file installation enabling the :install task
+ # to clean up after itself.
+ task :files do
+ mkdir_p RBX_BASE_PATH, :verbose => true
+ mkdir_p RBX_RBA_PATH, :verbose => true
+ mkdir_p RBX_EXT_PATH, :verbose => true
+ mkdir_p RBX_BIN_PATH, :verbose => true
+ mkdir_p RBX_LIB_PATH, :verbose => true
+
+ install "vm/subtend/ruby.h", File.join(RBX_EXT_PATH, "ruby.h"),
+ :mode => 0644, :verbose => true
+
+ File.open File.join(RBX_EXT_PATH, "defines.h"), "w" do |f|
+ f.puts "// This file left empty"
+ end
+
+ File.open File.join(RBX_EXT_PATH, "missing.h"), "w" do |f|
+ f.puts "// This file left empty"
+ end
+
+ core_files = Rake::FileList.new('runtime/index',
+ 'runtime/platform.conf',
+ 'runtime/**/*.rb{a,c}',
+ 'runtime/**/.load_order.txt')
+ install_files core_files, RBX_RBA_PATH
+
+ lib_files = Rake::FileList.new 'lib/**/*'
+ install_files lib_files, RBX_LIB_PATH
+
+ Rake::FileList.new("#{RBX_LIB_PATH}/**/*.rb").sort.each do |rb|
+ compile_ruby rb, "#{rb}c"
+ end
+
+ install 'vm/vm', install_bin, :mode => 0755, :verbose => true
+ end
+end
+
def rbx_compile(from)
sh "bin/rbx compile -f #{from}"
end
@@ -89,18 +154,18 @@ desc 'Compare an rbc file made by MRI with one made by rbx'
task :compare, :file do |task, args|
file = args[:file]
raise "Please supply something that exists" unless File.exist? file
-
+
mri_compile file, file + 'c.mri'
rbx_compile file
-
+
File.open(file + 'c.mri') do |mri|
File.open(file + 'c') do |rbx|
while m = mri.gets and r = rbx.gets
puts "Line of Failure: #{rbx.lineno}" and break unless m === r
end
end
end
-
+
end
namespace :clean do
View
@@ -46,6 +46,6 @@ def to_sexp_ruby_parser(name="(eval)", line = 1, lit_rewriter=true)
end
def to_sexp(name="(eval)", line=1, rewriter=true)
- to_sexp_ruby_parser name, line, rewriter
+ to_sexp_sydney_parser name, line, rewriter
end
end
View
@@ -2,6 +2,7 @@
begin
ENV = EnvironmentVariables.new
+ String.ruby_parser if ENV['RUBY_PARSER']
String.sydney_parser if ENV['SYDNEY'] or ENV['SYDPARSE']
# define a global "start time" to use for process calculation
@@ -36,8 +37,12 @@
# Setup $LOAD_PATH.
+# Add a fallback directory if Rubinius::LIB_PATH doesn't exist
+lib_path = File.expand_path(Rubinius::LIB_PATH)
+lib_path = File.join(Dir.pwd, 'lib') unless File.exists?(lib_path)
+
additions = []
-additions << File.expand_path("#{Rubinius::BASE_PATH}/lib")
+additions << lib_path
# The main stdlib location
# HACK todo remove this comment when we're setting this constant in the VM
View
@@ -15,24 +15,28 @@
# We assume that if ENV['PREFIX'] is set, we are building in
# install mode, otherwise development mode. For more details,
# see doc/build_system.txt.
-if ENV['PREFIX']
+if Rake.application.top_level_tasks.grep(/install/)
+ ENV['PREFIX'] = "/usr/local" unless ENV['PREFIX']
RBX_PREFIX = ENV['PREFIX']
RBX_BINPATH = "#{RBX_PREFIX}/bin"
RBX_LIBPATH = "#{RBX_PREFIX}/lib"
RBX_BASE_PATH = "#{RBX_PREFIX}/lib/rubinius/#{RBX_LIBVER}"
+ RBX_EXT_PATH = "#{RBX_BASE_PATH}/#{RBX_HOST}"
else
RBX_PREFIX = Dir.pwd
RBX_BASE_PATH = RBX_PREFIX
RBX_BINPATH = "#{RBX_BASE_PATH}/bin"
RBX_LIBPATH = "#{RBX_BASE_PATH}/vm"
+ RBX_EXT_PATH = "#{RBX_BASE_PATH}/#{RBX_LIBVER}/#{RBX_HOST}"
end
# RubyGems is already using Rubinius::CODE_PATH so we will
# continue to support it, although BASE_PATH is probably
# a better description.
RBX_CODE_PATH = RBX_BASE_PATH
RBX_RBA_PATH = "#{RBX_BASE_PATH}/runtime"
-RBX_EXT_PATH = "#{RBX_BASE_PATH}/#{RBX_LIBVER}/#{RBX_HOST}"
+RBX_BIN_PATH = "#{RBX_BASE_PATH}/bin"
+RBX_LIB_PATH = "#{RBX_BASE_PATH}/lib"
case RBX_HOST
when /darwin9/
View
@@ -240,6 +240,8 @@ module Rubinius
CODE_PATH = #{RBX_CODE_PATH.inspect}
EXT_PATH = #{RBX_EXT_PATH.inspect}
RBA_PATH = #{RBX_RBA_PATH.inspect}
+ BIN_PATH = #{RBX_BIN_PATH.inspect}
+ LIB_PATH = #{RBX_LIB_PATH.inspect}
RBX_VERSION = #{RBX_VERSION.inspect}
end
View
@@ -50,6 +50,8 @@ INSN_GEN = %w[ vm/gen/iseq_instruction_names.cpp
vm/gen/iseq_instruction_size.gen
vm/test/test_instructions.hpp ]
TYPE_GEN = %w[ vm/gen/includes.hpp
+ vm/gen/kind_of.hpp
+ vm/gen/object_types.hpp
vm/gen/typechecks.gen.cpp
vm/gen/primitives_declare.hpp
vm/gen/primitives_glue.gen.cpp ]
@@ -135,14 +137,10 @@ INCLUDES = EX_INC + %w[/usr/local/include vm/test/cxxtest vm .]
INCLUDES.map! { |f| "-I#{f}" }
# Default build options
-def add_directory_defines(flags)
- flags.delete_if { |f| /^-D(RBA|BASE)_PATH/ =~ f }
- flags << %[-DBASE_PATH=\\"#{RBX_BASE_PATH}\\"]
- flags << %[-DRBA_PATH=\\"#{RBX_RBA_PATH}\\"]
-end
-
-FLAGS = %W[ -pipe -Wall -Wno-deprecated ]
-add_directory_defines FLAGS
+FLAGS = %W[ -pipe -Wall -Wno-deprecated
+ -DBASE_PATH=\\"#{RBX_BASE_PATH}\\"
+ -DRBA_PATH=\\"#{RBX_RBA_PATH}\\"
+ ]
if RUBY_PLATFORM =~ /darwin/i && `sw_vers` =~ /10\.4/
FLAGS.concat %w(-DHAVE_STRLCAT -DHAVE_STRLCPY)

0 comments on commit 0e1df2f

Please sign in to comment.