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

* common.mk (ID_H_TARGET): phony target to update id.h.

* tool/ifchange, win32/ifchange.bat: --timestamp option added.

* tool/generic_erb.rb: --timestamp, --output and --if-change options
  added.

* template/id.h.tmpl: moved from id.h.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-10-17 10:46:23 +00:00
parent 6e738bf2b1
commit b025ce4678
8 changed files with 142 additions and 45 deletions

View file

@ -1,3 +1,14 @@
Fri Oct 17 19:46:20 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (ID_H_TARGET): phony target to update id.h.
* tool/ifchange, win32/ifchange.bat: --timestamp option added.
* tool/generic_erb.rb: --timestamp, --output and --if-change options
added.
* template/id.h.tmpl: moved from id.h.
Fri Oct 17 18:33:12 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* array.c (ary_resize_capa): renamed RESIZE_CAPA.

View file

@ -17,6 +17,7 @@ EXTCONF = extconf.rb
RBCONFIG = ./.rbconfig.time
LIBRUBY_EXTS = ./.libruby-with-ext.time
RDOCOUT = $(EXTOUT)/rdoc
ID_H_TARGET = -id.h-
DMYEXT = dmyext.$(OBJEXT)
NORMALMAINOBJ = main.$(OBJEXT)
@ -441,7 +442,7 @@ win32.$(OBJEXT): {$(VPATH)}win32.c
RUBY_H_INCLUDES = {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}defines.h \
{$(VPATH)}intern.h {$(VPATH)}missing.h {$(VPATH)}st.h
ENCODING_H_INCLUDES= {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h
ID_H_INCLUDES = {$(VPATH)}id.h {$(VPATH)}parse.h
ID_H_INCLUDES = {$(VPATH)}id.h
VM_CORE_H_INCLUDES = {$(VPATH)}vm_core.h {$(VPATH)}vm_opts.h \
{$(VPATH)}vm.h {$(VPATH)}thread_$(THREAD_MODEL).h \
{$(VPATH)}node.h $(ID_H_INCLUDES)
@ -465,20 +466,20 @@ enum.$(OBJEXT): {$(VPATH)}enum.c $(RUBY_H_INCLUDES) {$(VPATH)}node.h \
{$(VPATH)}util.h
enumerator.$(OBJEXT): {$(VPATH)}enumerator.c $(RUBY_H_INCLUDES)
error.$(OBJEXT): {$(VPATH)}error.c {$(VPATH)}known_errors.inc $(RUBY_H_INCLUDES) \
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}parse.y
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h
eval.$(OBJEXT): {$(VPATH)}eval.c {$(VPATH)}eval_intern.h \
$(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES) {$(VPATH)}eval_error.c \
{$(VPATH)}eval_jump.c {$(VPATH)}debug.h {$(VPATH)}parse.y \
{$(VPATH)}eval_jump.c {$(VPATH)}debug.h \
{$(VPATH)}iseq.h
load.$(OBJEXT): {$(VPATH)}load.c {$(VPATH)}eval_intern.h \
{$(VPATH)}util.h $(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES) \
{$(VPATH)}dln.h {$(VPATH)}debug.h {$(VPATH)}parse.y
{$(VPATH)}dln.h {$(VPATH)}debug.h
file.$(OBJEXT): {$(VPATH)}file.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
$(ENCODING_H_INCLUDES) {$(VPATH)}util.h {$(VPATH)}dln.h
gc.$(OBJEXT): {$(VPATH)}gc.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
{$(VPATH)}regex.h $(ENCODING_H_INCLUDES) $(VM_CORE_H_INCLUDES) \
{$(VPATH)}gc.h {$(VPATH)}io.h {$(VPATH)}eval_intern.h {$(VPATH)}util.h \
{$(VPATH)}debug.h {$(VPATH)}parse.y
{$(VPATH)}debug.h
hash.$(OBJEXT): {$(VPATH)}hash.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h
inits.$(OBJEXT): {$(VPATH)}inits.c $(RUBY_H_INCLUDES)
io.$(OBJEXT): {$(VPATH)}io.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
@ -492,16 +493,16 @@ numeric.$(OBJEXT): {$(VPATH)}numeric.c $(RUBY_H_INCLUDES) \
$(ENCODING_H_INCLUDES)
object.$(OBJEXT): {$(VPATH)}object.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h
pack.$(OBJEXT): {$(VPATH)}pack.c $(RUBY_H_INCLUDES)
parse.$(OBJEXT): {$(VPATH)}parse.c {$(VPATH)}parse.y $(RUBY_H_INCLUDES) \
parse.$(OBJEXT): {$(VPATH)}parse.c $(RUBY_H_INCLUDES) \
{$(VPATH)}node.h $(ENCODING_H_INCLUDES) $(ID_H_INCLUDES) \
{$(VPATH)}regenc.h {$(VPATH)}regex.h {$(VPATH)}util.h {$(VPATH)}lex.c \
{$(VPATH)}keywords {$(VPATH)}id.c
proc.$(OBJEXT): {$(VPATH)}proc.c {$(VPATH)}eval_intern.h \
$(RUBY_H_INCLUDES) {$(VPATH)}gc.h $(VM_CORE_H_INCLUDES) \
{$(VPATH)}debug.h {$(VPATH)}parse.y
{$(VPATH)}debug.h
process.$(OBJEXT): {$(VPATH)}process.c $(RUBY_H_INCLUDES) \
{$(VPATH)}util.h {$(VPATH)}io.h $(ENCODING_H_INCLUDES) {$(VPATH)}dln.h \
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}parse.y
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h
random.$(OBJEXT): {$(VPATH)}random.c $(RUBY_H_INCLUDES)
range.$(OBJEXT): {$(VPATH)}range.c $(RUBY_H_INCLUDES) \
$(ENCODING_H_INCLUDES)
@ -525,11 +526,11 @@ regsyntax.$(OBJEXT): {$(VPATH)}regsyntax.c {$(VPATH)}regint.h \
{$(VPATH)}regenc.h {$(VPATH)}oniguruma.h $(RUBY_H_INCLUDES)
ruby.$(OBJEXT): {$(VPATH)}ruby.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \
$(ENCODING_H_INCLUDES) {$(VPATH)}eval_intern.h $(VM_CORE_H_INCLUDES) \
{$(VPATH)}dln.h {$(VPATH)}debug.h {$(VPATH)}parse.y
{$(VPATH)}dln.h {$(VPATH)}debug.h
safe.$(OBJEXT): {$(VPATH)}safe.c $(RUBY_H_INCLUDES) \
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}parse.y
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h
signal.$(OBJEXT): {$(VPATH)}signal.c $(RUBY_H_INCLUDES) \
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}parse.y
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h
sprintf.$(OBJEXT): {$(VPATH)}sprintf.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
{$(VPATH)}regex.h {$(VPATH)}vsnprintf.c $(ENCODING_H_INCLUDES)
st.$(OBJEXT): {$(VPATH)}st.c {$(VPATH)}config.h {$(VPATH)}defines.h \
@ -542,12 +543,12 @@ string.$(OBJEXT): {$(VPATH)}string.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
struct.$(OBJEXT): {$(VPATH)}struct.c $(RUBY_H_INCLUDES)
thread.$(OBJEXT): {$(VPATH)}thread.c {$(VPATH)}eval_intern.h \
$(RUBY_H_INCLUDES) {$(VPATH)}gc.h $(VM_CORE_H_INCLUDES) \
{$(VPATH)}debug.h {$(VPATH)}parse.y {$(VPATH)}thread_$(THREAD_MODEL).c
{$(VPATH)}debug.h {$(VPATH)}thread_$(THREAD_MODEL).c
transcode.$(OBJEXT): {$(VPATH)}transcode.c $(RUBY_H_INCLUDES) \
$(ENCODING_H_INCLUDES) {$(VPATH)}transcode_data.h
cont.$(OBJEXT): {$(VPATH)}cont.c $(RUBY_H_INCLUDES) \
$(VM_CORE_H_INCLUDES) {$(VPATH)}gc.h {$(VPATH)}eval_intern.h \
{$(VPATH)}debug.h {$(VPATH)}parse.y
{$(VPATH)}debug.h
time.$(OBJEXT): {$(VPATH)}time.c $(RUBY_H_INCLUDES) \
$(ENCODING_H_INCLUDES)
util.$(OBJEXT): {$(VPATH)}util.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h
@ -558,30 +559,28 @@ version.$(OBJEXT): {$(VPATH)}version.c $(RUBY_H_INCLUDES) \
compile.$(OBJEXT): {$(VPATH)}compile.c {$(VPATH)}iseq.h \
$(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES) {$(VPATH)}insns.inc \
{$(VPATH)}insns_info.inc {$(VPATH)}optinsn.inc {$(VPATH)}debug.h \
{$(VPATH)}parse.y
{$(VPATH)}insns_info.inc {$(VPATH)}optinsn.inc {$(VPATH)}debug.h
iseq.$(OBJEXT): {$(VPATH)}iseq.c {$(VPATH)}gc.h {$(VPATH)}iseq.h \
$(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES) {$(VPATH)}insns.inc \
{$(VPATH)}insns_info.inc {$(VPATH)}node_name.inc {$(VPATH)}debug.h \
{$(VPATH)}parse.y
{$(VPATH)}insns_info.inc {$(VPATH)}node_name.inc {$(VPATH)}debug.h
vm.$(OBJEXT): {$(VPATH)}vm.c {$(VPATH)}gc.h {$(VPATH)}iseq.h \
{$(VPATH)}eval_intern.h $(RUBY_H_INCLUDES) $(ENCODING_H_INCLUDES) \
$(VM_CORE_H_INCLUDES) {$(VPATH)}vm_method.c {$(VPATH)}vm_eval.c \
{$(VPATH)}vm_insnhelper.c {$(VPATH)}vm_insnhelper.h {$(VPATH)}vm_exec.c \
{$(VPATH)}vm_exec.h {$(VPATH)}insns.def {$(VPATH)}vmtc.inc \
{$(VPATH)}vm.inc {$(VPATH)}insns.inc {$(VPATH)}debug.h {$(VPATH)}parse.y
{$(VPATH)}vm.inc {$(VPATH)}insns.inc {$(VPATH)}debug.h
vm_dump.$(OBJEXT): {$(VPATH)}vm_dump.c $(RUBY_H_INCLUDES) \
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}parse.y
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h
debug.$(OBJEXT): {$(VPATH)}debug.c $(RUBY_H_INCLUDES) \
$(ENCODING_H_INCLUDES) $(VM_CORE_H_INCLUDES) {$(VPATH)}eval_intern.h \
{$(VPATH)}util.h {$(VPATH)}debug.h {$(VPATH)}parse.y
{$(VPATH)}util.h {$(VPATH)}debug.h
id.$(OBJEXT): {$(VPATH)}id.c $(RUBY_H_INCLUDES) $(ID_H_INCLUDES)
miniprelude.$(OBJEXT): {$(VPATH)}miniprelude.c $(RUBY_H_INCLUDES) \
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}parse.y
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h
prelude.$(OBJEXT): {$(VPATH)}prelude.c $(RUBY_H_INCLUDES) \
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}parse.y
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h
golf_prelude.$(OBJEXT): {$(VPATH)}golf_prelude.c $(RUBY_H_INCLUDES) \
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}parse.y
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h
goruby.$(OBJEXT): {$(VPATH)}goruby.c {$(VPATH)}main.c $(RUBY_H_INCLUDES) \
{$(VPATH)}debug.h {$(VPATH)}node.h
@ -626,7 +625,7 @@ vmtc.inc: $(srcdir)/template/vmtc.inc.tmpl
vm.inc: $(srcdir)/template/vm.inc.tmpl
srcs: {$(VPATH)}parse.c {$(VPATH)}lex.c {$(VPATH)}newline.c $(srcdir)/ext/ripper/ripper.c srcs-enc
srcs: {$(VPATH)}parse.c $(ID_H_TARGET) {$(VPATH)}lex.c {$(VPATH)}newline.c $(srcdir)/ext/ripper/ripper.c srcs-enc
srcs-enc: $(ENC_MK)
$(MAKE) -f $(ENC_MK) RUBY="$(MINIRUBY)" MINIRUBY="$(MINIRUBY)" $(MFLAGS) srcs
@ -646,6 +645,12 @@ transdb.h: $(PREP) srcs-enc
$(MINIRUBY) $(srcdir)/enc/trans/make_transdb.rb $@.new $(srcdir)/enc/trans enc/trans
$(IFCHANGE) "$@" "$@.new"
{$(VPATH)}id.h:
$(CPP) $(CPPFLAGS) -DUSE_PARSE_H $@
$(ID_H_TARGET): {$(VPATH)}parse.c $(srcdir)/tool/generic_erb.rb $(srcdir)/template/id.h.tmpl
$(BASERUBY) $(srcdir)/tool/generic_erb.rb --if-change --output=$(srcdir)/id.h $(srcdir)/template/id.h.tmpl --vpath=$(VPATH) parse.c
known_errors.inc: $(srcdir)/template/known_errors.inc.tmpl $(srcdir)/defs/known_errors.def
$(BASERUBY) $(srcdir)/tool/generic_erb.rb $(srcdir)/template/known_errors.inc.tmpl $(srcdir)/defs/known_errors.def > $@

View file

@ -9,7 +9,7 @@ ifeq (@target_os@,cygwin)
else
DLL_BASE_NAME := $(RUBY_SO_NAME)
DLLWRAP += -mno-cygwin
VPATH += $(srcdir)/win32
VPATH := $(VPATH):$(srcdir)/win32
endif
ifneq ($(ENABLE_SHARED),yes)

View file

@ -19,6 +19,7 @@
#include "ruby/st.h"
#include "ruby/encoding.h"
#include "node.h"
#include "parse.h"
#include "id.h"
#include "regenc.h"
#include <stdio.h>

View file

@ -1,3 +1,5 @@
%# -*- c -*-
/* DO NOT EDIT THIS FILE DIRECTLY */
/**********************************************************************
id.h -
@ -8,7 +10,28 @@
Copyright (C) 2007 Koichi Sasada
**********************************************************************/
<%
require 'optparse'
vpath = ["."]
input = nil
opt = OptionParser.new do |o|
o.on('-v', '--vpath=DIR') {|dirs| vpath.concat dirs.split(File::PATH_SEPARATOR)}
input, = o.order!(ARGV)
end or abort opt.opt_s
tokens = nil
vpath.find do |dir|
begin
if line = File.read(File.join(dir, input))[/^\s*enum\s+yytokentype\s*\{([^{}]*)\s*\};/m, 1]
tokens = line.scan(/\b(t(?:LAST_TOKEN|U(?:PLUS|MINUS)|POW|CMP|EQQ?|[NGL]EQ|(?:AND|OR)OP|N?MATCH|DOT\d|AREF|ASET|[LR]SHFT|LAMBDA)|id\w+)\s*=\s*(\d+),?/m)
end
rescue Errno::ENOENT
nil
else
true
end
end
%>
#ifndef RUBY_ID_H
#define RUBY_ID_H
@ -23,12 +46,21 @@
#define ID_JUNK 0x07
#define ID_INTERNAL ID_JUNK
#ifdef USE_PARSE_H
#include "parse.h"
#endif
#define symIFUNC ID2SYM(idIFUNC)
#define symCFUNC ID2SYM(idCFUNC)
enum ruby_method_ids {
#ifndef tLAST_TOKEN
% tokens.each do |token, value|
<%=token%> = <%=value%>,
% end
#elif <%= tokens.map {|token, value|"#{token} != #{value}"}.join(" || \\\n ") %>
#error id.h is out of date.
#endif
idPLUS = '+',
idMINUS = '-',
idMULT = '*',
@ -62,22 +94,22 @@ enum ruby_method_ids {
tBitblt,
tAnswer,
#endif
tLAST_ID
tLAST_ID,
#define TOKEN2ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL)
TOKEN2ID(Intern),
TOKEN2ID(MethodMissing),
TOKEN2ID(Length),
TOKEN2ID(Gets),
TOKEN2ID(Succ),
TOKEN2ID(Each),
TOKEN2ID(Lambda),
TOKEN2ID(Send),
TOKEN2ID(__send__),
TOKEN2ID(Initialize),
#if SUPPORT_JOKE
TOKEN2ID(Bitblt),
TOKEN2ID(Answer),
#endif
};
#define idIntern ((tIntern<<ID_SCOPE_SHIFT)|ID_LOCAL)
#define idMethodMissing ((tMethodMissing<<ID_SCOPE_SHIFT)|ID_LOCAL)
#define idLength ((tLength<<ID_SCOPE_SHIFT)|ID_LOCAL)
#define idGets ((tGets<<ID_SCOPE_SHIFT)|ID_LOCAL)
#define idSucc ((tSucc<<ID_SCOPE_SHIFT)|ID_LOCAL)
#define idEach ((tEach<<ID_SCOPE_SHIFT)|ID_LOCAL)
#define idLambda ((tLambda<<ID_SCOPE_SHIFT)|ID_LOCAL)
#define idSend ((tSend<<ID_SCOPE_SHIFT)|ID_LOCAL)
#define id__send__ ((t__send__<<ID_SCOPE_SHIFT)|ID_LOCAL)
#define idInitialize ((tInitialize<<ID_SCOPE_SHIFT)|ID_LOCAL)
#if SUPPORT_JOKE
#define idBitblt ((tBitblt<<ID_SCOPE_SHIFT)|ID_LOCAL)
#define idAnswer ((tAnswer<<ID_SCOPE_SHIFT)|ID_LOCAL)
#endif
#endif /* RUBY_ID_H */

View file

@ -1,4 +1,34 @@
require 'erb'
require 'optparse'
require 'fileutils'
timestamp = nil
output = nil
ifchange = nil
opt = OptionParser.new do |o|
o.on('-t', '--timestamp[=PATH]') {|v| timestamp = v || true}
o.on('-o', '--output=PATH') {|v| output = v}
o.on('-c', '--[no-]if-change') {|v| ifchange = v}
o.order!(ARGV)
end or abort opt.opt_s
template = ARGV.shift
ERB.new(File.read(template), nil, '%').run
erb = ERB.new(File.read(template), nil, '%')
erb.filename = template
result = erb.result
if output
if ifchange
if (IO.read(output) rescue nil) == result
puts "#{output} unchanged"
else
open(output, "wb") {|f| f.print result}
puts "#{output} updated"
end
end
if timestamp
if timestamp == true
dir, base = File.split(output)
timestamp = File.join(dir, ".time." + base)
end
FileUtils.touch(timestamp)
end
end

View file

@ -1,6 +1,11 @@
#!/bin/sh
# usage: ifchange target temporary
unset timestamp
if [ "$1" = --timestamp ]; then
timestamp=yes
shift
fi
target="$1"
temp="$2"
if [ "$temp" = - ]; then
@ -15,3 +20,6 @@ else
echo "$target updated"
mv -f "$temp" "$target"
fi
if [ $timestamp ]; then
touch `dirname "$target"`/.time.`basename "$target"`
fi

View file

@ -3,6 +3,11 @@
if "%1" == "" goto :end
set timestamp=
if "%1" == "--timestamp" (
set timestamp=yes
shift
)
set dest=%1
set src=%2
set dest=%dest:/=\%
@ -47,13 +52,18 @@ goto :end
if not exist %src% goto :end
if exist %dest% (
fc.exe %dest% %src% > nul && (
echo %dest% unchanged.
echo %1 unchanged.
del %src%
goto :end
goto :nt_end
)
)
echo %dest% updated.
echo %1 updated.
copy %src% %dest% > nul
del %src%
:nt_end
if "%timestamp%" == "" goto :end
for %%I in ("%dest%") do set timestamp=%%~dpI\.time.%%~nxI
if not exist "%timestamp%" copy nul "%timestamp%" > nul
goto :end >> "%timestamp%"
:end