Dear Lazyweb: Gem Platforms

E

Eric Hodel

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: <kbd>gem install tattle; tattle</
kbd>. (Yes, AIX users, I'm talking to you.)
 
E

Eric Hodel

"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
 
A

ara.t.howard

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.

you will be a hero if this happens: honestly!

a @ http://drawohara.com/
 
D

Daniel Berger

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.

Do I have all the platforms people run Ruby and RubyGems on? If the
answer to this one is no, do this: <kbd>gem install tattle; tattle</
kbd>. (Yes, AIX users, I'm talking to you.)

I wasn't able to use tattle (because I couldn't get rubygems to
install, because I couldn't get zlib to build), but here's all the
rbconfig info I have:

djberge@td191> uname -a
HP-UX td191 B.11.31 U 9000/800 3397116299 unlimited-user license

ALLOCA =>
AR => ar
ARCHFILE =>
ARCH_FLAG =>
AS => as
ASFLAGS =>
CC => cc -Ae -s
CCDLFLAGS => +Z
CFLAGS => -g
COMMON_HEADERS =>
COMMON_LIBS =>
COMMON_MACROS =>
CP => cp
CPP => cc -Ae -s -E
CPPFLAGS =>
CPPOUTFILE => -o conftest.i
DESTDIR =>
DLDFLAGS => -E
DLDLIBS => -lc
DLEXT => sl
DLEXT2 =>
DLLWRAP =>
ECHO_C => \c
ECHO_N =>
ECHO_T =>
EGREP => grep -E
ENABLE_SHARED => no
EXEEXT =>
EXPORT_PREFIX =>
EXTOUT => .ext
EXTSTATIC =>
GNU_LD => no
INSTALL => /opt/imake/bin/install -c
INSTALL_DATA => /opt/imake/bin/install -c -m 644
INSTALL_PROGRAM => /opt/imake/bin/install -c
INSTALL_SCRIPT => /opt/imake/bin/install -c
LDFLAGS => -L.
LDSHARED => ld -b
LIBEXT => a
LIBPATHENV => SHLIB_PATH
LIBPATHFLAG => -L%s
LIBRUBY => libruby-static.a
LIBRUBYARG => -lruby-static
LIBRUBYARG_SHARED =>
LIBRUBYARG_STATIC => -lruby-static
LIBRUBY_A => libruby-static.a
LIBRUBY_ALIASES => libruby.so
LIBRUBY_DLDFLAGS => -E
LIBRUBY_LDSHARED => ld -b
LIBRUBY_SO => libruby.so.1.8.6
LIBS => -ldld -lcrypt -lm
LINK_SO =>
LN_S => ln -s
MAINLIBS =>
MAJOR => 1
MAKEDIRS => mkdir -p
MAKEFILES => Makefile
MANTYPE => man
MINIRUBY => ./miniruby
MINOR => 8
NM =>
NROFF => /usr/bin/nroff
OBJDUMP =>
OBJEXT => o
OUTFLAG => -o
PACKAGE_BUGREPORT =>
PACKAGE_NAME =>
PACKAGE_STRING =>
PACKAGE_TARNAME =>
PACKAGE_VERSION =>
PATH_SEPARATOR => :
PREP => miniruby
RANLIB => ranlib
RDOCTARGET =>
RM => rm -f
RPATHFLAG =>
RUBYW_INSTALL_NAME =>
RUBY_INSTALL_NAME => ruby
RUBY_SO_NAME => ruby
RUNRUBY => ./miniruby $(srcdir)/runruby.rb --extout=.ext --
SET_MAKE =>
SHELL => /bin/sh
SOLIBS =>
STATIC =>
STRIP => strip
TEENY => 6
TRY_LINK =>
WINDRES =>
XCFLAGS => -DRUBY_EXPORT -DYYMAXDEPTH=300
XLDFLAGS => -Wl,-E
YACC => yacc -Nl40000 -Nm40000
arch => hppa2.0w-hpux11.31
archdir => /house/djberge/lib/ruby/1.8/hppa2.0w-hpux11.31
bindir => /house/djberge/bin
build => hppa2.0w-hp-hpux11.31
build_alias =>
build_cpu => hppa2.0w
build_os => hpux11.31
build_vendor => hp
configure_args => '--prefix=/house/djberge' 'CC=cc -Ae -s'
datadir => /house/djberge/share
exec_prefix => /house/djberge
host => hppa2.0w-hp-hpux11.31
host_alias =>
host_cpu => hppa2.0w
host_os => hpux11.31
host_vendor => hp
includedir => /house/djberge/include
infodir => /house/djberge/info
libdir => /house/djberge/lib
libexecdir => /house/djberge/libexec
localstatedir => /house/djberge/var
mandir => /house/djberge/man
oldincludedir => /usr/include
prefix => /house/djberge
ruby_install_name => ruby
ruby_version => 1.8
rubylibdir => /house/djberge/lib/ruby/1.8
rubyw_install_name =>
sbindir => /house/djberge/sbin
setup => Setup
sharedstatedir => /house/djberge/com
sitearch => hppa2.0w-hpux11.31
sitearchdir => /house/djberge/lib/ruby/site_ruby/1.8/hppa2.0w-
hpux11.31
sitedir => /house/djberge/lib/ruby/site_ruby
sitelibdir => /house/djberge/lib/ruby/site_ruby/1.8
sysconfdir => /house/djberge/etc
target => hppa2.0w-hp-hpux11.31
target_alias =>
target_cpu => hppa2.0w
target_os => hpux11.31
target_vendor => hp
topdir => /house/djberge/lib/ruby/1.8/hppa2.0w-hpux11.31

Regards,

Dan
 
E

Eric Hodel

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.

Do I have all the platforms people run Ruby and RubyGems on? If the
answer to this one is no, do this: <kbd>gem install tattle; tattle</
kbd>. (Yes, AIX users, I'm talking to you.)

I wasn't able to use tattle (because I couldn't get rubygems to
install, because I couldn't get zlib to build), but here's all the
rbconfig info I have:

[...]
arch => hppa2.0w-hpux11.31
[...]

Beautiful, awesome, thanks!
 
A

Andre Nathan

Hi Eric

Do I have all the platforms people run Ruby and RubyGems on? If the
answer to this one is no, do this: <kbd>gem install tattle; tattle</
kbd>. (Yes, AIX users, I'm talking to you.)

NetBSD and DragonFly seem to be missing. Unfortunately I don't have any
machines running those to run tattle on (I suspect the arch strings
would be "netbsd" and "dragonfly" though). Maybe someone can confirm.

Andre
 
Y

Yutaka Kanemoto

Hi

I'm not sure if there were any AIX-aware gems ;-), but
Do I have all the platforms people run Ruby and RubyGems on? If the
answer to this one is no, do this: <kbd>gem install tattle; tattle</
kbd>. (Yes, AIX users, I'm talking to you.)
done.
 
J

Jeremy McAnally

Can you hack in developer/user dependencies while you're in there? ;)

--Jeremy

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: <kbd>gem install tattle; tattle</
kbd>. (Yes, AIX users, I'm talking to you.)


--
http://www.jeremymcanally.com/

My free Ruby e-book:
http://www.humblelittlerubybook.com/book/

My blogs:
http://www.mrneighborly.com/
http://www.rubyinpractice.com/
 
A

Andre Nathan

NetBSD and DragonFly seem to be missing. Unfortunately I don't have any
machines running those to run tattle on (I suspect the arch strings
would be "netbsd" and "dragonfly" though). Maybe someone can confirm.

Sent one for NetBSD. It's "netbsdelf" actually.

Andre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top