From 28e5e5648cc3666537c393b2636c4aa34fdb22c1 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Sun, 11 Sep 2016 12:46:55 -0400
Subject: [PATCH] Fix and simplify MSVC build's handling of xml/xslt/uuid
 dependencies.

Solution.pm mistakenly believed that the xml option requires the xslt
option, when actually the dependency is the other way around; and it
believed that libxml requires libiconv, which is not necessarily so,
so we shouldn't enforce it here.  Fix the option cross-checking logic.

Also, since AddProject already takes care of adding libxml and libxslt
include and library dependencies to every project, there's no need
for the custom code that did that in mkvcbuild.  While at it, let's
handle the similar dependencies for uuid in a similar fashion.

Given the lack of field complaints about these overly strict build
dependency requirements, there seems no need for a back-patch.

Michael Paquier

Discussion: <CAB7nPqR0+gpu3mRQvFjf-V-bMxmiSJ6NpTg9_WzVDL+a31cV2g@mail.gmail.com>
---
 src/tools/msvc/Mkvcbuild.pm | 22 ++--------------------
 src/tools/msvc/Solution.pm  | 12 +++++++-----
 2 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index b3ed1f56e21..93dfd24a83b 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -381,18 +381,7 @@ sub mkvcbuild
 	$zic->AddDirResourceFile('src/timezone');
 	$zic->AddReference($libpgcommon, $libpgport);
 
-	if ($solution->{options}->{xml})
-	{
-		$contrib_extraincludes->{'pgxml'} = [
-			$solution->{options}->{xml} . '/include',
-			$solution->{options}->{xslt} . '/include',
-			$solution->{options}->{iconv} . '/include' ];
-
-		$contrib_extralibs->{'pgxml'} = [
-			$solution->{options}->{xml} . '/lib/libxml2.lib',
-			$solution->{options}->{xslt} . '/lib/libxslt.lib' ];
-	}
-	else
+	if (!$solution->{options}->{xml})
 	{
 		push @contrib_excludes, 'xml2';
 	}
@@ -402,14 +391,7 @@ sub mkvcbuild
 		push @contrib_excludes, 'sslinfo';
 	}
 
-	if ($solution->{options}->{uuid})
-	{
-		$contrib_extraincludes->{'uuid-ossp'} =
-		  [ $solution->{options}->{uuid} . '/include' ];
-		$contrib_extralibs->{'uuid-ossp'} =
-		  [ $solution->{options}->{uuid} . '/lib/uuid.lib' ];
-	}
-	else
+	if (!$solution->{options}->{uuid})
 	{
 		push @contrib_excludes, 'uuid-ossp';
 	}
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 9cb1ad36cf3..8217d06f28e 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -37,12 +37,9 @@ sub _new
 	  unless exists $options->{float8byval};
 	die "float8byval not permitted on 32 bit platforms"
 	  if $options->{float8byval} && $bits == 32;
-	if ($options->{xml})
+	if ($options->{xslt} && !$options->{xml})
 	{
-		if (!($options->{xslt} && $options->{iconv}))
-		{
-			die "XML requires both XSLT and ICONV\n";
-		}
+		die "XSLT requires XML\n";
 	}
 	$options->{blocksize} = 8
 	  unless $options->{blocksize};    # undef or 0 means default
@@ -555,6 +552,11 @@ sub AddProject
 		$proj->AddIncludeDir($self->{options}->{xslt} . '\include');
 		$proj->AddLibrary($self->{options}->{xslt} . '\lib\libxslt.lib');
 	}
+	if ($self->{options}->{uuid})
+	{
+		$proj->AddIncludeDir($self->{options}->{uuid} . '\include');
+		$proj->AddLibrary($self->{options}->{uuid} . '\lib\uuid.lib');
+	}
 	return $proj;
 }
 
-- 
GitLab