Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions ext/io/console/depend
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
win32_vk.inc: win32_vk.list $(srcdir)/extract-vk.rb

.list.inc:
( \
$(RUBY) $(srcdir)/extract-vk.rb $< && \
gperf --ignore-case -L ANSI-C -E -C -P -p -j1 -i 1 -g -o -t -K ofs -N console_win32_vk -k* $< \
| sed -f $(top_srcdir)/tool/gperf.sed \
) > $(@F)

.SUFFIXES: .chksum .list .inc

.list.chksum:
@$(RUBY) -I$(top_srcdir)/tool -rchecksum \
-e "Checksum.update(ARGV) {|k|k.copy(k.target) rescue k.make(k.target)}" \
-- --make=$(MAKE) -I$(srcdir) $(<F) $(@F:.chksum=.inc)
# AUTOGENERATED DEPENDENCIES START
console.o: console.c
# AUTOGENERATED DEPENDENCIES END
16 changes: 15 additions & 1 deletion ext/io/console/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,22 @@
have_const("RB_WARN_CATEGORY_DEPRECATED")
win32 or have_func("ttyname_r") or have_func("ttyname")
have_func("rb_prepend_module") # not exported by TruffleRuby
vk_tool = find_executable("gperf")
create_makefile("io/console") {|conf|
conf << "\n""VK_HEADER = #{vk_header}\n"
conf << "###\n" "all: # the default target\n"
if vk_header
conf << <<~MK
VK_HEADER = #{vk_header}
console.#$OBJEXT: $(VK_HEADER)
MK
end
if vk_tool
unless conf.any? {|c| /^ *top_srcdir *=/.match?(c)}
conf << "top_srcdir = $(srcdir)/../../..\n"
end
conf.concat(depend_rules(File.read("#$srcdir/win32_vk.mk")))
end
conf
}
when nil
File.write("Makefile", dummy_makefile($srcdir).join(""))
Expand Down
13 changes: 12 additions & 1 deletion ext/io/console/extract-vk.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
code = [+""]
ARGF.read.scan(/^\w+,\s*\KVK_\w+/) do |n|
source = File.read(ARGV.shift)
source.scan(/^\w+,\s*\KVK_\w+/) do |n|
puts("#ifndef #{n}\n# define #{n} UNDEFINED_VK\n#endif")
code << +"" if n.size + code.last.size > 60
code.last << " x(#{n})z"
end
puts ["#define EACH_VK(x,z)", code].join(" \\\n "), ""
IO.popen(["gperf", *ARGV], "r+") do |f|
w = Thread.start {
f.puts source
f.close_write
}
puts f.read.sub(/^\w*hash .*\{(?m:.*?)\n\}/) {
$&.sub!(" hval = ", " hval = (unsigned int)")
}
w.join
end
13 changes: 13 additions & 0 deletions ext/io/console/win32_vk.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
win32_vk.inc: win32_vk.list $(srcdir)/extract-vk.rb

.list.inc:
$(Q)$(RUBY) $(srcdir)/extract-vk.rb $< \
--ignore-case -L ANSI-C -E -C -P -p -j1 -i 1 -g -o -t -K ofs -N console_win32_vk -k* \
> $(@F)

.SUFFIXES: .chksum .list .inc

.list.chksum:
@$(RUBY) -I$(top_srcdir)/tool -rchecksum \
-e "Checksum.update(ARGV) {|k|k.copy(k.target) rescue k.make(k.target)}" \
-- --make=$(MAKE) -I$(srcdir) $(<F) $(@F:.chksum=.inc)
4 changes: 0 additions & 4 deletions tool/gperf.sed

This file was deleted.