2022-04-01 07:15:00 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
# shareable_constant_value: literal
|
2015-06-09 22:06:28 -04:00
|
|
|
<%
|
|
|
|
arg = {}
|
|
|
|
while /\A(\w+)=(.*)/ =~ ARGV[0]
|
|
|
|
arg[$1] = $2
|
|
|
|
arg[$1].tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
|
|
|
|
ARGV.shift
|
|
|
|
end
|
2015-07-28 22:06:38 -04:00
|
|
|
if inc = arg['i']
|
|
|
|
src = inc == '-' ? STDIN.read : File.read(inc)
|
2022-09-04 22:00:20 -04:00
|
|
|
else
|
|
|
|
src = ""
|
|
|
|
end
|
|
|
|
def src.value(name)
|
|
|
|
unless val = self[/\bruby_#{name}(?:\[\])?\s*=\s*((?:"(?:\\.|[^\"\\])*"\s*)*(?=;)|[^{};]+)/m, 1]
|
|
|
|
return
|
2015-06-09 22:06:28 -04:00
|
|
|
end
|
2022-09-04 22:00:20 -04:00
|
|
|
eval(val.gsub(/#/, '\\#').gsub(/((?:\G|[^\\])(?:\\\\)*)\n/, '\1'))
|
|
|
|
end
|
2022-09-04 22:25:42 -04:00
|
|
|
arg['versions'] = version = {}
|
2022-09-04 22:00:20 -04:00
|
|
|
File.read(File.join(arg['srcdir'], 'version.c')).
|
|
|
|
scan(/rb_define_global_const\("(RUBY_\w+)",[^;]*?\bMK(?:INT|(STR))\(([^()]*)\)/m) do |n, s, v|
|
2022-09-05 00:08:23 -04:00
|
|
|
version[n] = arg[v] || src.value(v) || (s ? v : 0)
|
2015-06-09 22:06:28 -04:00
|
|
|
end
|
2022-09-05 00:08:23 -04:00
|
|
|
arg['RUBY_DESCRIPTION_WITH_MJIT'] = src.value('description_with_mjit') || 'description_with_mjit'
|
|
|
|
arg['RUBY_DESCRIPTION_WITH_YJIT'] = src.value('description_with_yjit') || 'description_with_yjit'
|
2015-06-09 22:06:28 -04:00
|
|
|
%>baseruby="<%=arg['BASERUBY']%>"
|
2015-11-22 01:42:14 -05:00
|
|
|
_\
|
|
|
|
=begin
|
2015-04-12 19:24:33 -04:00
|
|
|
_=
|
2015-11-22 01:42:14 -05:00
|
|
|
ruby="${RUBY-$baseruby}"
|
|
|
|
case "$ruby" in "echo "*) $ruby; exit $?;; esac
|
|
|
|
case "$0" in /*) r=-r"$0";; *) r=-r"./$0";; esac
|
|
|
|
exec $ruby "$r" "$@"
|
|
|
|
=end
|
|
|
|
=baseruby
|
2009-02-19 01:47:13 -05:00
|
|
|
class Object
|
2011-02-10 21:39:05 -05:00
|
|
|
remove_const :CROSS_COMPILING if defined?(CROSS_COMPILING)
|
2009-02-19 01:47:13 -05:00
|
|
|
CROSS_COMPILING = RUBY_PLATFORM
|
2015-06-09 22:06:28 -04:00
|
|
|
constants.grep(/^RUBY_/) {|n| remove_const n}
|
|
|
|
% arg['versions'].each {|n, v|
|
2022-04-11 13:28:07 -04:00
|
|
|
<%=n%> = <%if n=='RUBY_DESCRIPTION' %>case
|
|
|
|
when RubyVM.const_defined?(:MJIT) && RubyVM::MJIT.enabled?
|
|
|
|
<%=arg['RUBY_DESCRIPTION_WITH_MJIT'].inspect%>
|
|
|
|
when RubyVM.const_defined?(:YJIT) && RubyVM::YJIT.enabled?
|
|
|
|
<%=arg['RUBY_DESCRIPTION_WITH_YJIT'].inspect%>
|
|
|
|
else
|
|
|
|
<%=v.inspect%>
|
|
|
|
end<%else%><%=v.inspect%><%end%>
|
2015-06-09 22:06:28 -04:00
|
|
|
% }
|
2009-02-19 01:47:13 -05:00
|
|
|
end
|
2015-04-12 19:25:21 -04:00
|
|
|
builddir = File.dirname(File.expand_path(__FILE__))
|
2015-09-04 06:06:49 -04:00
|
|
|
srcdir = "<%=arg['srcdir']%>"
|
|
|
|
top_srcdir = File.realpath(srcdir, builddir)
|
2014-07-06 01:20:10 -04:00
|
|
|
fake = File.join(top_srcdir, "tool/fake.rb")
|
2018-08-27 10:25:14 -04:00
|
|
|
eval(File.binread(fake), nil, fake)
|
2018-07-03 00:43:27 -04:00
|
|
|
ropt = "-r#{__FILE__}"
|
|
|
|
["RUBYOPT"].each do |flag|
|
2018-08-27 10:33:10 -04:00
|
|
|
opt = ENV[flag]
|
2019-04-18 18:30:01 -04:00
|
|
|
opt = opt ? ([ropt] | opt.b.split(/\s+/)).join(" ") : ropt
|
2018-07-03 00:43:27 -04:00
|
|
|
ENV[flag] = opt
|
|
|
|
end
|