Files
Yusuke EndohandClaude Opus 5.5 9b23d39c44 [ruby/prism] Resync prism as Ruby::Prism
This is the output of

    ruby tool/sync_default_gems.rb prism
    git rm -r lib/prism.rb lib/prism

at https://github.com/ruby/prism/commit/0a5f9c9, with the new mapping:
lib/prism is now lib/ruby/prism, the namespace is rewritten to
Ruby::Prism, and lib/prism/prism.gemspec is no longer imported, so
prism is no longer installed as a default gem.

prism/srcs.mk.in (excluded from the sync) follows the template engine,
now Ruby::Prism::Template: it defines the Ruby module, which does not
exist in BASERUBY older than Ruby 4.0, before loading
templates/template.rb.

Ruby::Prism is the very parser that parsed the running code, no
matter which version of the prism gem is installed; the two can be
loaded side by side (the ruby binary is built with -fvisibility=hidden,
so the gem's pm_* and rb_cPrism* symbols do not collide with the
built-in ones).

[Bug #22379]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 04:27:15 +09:00

58 lines
1.9 KiB
Ruby

<% # -*- ruby -*-
# :stopdoc:
# templates/template.rb defines Ruby::Prism::Template, and BASERUBY may be
# older than Ruby 4.0, where the Ruby module does not exist.
module Ruby; end unless defined?(Ruby)
require_relative 'templates/template'
script = File.basename(__FILE__)
srcs = output ? File.basename(output) : script.chomp('.in')
mk = 'uncommon.mk'
# %>
PRISM_TEMPLATES_DIR = $(PRISM_SRCDIR)/templates
PRISM_TEMPLATE = $(PRISM_TEMPLATES_DIR)/template.rb
PRISM_RUN_TEMPLATE = $(BASERUBY) -e "module Ruby; end unless defined?(Ruby); load ARGV.shift; Ruby::Prism::Template.render(ARGV[0], write_to: ARGV[1])" $(PRISM_TEMPLATE)
PRISM_CONFIG = $(PRISM_SRCDIR)/config.yml
srcs <%=%><%=mk%>: prism/.srcs.mk.time
prism/.srcs.mk.time: $(order_only) $(PRISM_BUILD_DIR)/.time
prism/$(HAVE_BASERUBY:no=.srcs.mk.time):
touch $@
prism/$(HAVE_BASERUBY:yes=.srcs.mk.time): \
$(PRISM_SRCDIR)/templates/template.rb \
$(PRISM_SRCDIR)/<%=%><%=script%>
$(BASERUBY) $(tooldir)/generic_erb.rb -c -t$@ -o $(PRISM_SRCDIR)/<%=%><%=srcs%> $(PRISM_SRCDIR)/<%=%><%=script%>
distclean-prism-srcs::
$(RM) prism/.srcs.mk.time
$(RMDIRS) prism || $(NULLCMD)
distclean-srcs-local:: distclean-prism-srcs
realclean-prism-srcs:: distclean-prism-srcs
$(RM) $(PRISM_SRCDIR)/<%=%><%=srcs%>
realclean-srcs-local:: realclean-prism-srcs
main srcs: prism-srcs
main incs: prism-incs
<% Ruby::Prism::Template::TEMPLATES.map do |t|
/\.(?:[ch]|rb)\z/ =~ t or next
s = '$(srcdir)/' + t.sub(%r[\A(?:(src)|ext|include)/]) {$1 && 'prism/'}
s.sub!(%r[\A\$\(srcdir\)/lib/prism/], %q[$(srcdir)/lib/ruby/prism/])
s.sub!(%r[\A\$(srcdir)/prism/], '$(PRISM_SRCDIR)/')
target = s.end_with?('.h') ? 'incs' : 'srcs'
# %>
prism-<%=%><%=target%>: <%=%><%=s%>
<%=%><%=s%>: $(PRISM_CONFIG) $(PRISM_TEMPLATE) $(PRISM_TEMPLATES_DIR)/<%=%><%=t%>.erb
$(Q) $(PRISM_RUN_TEMPLATE) <%=%><%=t%> $@
realclean-prism-srcs::
$(RM) <%=%><%=s%>
<%
end
# %>