summaryrefslogtreecommitdiff
path: root/template
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-10 02:06:28 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-10 02:06:28 (GMT)
commitc5634371dcd1e49501989f3c713f1fd1f76c572e (patch)
treebd895b70c1f04fde447ef9a8579a7eb0ee3db1bd /template
parentd3bce791837b0384f8b68212334cc172b4423754 (diff)
fake.rb.in: accurate fake
* template/fake.rb.in: turn into erb template from autoconf template to fake more accurately. * common.mk (fake.rb): needs preprocessed file now. * version.c (Init_version): add dummy expression to RUBY_ENGINE_VERSION. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'template')
-rw-r--r--template/fake.rb.in33
1 files changed, 20 insertions, 13 deletions
diff --git a/template/fake.rb.in b/template/fake.rb.in
index 7e47c2c..a2de876 100644
--- a/template/fake.rb.in
+++ b/template/fake.rb.in
@@ -1,4 +1,18 @@
-baseruby="@BASERUBY@"
+<%
+arg = {}
+while /\A(\w+)=(.*)/ =~ ARGV[0]
+ arg[$1] = $2
+ arg[$1].tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
+ ARGV.shift
+end
+if arg['i']
+ src = File.read(arg['i'])
+ arg['versions'] = version = {}
+ src.scan(/rb_define_global_const\("(RUBY_\w+)",\s*(?:.*rb_\w*str_new\w*\((\w+)|\(*\(VALUE\)\((.+)\)\)\s*<<\s?)/) do |n, s, i|
+ version[n] = i ? i.to_i : src[/\b#{s}\[\]\s*=\s*((?:"(?:\\.|[^\"\\])*"\s*)*);/m, 1].gsub(/\A"|"\z|" *"/, '').gsub(/\\(.)/, '\1')
+ end
+end
+%>baseruby="<%=arg['BASERUBY']%>"
ruby="${RUBY-$baseruby}"
_=
"eval" "{" \
@@ -10,20 +24,13 @@ ruby=ruby
class Object
remove_const :CROSS_COMPILING if defined?(CROSS_COMPILING)
CROSS_COMPILING = RUBY_PLATFORM
- remove_const :RUBY_PLATFORM
- remove_const :RUBY_VERSION
- remove_const :RUBY_PATCHLEVEL
- remove_const :RUBY_RELEASE_DATE
- remove_const :RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
- RUBY_PLATFORM = "@arch@"
- RUBY_VERSION = "@RUBY_PROGRAM_VERSION@"
- RUBY_PATCHLEVEL = @PATCHLEVEL@
- RUBY_RELEASE_DATE = "@RUBY_RELEASE_DATE@"
- patchlevel_str = RUBY_PATCHLEVEL == -1 ? "dev" : "p#{RUBY_PATCHLEVEL}"
- RUBY_DESCRIPTION = "ruby #{RUBY_VERSION}#{patchlevel_str} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
+ constants.grep(/^RUBY_/) {|n| remove_const n}
+% arg['versions'].each {|n, v|
+ <%=n%> = <%=v.inspect%>
+% }
end
builddir = File.dirname(File.expand_path(__FILE__))
-top_srcdir = File.expand_path("@srcdir@", builddir)
+top_srcdir = File.expand_path("<%=arg['srcdir']%>", builddir)
$:.unshift(builddir)
fake = File.join(top_srcdir, "tool/fake.rb")
eval(File.read(fake), nil, fake)