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

Process token IDs from id.def without id.h

Fixes id.h error during updating ripper.c by `make after-update`.

While it used to update id.h in the build directory, but was trying to
update ripper.c in the source directory.  In principle, files in the
source directory can or should not depend on files in the build
directory.
This commit is contained in:
Nobuyoshi Nakada 2022-09-08 15:36:04 +09:00
parent a977c66312
commit bcf82b7c26
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
3 changed files with 8 additions and 12 deletions

View file

@ -933,7 +933,7 @@ PHONY:
{$(srcdir)}.y.c:
$(ECHO) generating $@
$(Q)$(BASERUBY) $(tooldir)/id2token.rb --path-separator=.$(PATH_SEPARATOR)./ --vpath=$(VPATH) id.h $(SRC_FILE) > parse.tmp.y
$(Q)$(BASERUBY) $(tooldir)/id2token.rb $(SRC_FILE) > parse.tmp.y
$(Q)$(BASERUBY) $(tooldir)/pure_parser.rb parse.tmp.y $(YACC)
$(Q)$(RM) parse.tmp.y.bak
$(Q)$(YACC) -d $(YFLAGS) -o y.tab.c parse.tmp.y
@ -1219,7 +1219,7 @@ revision.$(HAVE_BASERUBY:yes=tmp):: $(srcdir)/version.h $(tooldir)/file2lastrev.
$(REVISION_H): revision.tmp
$(Q)$(IFCHANGE) "--timestamp=$@" "$(srcdir)/revision.h" revision.tmp
$(srcdir)/ext/ripper/ripper.c: $(srcdir)/ext/ripper/tools/preproc.rb $(srcdir)/parse.y id.h $(srcdir)/ext/ripper/depend
$(srcdir)/ext/ripper/ripper.c: $(srcdir)/ext/ripper/tools/preproc.rb $(srcdir)/parse.y $(srcdir)/defs/id.def $(srcdir)/ext/ripper/depend
$(ECHO) generating $@
$(Q) $(CHDIR) $(@D) && \
sed -e 's/{\$$([^(){}]*)[^{}]*}//g' -e /AUTOGENERATED/q depend | \

View file

@ -17,10 +17,9 @@ ripper.o: ripper.c
all: check
static: check
ripper.y: $(srcdir)/tools/preproc.rb $(srcdir)/tools/dsl.rb $(top_srcdir)/parse.y {$(VPATH)}id.h
ripper.y: $(srcdir)/tools/preproc.rb $(srcdir)/tools/dsl.rb $(top_srcdir)/parse.y $(top_srcdir)/defs/id.def
$(ECHO) extracting $@ from $(top_srcdir)/parse.y
$(Q) $(RUBY) $(top_srcdir)/tool/id2token.rb --path-separator=.$(PATH_SEPARATOR)./ \
--vpath=$(VPATH)$(PATH_SEPARATOR)$(top_srcdir) id.h $(top_srcdir)/parse.y > ripper.tmp.y
$(Q) $(RUBY) $(top_srcdir)/tool/id2token.rb $(top_srcdir)/parse.y > ripper.tmp.y
$(Q) $(RUBY) $(top_srcdir)/tool/pure_parser.rb ripper.tmp.y $(BISON)
$(Q) $(RM) ripper.tmp.y.bak
$(Q) $(RUBY) $(srcdir)/tools/preproc.rb ripper.tmp.y --output=$@

View file

@ -5,18 +5,15 @@
BEGIN {
require 'optparse'
require_relative 'lib/vpath'
vpath = VPath.new
header = nil
opt = OptionParser.new do |o|
vpath.def_options(o)
header = o.order!(ARGV).shift
o.order!(ARGV)
end or abort opt.opt_s
TOKENS = {}
h = vpath.read(header) rescue abort("#{header} not found in #{vpath.inspect}")
h.scan(/^#define\s+RUBY_TOKEN_(\w+)\s+(\d+)/) do |token, id|
defs = File.join(File.dirname(File.dirname(__FILE__)), "defs/id.def")
ids = eval(File.read(defs), nil, defs)
ids[:token_op].each do |_id, _op, token, id|
TOKENS[token] = id
end