From e0ee307a199fcf47523b395ce99052ec51e69476 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 24 Jan 2016 15:51:21 -0500 Subject: Updates for newer Windows toolchain --- copy_dlls | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'copy_dlls') diff --git a/copy_dlls b/copy_dlls index ea7da779..c9355734 100755 --- a/copy_dlls +++ b/copy_dlls @@ -7,8 +7,8 @@ use File::Basename; my $whoami = basename($0); -usage() unless @ARGV == 3; -my ($file, $destdir, $objdump) = @ARGV; +usage() unless @ARGV == 4; +my ($file, $destdir, $objdump, $windows_wordsize) = @ARGV; my $filedir = dirname($file); my %dlls = (); @@ -40,10 +40,39 @@ if (! defined $format) # DLLs. my $sep = ($^O eq 'MSWin32' ? ';' : ':'); my @path = ($filedir, '.', split($sep, $ENV{'PATH'})); +foreach my $var (qw(LIB)) +{ + if (exists $ENV{$var}) + { + push(@path, split($sep, $ENV{$var})); + } +} if (-f "$file.manifest") { unshift(@path, get_manifest_dirs("$file.manifest")); } +my $redist_suffix = (($windows_wordsize eq '64') ? "x64" : "x86"); +if (exists $ENV{'VCINSTALLDIR'}) +{ + my $redist = $ENV{'VCINSTALLDIR'} . "/Redist/$redist_suffix"; + if (opendir(D, $redist)) + { + my @entries = readdir(D); + closedir(D); + foreach my $e (@entries) + { + if ($e =~ m/\.CRT$/i) + { + unshift(@path, "$redist/$e"); + } + } + } +} +if (exists $ENV{'UNIVERSALCRTSDKDIR'}) +{ + my $redist = $ENV{'UNIVERSALCRTSDKDIR'} . "/Redist/ucrt/DLLs/$redist_suffix"; + unshift(@path, $redist); +} my @final = (); my @notfound = (); dll_loop: @@ -75,7 +104,7 @@ foreach my $f (@final) { $f =~ s,\\,/,g; print "Copying $f to $destdir\n"; - system("cp -p $f $destdir") == 0 or + system("cp -p '$f' '$destdir'") == 0 or die "$whoami: copy $f to $destdir failed\n"; } @@ -92,7 +121,7 @@ sub is_format return 1; } my $result = 0; - my $file_format = `file $file`; + my $file_format = `file "$file"`; print "$file $format $file_format\n"; if ($? == 0) { -- cgit v1.2.3-54-g00ecf