2006-10-22 19:17:09 +02:00
|
|
|
my @def;
|
|
|
|
|
|
|
|
die "Usage: gendef.pl <modulepath>\n" unless ($ARGV[0] =~ /\\([^\\]+$)/);
|
|
|
|
my $defname = uc $1;
|
|
|
|
|
2007-03-12 20:10:50 +01:00
|
|
|
if (-f "$ARGV[0]/$defname.def")
|
|
|
|
{
|
|
|
|
print "Not re-generating $defname.DEF, file already exists.\n";
|
|
|
|
exit(0);
|
2006-10-22 19:17:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print "Generating $defname.DEF from directory $ARGV[0]\n";
|
|
|
|
|
2007-03-12 20:10:50 +01:00
|
|
|
while (<$ARGV[0]/*.obj>)
|
|
|
|
{
|
2006-10-22 19:17:09 +02:00
|
|
|
print ".";
|
2007-03-12 20:10:50 +01:00
|
|
|
system("dumpbin /symbols /out:symbols.out $_ >NUL") && die "Could not call dumpbin";
|
|
|
|
open(F, "<symbols.out") || die "Could not open symbols.out for $_\n";
|
|
|
|
while (<F>)
|
|
|
|
{
|
|
|
|
s/\(\)//g;
|
|
|
|
next unless /^\d/;
|
|
|
|
my @pieces = split;
|
|
|
|
next unless $pieces[6];
|
|
|
|
next if ($pieces[2] eq "UNDEF");
|
|
|
|
next unless ($pieces[4] eq "External");
|
|
|
|
next if $pieces[6] =~ /^@/;
|
|
|
|
next if $pieces[6] =~ /^\(/;
|
|
|
|
next if $pieces[6] =~ /^__real/;
|
|
|
|
next if $pieces[6] =~ /^__imp/;
|
|
|
|
next if $pieces[6] =~ /NULL_THUNK_DATA$/;
|
|
|
|
next if $pieces[6] =~ /^__IMPORT_DESCRIPTOR/;
|
|
|
|
next if $pieces[6] =~ /^__NULL_IMPORT/;
|
2006-10-22 19:17:09 +02:00
|
|
|
|
2007-03-12 20:10:50 +01:00
|
|
|
push @def, $pieces[6];
|
|
|
|
}
|
|
|
|
close(F);
|
|
|
|
unlink("symbols.out");
|
2006-10-22 19:17:09 +02:00
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
|
|
|
|
open(DEF,">$ARGV[0]/$defname.def") || die "Could not write to $defname\n";
|
|
|
|
print DEF "EXPORTS\n";
|
|
|
|
my $i = 0;
|
|
|
|
my $last = "";
|
2007-03-12 20:10:50 +01:00
|
|
|
foreach my $f (sort @def)
|
|
|
|
{
|
|
|
|
next if ($f eq $last);
|
|
|
|
$last = $f;
|
|
|
|
$f =~ s/^_//;
|
|
|
|
$i++;
|
|
|
|
|
|
|
|
# print DEF " $f \@ $i\n"; # ordinaled exports?
|
|
|
|
print DEF " $f\n";
|
2006-10-22 19:17:09 +02:00
|
|
|
}
|
|
|
|
close(DEF);
|
|
|
|
print "Generated $i symbols\n";
|