From: Eric Hodel Date: 2007-08-21T15:33:37+09:00 Subject: Re: Dear Lazyweb: Gem Platforms On Aug 20, 2007, at 22:11, Nick Sieger wrote: > "java" is actually not used in either CPU or OS strings in the > config hash > currently (this is reflected in the tattle data). JRuby uses > "java" either > in the 'arch' or 'target' strings: > > irb(main):002:0> Config::CONFIG.select {|k,v| v =~ /java/} > => [["archdir", > "/Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/ > 1.8/java"], > ["arch", "i386-java1.5"], ["build", "java1.5"], ["sitearchdir", > "/Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/ > 1.8/java"], > ["target", "java1.5"]] > irb(main):003:0> RUBY_PLATFORM > => "java" > > Can you work 'arch' into the logic somehow? Or suggest an > alternative way > to ensure that JRuby/java platform is possible for gems? How's this? It now uses Config::CONFIG['arch']: def match(arch) cpu, os = arch.split '-', 2 cpu, os = nil, cpu if os.nil? # java 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$/ then [ 'java', nil ] 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' arch = Config::CONFIG['arch'] cpu, os = arch.split '-', 2 puts "Your cpu is: #{cpu.inspect}" puts "Your os is: #{os.inspect}" puts "Your platform is: #{match(arch).inspect}" raise "need a tattle arch dump yaml file!" if ARGV.empty? puts "loading archs..." require 'yaml' archs = YAML.load(ARGF.read)['arch'].keys def recognize(*archs) unmatched = {} seen = {} archs.each do |arch| platform = match arch seen[platform] = true unmatched[arch] = true if platform =~ /-unknown$/ end return unmatched.keys, seen.keys end unmatched, unique = recognize(*archs) puts "found #{unique.length} unique platforms" puts puts unique.sort.join("\n") unless unmatched.empty? then puts puts "unmatched" puts puts unmatched.join("\n") end -- Poor workers blame their tools. Good workers build better tools. The best workers get their tools to do the work for them. -- Syndicate Wars