The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Dear Lazyweb: Gem Platforms

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Hodel

Posts: 660
Nickname: drbrain
Registered: Mar, 2006

Eric Hodel is a long-time Rubyist and co-founder of Seattle.rb.
Dear Lazyweb: Gem Platforms Posted: Aug 20, 2007 10:07 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eric Hodel.
Original Post: Dear Lazyweb: Gem Platforms
Feed Title: Segment7
Feed URL: http://blog.segment7.net/articles.rss
Feed Description: Posts about and around Ruby, MetaRuby, ruby2c, ZenTest and work at The Robot Co-op.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eric Hodel
Latest Posts From Segment7

Advertisement

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, 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. (Yes, AIX users, I’m talking to you.)

Read: Dear Lazyweb: Gem Platforms

Topic: My Mac Can't Count Previous Topic   Next Topic Topic: Almuerzo Cody Fauser y has_many :developers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use