mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add a tool to scan for dependencies on Windows
Similar to ldd on Linux. Signed-off-by: Thiago Macieira <thiago@macieira.org>
This commit is contained in:
parent
57994fa7a1
commit
2fedb100ca
2 changed files with 79 additions and 5 deletions
69
scripts/win-ldd.pl
Normal file
69
scripts/win-ldd.pl
Normal file
|
@ -0,0 +1,69 @@
|
|||
#!perl
|
||||
use strict;
|
||||
my %deploy;
|
||||
my $objdump = $ENV{objdump} ? $ENV{objdump} : "i686-w64-mingw32-objdump";
|
||||
my @searchdirs;
|
||||
|
||||
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";
|
||||
}
|
|
@ -39,11 +39,6 @@ mac {
|
|||
WINDOWSSTAGING = packaging/windows
|
||||
|
||||
deploy.path = $$WINDOWSSTAGING
|
||||
for(qtlib, $$list(QtCore QtGui QtNetwork QtWebKit QtSvg QtXml QtDeclarative)) {
|
||||
CONFIG(debug, debug|release): deploy.files += $$[QT_INSTALL_BINS]/$${qtlib}d4.dll
|
||||
else: deploy.files += $$[QT_INSTALL_BINS]/$${qtlib}4.dll
|
||||
}
|
||||
|
||||
deploy.files += $$marbledir.files $$xslt.files $$doc.files
|
||||
target.path = $$WINDOWSSTAGING
|
||||
INSTALLS += deploy target
|
||||
|
@ -53,6 +48,16 @@ mac {
|
|||
qt_conf.commands += $${nltab}echo \'Plugins=plugins\' >> $@
|
||||
qt_conf.target = $$PWD/packaging/windows/qt.conf
|
||||
install.depends += qt_conf
|
||||
|
||||
!win32-msvc* {
|
||||
!equals($$QMAKE_HOST.os, "Windows"): dlls.commands += OBJDUMP=`$(CC) -dumpmachine`-objdump
|
||||
dlls.commands += perl $$PWD/scripts/win-ldd.pl $(DESTDIR_TARGET)
|
||||
dlls.commands += `$(CC) -print-search-dirs | $(SED) -n \'/^libraries: =/{s///;s/:/\\n/g;p;q;}\' | $(SED) -E \'s,/lib/?\\\$\$,/bin,\'`
|
||||
dlls.commands += $$LIBS
|
||||
dlls.commands += | while read name; do $(INSTALL_FILE) \$\$name $$PWD/$$WINDOWSSTAGING; done
|
||||
dlls.depends = $(DESTDIR_TARGET)
|
||||
install.depends += dlls
|
||||
}
|
||||
} else {
|
||||
# Linux install rules
|
||||
# On Linux, we can count on packagers doing the right thing
|
||||
|
|
Loading…
Add table
Reference in a new issue