Compile using the Visual Studio 2019
Hello,
While trying to setup a test environment under Windows I have managed to
build the source using the latest Visual Studio 2019 [1]https://visualstudio.microsoft.com/vs/.
It's only been tested in this one environment, Windows 10 x64, but the
changes seem tool dependant only.
Regards,
Juan José Santamaría Flecha
Attachments:
build_using_msvc2019.patchapplication/octet-stream; name=build_using_msvc2019.patchDownload
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 149213378c..c5504730c3 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -467,4 +467,27 @@ sub new
return $self;
}
+#
+# Package that encapsulates a Visual C++ 2019 project file
+#
+
+use strict;
+use warnings;
+use base qw(MSBuildProject);
+
+no warnings qw(redefine); ## no critic
+
+sub new
+{
+ my $classname = shift;
+ my $self = $classname->SUPER::_new(@_);
+ bless($self, $classname);
+
+ $self->{vcver} = '16.00';
+ $self->{PlatformToolset} = 'v142';
+ $self->{ToolsVersion} = '16.0';
+
+ return $self;
+}
+
1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 4ab81d3402..c7b6575e42 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -4,7 +4,7 @@ MSVC build
==========
This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2013 - 2017. This builds the whole backend, not just
+Microsoft Visual Studio 2013 - 2019. This builds the whole backend, not just
the libpq frontend library. For more information, see the documentation
chapter "Installation on Windows" and the description below.
@@ -89,10 +89,10 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
(Mkvcbuild.pm) which creates the Visual Studio project and solution files.
It does this by using VSObjectFactory::CreateSolution to create an object
implementing the Solution interface (this could be either a VS2013Solution,
-or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
-the user's build environment) and adding objects implementing the corresponding
-Project interface (VC2013Project or VC2015Project or VC2017Project from
-MSBuildProject.pm) to it.
+or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in
+Solution.pm, depending on the user's build environment) and adding objects
+implementing the corresponding Project interface (VC2013Project or
+VC2015Project or VC2017Project or VC2019Project from MSBuildProject.pm) to it.
When Solution::Save is called, the implementations of Solution and Project
save their content in the appropriate format.
The final step of starting the appropriate build program (msbuild) is
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 2ea224d770..e4afac4524 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -871,6 +871,34 @@ sub new
return $self;
}
+package VS2019Solution;
+
+#
+# Package that encapsulates a Visual Studio 2019 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+no warnings qw(redefine); ## no critic
+
+sub new
+{
+ my $classname = shift;
+ my $self = $classname->SUPER::_new(@_);
+ bless($self, $classname);
+
+ $self->{solutionFileVersion} = '12.00';
+ $self->{vcver} = '16.00';
+ $self->{visualStudioName} = 'Visual Studio 2019';
+ $self->{VisualStudioVersion} = '16.0.28803.202';
+ $self->{MinimumVisualStudioVersion} = '10.0.40219.1';
+
+ return $self;
+}
+
sub GetAdditionalHeaders
{
my ($self, $f) = @_;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index 1a94cd866e..a5bc7b29be 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -39,12 +39,17 @@ sub CreateSolution
return new VS2015Solution(@_);
}
- # visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
- elsif (($visualStudioVersion ge '14.10')
- or ($visualStudioVersion eq '15.00'))
+ elsif (($visualStudioVersion ge '14.10'))
{
return new VS2017Solution(@_);
}
+
+ # visual 2019 hasn't changed the nmake version to 15, so adjust the check to support it.
+ elsif (($visualStudioVersion ge '14.20')
+ or ($visualStudioVersion eq '15.00'))
+ {
+ return new VS2019Solution(@_);
+ }
else
{
croak $visualStudioVersion;
@@ -70,12 +75,17 @@ sub CreateProject
return new VC2015Project(@_);
}
- # visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
- elsif (($visualStudioVersion ge '14.10')
- or ($visualStudioVersion eq '15.00'))
+ elsif (($visualStudioVersion ge '14.10'))
{
return new VC2017Project(@_);
}
+
+ # visual 2019 hasn't changed the nmake version to 15, so adjust the check to support it.
+ elsif (($visualStudioVersion ge '14.20')
+ or ($visualStudioVersion eq '15.00'))
+ {
+ return new VC2019Project(@_);
+ }
else
{
croak $visualStudioVersion;
@@ -106,7 +116,7 @@ sub _GetVisualStudioVersion
{
my ($major, $minor) = @_;
- # visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
+ # visual 2019 hasn't changed the nmake version to 15, so still using the older version for comparison.
if ($major > 14)
{
carp
On Tue, 21 May 2019 at 05:46, Juan José Santamaría Flecha
<juanjo.santamaria@gmail.com> wrote:
While trying to setup a test environment under Windows I have managed to build the source using the latest Visual Studio 2019 [1].
It's only been tested in this one environment, Windows 10 x64, but the changes seem tool dependant only.
Thanks for doing work on this. Just to let you know there's already
some work pending to do this in
/messages/by-id/CAJrrPGegJG_gtQBMQffCNBny3i3fpe8QfE0DUkPSQEZf-FoY9w@mail.gmail.com
It's marked in the next commitfest entry in
https://commitfest.postgresql.org/23/2122/
Maybe you could take a look at that and maybe sign up to review it?
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
On Tue, May 21, 2019 at 02:37:10PM +1200, David Rowley wrote:
Maybe you could take a look at that and maybe sign up to review it?
Yes, that would be great. New VS environments are a pain to set up so
any input is welcome.
- # visual 2017 hasn't changed the nmake version to 15, so still
using the older version for comparison.
+ # visual 2019 hasn't changed the nmake version to
15, so still using the older version for comparison.
if ($major > 14)
I have not checked the other patch and I am pretty sure that you are
doing the same thing. Still, for the notice, this comment update is
incorrect as VS 2017 also marks nmake with version 15.
--
Michael
On Tue, May 21, 2019 at 7:36 AM Michael Paquier <michael@paquier.xyz> wrote:
On Tue, May 21, 2019 at 02:37:10PM +1200, David Rowley wrote:
Maybe you could take a look at that and maybe sign up to review it?
Yes, that would be great. New VS environments are a pain to set up so
any input is welcome.
At some point I did check, but that previous work went unnoticed. Now that
I have a better knowledge about building on Windows I will take a look at
it.
I have not checked the other patch and I am pretty sure that you are
doing the same thing. Still, for the notice, this comment update is
incorrect as VS 2017 also marks nmake with version 15.
I don't want to keep this thread going any further, so I will check the
other patch and see how it goes through this point.
Regards,
Juan José Santamaría Flecha