From 243a775196160302c623a82e93361e0b423b84b7 Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Mon, 23 Nov 2009 21:31:57 -0800 Subject: [PATCH] Reworked configuring tasks. The ./configure script is the root of the configuration data tree. All basic configuration values should be defined by running this script. The data flows out to two primary places: ./config.rb and vm/gen/config.h. The data in config.rb can be loaded to access configuration values in e.g. rake tasks. The data in vm/gen/config.h is used to set the fundamental constants in the VM. All other configuration data is derived from these two locations. For example, lib/rbconfig.rb values are derived from the basic path constants defined via config.h. --- .gitignore | 3 - Rakefile | 7 +- configure | 169 +++++++--- .../bootstrap/{config.rb => configuration.rb} | 0 kernel/bootstrap/load_order.txt | 4 +- kernel/delta/load_order.txt | 1 + kernel/delta/rubinius.rb | 2 +- kernel/delta/ruby_constants.rb | 13 + kernel/loader.rb | 14 +- lib/rbconfig.rb | 195 ++++++++++++ lib/rubygems/defaults/rbx.rb | 11 +- rakelib/configuration.rb | 80 ----- rakelib/configure.rake | 291 ------------------ rakelib/kernel.rake | 9 +- rakelib/release.rake | 2 +- rakelib/vm.rake | 26 +- spec/library/config/rbconfig_spec.rb | 15 +- vm/agent.cpp | 2 + vm/config.h | 1 + vm/drivers/cli.cpp | 4 +- vm/environment.cpp | 6 +- vm/ontology.cpp | 102 ++---- 22 files changed, 416 insertions(+), 541 deletions(-) rename kernel/bootstrap/{config.rb => configuration.rb} (100%) create mode 100644 kernel/delta/ruby_constants.rb create mode 100644 lib/rbconfig.rb delete mode 100644 rakelib/configuration.rb delete mode 100644 rakelib/configure.rake diff --git a/.gitignore b/.gitignore index 0feed14e5d..1ff81a0a9a 100644 --- a/.gitignore +++ b/.gitignore @@ -62,15 +62,12 @@ tmtags /vm/log /vm/.deps -/kernel/bootstrap/rubinius_config.rb -/kernel/bootstrap/ruby_config.rb /kernel/delta/signature.rb /lib/compiler/opcodes.rb /lib/etc.rb /lib/kernel.rb -/lib/rbconfig.rb /lib/zlib.rb /lib/fcntl.rb /lib/openssl/digest.rb diff --git a/Rakefile b/Rakefile index f67e4d50ea..f006607185 100644 --- a/Rakefile +++ b/Rakefile @@ -9,6 +9,12 @@ if !$verbose and respond_to?(:verbose) verbose(false) if verbose() == :default end +unless File.exists?(File.expand_path("../config.rb", __FILE__)) and + File.exists?(File.expand_path("../vm/gen/config.h", __FILE__)) + STDERR.puts "Please run ./configure first" + exit 1 +end + $dlext = Config::CONFIG["DLEXT"] $compiler = nil @@ -76,7 +82,6 @@ task :clean => %w[ kernel:clean clean:crap extensions:clean - configure:clean ] desc 'Remove rubinius build files and external library build files' diff --git a/configure b/configure index 94316d3278..c5e6c053a7 100755 --- a/configure +++ b/configure @@ -1,5 +1,6 @@ #!/usr/bin/env ruby +require 'rbconfig' require 'tempfile' root = File.expand_path File.dirname(__FILE__) @@ -9,22 +10,51 @@ require File.join(root, "kernel", "delta", "options") class Configure def initialize(root) + @defines = [] @config = File.join(root, "config.rb") - @llvm = :no - @llvm_path = nil + # LLVM settings + @llvm = :no + @llvm_path = nil @llvm_configure = nil - @prefix = nil - @defines = [] - - @llvm_svn_dir = File.join(root, "vm", "external_libs", "llvm") + @llvm_svn_dir = File.join(root, "vm", "external_libs", "llvm") + + # File system paths + @bindir = root + "/bin" + @includedir = root + "/vm/capi" + @libdir = root + @mandir = root + "/man" + @gemsdir = root + "/gems" + @program_name = "rbx" + + # Essential settings + @libversion = "0.13" + @version = "#{@libversion}.0" + + if File.directory? root + "/.git" + @buildrev = `git rev-list --all | head -n1`.chomp + else + @buildrev = "release" + end - o = Rubinius::Options.new "Usage: configure [options]", 40 + # TODO: conditionalize for Windows + @host = `./rakelib/config.guess`.chomp + /([^-]+)-([^-]+)-(.*)/ =~ @host + @cpu, @vendor, @os = $1, $2, $3 - o.on "-h", "--help", "Display this help" do - puts o - exit 1 + # TODO: add conditionals for platforms + if Config::CONFIG["build_os"] =~ /darwin/ + @ldshared = "cc -dynamic -bundle -undefined suppress -flat_namespace" + else + @ldshared = "cc -shared" end + end + + def options + o = Rubinius::Options.new "Usage: configure [options]", 30 + o.left_align + + o.doc " LLVM settings" o.on("--enable-llvm", "[MODE]", "Build with LLVM") do |which| @@ -35,14 +65,54 @@ class Configure @llvm_path = dir end - o.on "--prefix", "PATH", "Where to install Rubinius" do |dir| - @prefix = dir + o.on "--update-prebuilt", "Update prebuilt LLVM packages from the internet" do + update_prebuilt end - o.on "--update-prebuilt", "Update prebuilt packages from the internet" do - update_prebuilt + o.doc "\n File system paths for installing Rubinius" + + o.on "-P", "--prefix", "PATH", "Install Rubinius in subdirectories of PATH" do |dir| + @bindir = dir + "/bin" + @includedir = dir + "/include" + @libdir = dir + @mandir = dir + "/man" + @gemsdir = dir + "/gems" + end + + o.on "-B", "--bindir", "PATH", "Install Rubinius executable in PATH" do |dir| + @bindir = dir end + o.on "-I", "--includedir", "PATH", "Install Rubinius C-API include files in PATH" do |dir| + @includedir = dir + end + + o.on "-L", "--libdir", "PATH", "Install Ruby library in PATH" do |dir| + @libdir = dir + end + + o.on "-M", "--mandir", "PATH", "Install man pages in PATH" do |dir| + @mandir = dir + end + + o.on "-G", "--gemsdir", "PATH", "Install gems in PATH" do |dir| + @gemsdir = dir + end + + o.on "--version", "VER", "Set Rubinius version to VER (default #{@version})" do |v| + @version = v + end + + o.doc "\n Help!" + + o.on "-V", "--verbose", "Print debugging info" do + @verbose = true + end + + o.help + + o.doc "" + @options = o end @@ -240,38 +310,63 @@ class Configure detect_features end - def arch - @arch ||= `./rakelib/config.guess`.strip - end - def compiler ENV['CC'] || "gcc" end def write_config File.open @config, "w" do |f| - f.puts "module Rubinius" - f.puts "BUILD_CONFIG = {" - f.puts " :llvm => :#{@llvm}," - f.puts " :llvm_configure => '#{@llvm_configure}'," - f.puts " :arch => '#{arch()}'," - f.puts " :prefix => #{@prefix.inspect}," - f.puts " :compiler => '#{compiler}'," - if @defines.empty? - f.puts " :defines => []" - else - f.puts " :defines => ['#{@defines.join(', ')}']" - end - f.puts "}" - f.puts "end" + f.puts <<-EOC +module Rubinius + BUILD_CONFIG = { + :llvm => :#{@llvm}, + :llvm_configure => "#{@llvm_configure}", + :compiler => "#{compiler()}", + :defines => #{@defines.inspect}, + :host => "#{@host}", + :cpu => "#{@cpu}", + :vendor => "#{@vendor}", + :os => "#{@os}", + :bindir => "#{@bindir}", + :libdir => "#{@libdir}", + :includedir => "#{@includedir}", + :mandir => "#{@mandir}", + :gemsdir => "#{@gemsdir}", + :program_name => "#{@program_name}" + } +end + EOC + end + + Dir.mkdir "vm/gen" unless File.directory? "vm/gen" + + File.open "vm/gen/config.h", "w" do |f| + f.puts <<-EOC +#define RBX_HOST "#{@host}" +#define RBX_CPU "#{@cpu}" +#define RBX_VENDOR "#{@vendor}" +#define RBX_OS "#{@os}" +#define RBX_BIN_PATH "#{@bindir}" +#define RBX_GEMS_PATH "#{@gemsdir}" +#define RBX_RUNTIME "#{@libdir}/runtime" +#define RBX_LIB_PATH "#{@libdir}/lib" +#define RBX_EXT_PATH "#{@libdir}/lib/ext" +#define RBX_HDR_PATH "#{@includedir}" +#define RBX_VERSION "#{@version}" +#define RBX_LIB_VERSION "#{@libversion}" +#define RBX_BUILD_REV "#{@buildrev}" +#define RBX_LDSHARED "#{@ldshared}" + EOC end end + def run + options + parse ARGV + process + write_config + end end STDOUT.sync = true - -c = Configure.new(root) -c.parse ARGV -c.process -c.write_config +Configure.new(root).run diff --git a/kernel/bootstrap/config.rb b/kernel/bootstrap/configuration.rb similarity index 100% rename from kernel/bootstrap/config.rb rename to kernel/bootstrap/configuration.rb diff --git a/kernel/bootstrap/load_order.txt b/kernel/bootstrap/load_order.txt index 5d919a78f1..d7b5ad3f9b 100644 --- a/kernel/bootstrap/load_order.txt +++ b/kernel/bootstrap/load_order.txt @@ -6,7 +6,7 @@ channel.rbc class.rbc compactlookuptable.rbc compiled_method.rbc -config.rbc +configuration.rbc dir.rbc exception.rbc executable.rbc @@ -25,8 +25,6 @@ proc.rbc process.rbc regexp.rbc rubinius.rbc -rubinius_config.rbc -ruby_config.rbc scheduler.rbc selector.rbc sendsite.rbc diff --git a/kernel/delta/load_order.txt b/kernel/delta/load_order.txt index ace470d069..3e0596cd65 100644 --- a/kernel/delta/load_order.txt +++ b/kernel/delta/load_order.txt @@ -4,6 +4,7 @@ class.rbc exception.rbc file.rbc io.rbc +ruby_constants.rbc rubinius.rbc module.rbc filetest.rbc diff --git a/kernel/delta/rubinius.rb b/kernel/delta/rubinius.rb index 5504202d89..58e2a992ec 100644 --- a/kernel/delta/rubinius.rb +++ b/kernel/delta/rubinius.rb @@ -167,7 +167,7 @@ def self.version end - str = "rubinius #{RBX_VERSION} (#{RUBY_VERSION} #{BUILDREV[0..7]} #{RUBY_RELEASE_DATE}" + str = "rubinius #{VERSION} (#{RUBY_VERSION} #{BUILD_REV[0..7]} #{RUBY_RELEASE_DATE}" unless extra.empty? str << " #{extra}" diff --git a/kernel/delta/ruby_constants.rb b/kernel/delta/ruby_constants.rb new file mode 100644 index 0000000000..91d352621e --- /dev/null +++ b/kernel/delta/ruby_constants.rb @@ -0,0 +1,13 @@ +# Ruby constants +# +RUBY_ENGINE = "rbx" +RUBY_PLATFORM = Rubinius::HOST.dup +RUBY_VERSION = "1.8.7" +RUBY_PATCHLEVEL = 174 +RUBY_RELEASE_DATE = "2009-11-06" +RUBY_COPYRIGHT = "rubinius - Copyright (C) 2006-2009 Evan Phoenix" + +# Deprecated Ruby constants +# +VERSION = RUBY_VERSION +PLATFORM = RUBY_PLATFORM diff --git a/kernel/loader.rb b/kernel/loader.rb index c81b5384f2..e4bbac7a20 100644 --- a/kernel/loader.rb +++ b/kernel/loader.rb @@ -13,7 +13,7 @@ def initialize @run_irb = true @printed_version = false - @gem_bin = File.join Rubinius::CODE_PATH, "gems", "bin" + @gem_bin = File.join Rubinius::GEMS_PATH, "bin" end # Finish setting up after loading kernel. @@ -44,17 +44,15 @@ def preamble def system_load_path @stage = "setting up system load path" - # Add a fallback directory if Rubinius::LIB_PATH doesn't exist - @main_lib = File.expand_path(LIB_PATH) - @main_lib = File.join(Dir.pwd, 'lib') unless File.exists?(@main_lib) + @main_lib = File.expand_path(Rubinius::LIB_PATH) # This conforms more closely to MRI. It is necessary to support # paths that mkmf adds when compiling and installing native exts. additions = [] - additions << SITELIBDIR - additions << SITEARCHDIR - additions << SITEDIR - additions << RUBYLIBDIR + #additions << SITELIBDIR + #additions << SITEARCHDIR + #additions << SITEDIR + #additions << RUBYLIBDIR additions << @main_lib additions.uniq! diff --git a/lib/rbconfig.rb b/lib/rbconfig.rb new file mode 100644 index 0000000000..0400107435 --- /dev/null +++ b/lib/rbconfig.rb @@ -0,0 +1,195 @@ +module Config + unless defined? RUBY_ENGINE and RUBY_ENGINE == "rbx" then + raise "Looks like you loaded the Rubinius rbconfig, but this is not Rubinius." + end + + prefix = File.dirname(File.dirname(__FILE__)) + + CONFIG = {} + + CONFIG["prefix"] = prefix + CONFIG["install_prefix"] = '/Users/brian/devel/rubinius' + CONFIG["DLEXT"] = Rubinius::LIBSUFFIX[1..-1] + CONFIG["EXEEXT"] = "" + CONFIG["ruby_install_name"] = RUBY_ENGINE.dup + CONFIG["RUBY_INSTALL_NAME"] = RUBY_ENGINE.dup + CONFIG["exec_prefix"] = "$(prefix)" + if File.exists?(File.join(prefix, "bin", "rbx")) + CONFIG["bindir"] = "$(exec_prefix)/bin" + else + CONFIG["bindir"] = '/Users/brian/devel/rubinius/bin' + end + CONFIG["sbindir"] = "$(exec_prefix)/sbin" + CONFIG["libexecdir"] = "$(exec_prefix)/libexec" + CONFIG["datarootdir"] = "$(prefix)/share" + CONFIG["datadir"] = "$(datarootdir)" + CONFIG["sysconfdir"] = "$(prefix)/etc" + CONFIG["sharedstatedir"] = "$(prefix)/com" + CONFIG["localstatedir"] = "$(prefix)/var" + CONFIG["includedir"] = "$(prefix)/include" + CONFIG["oldincludedir"] = "/usr/include" + CONFIG["docdir"] = "$(datarootdir)/doc/$(PACKAGE)" + CONFIG["infodir"] = "$(datarootdir)/info" + CONFIG["htmldir"] = "$(docdir)" + CONFIG["dvidir"] = "$(docdir)" + CONFIG["pdfdir"] = "$(docdir)" + CONFIG["psdir"] = "$(docdir)" + CONFIG["libdir"] = "$(exec_prefix)/lib" + CONFIG["localedir"] = "$(datarootdir)/locale" + CONFIG["mandir"] = "$(datarootdir)/man" + major, minor, teeny = RUBY_VERSION.split(".") + CONFIG["MAJOR"] = major + CONFIG["MINOR"] = minor + CONFIG["TEENY"] = teeny + CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)" + CONFIG["RUBY_SO_NAME"] = "rubinius-#{Rubinius::VERSION}" + CONFIG["rubyhdrdir"] = "#{Rubinius::HDR_PATH}" + + sitedir = "#{Rubinius::LIB_PATH}/rubinius" + sitelibdir = "#{sitedir}/#{Rubinius::LIB_VERSION}" + arch = "#{Rubinius::CPU}-#{Rubinius::OS}" + + CONFIG["sitedir"] = sitedir + CONFIG["sitelibdir"] = sitelibdir + CONFIG["arch"] = arch + CONFIG["sitearch"] = arch + CONFIG["rubylibdir"] = sitelibdir + CONFIG["archdir"] = "#{sitelibdir}/#{arch}" + CONFIG["sitearchdir"] = "#{sitelibdir}/#{arch}" + CONFIG["topdir"] = File.dirname(__FILE__) + # some of these only relevant to cross-compiling + cpu = Rubinius::CPU + vendor = Rubinius::VENDOR + os = Rubinius::OS + CONFIG["build"] = "#{cpu}-#{vendor}-#{os}" + CONFIG["build_cpu"] = "#{cpu}" + CONFIG["build_vendor"] = "#{vendor}" + CONFIG["build_os"] = "#{os}" + CONFIG["host"] = "#{cpu}-#{vendor}-#{os}" + CONFIG["host_cpu"] = "#{cpu}" + CONFIG["host_vendor"] = "#{vendor}" + CONFIG["host_os"] = "#{os}" + CONFIG["target"] = "#{cpu}-#{vendor}-#{os}" + CONFIG["target_cpu"] = "#{cpu}" + CONFIG["target_vendor"] = "#{vendor}" + CONFIG["target_os"] = "#{os}" + CONFIG["build_alias"] = "" + CONFIG["host_alias"] = "" + CONFIG["target_alias"] = "" + # command line utilities + CONFIG["SHELL"] = "/bin/sh" + CONFIG["ECHO_C"] = "" + CONFIG["ECHO_N"] = "-n" + CONFIG["ECHO_T"] = "" + CONFIG["GREP"] = "/usr/bin/grep" + CONFIG["EGREP"] = "/usr/bin/grep -E" + CONFIG["RM"] = "rm -f" + CONFIG["CP"] = "cp" + CONFIG["NROFF"] = "/usr/bin/nroff" + CONFIG["MAKEDIRS"] = "mkdir -p" + # compile tools + CONFIG["CC"] = "gcc" + CONFIG["CPP"] = "gcc -E" + CONFIG["YACC"] = "bison -y" + CONFIG["RANLIB"] = "ranlib" + CONFIG["AR"] = "ar" + CONFIG["AS"] = "as" + CONFIG["WINDRES"] = "" + CONFIG["DLLWRAP"] = "" + CONFIG["OBJDUMP"] = "" + CONFIG["LN_S"] = "ln -s" + CONFIG["NM"] = "" + CONFIG["INSTALL"] = "/usr/bin/install -c" + CONFIG["INSTALL_PROGRAM"] = "$(INSTALL)" + CONFIG["INSTALL_SCRIPT"] = "$(INSTALL)" + CONFIG["INSTALL_DATA"] = "$(INSTALL) -m 644" + CONFIG["STRIP"] = "strip -A -n" + CONFIG["MANTYPE"] = "doc" + CONFIG["MAKEFILES"] = "Makefile" + # compile tools flags + CONFIG["CFLAGS"] = "-Wall -ggdb3 -O2" + CONFIG["LDFLAGS"] = "" + CONFIG["CPPFLAGS"] = "" + CONFIG["OBJEXT"] = "o" + CONFIG["GNU_LD"] = "" + CONFIG["CPPOUTFILE"] = "" + CONFIG["OUTFLAG"] = "-o " + CONFIG["YFLAGS"] = "" + CONFIG["ASFLAGS"] = "" + CONFIG["DLDFLAGS"] = "" + CONFIG["ARCH_FLAG"] = "" + CONFIG["STATIC"] = "" + CONFIG["CCDLFLAGS"] = "" + CONFIG["XCFLAGS"] = "" + CONFIG["XLDFLAGS"] = "" + CONFIG["LIBRUBY_DLDFLAGS"] = "" + CONFIG["rubyw_install_name"] = "" + CONFIG["RUBYW_INSTALL_NAME"] = "" + CONFIG["SOLIBS"] = "" + CONFIG["DLDLIBS"] = "" + CONFIG["ENABLE_SHARED"] = "" + CONFIG["MAINLIBS"] = "" + CONFIG["COMMON_LIBS"] = "" + CONFIG["COMMON_MACROS"] = "" + CONFIG["COMMON_HEADERS"] = "" + CONFIG["EXPORT_PREFIX"] = "" + CONFIG["EXTOUT"] = ".ext" + CONFIG["ARCHFILE"] = "" + CONFIG["RDOCTARGET"] = "" + CONFIG["LIBRUBY_A"] = "" + CONFIG["LIBRUBY_SO"] = "lib$(RUBY_SO_NAME).$(DLEXT)" + CONFIG["LIBRUBY_ALIASES"] = "lib$(RUBY_SO_NAME).$(DLEXT)" + CONFIG["LIBRUBY"] = "$(LIBRUBY_SO)" + CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_STATIC)" + CONFIG["LIBRUBYARG_STATIC"] = "" + CONFIG["LIBRUBYARG_SHARED"] = "-l$(RUBY_SO_NAME)" + CONFIG["configure_args"] = "" + CONFIG["ALLOCA"] = "" + CONFIG["LIBEXT"] = "a" + CONFIG["LINK_SO"] = "" + CONFIG["LIBPATHFLAG"] = " -L%s" + CONFIG["RPATHFLAG"] = "" + CONFIG["LIBPATHENV"] = "DYLD_LIBRARY_PATH" + CONFIG["TRY_LINK"] = "" + CONFIG["EXTSTATIC"] = "" + CONFIG["setup"] = "Setup" + CONFIG["PATH_SEPARATOR"] = ":" + CONFIG["PACKAGE_NAME"] = "" + CONFIG["PACKAGE_TARNAME"] = "" + CONFIG["PACKAGE_VERSION"] = "" + CONFIG["PACKAGE_STRING"] = "" + CONFIG["PACKAGE_BUGREPORT"] = "" + CONFIG["LDSHARED"] = Rubinius::LDSHARED + CONFIG["LIBRUBY_LDSHARED"] = Rubinius::LDSHARED + + # Adapted from MRI's' rbconfig.rb + MAKEFILE_CONFIG = {} + CONFIG.each { |k,v| MAKEFILE_CONFIG[k] = v.kind_of?(String) ? v.dup : v } + + def Config.expand(val, config = CONFIG) + return val unless val.kind_of? String + + val.gsub!(/\$\$|\$\(([^()]+)\)|\$\{([^{}]+)\}/) do |var| + if !(v = $1 || $2) + '$' + elsif key = config[v = v[/\A[^:]+(?=(?::(.*?)=(.*))?\z)/]] + pat, sub = $1, $2 + config[v] = false + Config.expand(key, config) + config[v] = key + key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat + key + else + var + end + end + val + end + + CONFIG.each_value do |val| + Config.expand(val) + end +end + +CROSS_COMPILING = nil unless defined? CROSS_COMPILING +RbConfig = Config diff --git a/lib/rubygems/defaults/rbx.rb b/lib/rubygems/defaults/rbx.rb index 8c25d188ec..e952f9a5f8 100644 --- a/lib/rubygems/defaults/rbx.rb +++ b/lib/rubygems/defaults/rbx.rb @@ -1,21 +1,20 @@ # Add a Rubinius platform to the platforms list. cpu = Gem::Platform.local.cpu -version = Rubinius::RBX_VERSION.split('.')[0, 2].join '.' +version = Rubinius::VERSION.split('.')[0, 2].join '.' Gem.platforms << Gem::Platform.new([cpu, 'rubinius', version]) module Gem def self.default_bindir - File.join Rubinius::CODE_PATH, "gems", "bin" + File.join Rubinius::GEMS_PATH, "bin" end def self.default_dir - File.join Rubinius::CODE_PATH, 'gems', Gem::ConfigMap[:ruby_version] + File.join Rubinius::GEMS_PATH, Gem::ConfigMap[:ruby_version] end def self.default_preinstalled_dir - version = Rubinius::RBX_VERSION.split('.')[0, 2].join '.' - pre_installed = File.join Rubinius::CODE_PATH, "gems", - "rubinius", version + version = Rubinius::VERSION.split('.')[0, 2].join '.' + pre_installed = File.join Rubinius::GEMS_PATH, "rubinius", version end def self.default_path diff --git a/rakelib/configuration.rb b/rakelib/configuration.rb deleted file mode 100644 index 61ffcb0489..0000000000 --- a/rakelib/configuration.rb +++ /dev/null @@ -1,80 +0,0 @@ -# configuration for Rubinius - -config_path = File.join(File.dirname(__FILE__), "..", "config.rb") -unless File.file?(config_path) - STDERR.puts "Please run ./configure first" - exit 1 -end - -load config_path - -RBX_DTRACE = nil -RBX_RUBY_ENGINE = 'rbx' -RBX_RUBY_VERSION = '1.8.7' -RBX_RUBY_PATCHLEVEL = 174 -RBX_RUBY_RELDATE = '2009-11-06' -RBX_LIBVER = '0.13' -RBX_VERSION = "#{RBX_LIBVER}.0" -RBX_HOST = `./rakelib/config.guess`.chomp - -if File.directory? ".git" - RBX_BUILDREV = `git rev-list --all | head -n1`.chomp -else - RBX_BUILDREV = "release" -end - -RBX_CC = Rubinius::BUILD_CONFIG[:compiler] - -# There are two ways to build Rubinius: development and install. -# We assume that if prefix is set, we are building in -# install mode, otherwise development mode. For more details, -# see doc/build_system.txt. -if prefix = Rubinius::BUILD_CONFIG[:prefix] - RBX_PREFIX = prefix - RBX_BINPATH = "#{RBX_PREFIX}/bin" - RBX_LIBPATH = "#{RBX_PREFIX}/lib" - RBX_BASE_PATH = "#{RBX_PREFIX}/lib/rubinius/#{RBX_LIBVER}" - RBX_HDR_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_HDR_PATH = "#{RBX_BASE_PATH}/vm/capi" -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_BIN_PATH = "#{RBX_BASE_PATH}/bin" -RBX_LIB_PATH = "#{RBX_BASE_PATH}/lib" -RBX_EXT_PATH = "#{RBX_BASE_PATH}/lib/ext" - -/([^-]+)-([^-]+)-(.*)/ =~ RBX_HOST -RBX_CPU, RBX_VENDOR, RBX_OS = $1, $2, $3 - -RBX_SITEDIR = "#{RBX_PREFIX}/lib/rubinius" -RBX_SITELIBDIR = "#{RBX_SITEDIR}/#{RBX_LIBVER}" -RBX_RUBYLIBDIR = RBX_SITELIBDIR -RBX_ARCH = "#{RBX_CPU}-#{RBX_OS}" -RBX_SITEARCH = RBX_ARCH -RBX_ARCHDIR = "#{RBX_RUBYLIBDIR}/#{RBX_ARCH}" -RBX_SITEARCHDIR = "#{RBX_SITELIBDIR}/#{RBX_SITEARCH}" - -case RBX_HOST -when /darwin9/ - RBX_DARWIN = 1 - RBX_DISABLE_KQUEUE = 1 -when /darwin/ - RBX_DARWIN = 1 - RBX_DISABLE_KQUEUE = 1 -when /freebsd/ - RBX_DARWIN = 0 - RBX_DISABLE_KQUEUE = 1 -else - RBX_DARWIN = 0 - RBX_DISABLE_KQUEUE = 0 -end - diff --git a/rakelib/configure.rake b/rakelib/configure.rake deleted file mode 100644 index c59361812b..0000000000 --- a/rakelib/configure.rake +++ /dev/null @@ -1,291 +0,0 @@ -# configure.rake - handles all configuration and generate needed build files - -require 'rbconfig' -require 'rakelib/configuration' - -file 'lib/rbconfig.rb' => 'rakelib/configure.rake' do - write_rbconfig -end - -def write_rbconfig - File.open 'lib/rbconfig.rb', 'w' do |f| - f.puts '#--' - f.puts '# This file was generated from rakelib/configure.rake' - f.puts '#++' - f.puts - f.puts 'module Config' - f.puts ' unless defined? RUBY_ENGINE and RUBY_ENGINE == "rbx" then' - f.puts ' raise "Looks like you loaded the Rubinius rbconfig, but this is not Rubinius."' - f.puts ' end' - f.puts - f.puts ' prefix = File.dirname(File.dirname(__FILE__))' - f.puts - f.puts ' CONFIG = {}' - f.puts - f.puts ' CONFIG["prefix"] = prefix' - f.puts " CONFIG[\"install_prefix\"] = '#{RBX_PREFIX}'" - f.puts ' CONFIG["DLEXT"] = Rubinius::LIBSUFFIX[1..-1]' - f.puts ' CONFIG["EXEEXT"] = ""' - f.puts ' CONFIG["ruby_install_name"] = RUBY_ENGINE.dup' - f.puts ' CONFIG["RUBY_INSTALL_NAME"] = RUBY_ENGINE.dup' - - f.puts ' CONFIG["exec_prefix"] = "$(prefix)"' - f.puts ' if File.exists?(File.join(prefix, "bin", "rbx"))' - f.puts ' CONFIG["bindir"] = "$(exec_prefix)/bin"' - f.puts ' else' - f.puts " CONFIG[\"bindir\"] = '#{RBX_BINPATH}'" - f.puts ' end' - f.puts ' CONFIG["sbindir"] = "$(exec_prefix)/sbin"' - f.puts ' CONFIG["libexecdir"] = "$(exec_prefix)/libexec"' - f.puts ' CONFIG["datarootdir"] = "$(prefix)/share"' - f.puts ' CONFIG["datadir"] = "$(datarootdir)"' - f.puts ' CONFIG["sysconfdir"] = "$(prefix)/etc"' - f.puts ' CONFIG["sharedstatedir"] = "$(prefix)/com"' - f.puts ' CONFIG["localstatedir"] = "$(prefix)/var"' - f.puts ' CONFIG["includedir"] = "$(prefix)/include"' - f.puts ' CONFIG["oldincludedir"] = "/usr/include"' - f.puts ' CONFIG["docdir"] = "$(datarootdir)/doc/$(PACKAGE)"' - f.puts ' CONFIG["infodir"] = "$(datarootdir)/info"' - f.puts ' CONFIG["htmldir"] = "$(docdir)"' - f.puts ' CONFIG["dvidir"] = "$(docdir)"' - f.puts ' CONFIG["pdfdir"] = "$(docdir)"' - f.puts ' CONFIG["psdir"] = "$(docdir)"' - f.puts ' CONFIG["libdir"] = "$(exec_prefix)/lib"' - f.puts ' CONFIG["localedir"] = "$(datarootdir)/locale"' - f.puts ' CONFIG["mandir"] = "$(datarootdir)/man"' - - f.puts ' major, minor, teeny = RUBY_VERSION.split(".")' - f.puts ' CONFIG["MAJOR"] = "#{major}"' - f.puts ' CONFIG["MINOR"] = "#{minor}"' - f.puts ' CONFIG["TEENY"] = "#{teeny}"' - f.puts ' CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"' - f.puts ' CONFIG["RUBY_SO_NAME"] = "rubinius-#{Rubinius::RBX_VERSION}"' - - f.puts ' CONFIG["rubyhdrdir"] = "#{Rubinius::HDR_PATH}"' - f.puts ' CONFIG["sitedir"] = "#{Rubinius::SITEDIR}"' - f.puts ' CONFIG["sitelibdir"] = "#{Rubinius::SITELIBDIR}"' - f.puts ' CONFIG["arch"] = "#{Rubinius::ARCH}"' - f.puts ' CONFIG["sitearch"] = "#{Rubinius::SITEARCH}"' - f.puts ' CONFIG["rubylibdir"] = "#{Rubinius::RUBYLIBDIR}"' - f.puts ' CONFIG["archdir"] = "#{Rubinius::ARCHDIR}"' - f.puts ' CONFIG["sitearchdir"] = "#{Rubinius::SITEARCHDIR}"' - f.puts ' CONFIG["topdir"] = File.dirname(__FILE__)' - - f.puts ' # some of these only relevant to cross-compiling' - f.puts ' cpu = Rubinius::CONFIG_CPU' - f.puts ' vendor = Rubinius::CONFIG_VENDOR' - f.puts ' os = Rubinius::CONFIG_OS' - f.puts ' CONFIG["build"] = "#{cpu}-#{vendor}-#{os}"' - f.puts ' CONFIG["build_cpu"] = "#{cpu}"' - f.puts ' CONFIG["build_vendor"] = "#{vendor}"' - f.puts ' CONFIG["build_os"] = "#{os}"' - f.puts ' CONFIG["host"] = "#{cpu}-#{vendor}-#{os}"' - f.puts ' CONFIG["host_cpu"] = "#{cpu}"' - f.puts ' CONFIG["host_vendor"] = "#{vendor}"' - f.puts ' CONFIG["host_os"] = "#{os}"' - f.puts ' CONFIG["target"] = "#{cpu}-#{vendor}-#{os}"' - f.puts ' CONFIG["target_cpu"] = "#{cpu}"' - f.puts ' CONFIG["target_vendor"] = "#{vendor}"' - f.puts ' CONFIG["target_os"] = "#{os}"' - f.puts ' CONFIG["build_alias"] = ""' - f.puts ' CONFIG["host_alias"] = ""' - f.puts ' CONFIG["target_alias"] = ""' - - # TODO: we need to be able to discover these, but for now, UNIXy defaults - f.puts ' # command line utilities' - f.puts ' CONFIG["SHELL"] = "/bin/sh"' - f.puts ' CONFIG["ECHO_C"] = ""' - f.puts ' CONFIG["ECHO_N"] = "-n"' - f.puts ' CONFIG["ECHO_T"] = ""' - f.puts ' CONFIG["GREP"] = "/usr/bin/grep"' - f.puts ' CONFIG["EGREP"] = "/usr/bin/grep -E"' - f.puts ' CONFIG["RM"] = "rm -f"' - f.puts ' CONFIG["CP"] = "cp"' - f.puts ' CONFIG["NROFF"] = "/usr/bin/nroff"' - f.puts ' CONFIG["MAKEDIRS"] = "mkdir -p"' - - f.puts ' # compile tools' - f.puts ' CONFIG["CC"] = "gcc"' - f.puts ' CONFIG["CPP"] = "gcc -E"' - f.puts ' CONFIG["YACC"] = "bison -y"' - f.puts ' CONFIG["RANLIB"] = "ranlib"' - f.puts ' CONFIG["AR"] = "ar"' - f.puts ' CONFIG["AS"] = "as"' - f.puts ' CONFIG["WINDRES"] = ""' - f.puts ' CONFIG["DLLWRAP"] = ""' - f.puts ' CONFIG["OBJDUMP"] = ""' - f.puts ' CONFIG["LN_S"] = "ln -s"' - f.puts ' CONFIG["NM"] = ""' - f.puts ' CONFIG["INSTALL"] = "/usr/bin/install -c"' - f.puts ' CONFIG["INSTALL_PROGRAM"] = "$(INSTALL)"' - f.puts ' CONFIG["INSTALL_SCRIPT"] = "$(INSTALL)"' - f.puts ' CONFIG["INSTALL_DATA"] = "$(INSTALL) -m 644"' - f.puts ' CONFIG["STRIP"] = "strip -A -n"' - f.puts ' CONFIG["MANTYPE"] = "doc"' - f.puts ' CONFIG["MAKEFILES"] = "Makefile"' - - # TODO: fill in these values - f.puts ' # compile tools flags' - f.puts ' CONFIG["CFLAGS"] = "-Wall -ggdb3 -O2"' - f.puts ' CONFIG["LDFLAGS"] = ""' - f.puts ' CONFIG["CPPFLAGS"] = ""' - f.puts ' CONFIG["OBJEXT"] = "o"' - f.puts ' CONFIG["GNU_LD"] = ""' - f.puts ' CONFIG["CPPOUTFILE"] = ""' - f.puts ' CONFIG["OUTFLAG"] = "-o "' - f.puts ' CONFIG["YFLAGS"] = ""' - f.puts ' CONFIG["ASFLAGS"] = ""' - f.puts ' CONFIG["DLDFLAGS"] = ""' - f.puts ' CONFIG["ARCH_FLAG"] = ""' - f.puts ' CONFIG["STATIC"] = ""' - f.puts ' CONFIG["CCDLFLAGS"] = ""' - f.puts ' CONFIG["XCFLAGS"] = ""' - f.puts ' CONFIG["XLDFLAGS"] = ""' - f.puts ' CONFIG["LIBRUBY_DLDFLAGS"] = ""' - f.puts ' CONFIG["rubyw_install_name"] = ""' - f.puts ' CONFIG["RUBYW_INSTALL_NAME"] = ""' - f.puts ' CONFIG["SOLIBS"] = ""' - f.puts ' CONFIG["DLDLIBS"] = ""' - f.puts ' CONFIG["ENABLE_SHARED"] = ""' - f.puts ' CONFIG["MAINLIBS"] = ""' - f.puts ' CONFIG["COMMON_LIBS"] = ""' - f.puts ' CONFIG["COMMON_MACROS"] = ""' - f.puts ' CONFIG["COMMON_HEADERS"] = ""' - f.puts ' CONFIG["EXPORT_PREFIX"] = ""' - f.puts ' CONFIG["EXTOUT"] = ".ext"' - f.puts ' CONFIG["ARCHFILE"] = ""' - f.puts ' CONFIG["RDOCTARGET"] = ""' - f.puts ' CONFIG["LIBRUBY_A"] = ""' - f.puts ' CONFIG["LIBRUBY_SO"] = "lib$(RUBY_SO_NAME).$(DLEXT)"' - f.puts ' CONFIG["LIBRUBY_ALIASES"] = "lib$(RUBY_SO_NAME).$(DLEXT)"' - f.puts ' CONFIG["LIBRUBY"] = "$(LIBRUBY_SO)"' - f.puts ' CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_STATIC)"' - f.puts ' CONFIG["LIBRUBYARG_STATIC"] = ""' - f.puts ' CONFIG["LIBRUBYARG_SHARED"] = "-l$(RUBY_SO_NAME)"' - f.puts ' CONFIG["configure_args"] = ""' - f.puts ' CONFIG["ALLOCA"] = ""' - f.puts ' CONFIG["LIBEXT"] = "a"' - f.puts ' CONFIG["LINK_SO"] = ""' - f.puts ' CONFIG["LIBPATHFLAG"] = " -L%s"' - f.puts ' CONFIG["RPATHFLAG"] = ""' - f.puts ' CONFIG["LIBPATHENV"] = "DYLD_LIBRARY_PATH"' - f.puts ' CONFIG["TRY_LINK"] = ""' - f.puts ' CONFIG["EXTSTATIC"] = ""' - f.puts ' CONFIG["setup"] = "Setup"' - f.puts ' CONFIG["PATH_SEPARATOR"] = ":"' - f.puts ' CONFIG["PACKAGE_NAME"] = ""' - f.puts ' CONFIG["PACKAGE_TARNAME"] = ""' - f.puts ' CONFIG["PACKAGE_VERSION"] = ""' - f.puts ' CONFIG["PACKAGE_STRING"] = ""' - f.puts ' CONFIG["PACKAGE_BUGREPORT"] = ""' - - # @todo create a config step that sets the values used to compile - # Rubinius; read those values for these types of config variables - if Config::CONFIG["build_os"] =~ /darwin/ - f.puts ' CONFIG["LDSHARED"] = "cc -dynamic -bundle -undefined suppress -flat_namespace"' - f.puts ' CONFIG["LIBRUBY_LDSHARED"] = "cc -dynamic -bundle -undefined suppress -flat_namespace"' - else - f.puts ' CONFIG["LDSHARED"] = "cc -shared"' - f.puts ' CONFIG["LIBRUBY_LDSHARED"] = "cc -shared"' - end - f.puts - f.puts <<-EOC - # Adapted from MRI's' rbconfig.rb - MAKEFILE_CONFIG = {} - CONFIG.each { |k,v| MAKEFILE_CONFIG[k] = v.kind_of?(String) ? v.dup : v } - - def Config.expand(val, config = CONFIG) - return val unless val.kind_of? String - - val.gsub!(/\\$\\$|\\$\\(([^()]+)\\)|\\$\\{([^{}]+)\\}/) do |var| - if !(v = $1 || $2) - '$' - elsif key = config[v = v[/\\A[^:]+(?=(?::(.*?)=(.*))?\\z)/]] - pat, sub = $1, $2 - config[v] = false - Config.expand(key, config) - config[v] = key - key = key.gsub(/\#{Regexp.quote(pat)}(?=\\s|\\z)/n) {sub} if pat - key - else - var - end - end - val - end - - CONFIG.each_value do |val| - Config.expand(val) - end -EOC - f.puts "end" - f.puts - f.puts "CROSS_COMPILING = nil unless defined? CROSS_COMPILING" - f.puts "RbConfig = Config" - end -end - -file 'kernel/bootstrap/rubinius_config.rb' => - %w[rakelib/configuration.rb rakelib/configure.rake] do |task, args| - open task.name, 'w' do |io| - io << <<-EOF -#-- -# This file was generated from rakelib/configure.rake -#++ - -module Rubinius - BUILDREV = #{RBX_BUILDREV.inspect} - BASE_PATH = #{RBX_BASE_PATH.inspect} - 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} - HDR_PATH = #{RBX_HDR_PATH.inspect} - RBX_VERSION = #{RBX_VERSION.inspect} - CONFIG_CPU = #{RBX_CPU.inspect} - CONFIG_VENDOR = #{RBX_VENDOR.inspect} - CONFIG_OS = #{RBX_OS.inspect} - SITEDIR = #{RBX_SITEDIR.inspect} - SITELIBDIR = #{RBX_SITELIBDIR.inspect} - ARCH = #{RBX_ARCH.inspect} - SITEARCH = #{RBX_SITEARCH.inspect} - RUBYLIBDIR = #{RBX_RUBYLIBDIR.inspect} - ARCHDIR = #{RBX_ARCHDIR.inspect} - SITEARCHDIR = #{RBX_SITEARCHDIR.inspect} -end - - EOF - end -end - -file 'kernel/bootstrap/ruby_config.rb' => - %w[rakelib/configuration.rb rakelib/configure.rake] do |task, args| - open task.name, 'w' do |io| - io << <<-EOF -#-- -# This file was generated from rakelib/configure.rake -#++ - -PLATFORM = #{RBX_HOST.inspect} - -RUBY_ENGINE = #{RBX_RUBY_ENGINE.inspect} -RUBY_PATCHLEVEL = #{RBX_RUBY_PATCHLEVEL.inspect} -RUBY_PLATFORM = #{RBX_HOST.inspect} -RUBY_RELEASE_DATE = #{RBX_RUBY_RELDATE.inspect} -RUBY_VERSION = #{RBX_RUBY_VERSION.inspect} -RUBY_COPYRIGHT = "rubinius - Copyright (C) 2006-2009 Evan Phoenix" - -VERSION = RUBY_VERSION - EOF - end -end - -namespace :configure do - task :clean do - rm_f 'lib/rbconfig.rb' - rm_f 'kernel/bootstrap/rubinius_config.rb' - rm_f 'kernel/bootstrap/ruby_config.rb' - end -end - diff --git a/rakelib/kernel.rake b/rakelib/kernel.rake index 937d2a0517..96d931fdd2 100644 --- a/rakelib/kernel.rake +++ b/rakelib/kernel.rake @@ -62,10 +62,11 @@ dir_names.each do |dir| end # Generate file tasks for all kernel files. +compiler_signature = "kernel/delta/signature.rb" + FileList[ "kernel/**/*.rb", - "kernel/bootstrap/rubinius_config.rb", - "kernel/bootstrap/ruby_config.rb", + compiler_signature ].each do |rb| kernel_dependency rb, runtime end @@ -102,10 +103,6 @@ parser_ext_files = FileList[ # Generate a sha1 of all parser and compiler files to use as # as signature in the .rbc files. -compiler_signature = "kernel/delta/signature.rb" - -kernel_dependency compiler_signature, runtime - file compiler_signature => compiler_files + parser_ext_files do |t| require 'digest' digest = Digest::SHA1.new diff --git a/rakelib/release.rake b/rakelib/release.rake index 1ea207359a..515e38fced 100644 --- a/rakelib/release.rake +++ b/rakelib/release.rake @@ -1,4 +1,4 @@ -require 'rakelib/configuration' +require 'config' namespace :release do desc "Create the tarball for the release" diff --git a/rakelib/vm.rake b/rakelib/vm.rake index 6e0f3564ae..9608b63770 100644 --- a/rakelib/vm.rake +++ b/rakelib/vm.rake @@ -1,12 +1,14 @@ -require 'tmpdir' require 'rakelib/rubinius' -require 'rakelib/configuration' require 'rakelib/build' require 'rakelib/instruction_parser' + +require 'tmpdir' require 'ostruct' require 'lib/ffi/generator_task.rb' +require 'config' + config = OpenStruct.new config.use_jit = true config.compile_with_llvm = false @@ -156,10 +158,7 @@ INCLUDES = EX_INC + %w[vm/test/cxxtest vm . vm/assembler vm/assembler/udis8 INCLUDES.map! { |f| "-I#{f}" } # Default build options -BASIC_FLAGS = %W[ -pipe -Wall -Wno-deprecated - -DBASE_PATH=\\"#{RBX_BASE_PATH}\\" - -DRBA_PATH=\\"#{RBX_RBA_PATH}\\" - ] +BASIC_FLAGS = %W[ -pipe -Wall -Wno-deprecated ] FLAGS = BASIC_FLAGS.dup @@ -196,8 +195,6 @@ Rubinius::BUILD_CONFIG[:defines].each do |flag| FLAGS << "-D#{flag}" end -FLAGS << "-DRBX_HOST=\\\"#{RBX_HOST}\\\"" - BUILD_PRETASKS = [] if ENV['DEV'] @@ -311,7 +308,6 @@ namespace :build do build:llvm vm kernel:build - lib/rbconfig.rb build:ffi:preprocessor extensions ] @@ -627,15 +623,19 @@ namespace :vm do desc "Clean up vm build files" task :clean do - files = [ - objs, vm_objs, dep_file, TYPE_GEN, INSN_GEN, - 'vm/gen', + files = FileList[ + objs, + vm_objs, + dep_file, + TYPE_GEN, + INSN_GEN, + 'vm/gen/*', 'vm/test/runner', 'vm/test/runner.cpp', 'vm/test/runner.o', 'vm/vm', 'vm/.deps' - ].flatten + ].exclude("vm/gen/config.h") files.each do |filename| rm_rf filename, :verbose => $verbose diff --git a/spec/library/config/rbconfig_spec.rb b/spec/library/config/rbconfig_spec.rb index 068217ef40..9f97b688ec 100644 --- a/spec/library/config/rbconfig_spec.rb +++ b/spec/library/config/rbconfig_spec.rb @@ -63,7 +63,7 @@ def it_has_entries(name, entries) it_has_keys 'Config::CONFIG', keys entries = { - "RUBY_SO_NAME" => "rubinius-#{Rubinius::RBX_VERSION}", + "RUBY_SO_NAME" => "rubinius-#{Rubinius::VERSION}", "ruby_install_name" => "rbx", "ruby_version" => "1.8", } @@ -72,6 +72,10 @@ def it_has_entries(name, entries) end describe "Config::MAKEFILE_CONFIG" do + sitedir = "#{Rubinius::LIB_PATH}/rubinius" + sitelibdir = "#{sitedir}/#{Rubinius::LIB_VERSION}" + arch = "#{Rubinius::CPU}-#{Rubinius::OS}" + entries = { "exec_prefix" => "$(prefix)", "bindir" => "$(exec_prefix)/bin", @@ -93,12 +97,11 @@ def it_has_entries(name, entries) "libdir" => "$(exec_prefix)/lib", "localedir" => "$(datarootdir)/locale", "mandir" => "$(datarootdir)/man", - "sitedir" => "$(libdir)/ruby/site_ruby", "ruby_version" => "$(MAJOR).$(MINOR)", - "rubylibdir" => "#{Rubinius::RUBYLIBDIR}", - "archdir" => "#{Rubinius::ARCHDIR}", - "sitearchdir" => "#{Rubinius::SITEARCHDIR}", - "sitedir" => "#{Rubinius::SITEDIR}", + "rubylibdir" => sitelibdir, + "archdir" => "#{sitelibdir}/#{arch}", + "sitearchdir" => "#{sitelibdir}/#{arch}", + "sitedir" => "#{sitedir}", "rubyhdrdir" => "#{Rubinius::HDR_PATH}" } diff --git a/vm/agent.cpp b/vm/agent.cpp index d3375cac9d..47f2da6202 100644 --- a/vm/agent.cpp +++ b/vm/agent.cpp @@ -13,6 +13,8 @@ #include "agent.hpp" #include "exception.hpp" +#include "config.h" + namespace rubinius { bool QueryAgent::bind() { server_fd_ = ::socket(AF_INET, SOCK_STREAM, 0); diff --git a/vm/config.h b/vm/config.h index 2a2982dc8b..e207b62f66 100644 --- a/vm/config.h +++ b/vm/config.h @@ -1,6 +1,7 @@ #ifndef RBX_CONFIG #define RBX_CONFIG +#include "gen/config.h" #include "detection.hpp" #endif diff --git a/vm/drivers/cli.cpp b/vm/drivers/cli.cpp index 364349129e..2daa885784 100644 --- a/vm/drivers/cli.cpp +++ b/vm/drivers/cli.cpp @@ -8,6 +8,8 @@ #include "vm/type_info.hpp" #include "vm/exception.hpp" +#include "vm/config.h" + using namespace std; using namespace rubinius; @@ -80,7 +82,7 @@ int main(int argc, char** argv) { if(!runtime) { struct stat st; - runtime = RBA_PATH; + runtime = RBX_RUNTIME; if(stat(runtime, &st) == -1 || !S_ISDIR(st.st_mode)) { // Use throw rather than ::raise here because we're outside // the VM really. diff --git a/vm/environment.cpp b/vm/environment.cpp index 50b2d8ab30..b962613d0e 100644 --- a/vm/environment.cpp +++ b/vm/environment.cpp @@ -270,7 +270,11 @@ namespace rubinius { if(!state->probe->nil_p()) state->probe->load_runtime(state, file); std::ifstream stream(file.c_str()); - if(!stream) throw std::runtime_error("Unable to open file to run"); + if(!stream) { + std::string msg = std::string("Unable to open file to run: "); + msg.append(file); + throw std::runtime_error(msg); + } CompiledFile* cf = CompiledFile::load(stream); if(cf->magic != "!RBIX") throw std::runtime_error("Invalid file"); diff --git a/vm/ontology.cpp b/vm/ontology.cpp index cdfff02be4..90efc6ab7b 100644 --- a/vm/ontology.cpp +++ b/vm/ontology.cpp @@ -332,89 +332,25 @@ namespace rubinius { G(object)->set_const(state, "STDOUT", out_io); G(object)->set_const(state, "STDERR", err_io); -#if defined(__ppc__) || defined(__POWERPC__) || defined(_POWER) - G(rubinius)->set_const(state, "PLATFORM", symbol("ppc")); -#elif defined(__amd64__) - G(rubinius)->set_const(state, "PLATFORM", symbol("amd64")); -#elif defined(i386) || defined(__i386__) - G(rubinius)->set_const(state, "PLATFORM", symbol("x86")); -#elif defined(__alpha) || defined(__alpha__) - G(rubinius)->set_const(state, "PLATFORM", symbol("alpha")); -#elif defined(VAX) || defined(__VAX) - G(rubinius)->set_const(state, "PLATFORM", symbol("vax")); -#elif defined(__hppa__) - G(rubinius)->set_const(state, "PLATFORM", symbol("hppa")); -#elif defined(__sparc__) - G(rubinius)->set_const(state, "PLATFORM", symbol("sparc")); -#elif defined(__s390__) - G(rubinius)->set_const(state, "PLATFORM", symbol("s390")); -#elif (defined(TARGET_CPU_68K) || defined(__CFM68K__) || defined(m68k) || defined(_M_M68K)) - G(rubinius)->set_const(state, "PLATFORM", symbol("m68k")); -#else - G(rubinius)->set_const(state, "PLATFORM", symbol("unknown")); -#endif - -#if defined(__APPLE__) || defined(__MACH__) - G(rubinius)->set_const(state, "OS", symbol("darwin")); -#elif defined(__linux__) || defined(linux) || defined(__linux) - G(rubinius)->set_const(state, "OS", symbol("linux")); -#elif defined(__FreeBSD__) - G(rubinius)->set_const(state, "OS", symbol("freebsd")); -#elif defined(__CYGWIN__) - G(rubinius)->set_const(state, "OS", symbol("cygwin")); -#elif defined(__OS2__) - G(rubinius)->set_const(state, "OS", symbol("os2")); -#elif defined(__NT__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) - G(rubinius)->set_const(state, "OS", symbol("win32")); -#elif defined(__WINDOWS__) - G(rubinius)->set_const(state, "OS", symbol("windows_3x")); -#elif defined(__NETWARE_386__) - G(rubinius)->set_const(state, "OS", symbol("netware")); -#elif defined(__MSDOS__) - G(rubinius)->set_const(state, "OS", symbol("dos")); -#elif defined(VMS) || defined(__VMS__) - G(rubinius)->set_const(state, "OS", symbol("vms")); -#elif defined(__hpux__) - G(rubinius)->set_const(state, "OS", symbol("hpux")); -#elif defined(__sun__) || defined(__sun) - G(rubinius)->set_const(state, "OS", symbol("solaris")); -#elif defined(__svr4__) - G(rubinius)->set_const(state, "OS", symbol("unixware")); -#elif defined(_AIX) - G(rubinius)->set_const(state, "OS", symbol("aix")); -#elif (defined(_SCO_DS) && defined(_SCO_ELF) && defined(_SCO_XPG_VERS) && defined(_SCO_C_DIALECT)) - G(rubinius)->set_const(state, "OS", symbol("openserver")); -#elif defined(__unix__) - G(rubinius)->set_const(state, "OS", symbol("decunix")); -#else - G(rubinius)->set_const(state, "OS", symbol("unknown")); -#endif - -#if defined(__VERSION__) - G(rubinius)->set_const(state, "COMPILER_VERSION", String::create(state, __VERSION__)); -#else - G(rubinius)->set_const(state, "COMPILER_VERSION", Qnil); -#endif - -#if defined(_MSC_VER) - G(rubinius)->set_const(state, "COMPILER", symbol("microsoft")); -#elif defined(__DECC) || defined(VAXC) - G(rubinius)->set_const(state, "COMPILER", symbol("digital")); -#elif defined(__BORLANDC__) - G(rubinius)->set_const(state, "COMPILER", symbol("borland")); -#elif defined(__WATCOMC__) - G(rubinius)->set_const(state, "COMPILER", symbol("watcom")); -#elif defined(__GNUC__) - G(rubinius)->set_const(state, "COMPILER", symbol("gcc")); -#elif defined(__MWERKS__) - G(rubinius)->set_const(state, "COMPILER", symbol("metrowerks")); -#elif defined(__IBMC__) || defined(__IBMCPP__) - G(rubinius)->set_const(state, "COMPILER", symbol("ibm")); -#elif defined(__SUNPRO_C) - G(rubinius)->set_const(state, "COMPILER", symbol("sunpro")); -#else - G(rubinius)->set_const(state, "COMPILER", symbol("unknown")); -#endif + /* Fundamental constants. These are uniformly Strings and not symbols + * because some are passed to e.g. File.expand_path and having them + * be uniform is simpler. + */ + G(rubinius)->set_const(state, "BIN_PATH", String::create(state, RBX_BIN_PATH)); + G(rubinius)->set_const(state, "LIB_PATH", String::create(state, RBX_LIB_PATH)); + G(rubinius)->set_const(state, "EXT_PATH", String::create(state, RBX_EXT_PATH)); + G(rubinius)->set_const(state, "HDR_PATH", String::create(state, RBX_HDR_PATH)); + G(rubinius)->set_const(state, "GEMS_PATH", String::create(state, RBX_GEMS_PATH)); + + G(rubinius)->set_const(state, "VERSION", String::create(state, RBX_VERSION)); + G(rubinius)->set_const(state, "LIB_VERSION", String::create(state, RBX_LIB_VERSION)); + G(rubinius)->set_const(state, "BUILD_REV", String::create(state, RBX_BUILD_REV)); + G(rubinius)->set_const(state, "LDSHARED", String::create(state, RBX_LDSHARED)); + + G(rubinius)->set_const(state, "HOST", String::create(state, RBX_HOST)); + G(rubinius)->set_const(state, "CPU", String::create(state, RBX_CPU)); + G(rubinius)->set_const(state, "VENDOR", String::create(state, RBX_VENDOR)); + G(rubinius)->set_const(state, "OS", String::create(state, RBX_OS)); // Crazy? yep. int one = 1;