From: Park Heesob Date: 2002-09-13T13:22:18+09:00 Subject: Re: RubyInline and CrossPlatform concerns (was: Windows XP : RubyInline 1.0.4 Released!) Hi, "Ryan Davis" wrote in message news:AABCBCCE-C6CC-11D6-95F8-0030657CEB62@zenspider.com... > > Here is another version using mkmf. > > I don't mean to be a total bother, but does windoze have diff? diff > would be much more workable in this context. I'm having a hard time > dealing w/ your changes because they aren't file attachments, nor are > they diffs. As a result, I have to deal with all sorts of whitespace > issues and the like. > OK, Here is diff of original and my first version. ================================================= @@ -13,20 +13,13 @@ def inline(args, src) - tmpdir = ENV['INLINEDIR'] || ENV['HOME'] + "/.ruby_inline" + tmpdir = ENV['TMP'] + "/.ruby_inline" unless File.directory? tmpdir then $stderr.puts "NOTE: creating #{tmpdir} for RubyInline" Dir.mkdir(tmpdir, 0700) end - mode = File.stat(tmpdir).mode - unless (mode % 01000) == 0700 then # FIX: not platform independent. - $stderr.printf "mode = %o\n", mode - $stderr.puts "#{tmpdir} is insecure, needs 0700 for perms" - exit 1 - end - myclass = self.class mymethod = self.caller_method_name mod_name = "Mod_#{myclass}_#{mymethod}" @@ -46,6 +39,7 @@ end cc = "#{Config::CONFIG['LDSHARED']} #{Config::CONFIG['CFLAGS']} -I #{hdrdir}" + libs = " #{Config::CONFIG["libdir"]}/#{Config::CONFIG['LIBRUBYARG']}" src_name = "#{tmpdir}/#{mod_name}.c" $stderr.puts "Building #{so_name} with '#{cc}'" @@ -70,7 +64,9 @@ f.close # Compiling - `#{cc} -o #{so_name} #{src_name}` + cmd = "#{cc} -o #{so_name} #{src_name} #{libs}".gsub('/','\\') + + " -link /INCREMENTAL:no /EXPORT:Init_#{mod_name}" + `#{cmd}` end ======================================== original and second version ========================================== @@ -1,6 +1,6 @@ #!/usr/local/bin/ruby -w -require "rbconfig" +require 'mkmf' def caller_method_name() /\`([^\']+)\'/.match(caller(2).first)[1] @@ -13,41 +13,25 @@ def inline(args, src) + if /mswin32/ =~ RUBY_PLATFORM + tmpdir = ENV['INLINEDIR'] || ENV['HOMEDRIVE'] + ENV['HOMEPATH'] + "/.ruby_inline" + else tmpdir = ENV['INLINEDIR'] || ENV['HOME'] + "/.ruby_inline" + end unless File.directory? tmpdir then $stderr.puts "NOTE: creating #{tmpdir} for RubyInline" Dir.mkdir(tmpdir, 0700) end - mode = File.stat(tmpdir).mode - unless (mode % 01000) == 0700 then # FIX: not platform independent. - $stderr.printf "mode = %o\n", mode - $stderr.puts "#{tmpdir} is insecure, needs 0700 for perms" - exit 1 - end - myclass = self.class mymethod = self.caller_method_name mod_name = "Mod_#{myclass}_#{mymethod}" so_name = "#{tmpdir}/#{mod_name}.so" unless File.file? so_name and File.mtime($0) < File.mtime(so_name) then - # extracted from mkmf.rb - srcdir = Config::CONFIG["srcdir"] - archdir = Config::CONFIG["archdir"] - if File.exist? archdir + "/ruby.h" - hdrdir = archdir - elsif File.exist? srcdir + "/ruby.h" - hdrdir = srcdir - else - $stderr.puts "ERROR: Can't find header files for ruby. Exiting..." - exit 1 - end - - cc = "#{Config::CONFIG['LDSHARED']} #{Config::CONFIG['CFLAGS']} -I #{hdrdir}" src_name = "#{tmpdir}/#{mod_name}.c" - $stderr.puts "Building #{so_name} with '#{cc}'" + $stderr.puts "Building #{so_name}" s = %Q{ #include "ruby.h" @@ -70,7 +54,13 @@ f.close # Compiling - `#{cc} -o #{so_name} #{src_name}` + cwd = Dir.pwd + Dir.chdir(tmpdir) + $INSTALLFILES = '' + create_makefile(mod_name) + make = with_config("make-prog", ENV["MAKE"] || "make") + `#{make}` + Dir.chdir(cwd) end =============================================================== Park Hee sob