On Wed, Mar 11, 2015 at 10:03 PM, Asif Naeem <anaeem...@gmail.com> wrote:
> Thank you Michael overall v3 patch looks good to me, There is one
> observation that it is not installing following lib files that are required
> for dev work i.e.

Thanks for your input.

>> inst\lib\libpq.lib
>> inst\lib\libpgtypes.lib
>> inst\lib\libecpg_compat.lib
>> inst\lib\libecpg.lib
>
> Please do let me know if I missed something but was not there a need to
> avoid installing related .dll files in lib (duplicate) along with bin
> directory e.g?

Yeas, right. Sorry for missing something like that. In HEAD, the
following things are installed regarding the shared libraries:
- In lib/, all .dll and .lib
- In bin/, only libpq.dll

So I have recoded the patch to use an hash of arrays (makes the code
more readable IMO) to be able to track more easily what to install
where, and process now does the following for shared libraries:
- In lib/, install all .dll and .lib
- In bin/, install all .dll

I hope that's fine to you.
Regards,
-- 
Michael
diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
index eba9aa0..c35a9dd 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,16 @@ sub CopySolutionOutput
 	while ($sln =~ $rem)
 	{
 		my $pf = $1;
-		my $dir;
-		my $ext;
+
+		# Hash of array to list things to install. This has the
+		# shape similar to that for each project to indicate
+		# what should be installed where. The hash key indicates
+		# the installation location, and the array elements define
+		# the file type to install:
+		# 'bin' => [ 'dll', 'lib' ]
+		# 'lib' => [ 'lib' ]
+		my %install_list;
+		my $is_sharedlib = 0;
 
 		$sln =~ s/$rem//;
 
@@ -247,22 +250,47 @@ 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 $mfname = -e "$projpath/GNUmakefile" ?
+				"$projpath/GNUmakefile" : "$projpath/Makefile";
+			my $mf = read_file($mfname) ||
+				croak "Could not open $mfname\n";
+
+			if ($mf =~ /^SO_MAJOR_VERSION\s*=\s*(.*)$/mg)
+			{
+				$is_sharedlib = 1;
+			}
+		}
+
 		if ($vcproj eq 'vcproj' && $proj =~ qr{ConfigurationType="([^"]+)"})
 		{
 			if ($1 == 1)
 			{
-				$dir = "bin";
-				$ext = "exe";
+				push( @{ $install_list { 'bin' } }, "exe");
 			}
 			elsif ($1 == 2)
 			{
-				$dir = "lib";
-				$ext = "dll";
+				push( @{ $install_list { 'lib' } }, "dll");
+				if ($is_sharedlib)
+				{
+					push( @{ $install_list { 'bin' } }, "dll");
+					push( @{ $install_list { 'lib' } }, "lib");
+				}
 			}
 			else
 			{
 
-# Static lib, such as libpgport, only used internally during build, don't install
+				# Static libraries, such as libpgport, only used internally
+				# during build, don't install.
 				next;
 			}
 		}
@@ -271,18 +299,21 @@ sub CopySolutionOutput
 		{
 			if ($1 eq 'Application')
 			{
-				$dir = "bin";
-				$ext = "exe";
+				push( @{ $install_list { 'bin' } }, "exe");
 			}
 			elsif ($1 eq 'DynamicLibrary')
 			{
-				$dir = "lib";
-				$ext = "dll";
+				push( @{ $install_list { 'lib' } }, "dll");
+				if ($is_sharedlib)
+				{
+					push( @{ $install_list { 'bin' } }, "dll");
+					push( @{ $install_list { 'lib' } }, "lib");
+				}
 			}
 			else    # 'StaticLibrary'
 			{
-
-# Static lib, such as libpgport, only used internally during build, don't install
+				# Static lib, such as libpgport, only used internally
+				# during build, don't install.
 				next;
 			}
 		}
@@ -290,8 +321,16 @@ 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";
+
+		# Install each element
+		foreach my $dir ( keys %install_list )
+		{
+			foreach my $ext ( @{ $install_list{ $dir } } )
+			{
+				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 ".";
-- 
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