On Wed, Mar 4, 2015 at 4:43 PM, Michael Paquier wrote:
> On Tue, Mar 3, 2015 at 8:36 PM, Asif Naeem wrote:
>> Thank you Michael. I have looked the patch.
>
> Thanks for the review!
>
>> Overall logic looks good to me,
>> I have checked it with MSVC{2013,2008}. It works for MSVC 2013 but fail for
>> MSVC 2008, I think the condition "if ($proj =~
>> qr{ResourceCompile\s*Include="([^"]+)"})" is not going to work for MSVC2008
>> and MSVC2005 i.e.
>> [...]
>
> Thanks for the details, my patch is definitely missing vcproj entries.
> Note that I don't have yet an environment with MSVC 2008 or similar, I
> just got 2010 on my box for now. So you will have to wait until I have
> a fresh environment to get an updated patch...

OK, so I have been able to figure out a regex expression scanning for
win32ver.rc in RelativePath for a vcproj file. For vcxproj files, I am
still using ResourceCompile. Attached is the promised patch.

>> Although this patch is going to make MSVC
>> build consistent with Cygwin and MinGW build, following files seems
>> redundant now, is there any use for them other than backward compatibility ?
>> i.e.
>>> inst\lib\libpq.dll
>>> inst\lib\libpgtypes.dll
>>> inst\lib\libecpg_compat.dll
>>> inst\lib\libecpg.dll
>
> Indeed, I haven't noticed them. But we can simply remove them as they
> are installed in bin/ as well with this patch, it seems better for
> consistency with MinGW and Cygwin in any case.

Those entries are removed as well in the patch.

Regards,
-- 
Michael
From 257685e441ad940012600202e720de447ae5d6dc Mon Sep 17 00:00:00 2001
From: Michael Paquier <mich...@otacoo.com>
Date: Tue, 23 Dec 2014 21:58:50 -0800
Subject: [PATCH] Install shared libraries in bin/ and lib/ on 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 | 52 +++++++++++++++++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 13 deletions(-)

diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
index eba9aa0..237a0e6 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");
@@ -108,12 +107,8 @@ sub Install
 		$target . '/lib/',
 		"$conf\\",
 		"postgres\\postgres.lib",
-		"libpq\\libpq.lib",
-		"libecpg\\libecpg.lib",
 		"libpgcommon\\libpgcommon.lib",
-		"libpgport\\libpgport.lib",
-		"libpgtypes\\libpgtypes.lib",
-		"libecpg_compat\\libecpg_compat.lib");
+		"libpgport\\libpgport.lib");
 	CopyContribFiles($config, $target);
 	CopyIncludeFiles($target);
 
@@ -236,8 +231,9 @@ sub CopySolutionOutput
 	while ($sln =~ $rem)
 	{
 		my $pf = $1;
-		my $dir;
+		my @dirs;
 		my $ext;
+		my $is_sharedlib = 0;
 
 		$sln =~ s/$rem//;
 
@@ -247,17 +243,40 @@ sub CopySolutionOutput
 
 		my $proj = read_file("$pf.$vcproj")
 		  || croak "Could not open $pf.$vcproj\n";
+
+		# Check if 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 (($vcproj eq 'vcxproj' &&
+			 $proj =~ qr{ResourceCompile\s*Include="([^"]+)"}) ||
+			($vcproj eq 'vcproj' &&
+			 $proj =~ qr{File\s*RelativePath="([^\"]+)\.rc"}))
+		{
+			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 +290,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 +313,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 ".";
-- 
1.9.2.msysgit.0

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to