diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-30 14:12:25 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-30 14:12:25 +0000 |
commit | e60463034a468ec9fcee73466e76bd541c9a39c3 (patch) | |
tree | fbb640c59324a524ee50396c7e7a40923cdaa7a4 /tool | |
parent | 045136d47599596c78e72ecb8de688671dfae669 (diff) | |
download | ruby-e60463034a468ec9fcee73466e76bd541c9a39c3.tar.gz |
* 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
Diffstat (limited to 'tool')
-rwxr-xr-x | tool/compile_prelude.rb | 21 |
1 files changed, 20 insertions, 1 deletions
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(":") + "<internal:" + prelude + ">" +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("<internal:" + File.basename(prelude, ".rb") + ">")%>; +static const char prelude_name<%=i%>[] = <%=c_esc(prelude_name(prelude))%>; static const char prelude_code<%=i%>[] = % (setup_lines+lines).each {|line| <%=line%> |