1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Set fake.rb variables by command line arguments

Then fallbacks to preprocessed version.h.
This commit is contained in:
Nobuyoshi Nakada 2022-09-05 11:00:20 +09:00
parent f6d569b7c0
commit 68a092a469
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -9,19 +9,23 @@ while /\A(\w+)=(.*)/ =~ ARGV[0]
end end
if inc = arg['i'] if inc = arg['i']
src = inc == '-' ? STDIN.read : File.read(inc) src = inc == '-' ? STDIN.read : File.read(inc)
def src.value(name) else
eval(self[/\bruby_#{name}(?:\[\])?\s*=\s*((?:"(?:\\.|[^\"\\])*"\s*)*(?=;)|[^{};]+)/m, 1]. src = ""
gsub(/#/, '\\#').
gsub(/((?:\G|[^\\])(?:\\\\)*)\n/, '\1'))
end
arg['versions'] = version = {}
File.read(File.join(arg['srcdir'], 'version.c')).
scan(/rb_define_global_const\("(RUBY_\w+)",[^;]*?\bMK(?:INT|STR)\(([^()]*)\)/m) do |n, v|
version[n] = src.value(v)
end
arg['RUBY_DESCRIPTION_WITH_MJIT'] = src.value('description_with_mjit')
arg['RUBY_DESCRIPTION_WITH_YJIT'] = src.value('description_with_yjit')
end end
def src.value(name)
unless val = self[/\bruby_#{name}(?:\[\])?\s*=\s*((?:"(?:\\.|[^\"\\])*"\s*)*(?=;)|[^{};]+)/m, 1]
return
end
eval(val.gsub(/#/, '\\#').gsub(/((?:\G|[^\\])(?:\\\\)*)\n/, '\1'))
end
version = Hash.new {|h, v| h[v] || src.value(v)}
arg['versions'] = version
File.read(File.join(arg['srcdir'], 'version.c')).
scan(/rb_define_global_const\("(RUBY_\w+)",[^;]*?\bMK(?:INT|(STR))\(([^()]*)\)/m) do |n, s, v|
version[n] = arg[v] || (s ? "" : 0)
end
arg['RUBY_DESCRIPTION_WITH_MJIT'] = arg['description_with_mjit'] || ""
arg['RUBY_DESCRIPTION_WITH_YJIT'] = arg['description_with_yjit'] || ""
%>baseruby="<%=arg['BASERUBY']%>" %>baseruby="<%=arg['BASERUBY']%>"
_\ _\
=begin =begin