* win32/mkexports.rb (Exports#objdump, Exports#each_line): extracted.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
23c2cf545c
commit
a9396fd580
@ -1,3 +1,7 @@
|
|||||||
|
Wed May 28 17:50:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* win32/mkexports.rb (Exports#objdump, Exports#each_line): extracted.
|
||||||
|
|
||||||
Wed May 28 17:41:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed May 28 17:41:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* Makefile.in (MKPREP): appended $(RBCONFIG).
|
* Makefile.in (MKPREP): appended $(RBCONFIG).
|
||||||
|
@ -27,7 +27,7 @@ class Exports
|
|||||||
|
|
||||||
def self.output(output = $output, &block)
|
def self.output(output = $output, &block)
|
||||||
if output
|
if output
|
||||||
open(output, 'w', &block)
|
open(output, 'wb', &block)
|
||||||
else
|
else
|
||||||
yield STDOUT
|
yield STDOUT
|
||||||
end
|
end
|
||||||
@ -74,18 +74,31 @@ class Exports
|
|||||||
def each_export(objs)
|
def each_export(objs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def objdump(objs, &block)
|
||||||
|
if objs.empty?
|
||||||
|
$stdin.each_line(&block)
|
||||||
|
else
|
||||||
|
each_line(objs, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def symbols()
|
def symbols()
|
||||||
@syms.sort.collect {|k, v| v ? v == true ? "#{k} DATA" : "#{k}=#{v}" : k}
|
@syms.sort.collect {|k, v| v ? v == true ? "#{k} DATA" : "#{k}=#{v}" : k}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Exports::Mswin < Exports
|
class Exports::Mswin < Exports
|
||||||
|
def each_line(objs, &block)
|
||||||
|
IO.popen(%w"dumpbin -symbols -exports" + objs) do |f|
|
||||||
|
f.each(&block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def each_export(objs)
|
def each_export(objs)
|
||||||
noprefix = ($arch ||= nil and /^(sh|i\d86)/ !~ $arch)
|
noprefix = ($arch ||= nil and /^(sh|i\d86)/ !~ $arch)
|
||||||
objs = objs.collect {|s| s.tr('/', '\\')}
|
objs = objs.collect {|s| s.tr('/', '\\')}
|
||||||
filetype = nil
|
filetype = nil
|
||||||
IO.popen(%w"dumpbin -symbols -exports" + objs) do |f|
|
objdump(objs) do |l|
|
||||||
f.each do |l|
|
|
||||||
if (filetype = l[/^File Type: (.+)/, 1])..(/^\f/ =~ l)
|
if (filetype = l[/^File Type: (.+)/, 1])..(/^\f/ =~ l)
|
||||||
case filetype
|
case filetype
|
||||||
when /OBJECT/, /LIBRARY/
|
when /OBJECT/, /LIBRARY/
|
||||||
@ -107,7 +120,6 @@ class Exports::Mswin < Exports
|
|||||||
yield l.strip, is_data
|
yield l.strip, is_data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
yield "strcasecmp", "msvcrt.stricmp"
|
yield "strcasecmp", "msvcrt.stricmp"
|
||||||
yield "strncasecmp", "msvcrt.strnicmp"
|
yield "strncasecmp", "msvcrt.strnicmp"
|
||||||
end
|
end
|
||||||
@ -118,9 +130,13 @@ class Exports::Mingw < Exports
|
|||||||
@@nm ||= RbConfig::CONFIG["NM"]
|
@@nm ||= RbConfig::CONFIG["NM"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def each_line(objs, &block)
|
||||||
|
IO.foreach("|#{self.class.nm} --extern --defined #{objs.join(' ')}", &block)
|
||||||
|
end
|
||||||
|
|
||||||
def each_export(objs)
|
def each_export(objs)
|
||||||
IO.popen([self.class.nm, "--extern", "--defined", *objs]) do |f|
|
objdump(objs) do |l|
|
||||||
f.each {|l| yield $1 if / [[:upper:]] _(.*)$/ =~ l}
|
yield $1 if / [[:upper:]] _(.*)$/ =~ l
|
||||||
end
|
end
|
||||||
yield "strcasecmp", "_stricmp"
|
yield "strcasecmp", "_stricmp"
|
||||||
yield "strncasecmp", "_strnicmp"
|
yield "strncasecmp", "_strnicmp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user