summaryrefslogtreecommitdiff
path: root/ruby_1_8_6/win32/mkexports.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ruby_1_8_6/win32/mkexports.rb')
-rwxr-xr-xruby_1_8_6/win32/mkexports.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/ruby_1_8_6/win32/mkexports.rb b/ruby_1_8_6/win32/mkexports.rb
new file mode 100755
index 0000000000..214e4c6772
--- /dev/null
+++ b/ruby_1_8_6/win32/mkexports.rb
@@ -0,0 +1,32 @@
+#!./miniruby -s
+
+$name = $library = $description = nil
+
+SYM = {}
+
+objs = ARGV.collect {|s| s.tr('/', '\\')}
+IO.foreach("|dumpbin -symbols " + objs.join(' ')) do |l|
+ next if /^[0-9A-F]+ 0+ UNDEF / =~ l
+ next unless l.sub!(/.*\sExternal\s+\|\s+/, '')
+ if l.sub!(/^_/, '')
+ next if /@.*@/ =~ l || /@[0-9a-f]{16}$/ =~ l
+ elsif !l.sub!(/^(\S+) \([^@?\`\']*\)$/, '\1')
+ next
+ end
+ SYM[l.strip] = true
+end
+
+exports = []
+if $name
+ exports << "Name " + $name
+elsif $library
+ exports << "Library " + $library
+end
+exports << "Description " + $description.dump if $description
+exports << "EXPORTS" << SYM.keys.sort
+
+if $output
+ open($output, 'w') {|f| f.puts exports.join("\n")}
+else
+ puts exports.join("\n")
+end