From 13ca64cb5cdae419d6ee1bbf7c7a04f6bd3d2388 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Tue, 23 Dec 2014 21:58:50 -0800 Subject: [PATCH 2/2] Install shared libraries in bin/ and lib/ with MSVC This is the MSVC part of the previous commit, to ensure that install is completely consistent with the multiple methods supported. --- src/tools/msvc/Install.pm | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm index eba9aa0..616cd9d 100644 --- a/src/tools/msvc/Install.pm +++ b/src/tools/msvc/Install.pm @@ -91,7 +91,6 @@ sub Install } CopySolutionOutput($conf, $target); - lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll'); my $sample_files = []; my @top_dir = ("src"); @top_dir = ("src\\bin", "src\\interfaces") if ($insttype eq "client"); @@ -236,8 +235,9 @@ sub CopySolutionOutput while ($sln =~ $rem) { my $pf = $1; - my $dir; + my @dirs; my $ext; + my $is_sharedlib = 0; $sln =~ s/$rem//; @@ -247,17 +247,37 @@ sub CopySolutionOutput my $proj = read_file("$pf.$vcproj") || croak "Could not open $pf.$vcproj\n"; + + # Check this project uses a shared library by looking if + # SO_MAJOR_VERSION is defined in its Makefile, whose path + # can be found using the resource file of this project. + if ($proj =~ qr{ResourceCompile\s*Include="([^"]+)"}) + { + my $projpath = dirname($1); + my $mf = read_file($projpath . '/Makefile') + || croak "Could not open $projpath/Makefile\n"; + + if ($mf =~ /^SO_MAJOR_VERSION\s*=\s*(.*)$/mg) + { + $is_sharedlib = 1; + } + } + if ($vcproj eq 'vcproj' && $proj =~ qr{ConfigurationType="([^"]+)"}) { if ($1 == 1) { - $dir = "bin"; + @dirs = qw(bin); $ext = "exe"; } elsif ($1 == 2) { - $dir = "lib"; + @dirs = qw(lib); $ext = "dll"; + if ($is_sharedlib) + { + push(@dirs, 'bin'); + } } else { @@ -271,13 +291,17 @@ sub CopySolutionOutput { if ($1 eq 'Application') { - $dir = "bin"; + @dirs = qw(bin); $ext = "exe"; } elsif ($1 eq 'DynamicLibrary') { - $dir = "lib"; + @dirs = qw(lib); $ext = "dll"; + if ($is_sharedlib) + { + push(@dirs, 'bin'); + } } else # 'StaticLibrary' { @@ -290,8 +314,11 @@ sub CopySolutionOutput { croak "Could not parse $pf.$vcproj\n"; } - lcopy("$conf\\$pf\\$pf.$ext", "$target\\$dir\\$pf.$ext") - || croak "Could not copy $pf.$ext\n"; + foreach my $dir (@dirs) + { + lcopy("$conf\\$pf\\$pf.$ext", "$target\\$dir\\$pf.$ext") + || croak "Could not copy $pf.$ext\n"; + } lcopy("$conf\\$pf\\$pf.pdb", "$target\\symbols\\$pf.pdb") || croak "Could not copy $pf.pdb\n"; print "."; -- 2.2.1