* enc/depend, enc/make_encmake.rb: use erb.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-12-22 18:35:53 +00:00
Родитель 872899fa58
Коммит cd42707d86
3 изменённых файлов: 41 добавлений и 38 удалений

Просмотреть файл

@ -1,4 +1,4 @@
Sun Dec 23 03:26:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Dec 23 03:35:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* version.h: use patchlevel if revision is not set. * version.h: use patchlevel if revision is not set.
@ -8,6 +8,8 @@ Sun Dec 23 03:26:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (encs, ext/ripper/ripper.c): MAKEFLAGS needs -. * common.mk (encs, ext/ripper/ripper.c): MAKEFLAGS needs -.
* enc/depend, enc/make_encmake.rb: use erb.
Sun Dec 23 01:56:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org> Sun Dec 23 01:56:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_mode_enc): do not set encoding unless explicitly * io.c (rb_io_mode_enc): do not set encoding unless explicitly

Просмотреть файл

@ -1,49 +1,49 @@
! encs = Dir.open($srcdir) {|d| d.grep(/.+\.c\z/)} - BUILTIN_ENCS % encs = Dir.open($srcdir) {|d| d.grep(/.+\.c\z/)} - BUILTIN_ENCS
! encs.each {|e| e.chomp!(".c")} % encs.each {|e| e.chomp!(".c")}
! encs = encs.sort_by {|e| e.split(/(\d+)/).map {|n| Integer(n) rescue n}} % encs = encs.sort_by {|e| e.split(/(\d+)/).map {|n| Integer(n) rescue n}}
VPATH = <% %w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(top_srcdir) $(srcdir)].join(CONFIG["PATH_SEPARATOR"]) %> VPATH = <%=%w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(top_srcdir) $(srcdir)].join(CONFIG["PATH_SEPARATOR"])%>
LIBPATH = <%libpathflag($DEFLIBPATH)%> LIBPATH = <%=libpathflag($DEFLIBPATH)%>
ENCOBJS = <%encs.map {|e|"#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%"\n" if encs.size>1%> ENCOBJS = <%=encs.map {|e|"#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%="\n" if encs.size>1%>
ENCDEFS = <%encs.map {|e|"#{e}.def"}.join(" \\\n\t ") if DEFFILE%><%"\n" if encs.size>1%> ENCDEFS = <%=encs.map {|e|"#{e}.def"}.join(" \\\n\t ") if DEFFILE%><%="\n" if encs.size>1%>
ENCSOS = <%encs.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%> ENCSOS = <%=encs.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%>
all: $(ENCSOS) all: $(ENCSOS)
! COMPILE_RULES.each do |rule| % COMPILE_RULES.each do |rule|
<% rule % %w[c $(OBJEXT)] %> <%= rule % %w[c $(OBJEXT)] %>
<%COMPILE_C%> <%=COMPILE_C%>
! end % end
! unless encs.empty? % unless encs.empty?
$(ENCOBJS): regenc.h oniguruma.h config.h defines.h $(ENCOBJS): regenc.h oniguruma.h config.h defines.h
! encs.each do |e| % encs.each do |e|
<%e%>.so: $(ENCSODIR)/<%e%>.$(DLEXT) <%=e%>.so: $(ENCSODIR)/<%=e%>.$(DLEXT)
! end % end
! end % end
! link_so = LINK_SO.gsub(/\n/, "\n\t") % link_so = LINK_SO.gsub(/\n/, "\n\t")
! encs.each do |e| % encs.each do |e|
! deps = "#{e}.$(OBJEXT)" % deps = "#{e}.$(OBJEXT)"
! deps << " #{e}-$(arch).def" if DEFFILE % deps << " #{e}-$(arch).def" if DEFFILE
$(ENCSODIR)/<%e%>.$(DLEXT): <%deps%> $(ENCSODIR)/<%=e%>.$(DLEXT): <%=deps%>
<%link_so.sub(/\$\(OBJS\)/, deps)%> <%=link_so.sub(/\$\(OBJS\)/, deps)%>
! end % end
! if DEFFILE % if DEFFILE
! encs.each do |e| % encs.each do |e|
<%e%>-$(arch).def: enc.mk <%=e%>-$(arch).def: enc.mk
echo EXPORTS > $@ echo EXPORTS > $@
echo <%EXPORT_PREFIX%>Init_<%e%> >> $@ echo <%=EXPORT_PREFIX%>Init_<%=e%> >> $@
! end % end
! end % end
! encs.each do |e| % encs.each do |e|
<%e%>.$(OBJEXT): <%e%>.c <%=e%>.$(OBJEXT): <%=e%>.c
! end % end
clean: clean:
$(RM) $(ENCSOS) $(RM) $(ENCSOS)

Просмотреть файл

@ -5,10 +5,10 @@ $:.unshift(File.join(dir, "lib"))
$:.unshift(dir) $:.unshift(dir)
$:.unshift(".") $:.unshift(".")
require 'mkmf' require 'mkmf'
require 'tool/serb' require 'erb'
if /--builtin-encs=/ =~ ARGV[0] if /--builtin-encs=/ =~ ARGV[0]
BUILTIN_ENCS = $'.split.each {|e| e.sub!(/(?:\.\w+)?\z/, '.c')} BUILTIN_ENCS = $'.split.map {|e| File.basename(e, '.*') << '.c'}
ARGV.shift ARGV.shift
else else
BUILTIN_ENCS = [] BUILTIN_ENCS = []
@ -19,8 +19,9 @@ DEFFILE = (true if CONFIG["DLDFLAGS"].sub!(/\s+-def:\$\(DEFFILE\)\s+/, ' '))
mkin = File.read(File.join($srcdir, "Makefile.in")) mkin = File.read(File.join($srcdir, "Makefile.in"))
mkin.gsub!(/@(#{CONFIG.keys.join('|')})@/) {CONFIG[$1]} mkin.gsub!(/@(#{CONFIG.keys.join('|')})@/) {CONFIG[$1]}
if File.exist?(depend = File.join($srcdir, "depend")) if File.exist?(depend = File.join($srcdir, "depend"))
tmp = '' erb = ERB.new(File.read(depend), nil, '%')
eval(serb(File.read(depend), 'tmp'), binding, depend) erb.filename = depend
tmp = erb.result(binding)
mkin << "\n#### depend ####\n\n" << depend_rules(tmp).join mkin << "\n#### depend ####\n\n" << depend_rules(tmp).join
end end
open(ARGV[0], 'wb') {|f| open(ARGV[0], 'wb') {|f|