ruby-changes:38353
From: nobu <ko1@a...>
Date: Thu, 7 May 2015 06:54:23 +0900 (JST)
Subject: [ruby-changes:38353] nobu:r50434 (trunk): io/console: win32_vk dependencies
nobu 2015-05-07 06:54:07 +0900 (Thu, 07 May 2015) New Revision: 50434 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50434 Log: io/console: win32_vk dependencies * ext/io/console/depend: check if VK table is modified by the checksum. Added files: trunk/ext/io/console/win32_vk.chksum trunk/tool/checksum.rb Modified files: trunk/ext/io/console/depend trunk/ext/io/console/extconf.rb Index: ext/io/console/depend =================================================================== --- ext/io/console/depend (revision 50433) +++ ext/io/console/depend (revision 50434) @@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/io/console/depend#L1 +WIN32_VK_HEADER = {$(srcdir)}win32_vk.chksum + $(OBJS): $(HDRS) $(ruby_headers) \ $(VK_HEADER) \ $(hdrdir)/ruby/io.h \ @@ -6,5 +8,12 @@ $(OBJS): $(HDRS) $(ruby_headers) \ https://github.com/ruby/ruby/blob/trunk/ext/io/console/depend#L8 win32_vk.h: win32_vk.list -.list.h: - gperf --ignore-case -E -C -P -p -j1 -i 1 -g -o -t -K ofs -N console_win32_vk -k* --output-file=$@ $< +{$(srcdir)}.list.h: + gperf --ignore-case -E -C -P -p -j1 -i 1 -g -o -t -K ofs -N console_win32_vk -k* --output-file=$(@F) $< + +.SUFFIXES: .chksum .list + +{$(srcdir)}.list.chksum: + @$(RUBY) -I$(top_srcdir)/tool -rchecksum \ + -e "Checksum.update(ARGV) {|k,f|k.copy(f) rescue k.make(f)}" \ + -- --make=$(MAKE) -I$(srcdir) $(<F) $(@F:.chksum=.h) Index: ext/io/console/extconf.rb =================================================================== --- ext/io/console/extconf.rb (revision 50433) +++ ext/io/console/extconf.rb (revision 50434) @@ -5,7 +5,7 @@ hdr = nil https://github.com/ruby/ruby/blob/trunk/ext/io/console/extconf.rb#L5 case when macro_defined?("_WIN32", "") # rb_w32_map_errno: 1.8.7 - vk_header = "win32_vk.h" + vk_header = "$(WIN32_VK_HEADER)" when hdr = %w"termios.h termio.h".find {|h| have_header(h)} have_func("cfmakeraw", hdr) when have_header(hdr = "sgtty.h") Index: ext/io/console/win32_vk.chksum =================================================================== --- ext/io/console/win32_vk.chksum (revision 0) +++ ext/io/console/win32_vk.chksum (revision 50434) @@ -0,0 +1 @@ +src="win32_vk.list", len=3269, checksum=34076 Property changes on: ext/io/console/win32_vk.chksum ___________________________________________________________________ Added: svn:eol-style + LF Index: tool/checksum.rb =================================================================== --- tool/checksum.rb (revision 0) +++ tool/checksum.rb (revision 50434) @@ -0,0 +1,65 @@ https://github.com/ruby/ruby/blob/trunk/tool/checksum.rb#L1 +#!ruby + +require_relative 'vpath' + +class Checksum + def initialize(vpath) + @vpath = vpath + end + + def source=(source) + @source = source + @checksum = File.basename(source, ".*") + ".chksum" + end + + def update? + src = @vpath.read(@source) + @len = src.length + @sum = src.sum + begin + data = @vpath.read(@checksum) + rescue + return false + else + return false unless data[/src="([0-9a-z_.-]+)",/, 1] == @source + return false unless @len == data[/\blen=(\d+)/, 1].to_i + return false unless @sum == data[/\bchecksum=(\d+)/, 1].to_i + return true + end + end + + def update! + open(@checksum, "wb") {|f| + f.puts("src=\"#{@source}\", len=#{@len}, checksum=#{@sum}") + } + end + + def update + return true if update? + update! if ret = yield(self) + ret + end + + def copy(name) + @vpath.open(name, "rb") {|f| + IO.copy_stream(f, name) + } + true + end + + def make(arg) + system([@make, arg].compact.join(' ')) + end + + def def_options(opt = (require 'optparse'; OptionParser.new)) + @vpath.def_options(opt) + opt.on("--make=PATH") {|v| @make = v} + opt + end + + def self.update(argv) + k = new(VPath.new) + k.source, *argv = k.def_options.parse(*argv) + k.update {|k| yield(k, *argv)} + end +end Property changes on: tool/checksum.rb ___________________________________________________________________ Added: svn:eol-style + LF Added: svn:executable + * -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/