From e60463034a468ec9fcee73466e76bd541c9a39c3 Mon Sep 17 00:00:00 2001 From: yugui Date: Thu, 30 Jul 2009 14:12:25 +0000 Subject: * tool/compile_prelude.rb: replaces "require" with in-place evaluation so that copy & paste for lib/rubygems/default.rb is not necessary. * gem_prelude.rb: removes copied codes from lib/rubygems/defaults.rb. uses require instead. * common.mk (prelude.c): adds dependency for lib/rubygems/defaults.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/compile_prelude.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'tool') diff --git a/tool/compile_prelude.rb b/tool/compile_prelude.rb index e0a011ce2d..48b9e2e1cf 100755 --- a/tool/compile_prelude.rb +++ b/tool/compile_prelude.rb @@ -23,6 +23,10 @@ C_ESC_PAT = Regexp.union(*C_ESC.keys) def c_esc(str) '"' + str.gsub(C_ESC_PAT) { C_ESC[$&] } + '"' end +def prelude_name(*path_nests) + prelude = path_nests.map{|prelude_path| File.basename(prelude_path, ".rb") }.join(":") + "" +end mkconf = nil setup_ruby_prefix = nil @@ -47,6 +51,16 @@ lines_list = preludes.map {|filename| "nil" end } + line.gsub!(/require\s*(\(?)\s*(["'])(.*?)\2\s*\1/) { + orig, path = $&, $3 + srcdir = File.expand_path("../..", __FILE__) + path = File.expand_path(path, srcdir) + if File.exist?(path) + "eval(%s, TOPLEVEL_BINDING, %s, %d)" % [ File.read(path).dump, prelude_name(filename, path).dump, 1] + else + orig + end + } lines << c_esc(line) } setup_lines = [] @@ -60,11 +74,16 @@ lines_list = preludes.map {|filename| require 'erb' tmp = ERB.new(<<'EOS', nil, '%').result(binding) +/* -*-c-*- + THIS FILE WAS AUTOGENERATED BY tool/compile_prelude.rb. DO NOT EDIT. + + soruces: <%= preludes.join(', ') %> +*/ #include "ruby/ruby.h" #include "vm_core.h" % preludes.zip(lines_list).each_with_index {|(prelude, (setup_lines, lines)), i| -static const char prelude_name<%=i%>[] = <%=c_esc("")%>; +static const char prelude_name<%=i%>[] = <%=c_esc(prelude_name(prelude))%>; static const char prelude_code<%=i%>[] = % (setup_lines+lines).each {|line| <%=line%> -- cgit v1.2.3