Permalink
Browse files

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.
  • Loading branch information...
1 parent 3bb6ecd commit 243a775196160302c623a82e93361e0b423b84b7 Brian Ford committed Nov 24, 2009
View
@@ -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
View
@@ -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'
View
@@ -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
File renamed without changes.
@@ -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
@@ -4,6 +4,7 @@ class.rbc
exception.rbc
file.rbc
io.rbc
+ruby_constants.rbc
rubinius.rbc
module.rbc
filetest.rbc
@@ -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}"
@@ -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
View
@@ -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!
Oops, something went wrong.

0 comments on commit 243a775

Please sign in to comment.