[前][次][番号順一覧][スレッド一覧]

ruby-changes:2434

From: ko1@a...
Date: 15 Nov 2007 11:55:14 +0900
Subject: [ruby-changes:2434] akr - Ruby:r13925 (trunk): * tool/compile_prelude.rb: adjust RbConfig::CONFIG paths relative

akr	2007-11-15 11:54:55 +0900 (Thu, 15 Nov 2007)

  New Revision: 13925

  Modified files:
    trunk/ChangeLog
    trunk/tool/compile_prelude.rb

  Log:
    * tool/compile_prelude.rb: adjust RbConfig::CONFIG paths relative
      to the installation path.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/tool/compile_prelude.rb?r1=13925&r2=13924
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13925&r2=13924

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13924)
+++ ChangeLog	(revision 13925)
@@ -1,3 +1,8 @@
+Thu Nov 15 11:52:16 2007  Tanaka Akira  <akr@f...>
+
+	* tool/compile_prelude.rb: adjust RbConfig::CONFIG paths relative
+	  to the installation path.
+
 Thu Nov 15 11:25:20 2007  Tanaka Akira  <akr@f...>
 
 	* ruby.c (usage): fix typo on --disable-gems option.
Index: tool/compile_prelude.rb
===================================================================
--- tool/compile_prelude.rb	(revision 13924)
+++ tool/compile_prelude.rb	(revision 13925)
@@ -1,6 +1,6 @@
 # This file is interpreted by $(BASERUBY) and miniruby.
-# $(BASERUBY) is used for prelude.c.
-# miniruby is used for ext_prelude.c.
+# $(BASERUBY) is used for miniprelude.c.
+# miniruby is used for prelude.c.
 # Since $(BASERUBY) may be older than Ruby 1.9,
 # Ruby 1.9 feature should not be used.
 
@@ -21,20 +21,34 @@
   '"' + str.gsub(C_ESC_PAT) { C_ESC[$&] } + '"'
 end
 
-lines_list = preludes.map {|prelude|
+mkconf = nil
+setup_ruby_prefix = nil
+lines_list = preludes.map {|filename|
   lines = []
-  File.readlines(prelude).each {|line|
+  need_ruby_prefix = false
+  File.readlines(filename).each {|line|
     line.gsub!(/RbConfig::CONFIG\["(\w+)"\]/) {
-      require 'rbconfig'
-      if RbConfig::CONFIG.has_key? $1
-        c_esc(RbConfig::CONFIG[$1])
+      unless mkconf
+        require 'rbconfig'
+        mkconf = RbConfig::MAKEFILE_CONFIG.merge('prefix'=>'#{ruby_prefix}')
+        exlen = $:.grep(%r{\A/}).last.length - RbConfig::CONFIG["prefix"].length
+        setup_ruby_prefix = "ruby_prefix = $:.grep(%r{\\A/}).last[0..#{-exlen-1}]\n"
+      end
+      if RbConfig::MAKEFILE_CONFIG.has_key? $1
+        val = RbConfig.expand("$(#$1)", mkconf)
+        need_ruby_prefix = true if /\A\#{ruby_prefix}/ =~ val
+        c_esc(val)
       else
         $&
       end
     }
     lines << c_esc(line)
   }
-  lines
+  setup_lines = []
+  if need_ruby_prefix
+    setup_lines << c_esc(setup_ruby_prefix)
+  end
+  [setup_lines, lines]
 }
 
 open(outfile, 'w'){|f|
@@ -45,11 +59,11 @@
 
 EOS__
 
-  preludes.zip(lines_list).each_with_index {|(prelude, lines), i|
+  preludes.zip(lines_list).each_with_index {|(prelude, (setup_lines, lines)), i|
     f.puts <<EOS__
 static const char prelude_name#{i}[] = "#{File.basename(prelude)}";
 static const char prelude_code#{i}[] =
-#{lines.join("\n")}
+#{(setup_lines+lines).join("\n")}
 ;
 EOS__
   }
@@ -59,12 +73,12 @@
 Init_prelude(void)
 {
 EOS__
-  preludes.length.times {|i|
+  lines_list.each_with_index {|(setup_lines, lines), i|
     f.puts <<EOS__
   rb_iseq_eval(rb_iseq_compile(
     rb_str_new(prelude_code#{i}, sizeof(prelude_code#{i}) - 1),
     rb_str_new(prelude_name#{i}, sizeof(prelude_name#{i}) - 1),
-    INT2FIX(1)));
+    INT2FIX(#{1-setup_lines.length})));
 
 EOS__
   }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]