As you may or may not have heard, RubyGems will be merged into Ruby
1.9 sometime in October. Before this can happen RubyGems needs to
automatically install dependencies based on platforms. Fortunately
I’ve got the automatic install part written. Unfortunately I don’t
know if I’ve got figuring out the platforms right. This is where you
come in.
Dear Lazyweb,
Here’s my proposal for how we recognize platforms. From
Config::CONFIG, take the target_os and run it through a case
statement to figure out OS and OS version (if any). Combine the
target_cpu, OS and OS version. This value is your platform.
(There will be a rubygems-platforms.gem much like sources.gem that can
be updated as necessary.)
Using the tattle data (http://tattle.rubygarden.org), the following
code recognizes 26 unique platforms:
def match(cpu, os)
cpu = case cpu
when /i\d86/ then ‘x86’
else cpu
end
os = case os
when /cygwin/ then [ ‘cygwin’, nil ]
when /darwin(\d+)?/ then [ ‘darwin’, $1 ]
when /freebsd(\d+)/ then [ ‘freebsd’, $1 ]
when /^java([\d.]*)/ then [ ‘java’, $1 ]
when /linux/ then [ ‘linux’, $1 ]
when /mingw32/ then [ ‘mingw32’, nil ]
when /mswin32/ then [ ‘mswin32’, nil ]
when /openbsd(\d+.\d+)/ then [ ‘openbsd’, $1 ]
when /solaris(\d+.\d+)/ then [ ‘solaris’, $1 ]
else [ ‘unknown’, nil ]
end
[cpu, os].flatten.compact.join(“-”)
end
require ‘rbconfig’
target_cpu = Config::CONFIG[‘target_cpu’]
target_os = Config::CONFIG[‘target_os’]
puts “Your target_cpu is: #{target_cpu.inspect}”
puts “Your target_os is: #{target_os.inspect}”
puts “Your platform is: #{match(target_cpu, target_os).inspect}”
Lazyweb, I have two major questions for you:
Did I get something wrong? Am I using autoconf’s target_os
correctly? Is Solaris 2.8 really incompatible with Solaris 2.9?
What is a 64-bit Windows’ target_os value?
Do I have all the platforms people run Ruby and RubyGems on? If the
answer to this one is no, do this: gem install tattle; tattle</
kbd>. (Yes, AIX users, I’m talking to you.)