Skip to content

Commit d49c127

Browse files
committed
Add support for Visual Studio 2019 in build scripts
This adjusts the documentation and the scripts related to the versions of Windows SDK supported. Author: Haribabu Kommi Reviewed-by: Andrew Dunstan, Juan José Santamaría Flecha, Michael Paquier Discussion: https://postgr.es/m/CAJrrPGcfqXhfPyMrny9apoDU7M1t59dzVAvoJ9AeAh5BJi+UzA@mail.gmail.com Backpatch-through: 9.4
1 parent 706cb9b commit d49c127

File tree

5 files changed

+115
-27
lines changed

5 files changed

+115
-27
lines changed

doc/src/sgml/install-windows.sgml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
<para>
2020
There are several different ways of building PostgreSQL on
2121
<productname>Windows</productname>. The simplest way to build with
22-
Microsoft tools is to install <productname>Visual Studio Express 2017
22+
Microsoft tools is to install <productname>Visual Studio Express 2019
2323
for Windows Desktop</productname> and use the included
2424
compiler. It is also possible to build with the full
25-
<productname>Microsoft Visual C++ 2005 to 2017</productname>.
25+
<productname>Microsoft Visual C++ 2005 to 2019</productname>.
2626
In some cases that requires the installation of the
2727
<productname>Windows SDK</productname> in addition to the compiler.
2828
</para>
@@ -77,28 +77,29 @@
7777
<productname>Visual Studio Express</productname> or some versions of the
7878
<productname>Microsoft Windows SDK</productname>. If you do not already have a
7979
<productname>Visual Studio</productname> environment set up, the easiest
80-
ways are to use the compilers from <productname>Visual Studio Express 2017
80+
ways are to use the compilers from <productname>Visual Studio Express 2019
8181
for Windows Desktop</productname> or those in the <productname>Windows SDK
82-
8.1</productname>, which are both free downloads from Microsoft.
82+
10</productname>, which are both free downloads from Microsoft.
8383
</para>
8484

8585
<para>
8686
Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
8787
32-bit PostgreSQL buils are possible with
8888
<productname>Visual Studio 2005</productname> to
89-
<productname>Visual Studio 2017</productname> (including Express editions),
90-
as well as standalone Windows SDK releases 6.0 to 8.1.
89+
<productname>Visual Studio 2019</productname> (including Express editions),
90+
as well as standalone Windows SDK releases 6.0 to 10.
9191
64-bit PostgreSQL builds are supported with
92-
<productname>Microsoft Windows SDK</productname> version 6.0a to 8.1 or
92+
<productname>Microsoft Windows SDK</productname> version 6.0a to 10 or
9393
<productname>Visual Studio 2008</productname> and above. Compilation
9494
is supported down to <productname>Windows XP</productname> and
9595
<productname>Windows Server 2003</> when building with
9696
<productname>Visual Studio 2005</> to
9797
<productname>Visual Studio 2013</productname>. Building with
9898
<productname>Visual Studio 2015</productname> is supported down to
9999
<productname>Windows Vista</> and <productname>Windows Server 2008</>.
100-
Building with <productname>Visual Studio 2017</productname> is supported
101-
down to <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
100+
Building with <productname>Visual Studio 2017</productname> and
101+
<productname>Visual Studio 2019</productname> is supported
102+
down to <productname>Windows 7 SP1</> and <productname>Windows Server 2008 R2 SP1</>.
102103
</para>
103104

104105
<para>
@@ -162,7 +163,7 @@ $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
162163
If your build environment doesn't ship with a supported version of the
163164
<productname>Microsoft Windows SDK</productname> it
164165
is recommended that you upgrade to the latest version (currently
165-
version 7.1), available for download from
166+
version 10), available for download from
166167
<ulink url="https://www.microsoft.com/download"></>.
167168
</para>
168169
<para>

src/tools/msvc/MSBuildProject.pm

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,4 +508,29 @@ sub new
508508
return $self;
509509
}
510510

511+
package VC2019Project;
512+
513+
#
514+
# Package that encapsulates a Visual C++ 2019 project file
515+
#
516+
517+
use strict;
518+
use warnings;
519+
use base qw(VC2012Project);
520+
521+
no warnings qw(redefine); ## no critic
522+
523+
sub new
524+
{
525+
my $classname = shift;
526+
my $self = $classname->SUPER::_new(@_);
527+
bless($self, $classname);
528+
529+
$self->{vcver} = '16.00';
530+
$self->{PlatformToolset} = 'v142';
531+
$self->{ToolsVersion} = '16.0';
532+
533+
return $self;
534+
}
535+
511536
1;

src/tools/msvc/README

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MSVC build
44
==========
55

66
This directory contains the tools required to build PostgreSQL using
7-
Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
7+
Microsoft Visual Studio 2005 - 2019. This builds the whole backend, not just
88
the libpq frontend library. For more information, see the documentation
99
chapter "Installation on Windows" and the description below.
1010

@@ -93,11 +93,12 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
9393
It does this by using VSObjectFactory::CreateSolution to create an object
9494
implementing the Solution interface (this could be either a VS2005Solution,
9595
a VS2008Solution, a VS2010Solution or a VS2012Solution or a VS2013Solution,
96-
or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
97-
the user's build environment) and adding objects implementing the corresponding
98-
Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
99-
VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
100-
from MSBuildProject.pm) to it.
96+
or a VS2015Solution or a VS2017Solution or a VS2019Solution, all in
97+
Solution.pm, depending on the user's build environment) and adding objects
98+
implementing the corresponding Project interface (VC2005Project or
99+
VC2008Project from VCBuildProject.pm or VC2010Project or VC2012Project or
100+
VC2013Project or VC2015Project or VC2017Project or VC2019Project from
101+
MSBuildProject.pm) to it.
101102
When Solution::Save is called, the implementations of Solution and Project
102103
save their content in the appropriate format.
103104
The final step of starting the appropriate build program (msbuild or vcbuild)

src/tools/msvc/Solution.pm

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,34 @@ sub new
925925
return $self;
926926
}
927927

928+
package VS2019Solution;
929+
930+
#
931+
# Package that encapsulates a Visual Studio 2019 solution file
932+
#
933+
934+
use Carp;
935+
use strict;
936+
use warnings;
937+
use base qw(Solution);
938+
939+
no warnings qw(redefine); ## no critic
940+
941+
sub new
942+
{
943+
my $classname = shift;
944+
my $self = $classname->SUPER::_new(@_);
945+
bless($self, $classname);
946+
947+
$self->{solutionFileVersion} = '12.00';
948+
$self->{vcver} = '16.00';
949+
$self->{visualStudioName} = 'Visual Studio 2019';
950+
$self->{VisualStudioVersion} = '16.0.28729.10';
951+
$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
952+
953+
return $self;
954+
}
955+
928956
sub GetAdditionalHeaders
929957
{
930958
my ($self, $f) = @_;

src/tools/msvc/VSObjectFactory.pm

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,30 @@ sub CreateSolution
5353
{
5454
return new VS2015Solution(@_);
5555
}
56-
# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
57-
elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
56+
57+
# The version of nmake bundled in Visual Studio 2017 is greater
58+
# than 14.10 and less than 14.20. And the version number is
59+
# actually 15.00.
60+
elsif (
61+
($visualStudioVersion ge '14.10' && $visualStudioVersion lt '14.20')
62+
|| $visualStudioVersion eq '15.00')
5863
{
5964
return new VS2017Solution(@_);
6065
}
66+
67+
# The version of nmake bundled in Visual Studio 2019 is greater
68+
# than 14.20 and less than 14.30. And the version number is
69+
# actually 16.00.
70+
elsif (
71+
($visualStudioVersion ge '14.20' && $visualStudioVersion lt '14.30')
72+
|| $visualStudioVersion eq '16.00')
73+
{
74+
return new VS2019Solution(@_);
75+
}
6176
else
6277
{
63-
croak $visualStudioVersion;
64-
croak "The requested Visual Studio version is not supported.";
78+
croak
79+
"The requested Visual Studio version $visualStudioVersion is not supported.";
6580
}
6681
}
6782

@@ -98,15 +113,30 @@ sub CreateProject
98113
{
99114
return new VC2015Project(@_);
100115
}
101-
# visual 2017 hasn't changed the nmake version to 15, so adjust the check to support it.
102-
elsif (($visualStudioVersion ge '14.10') or ($visualStudioVersion eq '15.00'))
116+
117+
# The version of nmake bundled in Visual Studio 2017 is greater
118+
# than 14.10 and less than 14.20. And the version number is
119+
# actually 15.00.
120+
elsif (
121+
($visualStudioVersion ge '14.10' && $visualStudioVersion lt '14.20')
122+
|| $visualStudioVersion eq '15.00')
103123
{
104124
return new VC2017Project(@_);
105125
}
126+
127+
# The version of nmake bundled in Visual Studio 2019 is greater
128+
# than 14.20 and less than 14.30. And the version number is
129+
# actually 16.00.
130+
elsif (
131+
($visualStudioVersion ge '14.20' && $visualStudioVersion lt '14.30')
132+
|| $visualStudioVersion eq '16.00')
133+
{
134+
return new VC2019Project(@_);
135+
}
106136
else
107137
{
108-
croak $visualStudioVersion;
109-
croak "The requested Visual Studio version is not supported.";
138+
croak
139+
"The requested Visual Studio version $visualStudioVersion is not supported.";
110140
}
111141
}
112142

@@ -143,12 +173,15 @@ sub DetermineVisualStudioVersion
143173
sub _GetVisualStudioVersion
144174
{
145175
my ($major, $minor) = @_;
146-
# visual 2017 hasn't changed the nmake version to 15, so still using the older version for comparison.
147-
if ($major > 14)
176+
177+
# The major visual studio that is supported has nmake
178+
# version <= 14.30, so stick with it as the latest version
179+
# if bumping on something even newer.
180+
if ($major >= 14 && $minor >= 30)
148181
{
149182
carp
150183
"The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
151-
return '14.00';
184+
return '14.20';
152185
}
153186
elsif ($major < 6)
154187
{

0 commit comments

Comments
 (0)