Commit 4a896f17984c6776fd6e5b3fd7bad12822d3afc2

Authored by Jay Berkenbilt
Committed by Jay Berkenbilt
1 parent dad8a3e6

Change copy-dlls to be mingw-only and work with cmake

Showing 1 changed file with 12 additions and 30 deletions
copy_dlls
1 #!/usr/bin/env perl 1 #!/usr/bin/env perl
2 -  
3 require 5.008; 2 require 5.008;
4 -BEGIN { $^W = 1; } 3 +use warnings;
5 use strict; 4 use strict;
6 use File::Basename; 5 use File::Basename;
  6 +use File::Path qw(make_path);
7 7
8 my $whoami = basename($0); 8 my $whoami = basename($0);
9 9
10 -usage() unless @ARGV == 4;  
11 -my ($file, $destdir, $objdump, $windows_wordsize) = @ARGV; 10 +usage() unless @ARGV == 3;
  11 +my ($file, $libqpdf, $destdir) = @ARGV;
12 my $filedir = dirname($file); 12 my $filedir = dirname($file);
13 13
14 my $sep = ($^O eq 'MSWin32' ? ';' : ':'); 14 my $sep = ($^O eq 'MSWin32' ? ';' : ':');
@@ -20,28 +20,6 @@ foreach my $var (qw(LIB)) @@ -20,28 +20,6 @@ foreach my $var (qw(LIB))
20 push(@path, split($sep, $ENV{$var})); 20 push(@path, split($sep, $ENV{$var}));
21 } 21 }
22 } 22 }
23 -my $redist_suffix = (($windows_wordsize eq '64') ? "x64" : "x86");  
24 -if (exists $ENV{'VCINSTALLDIR'})  
25 -{  
26 - my $redist = $ENV{'VCINSTALLDIR'} . "/Redist/$redist_suffix";  
27 - if (opendir(D, $redist))  
28 - {  
29 - my @entries = readdir(D);  
30 - closedir(D);  
31 - foreach my $e (@entries)  
32 - {  
33 - if ($e =~ m/\.CRT$/i)  
34 - {  
35 - unshift(@path, "$redist/$e");  
36 - }  
37 - }  
38 - }  
39 -}  
40 -if (exists $ENV{'UniversalCRTSdkDir'})  
41 -{  
42 - my $redist = $ENV{'UniversalCRTSdkDir'} . "/Redist/ucrt/DLLs/$redist_suffix";  
43 - unshift(@path, $redist);  
44 -}  
45 23
46 my $format = undef; 24 my $format = undef;
47 my @to_find = get_dlls($file); 25 my @to_find = get_dlls($file);
@@ -53,13 +31,16 @@ while (@to_find) @@ -53,13 +31,16 @@ while (@to_find)
53 { 31 {
54 my $dll = shift(@to_find); 32 my $dll = shift(@to_find);
55 my $found = 0; 33 my $found = 0;
56 - foreach my $dir (@path) 34 + foreach my $dir ($libqpdf, @path)
57 { 35 {
58 if ((-f "$dir/$dll") && is_format("$dir/$dll", $format)) 36 if ((-f "$dir/$dll") && is_format("$dir/$dll", $format))
59 { 37 {
60 if (! exists $final{$dll}) 38 if (! exists $final{$dll})
61 { 39 {
62 - $final{$dll} = "$dir/$dll"; 40 + if ($dir ne $libqpdf)
  41 + {
  42 + $final{$dll} = "$dir/$dll";
  43 + }
63 push(@to_find, get_dlls("$dir/$dll")); 44 push(@to_find, get_dlls("$dir/$dll"));
64 } 45 }
65 $found = 1; 46 $found = 1;
@@ -77,6 +58,7 @@ if (@notfound) @@ -77,6 +58,7 @@ if (@notfound)
77 join(', ', @notfound), "\n"; 58 join(', ', @notfound), "\n";
78 } 59 }
79 60
  61 +make_path($destdir);
80 foreach my $dll (sort keys (%final)) 62 foreach my $dll (sort keys (%final))
81 { 63 {
82 my $f = $final{$dll}; 64 my $f = $final{$dll};
@@ -90,7 +72,7 @@ sub get_dlls @@ -90,7 +72,7 @@ sub get_dlls
90 { 72 {
91 my @result = (); 73 my @result = ();
92 my $exe = shift; 74 my $exe = shift;
93 - open(O, "$objdump -p \"$exe\"|") or die "$whoami: can't run objdump\n"; 75 + open(O, "objdump -p \"$exe\"|") or die "$whoami: can't run objdump\n";
94 while (<O>) 76 while (<O>)
95 { 77 {
96 if (m/^\s+DLL Name:\s+(.+\.dll)/i) 78 if (m/^\s+DLL Name:\s+(.+\.dll)/i)
@@ -141,5 +123,5 @@ sub is_format @@ -141,5 +123,5 @@ sub is_format
141 123
142 sub usage 124 sub usage
143 { 125 {
144 - die "Usage: $whoami {exe|dll} destdir\n"; 126 + die "Usage: $whoami {exe|dll} libqpdf-dir destdir\n";
145 } 127 }