mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
245e29a72e
Unix developers, look away... this is how it's done on Windows: the binary loader searches $PATH for the DLLs, so let's reuse the same variable. This simplifies the command-line a little. Signed-off-by: Thiago Macieira <thiago@macieira.org>
69 lines
1.5 KiB
Perl
69 lines
1.5 KiB
Perl
#!perl
|
|
use strict;
|
|
my %deploy;
|
|
my $objdump = $ENV{objdump} ? $ENV{objdump} : "i686-w64-mingw32-objdump";
|
|
my @searchdirs = split(/:/, $ENV{PATH});
|
|
|
|
sub addDependenciesFor($) {
|
|
open OBJDUMP, "-|", $objdump, "-p", $_[0] or die;
|
|
while (<OBJDUMP>) {
|
|
last if /^The Import Tables/;
|
|
}
|
|
while (<OBJDUMP>) {
|
|
next unless /DLL Name: (.*)/;
|
|
$deploy{$1} = 0 unless defined($deploy{$1});
|
|
last if /^\w/;
|
|
}
|
|
close OBJDUMP;
|
|
}
|
|
|
|
sub findMissingDependencies {
|
|
for my $name (keys %deploy) {
|
|
next if $deploy{$name};
|
|
my $path;
|
|
for my $dir (@searchdirs) {
|
|
my $fpath = "$dir/$name";
|
|
my $lcfpath = "$dir/" . lc($name);
|
|
if (-e $fpath) {
|
|
$path = $fpath;
|
|
} elsif (-e $lcfpath) {
|
|
$path = $lcfpath;
|
|
} else {
|
|
next;
|
|
}
|
|
addDependenciesFor($path);
|
|
last;
|
|
}
|
|
|
|
$path = "/missing/file" unless $path;
|
|
$deploy{$name} = $path;
|
|
}
|
|
}
|
|
|
|
for (@ARGV) {
|
|
s/^-L//;
|
|
next if /^-/;
|
|
if (-d $_) {
|
|
push @searchdirs, $_;
|
|
} elsif (-f $_) {
|
|
$deploy{$_} = $_;
|
|
addDependenciesFor($_);
|
|
}
|
|
}
|
|
|
|
while (1) {
|
|
findMissingDependencies();
|
|
|
|
my $i = 0;
|
|
while (my ($name, $path) = each(%deploy)) {
|
|
next if $path;
|
|
++$i;
|
|
last;
|
|
}
|
|
last if $i == 0;
|
|
}
|
|
|
|
for (sort values %deploy) {
|
|
next if $_ eq "/missing/file";
|
|
print "$_\n";
|
|
}
|