Hi all, Here is a continuation of the thread which covered $subject for MinGW and Cygwin: http://www.postgresql.org/message-id/51f19059.7050...@pgexperts.com But this time it is for MSVC.
Just a bit of background... Since commit cb4a3b04 we are installing shared libraries in bin/ and lib/ for Cygwin and MinGW on Windows, but we are still missing MSVC, so as of now build method is inconsistent. Attached is a patch aimed at fixing this inconsistency. What it does is simple: when kicking Install.pm to install the deliverables of each project, we check if the project Makefile contains SO_MAJOR_VERSION. If yes, libraries of this project are installed in bin/ and lib/. The path to the Makefile is found by scanning ResourceCompile in the vcproj file, this method having the advantage to make the patch independent of build process. This also removes a wart present in Install.pm installing copying manually libpq.dll: - lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll'); I am adding an entry in the upcoming CF for this patch, and let's use this thread for this discussion. Regards, -- Michael
From 13ca64cb5cdae419d6ee1bbf7c7a04f6bd3d2388 Mon Sep 17 00:00:00 2001 From: Michael Paquier <michael@otacoo.com> 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
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers