README 4.6 KB
Newer Older
1
src/tools/msvc/README
Bruce Momjian's avatar
Bruce Momjian committed
2 3 4 5

MSVC build
==========

6
This directory contains the tools required to build PostgreSQL using
7
Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
8
the libpq frontend library. For more information, see the documentation
9
chapter "Installation on Windows" and the description below.
10 11


12 13
Notes about Visual Studio Express
---------------------------------
14
To build PostgreSQL using Visual Studio Express, the Microsoft Windows SDK
15
has to be installed. Since this is not included in the product
16 17
originally, extra steps are needed to make it work.

18 19
First, download and install a supported version of the Microsoft Windows SDK
from www.microsoft.com (v6.0 or greater).
20

21
Locate the files vcprojectengine.dll.express.config and
22 23 24 25 26 27 28
vcprojectengine.dll.config in the vc\vcpackages directory of
the Visual C++ Express installation. In these files, add the paths
to the Platform SDK to the Include, Library and Path tags. Be sure
to add them to the beginning of the list.

This should work for both GUI and commandline builds, but a restart
may be necessary.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

If you are using a recent version of the Microsoft Windows SDK that includes
the compilers and build tools you probably don't even need Visual Studio
Express to build PostgreSQL.


Structure of the build tools
----------------------------
The tools for building PostgreSQL using Microsoft Visual Studio currently
consist of the following files:

- Configuration files -
config_default.pl      default configuration arguments

A typical build environment has two more files, buildenv.pl and config.pl
that contain the user's build environment settings and configuration
arguments.


- User tools -
build.pl               tool to build the binaries
clean.bat              batch file for cleaning up generated files
install.pl             tool to install the generated files
mkvcbuild.pl           tool to generate the Visual Studio build files
vcregress.pl           tool to run the regression tests


- Internal tools -
gendef.pl              internal tool to generate .DEF files
pgbison.pl             internal tool to process .y files using bison
pgflex.pl              internal tool to process .l files using flex

Many of those .pl files also have a corresponding .bat-wrapper that doesn't
contain any additional logic.


- Internal modules -
Install.pm             module containing the install logic
Mkvcbuild.pm           module containing the code to generate the Visual
                       Studio build (project/solution) files
MSBuildProject.pm      module containing the code to generate MSBuild based
                       project files (Visual Studio 2010 or greater)
Project.pm             module containing the common code to generate the
                       Visual Studio project files. Also provides the
                       common interface of all project file generators
Solution.pm            module containing the code to generate the Visual
                       Studio solution files.
VCBuildProject.pm      module containing the code to generate VCBuild based
                       project files (Visual Studio 2005/2008)
78
VSObjectFactory.pm     factory module providing the code to create the
79 80 81 82 83 84 85 86 87
                       appropriate project/solution files for the current
                       environment


Description of the internals of the Visual Studio build process
---------------------------------------------------------------
By typing 'build' the user starts the build.bat wrapper which simply passes
it's arguments to build.pl.
In build.pl the user's buildenv.pl is used to set up the build environment
Robert Haas's avatar
Robert Haas committed
88
(i. e. path to bison and flex). In addition his config.pl file is merged into
89 90 91 92 93
config_default.pl to create the configuration arguments.
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 VS2005Solution,
94 95 96 97 98 99
a VS2008Solution, a VS2010Solution or a VS2012Solution or 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 (VC2005Project or VC2008Project from VCBuildProject.pm or
VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
from MSBuildProject.pm) to it.
100 101 102 103
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 or vcbuild)
is performed in build.pl again.