2007-03-17 14:50:42 +01:00
|
|
|
package Mkvcbuild;
|
2007-03-23 10:53:33 +01:00
|
|
|
|
2007-03-17 15:01:01 +01:00
|
|
|
#
|
|
|
|
# Package that generates build files for msvc build
|
|
|
|
#
|
Introduce latches. A latch is a boolean variable, with the capability to
wait until it is set. Latches can be used to reliably wait until a signal
arrives, which is hard otherwise because signals don't interrupt select()
on some platforms, and even when they do, there's race conditions.
On Unix, latches use the so called self-pipe trick under the covers to
implement the sleep until the latch is set, without race conditions. On
Windows, Windows events are used.
Use the new latch abstraction to sleep in walsender, so that as soon as
a transaction finishes, walsender is woken up to immediately send the WAL
to the standby. This reduces the latency between master and standby, which
is good.
Preliminary work by Fujii Masao. The latch implementation is by me, with
helpful comments from many people.
2010-09-11 17:48:04 +02:00
|
|
|
# $PostgreSQL: pgsql/src/tools/msvc/Mkvcbuild.pm,v 1.60 2010/09/11 15:48:04 heikki Exp $
|
2007-03-17 15:01:01 +01:00
|
|
|
#
|
2007-03-17 14:50:42 +01:00
|
|
|
use Carp;
|
|
|
|
use Win32;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Project;
|
|
|
|
use Solution;
|
2010-01-09 15:45:47 +01:00
|
|
|
use Cwd;
|
|
|
|
use File::Copy;
|
2007-03-17 14:50:42 +01:00
|
|
|
|
|
|
|
use Exporter;
|
|
|
|
our (@ISA, @EXPORT_OK);
|
|
|
|
@ISA = qw(Exporter);
|
|
|
|
@EXPORT_OK = qw(Mkvcbuild);
|
|
|
|
|
|
|
|
my $solution;
|
|
|
|
my $libpgport;
|
|
|
|
my $postgres;
|
|
|
|
my $libpq;
|
|
|
|
|
|
|
|
my $contrib_defines = {'refint' => 'REFINT_VERBOSE'};
|
2010-05-13 15:40:03 +02:00
|
|
|
my @contrib_uselibpq = ('dblink', 'oid2name', 'pgbench', 'pg_upgrade',
|
|
|
|
'vacuumlo');
|
|
|
|
my @contrib_uselibpgport = ('oid2name', 'pgbench', 'pg_standby',
|
2010-06-15 14:48:36 +02:00
|
|
|
'pg_archivecleanup', 'pg_upgrade', 'vacuumlo');
|
2007-03-17 14:50:42 +01:00
|
|
|
my $contrib_extralibs = {'pgbench' => ['wsock32.lib']};
|
2010-01-17 14:21:50 +01:00
|
|
|
my $contrib_extraincludes = {'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend']};
|
2007-03-17 14:50:42 +01:00
|
|
|
my $contrib_extrasource = {
|
|
|
|
'cube' => ['cubescan.l','cubeparse.y'],
|
|
|
|
'seg' => ['segscan.l','segparse.y']
|
|
|
|
};
|
2008-11-14 23:12:37 +01:00
|
|
|
my @contrib_excludes = ('pgcrypto','intagg');
|
2007-03-17 14:50:42 +01:00
|
|
|
|
|
|
|
sub mkvcbuild
|
|
|
|
{
|
|
|
|
our $config = shift;
|
|
|
|
|
|
|
|
chdir('..\..\..') if (-d '..\msvc' && -d '..\..\..\src');
|
|
|
|
die 'Must run from root or msvc directory' unless (-d 'src\tools\msvc' && -d 'src');
|
|
|
|
|
|
|
|
$solution = new Solution($config);
|
|
|
|
|
|
|
|
our @pgportfiles = qw(
|
2008-12-02 11:39:31 +01:00
|
|
|
chklocale.c crypt.c fseeko.c getrusage.c inet_aton.c random.c srandom.c
|
2009-07-16 19:43:52 +02:00
|
|
|
getaddrinfo.c gettimeofday.c kill.c open.c erand48.c
|
2010-07-03 01:25:27 +02:00
|
|
|
snprintf.c strlcat.c strlcpy.c dirmod.c exec.c noblock.c path.c pipe.c
|
2007-03-17 14:50:42 +01:00
|
|
|
pgsleep.c pgstrcasecmp.c qsort.c qsort_arg.c sprompt.c thread.c
|
2009-01-21 11:30:02 +01:00
|
|
|
getopt.c getopt_long.c dirent.c rint.c win32env.c win32error.c);
|
2007-03-17 14:50:42 +01:00
|
|
|
|
|
|
|
$libpgport = $solution->AddProject('libpgport','lib','misc');
|
|
|
|
$libpgport->AddDefine('FRONTEND');
|
|
|
|
$libpgport->AddFiles('src\port',@pgportfiles);
|
|
|
|
|
|
|
|
$postgres = $solution->AddProject('postgres','exe','','src\backend');
|
|
|
|
$postgres->AddIncludeDir('src\backend');
|
|
|
|
$postgres->AddDir('src\backend\port\win32');
|
|
|
|
$postgres->AddFile('src\backend\utils\fmgrtab.c');
|
|
|
|
$postgres->ReplaceFile('src\backend\port\dynloader.c','src\backend\port\dynloader\win32.c');
|
|
|
|
$postgres->ReplaceFile('src\backend\port\pg_sema.c','src\backend\port\win32_sema.c');
|
2007-03-21 15:39:23 +01:00
|
|
|
$postgres->ReplaceFile('src\backend\port\pg_shmem.c','src\backend\port\win32_shmem.c');
|
Introduce latches. A latch is a boolean variable, with the capability to
wait until it is set. Latches can be used to reliably wait until a signal
arrives, which is hard otherwise because signals don't interrupt select()
on some platforms, and even when they do, there's race conditions.
On Unix, latches use the so called self-pipe trick under the covers to
implement the sleep until the latch is set, without race conditions. On
Windows, Windows events are used.
Use the new latch abstraction to sleep in walsender, so that as soon as
a transaction finishes, walsender is woken up to immediately send the WAL
to the standby. This reduces the latency between master and standby, which
is good.
Preliminary work by Fujii Masao. The latch implementation is by me, with
helpful comments from many people.
2010-09-11 17:48:04 +02:00
|
|
|
$postgres->ReplaceFile('src\backend\port\pg_latch.c','src\backend\port\win32_latch.c');
|
2007-03-17 14:50:42 +01:00
|
|
|
$postgres->AddFiles('src\port',@pgportfiles);
|
|
|
|
$postgres->AddDir('src\timezone');
|
|
|
|
$postgres->AddFiles('src\backend\parser','scan.l','gram.y');
|
|
|
|
$postgres->AddFiles('src\backend\bootstrap','bootscanner.l','bootparse.y');
|
|
|
|
$postgres->AddFiles('src\backend\utils\misc','guc-file.l');
|
|
|
|
$postgres->AddDefine('BUILDING_DLL');
|
2008-02-05 15:17:23 +01:00
|
|
|
$postgres->AddLibrary('wsock32.lib');
|
|
|
|
$postgres->AddLibrary('ws2_32.lib');
|
|
|
|
$postgres->AddLibrary('secur32.lib');
|
2007-03-17 14:50:42 +01:00
|
|
|
$postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap});
|
|
|
|
$postgres->FullExportDLL('postgres.lib');
|
|
|
|
|
2007-08-21 17:10:41 +02:00
|
|
|
my $snowball = $solution->AddProject('dict_snowball','dll','','src\backend\snowball');
|
2010-04-09 15:05:58 +02:00
|
|
|
$snowball->RelocateFiles(
|
|
|
|
'src\backend\snowball\libstemmer',
|
|
|
|
sub {
|
|
|
|
return shift !~ /dict_snowball.c$/;
|
|
|
|
}
|
|
|
|
);
|
2007-08-21 17:10:41 +02:00
|
|
|
$snowball->AddIncludeDir('src\include\snowball');
|
|
|
|
$snowball->AddReference($postgres);
|
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
my $plpgsql = $solution->AddProject('plpgsql','dll','PLs','src\pl\plpgsql\src');
|
2009-11-12 01:13:00 +01:00
|
|
|
$plpgsql->AddFiles('src\pl\plpgsql\src', 'gram.y');
|
2007-03-17 14:50:42 +01:00
|
|
|
$plpgsql->AddReference($postgres);
|
|
|
|
|
|
|
|
if ($solution->{options}->{perl})
|
|
|
|
{
|
2010-04-09 15:05:58 +02:00
|
|
|
my $plperlsrc = "src\\pl\\plperl\\";
|
2007-03-17 14:50:42 +01:00
|
|
|
my $plperl = $solution->AddProject('plperl','dll','PLs','src\pl\plperl');
|
|
|
|
$plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE');
|
|
|
|
$plperl->AddDefine('PLPERL_HAVE_UID_GID');
|
2010-04-09 15:05:58 +02:00
|
|
|
foreach my $xs ('SPI.xs', 'Util.xs')
|
|
|
|
{
|
|
|
|
(my $xsc = $xs) =~ s/\.xs/.c/;
|
|
|
|
if (Solution::IsNewer("$plperlsrc$xsc","$plperlsrc$xs"))
|
|
|
|
{
|
|
|
|
print "Building $plperlsrc$xsc...\n";
|
|
|
|
system( $solution->{options}->{perl}
|
|
|
|
. '/bin/perl '
|
|
|
|
. $solution->{options}->{perl}
|
|
|
|
. '/lib/ExtUtils/xsubpp -typemap '
|
|
|
|
. $solution->{options}->{perl}
|
|
|
|
. '/lib/ExtUtils/typemap '
|
|
|
|
. "$plperlsrc$xs "
|
|
|
|
. ">$plperlsrc$xsc");
|
|
|
|
if ((!(-f "$plperlsrc$xsc")) || -z "$plperlsrc$xsc")
|
|
|
|
{
|
|
|
|
unlink("$plperlsrc$xsc"); # if zero size
|
|
|
|
die "Failed to create $xsc.\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-01-09 15:45:47 +01:00
|
|
|
if ( Solution::IsNewer('src\pl\plperl\perlchunks.h','src\pl\plperl\plc_perlboot.pl')
|
2010-05-13 23:33:00 +02:00
|
|
|
||Solution::IsNewer('src\pl\plperl\perlchunks.h','src\pl\plperl\plc_trusted.pl'))
|
2010-01-09 15:45:47 +01:00
|
|
|
{
|
|
|
|
print 'Building src\pl\plperl\perlchunks.h ...' . "\n";
|
|
|
|
my $basedir = getcwd;
|
|
|
|
chdir 'src\pl\plperl';
|
|
|
|
system( $solution->{options}->{perl}
|
|
|
|
. '/bin/perl '
|
|
|
|
. 'text2macro.pl '
|
|
|
|
. '--strip="^(\#.*|\s*)$$" '
|
2010-05-13 23:33:00 +02:00
|
|
|
. 'plc_perlboot.pl plc_trusted.pl '
|
2010-01-11 15:16:18 +01:00
|
|
|
. '>perlchunks.h');
|
2010-01-09 15:45:47 +01:00
|
|
|
chdir $basedir;
|
2010-01-11 15:16:18 +01:00
|
|
|
if ((!(-f 'src\pl\plperl\perlchunks.h')) || -z 'src\pl\plperl\perlchunks.h')
|
2010-01-09 15:45:47 +01:00
|
|
|
{
|
2010-01-11 15:16:18 +01:00
|
|
|
unlink('src\pl\plperl\perlchunks.h'); # if zero size
|
2010-01-09 15:45:47 +01:00
|
|
|
die 'Failed to create perlchunks.h' . "\n";
|
|
|
|
}
|
|
|
|
}
|
2010-05-13 23:33:00 +02:00
|
|
|
if ( Solution::IsNewer('src\pl\plperl\plperl_opmask.h','src\pl\plperl\plperl_opmask.pl'))
|
|
|
|
{
|
|
|
|
print 'Building src\pl\plperl\plperl_opmask.h ...' . "\n";
|
|
|
|
my $basedir = getcwd;
|
|
|
|
chdir 'src\pl\plperl';
|
|
|
|
system( $solution->{options}->{perl}
|
|
|
|
. '/bin/perl '
|
|
|
|
. 'plperl_opmask.pl '
|
|
|
|
. 'plperl_opmask.h');
|
|
|
|
chdir $basedir;
|
|
|
|
if ((!(-f 'src\pl\plperl\plperl_opmask.h')) || -z 'src\pl\plperl\plperl_opmask.h')
|
|
|
|
{
|
|
|
|
unlink('src\pl\plperl\plperl_opmask.h'); # if zero size
|
|
|
|
die 'Failed to create plperl_opmask.h' . "\n";
|
|
|
|
}
|
|
|
|
}
|
2007-03-17 14:50:42 +01:00
|
|
|
$plperl->AddReference($postgres);
|
2010-04-09 15:05:58 +02:00
|
|
|
my @perl_libs =
|
|
|
|
grep {/perl\d+.lib$/ }glob($solution->{options}->{perl} . '\lib\CORE\perl*.lib');
|
2009-06-05 20:29:56 +02:00
|
|
|
if (@perl_libs == 1)
|
2009-04-07 21:35:57 +02:00
|
|
|
{
|
2009-06-05 20:29:56 +02:00
|
|
|
$plperl->AddLibrary($perl_libs[0]);
|
2009-04-07 21:35:57 +02:00
|
|
|
}
|
2010-04-09 15:05:58 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
die "could not identify perl library version";
|
|
|
|
}
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($solution->{options}->{python})
|
|
|
|
{
|
2010-04-09 15:05:58 +02:00
|
|
|
|
2010-02-14 15:10:23 +01:00
|
|
|
# Attempt to get python version and location. Assume python.exe in specified dir.
|
2010-04-09 15:05:58 +02:00
|
|
|
open(P,
|
|
|
|
$solution->{options}->{python}
|
|
|
|
. "\\python -c \"import sys;print(sys.prefix);print(str(sys.version_info[0])+str(sys.version_info[1]))\" |"
|
|
|
|
) || die "Could not query for python version!\n";
|
|
|
|
my $pyprefix = <P>;
|
|
|
|
chomp($pyprefix);
|
|
|
|
my $pyver = <P>;
|
|
|
|
chomp($pyver);
|
2010-02-14 15:10:23 +01:00
|
|
|
close(P);
|
|
|
|
|
2010-04-09 15:05:58 +02:00
|
|
|
# Sometimes (always?) if python is not present, the execution actually works, but gives no data...
|
|
|
|
die "Failed to query python for version information\n"
|
|
|
|
if (!(defined($pyprefix) && defined($pyver)));
|
2010-02-14 15:10:23 +01:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
my $plpython = $solution->AddProject('plpython','dll','PLs','src\pl\plpython');
|
2010-02-14 15:10:23 +01:00
|
|
|
$plpython->AddIncludeDir($pyprefix . '\include');
|
|
|
|
$plpython->AddLibrary($pyprefix . "\\Libs\\python$pyver.lib");
|
2007-03-17 14:50:42 +01:00
|
|
|
$plpython->AddReference($postgres);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($solution->{options}->{tcl})
|
|
|
|
{
|
|
|
|
my $pltcl = $solution->AddProject('pltcl','dll','PLs','src\pl\tcl');
|
|
|
|
$pltcl->AddIncludeDir($solution->{options}->{tcl} . '\include');
|
|
|
|
$pltcl->AddReference($postgres);
|
2009-04-07 21:35:57 +02:00
|
|
|
if (-e $solution->{options}->{tcl} . '\lib\tcl85.lib')
|
|
|
|
{
|
|
|
|
$pltcl->AddLibrary($solution->{options}->{tcl} . '\lib\tcl85.lib');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$pltcl->AddLibrary($solution->{options}->{tcl} . '\lib\tcl84.lib');
|
|
|
|
}
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$libpq = $solution->AddProject('libpq','dll','interfaces','src\interfaces\libpq');
|
|
|
|
$libpq->AddDefine('FRONTEND');
|
2010-04-09 15:05:58 +02:00
|
|
|
$libpq->AddDefine('UNSAFE_STAT_OK');
|
2007-03-17 14:50:42 +01:00
|
|
|
$libpq->AddIncludeDir('src\port');
|
|
|
|
$libpq->AddLibrary('wsock32.lib');
|
2007-07-23 12:16:54 +02:00
|
|
|
$libpq->AddLibrary('secur32.lib');
|
2009-10-01 03:58:58 +02:00
|
|
|
$libpq->AddLibrary('ws2_32.lib');
|
2007-03-17 14:50:42 +01:00
|
|
|
$libpq->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap});
|
|
|
|
$libpq->UseDef('src\interfaces\libpq\libpqdll.def');
|
|
|
|
$libpq->ReplaceFile('src\interfaces\libpq\libpqrc.c','src\interfaces\libpq\libpq.rc');
|
|
|
|
$libpq->AddReference($libpgport);
|
|
|
|
|
2010-04-09 15:05:58 +02:00
|
|
|
my $libpqwalreceiver = $solution->AddProject('libpqwalreceiver', 'dll', '',
|
|
|
|
'src\backend\replication\libpqwalreceiver');
|
2010-01-20 10:22:43 +01:00
|
|
|
$libpqwalreceiver->AddIncludeDir('src\interfaces\libpq');
|
|
|
|
$libpqwalreceiver->AddReference($postgres,$libpq);
|
2010-01-16 12:55:38 +01:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
my $pgtypes =
|
|
|
|
$solution->AddProject('libpgtypes','dll','interfaces','src\interfaces\ecpg\pgtypeslib');
|
|
|
|
$pgtypes->AddDefine('FRONTEND');
|
2007-04-26 16:09:12 +02:00
|
|
|
$pgtypes->AddReference($libpgport);
|
2007-10-03 15:43:24 +02:00
|
|
|
$pgtypes->UseDef('src\interfaces\ecpg\pgtypeslib\pgtypeslib.def');
|
2007-03-17 14:50:42 +01:00
|
|
|
$pgtypes->AddIncludeDir('src\interfaces\ecpg\include');
|
|
|
|
|
2007-03-29 17:30:52 +02:00
|
|
|
my $libecpg =$solution->AddProject('libecpg','dll','interfaces','src\interfaces\ecpg\ecpglib');
|
|
|
|
$libecpg->AddDefine('FRONTEND');
|
|
|
|
$libecpg->AddIncludeDir('src\interfaces\ecpg\include');
|
|
|
|
$libecpg->AddIncludeDir('src\interfaces\libpq');
|
|
|
|
$libecpg->AddIncludeDir('src\port');
|
2007-10-03 14:11:00 +02:00
|
|
|
$libecpg->UseDef('src\interfaces\ecpg\ecpglib\ecpglib.def');
|
2007-03-29 17:30:52 +02:00
|
|
|
$libecpg->AddLibrary('wsock32.lib');
|
|
|
|
$libecpg->AddReference($libpq,$pgtypes,$libpgport);
|
|
|
|
|
|
|
|
my $libecpgcompat =
|
|
|
|
$solution->AddProject('libecpg_compat','dll','interfaces','src\interfaces\ecpg\compatlib');
|
|
|
|
$libecpgcompat->AddIncludeDir('src\interfaces\ecpg\include');
|
|
|
|
$libecpgcompat->AddIncludeDir('src\interfaces\libpq');
|
2007-10-03 15:43:24 +02:00
|
|
|
$libecpgcompat->UseDef('src\interfaces\ecpg\compatlib\compatlib.def');
|
2007-10-03 14:34:29 +02:00
|
|
|
$libecpgcompat->AddReference($pgtypes,$libecpg,$libpgport);
|
2007-03-29 17:30:52 +02:00
|
|
|
|
|
|
|
my $ecpg = $solution->AddProject('ecpg','exe','interfaces','src\interfaces\ecpg\preproc');
|
|
|
|
$ecpg->AddIncludeDir('src\interfaces\ecpg\include');
|
|
|
|
$ecpg->AddIncludeDir('src\interfaces\libpq');
|
2007-06-12 20:31:28 +02:00
|
|
|
$ecpg->AddPrefixInclude('src\interfaces\ecpg\preproc');
|
2007-03-29 17:30:52 +02:00
|
|
|
$ecpg->AddFiles('src\interfaces\ecpg\preproc','pgc.l','preproc.y');
|
|
|
|
$ecpg->AddDefine('MAJOR_VERSION=4');
|
|
|
|
$ecpg->AddDefine('MINOR_VERSION=2');
|
|
|
|
$ecpg->AddDefine('PATCHLEVEL=1');
|
2008-05-21 21:51:01 +02:00
|
|
|
$ecpg->AddDefine('ECPG_COMPILE');
|
2007-03-29 17:30:52 +02:00
|
|
|
$ecpg->AddReference($libpgport);
|
2007-03-17 14:50:42 +01:00
|
|
|
|
2007-06-12 13:07:34 +02:00
|
|
|
my $pgregress_ecpg = $solution->AddProject('pg_regress_ecpg','exe','misc');
|
|
|
|
$pgregress_ecpg->AddFile('src\interfaces\ecpg\test\pg_regress_ecpg.c');
|
|
|
|
$pgregress_ecpg->AddFile('src\test\regress\pg_regress.c');
|
|
|
|
$pgregress_ecpg->AddIncludeDir('src\port');
|
|
|
|
$pgregress_ecpg->AddIncludeDir('src\test\regress');
|
|
|
|
$pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
|
|
|
|
$pgregress_ecpg->AddDefine('FRONTEND');
|
|
|
|
$pgregress_ecpg->AddReference($libpgport);
|
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
# src/bin
|
2007-10-14 00:55:38 +02:00
|
|
|
my $initdb = AddSimpleFrontend('initdb');
|
|
|
|
$initdb->AddIncludeDir('src\interfaces\libpq');
|
2007-10-14 01:22:46 +02:00
|
|
|
$initdb->AddDefine('FRONTEND');
|
2008-02-05 15:17:23 +01:00
|
|
|
$initdb->AddLibrary('wsock32.lib');
|
|
|
|
$initdb->AddLibrary('ws2_32.lib');
|
2007-03-17 14:50:42 +01:00
|
|
|
|
|
|
|
my $pgconfig = AddSimpleFrontend('pg_config');
|
|
|
|
|
|
|
|
my $pgcontrol = AddSimpleFrontend('pg_controldata');
|
|
|
|
|
|
|
|
my $pgctl = AddSimpleFrontend('pg_ctl', 1);
|
|
|
|
|
|
|
|
my $pgreset = AddSimpleFrontend('pg_resetxlog');
|
|
|
|
|
|
|
|
my $pgevent = $solution->AddProject('pgevent','dll','bin');
|
|
|
|
$pgevent->AddFiles('src\bin\pgevent','pgevent.c','pgmsgevent.rc');
|
|
|
|
$pgevent->AddResourceFile('src\bin\pgevent','Eventlog message formatter');
|
|
|
|
$pgevent->RemoveFile('src\bin\pgevent\win32ver.rc');
|
|
|
|
$pgevent->UseDef('src\bin\pgevent\pgevent.def');
|
|
|
|
$pgevent->DisableLinkerWarnings('4104');
|
|
|
|
|
|
|
|
my $psql = AddSimpleFrontend('psql', 1);
|
|
|
|
$psql->AddIncludeDir('src\bin\pg_dump');
|
2007-07-07 09:43:21 +02:00
|
|
|
$psql->AddIncludeDir('src\backend');
|
2007-03-17 14:50:42 +01:00
|
|
|
$psql->AddFile('src\bin\psql\psqlscan.l');
|
|
|
|
|
|
|
|
my $pgdump = AddSimpleFrontend('pg_dump', 1);
|
2007-07-07 09:43:21 +02:00
|
|
|
$pgdump->AddIncludeDir('src\backend');
|
2007-03-17 14:50:42 +01:00
|
|
|
$pgdump->AddFile('src\bin\pg_dump\pg_dump.c');
|
|
|
|
$pgdump->AddFile('src\bin\pg_dump\common.c');
|
|
|
|
$pgdump->AddFile('src\bin\pg_dump\pg_dump_sort.c');
|
2009-03-08 20:13:38 +01:00
|
|
|
$pgdump->AddFile('src\bin\pg_dump\keywords.c');
|
|
|
|
$pgdump->AddFile('src\backend\parser\kwlookup.c');
|
2007-03-17 14:50:42 +01:00
|
|
|
|
|
|
|
my $pgdumpall = AddSimpleFrontend('pg_dump', 1);
|
|
|
|
$pgdumpall->{name} = 'pg_dumpall';
|
2007-07-07 09:43:21 +02:00
|
|
|
$pgdumpall->AddIncludeDir('src\backend');
|
2007-03-17 14:50:42 +01:00
|
|
|
$pgdumpall->AddFile('src\bin\pg_dump\pg_dumpall.c');
|
2009-03-08 20:13:38 +01:00
|
|
|
$pgdumpall->AddFile('src\bin\pg_dump\keywords.c');
|
|
|
|
$pgdumpall->AddFile('src\backend\parser\kwlookup.c');
|
2007-03-17 14:50:42 +01:00
|
|
|
|
|
|
|
my $pgrestore = AddSimpleFrontend('pg_dump', 1);
|
|
|
|
$pgrestore->{name} = 'pg_restore';
|
2007-07-07 09:43:21 +02:00
|
|
|
$pgrestore->AddIncludeDir('src\backend');
|
2007-03-17 14:50:42 +01:00
|
|
|
$pgrestore->AddFile('src\bin\pg_dump\pg_restore.c');
|
2009-03-08 20:13:38 +01:00
|
|
|
$pgrestore->AddFile('src\bin\pg_dump\keywords.c');
|
|
|
|
$pgrestore->AddFile('src\backend\parser\kwlookup.c');
|
2007-03-17 14:50:42 +01:00
|
|
|
|
|
|
|
my $zic = $solution->AddProject('zic','exe','utils');
|
|
|
|
$zic->AddFiles('src\timezone','zic.c','ialloc.c','scheck.c','localtime.c');
|
|
|
|
$zic->AddReference($libpgport);
|
|
|
|
|
|
|
|
if ($solution->{options}->{xml})
|
|
|
|
{
|
2007-03-24 15:13:27 +01:00
|
|
|
$contrib_extraincludes->{'pgxml'} = [
|
2007-03-17 14:50:42 +01:00
|
|
|
$solution->{options}->{xml} . '\include',
|
|
|
|
$solution->{options}->{xslt} . '\include',
|
|
|
|
$solution->{options}->{iconv} . '\include'
|
|
|
|
];
|
|
|
|
|
2007-03-24 15:13:27 +01:00
|
|
|
$contrib_extralibs->{'pgxml'} = [
|
2007-03-17 14:50:42 +01:00
|
|
|
$solution->{options}->{xml} . '\lib\libxml2.lib',
|
|
|
|
$solution->{options}->{xslt} . '\lib\libxslt.lib'
|
|
|
|
];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
push @contrib_excludes,'xml2';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$solution->{options}->{openssl})
|
|
|
|
{
|
|
|
|
push @contrib_excludes,'sslinfo';
|
|
|
|
}
|
|
|
|
|
2008-02-28 13:17:59 +01:00
|
|
|
if ($solution->{options}->{uuid})
|
|
|
|
{
|
2010-04-09 15:05:58 +02:00
|
|
|
$contrib_extraincludes->{'uuid-ossp'} = [ $solution->{options}->{uuid} . '\include' ];
|
|
|
|
$contrib_extralibs->{'uuid-ossp'} = [ $solution->{options}->{uuid} . '\lib\uuid.lib' ];
|
2008-02-28 13:17:59 +01:00
|
|
|
}
|
2010-04-09 15:05:58 +02:00
|
|
|
else
|
2008-02-28 13:17:59 +01:00
|
|
|
{
|
2010-04-09 15:05:58 +02:00
|
|
|
push @contrib_excludes,'uuid-ossp';
|
2008-02-28 13:17:59 +01:00
|
|
|
}
|
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
# Pgcrypto makefile too complex to parse....
|
|
|
|
my $pgcrypto = $solution->AddProject('pgcrypto','dll','crypto');
|
|
|
|
$pgcrypto->AddFiles(
|
|
|
|
'contrib\pgcrypto','pgcrypto.c','px.c','px-hmac.c',
|
|
|
|
'px-crypt.c','crypt-gensalt.c','crypt-blowfish.c','crypt-des.c',
|
|
|
|
'crypt-md5.c','mbuf.c','pgp.c','pgp-armor.c',
|
|
|
|
'pgp-cfb.c','pgp-compress.c','pgp-decrypt.c','pgp-encrypt.c',
|
|
|
|
'pgp-info.c','pgp-mpi.c','pgp-pubdec.c','pgp-pubenc.c',
|
|
|
|
'pgp-pubkey.c','pgp-s2k.c','pgp-pgsql.c'
|
|
|
|
);
|
|
|
|
if ($solution->{options}->{openssl})
|
|
|
|
{
|
|
|
|
$pgcrypto->AddFiles('contrib\pgcrypto', 'openssl.c','pgp-mpi-openssl.c');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$pgcrypto->AddFiles(
|
|
|
|
'contrib\pgcrypto', 'md5.c','sha1.c','sha2.c',
|
|
|
|
'internal.c','internal-sha2.c','blf.c','rijndael.c',
|
|
|
|
'fortuna.c','random.c','pgp-mpi-internal.c','imath.c'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$pgcrypto->AddReference($postgres);
|
|
|
|
$pgcrypto->AddLibrary('wsock32.lib');
|
2007-03-23 10:53:33 +01:00
|
|
|
my $mf = Project::read_file('contrib/pgcrypto/Makefile');
|
|
|
|
GenerateContribSqlFiles('pgcrypto', $mf);
|
2007-03-17 14:50:42 +01:00
|
|
|
|
|
|
|
my $D;
|
|
|
|
opendir($D, 'contrib') || croak "Could not opendir on contrib!\n";
|
|
|
|
while (my $d = readdir($D))
|
|
|
|
{
|
|
|
|
next if ($d =~ /^\./);
|
|
|
|
next unless (-f "contrib/$d/Makefile");
|
|
|
|
next if (grep {/^$d$/} @contrib_excludes);
|
|
|
|
AddContrib($d);
|
|
|
|
}
|
|
|
|
closedir($D);
|
|
|
|
|
2007-03-24 15:13:27 +01:00
|
|
|
$mf = Project::read_file('src\backend\utils\mb\conversion_procs\Makefile');
|
2007-03-17 14:50:42 +01:00
|
|
|
$mf =~ s{\\s*[\r\n]+}{}mg;
|
2009-08-07 22:50:22 +02:00
|
|
|
$mf =~ m{SUBDIRS\s*=\s*(.*)$}m || die 'Could not match in conversion makefile' . "\n";
|
2007-03-17 14:50:42 +01:00
|
|
|
foreach my $sub (split /\s+/,$1)
|
|
|
|
{
|
|
|
|
my $mf = Project::read_file('src\backend\utils\mb\conversion_procs\\' . $sub . '\Makefile');
|
|
|
|
my $p = $solution->AddProject($sub, 'dll', 'conversion procs');
|
|
|
|
$p->AddFile('src\backend\utils\mb\conversion_procs\\' . $sub . '\\' . $sub . '.c');
|
|
|
|
if ($mf =~ m{^SRCS\s*\+=\s*(.*)$}m)
|
|
|
|
{
|
|
|
|
$p->AddFile('src\backend\utils\mb\conversion_procs\\' . $sub . '\\' . $1);
|
|
|
|
}
|
|
|
|
$p->AddReference($postgres);
|
|
|
|
}
|
|
|
|
|
|
|
|
$mf = Project::read_file('src\bin\scripts\Makefile');
|
|
|
|
$mf =~ s{\\s*[\r\n]+}{}mg;
|
|
|
|
$mf =~ m{PROGRAMS\s*=\s*(.*)$}m || die 'Could not match in bin\scripts\Makefile' . "\n";
|
|
|
|
foreach my $prg (split /\s+/,$1)
|
|
|
|
{
|
|
|
|
my $proj = $solution->AddProject($prg,'exe','bin');
|
|
|
|
$mf =~ m{$prg\s*:\s*(.*)$}m || die 'Could not find script define for $prg' . "\n";
|
|
|
|
my @files = split /\s+/,$1;
|
|
|
|
foreach my $f (@files)
|
|
|
|
{
|
2009-03-08 20:13:38 +01:00
|
|
|
$f =~ s/\.o$/\.c/;
|
|
|
|
if ($f eq 'keywords.c')
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2009-03-08 20:13:38 +01:00
|
|
|
$proj->AddFile('src\bin\pg_dump\keywords.c');
|
|
|
|
}
|
|
|
|
elsif ($f eq 'kwlookup.c')
|
|
|
|
{
|
|
|
|
$proj->AddFile('src\backend\parser\kwlookup.c');
|
|
|
|
}
|
|
|
|
elsif ($f eq 'dumputils.c')
|
|
|
|
{
|
|
|
|
$proj->AddFile('src\bin\pg_dump\dumputils.c');
|
|
|
|
}
|
|
|
|
elsif ($f =~ /print\.c$/)
|
|
|
|
{ # Also catches mbprint.c
|
|
|
|
$proj->AddFile('src\bin\psql\\' . $f);
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-08 20:13:38 +01:00
|
|
|
$proj->AddFile('src\bin\scripts\\' . $f);
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$proj->AddIncludeDir('src\interfaces\libpq');
|
|
|
|
$proj->AddIncludeDir('src\bin\pg_dump');
|
|
|
|
$proj->AddIncludeDir('src\bin\psql');
|
|
|
|
$proj->AddReference($libpq,$libpgport);
|
|
|
|
$proj->AddResourceFile('src\bin\scripts','PostgreSQL Utility');
|
|
|
|
}
|
|
|
|
|
|
|
|
# Regression DLL and EXE
|
|
|
|
my $regress = $solution->AddProject('regress','dll','misc');
|
|
|
|
$regress->AddFile('src\test\regress\regress.c');
|
|
|
|
$regress->AddReference($postgres);
|
|
|
|
|
|
|
|
my $pgregress = $solution->AddProject('pg_regress','exe','misc');
|
|
|
|
$pgregress->AddFile('src\test\regress\pg_regress.c');
|
2007-06-12 13:07:34 +02:00
|
|
|
$pgregress->AddFile('src\test\regress\pg_regress_main.c');
|
2007-03-17 14:50:42 +01:00
|
|
|
$pgregress->AddIncludeDir('src\port');
|
|
|
|
$pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
|
|
|
|
$pgregress->AddReference($libpgport);
|
|
|
|
|
|
|
|
$solution->Save();
|
|
|
|
}
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# Utility functions #
|
|
|
|
#####################
|
|
|
|
|
|
|
|
# Add a simple frontend project (exe)
|
|
|
|
sub AddSimpleFrontend
|
|
|
|
{
|
|
|
|
my $n = shift;
|
|
|
|
my $uselibpq= shift;
|
|
|
|
|
|
|
|
my $p = $solution->AddProject($n,'exe','bin');
|
|
|
|
$p->AddDir('src\bin\\' . $n);
|
|
|
|
$p->AddReference($libpgport);
|
|
|
|
if ($uselibpq)
|
|
|
|
{
|
|
|
|
$p->AddIncludeDir('src\interfaces\libpq');
|
|
|
|
$p->AddReference($libpq);
|
|
|
|
}
|
|
|
|
return $p;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Add a simple contrib project
|
|
|
|
sub AddContrib
|
|
|
|
{
|
|
|
|
my $n = shift;
|
|
|
|
my $mf = Project::read_file('contrib\\' . $n . '\Makefile');
|
|
|
|
|
2007-03-24 15:13:27 +01:00
|
|
|
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2007-03-24 15:13:27 +01:00
|
|
|
my $dn = $1;
|
2007-03-17 14:50:42 +01:00
|
|
|
$mf =~ s{\\\s*[\r\n]+}{}mg;
|
2007-03-24 15:13:27 +01:00
|
|
|
my $proj = $solution->AddProject($dn, 'dll', 'contrib');
|
2007-03-17 14:50:42 +01:00
|
|
|
$mf =~ /^OBJS\s*=\s*(.*)$/gm || croak "Could not find objects in MODULE_big for $n\n";
|
2010-04-09 15:05:58 +02:00
|
|
|
my $objs = $1;
|
2008-05-09 18:01:05 +02:00
|
|
|
while ($objs =~ /\b([\w-]+\.o)\b/g)
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2010-04-09 15:05:58 +02:00
|
|
|
my $o = $1;
|
2007-03-17 14:50:42 +01:00
|
|
|
$o =~ s/\.o$/.c/;
|
|
|
|
$proj->AddFile('contrib\\' . $n . '\\' . $o);
|
|
|
|
}
|
|
|
|
$proj->AddReference($postgres);
|
|
|
|
if ($mf =~ /^SUBDIRS\s*:?=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
foreach my $d (split /\s+/, $1)
|
|
|
|
{
|
|
|
|
my $mf2 = Project::read_file('contrib\\' . $n . '\\' . $d . '\Makefile');
|
|
|
|
$mf2 =~ s{\\\s*[\r\n]+}{}mg;
|
|
|
|
$mf2 =~ /^SUBOBJS\s*=\s*(.*)$/gm
|
|
|
|
|| croak "Could not find objects in MODULE_big for $n, subdir $d\n";
|
2008-05-10 17:30:11 +02:00
|
|
|
$objs = $1;
|
2010-04-09 15:05:58 +02:00
|
|
|
while ($objs =~ /\b([\w-]+\.o)\b/g)
|
|
|
|
{
|
|
|
|
my $o = $1;
|
2007-03-17 14:50:42 +01:00
|
|
|
$o =~ s/\.o$/.c/;
|
|
|
|
$proj->AddFile('contrib\\' . $n . '\\' . $d . '\\' . $o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AdjustContribProj($proj);
|
|
|
|
}
|
|
|
|
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
foreach my $mod (split /\s+/, $1)
|
|
|
|
{
|
|
|
|
my $proj = $solution->AddProject($mod, 'dll', 'contrib');
|
|
|
|
$proj->AddFile('contrib\\' . $n . '\\' . $mod . '.c');
|
|
|
|
$proj->AddReference($postgres);
|
|
|
|
AdjustContribProj($proj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
my $proj = $solution->AddProject($1, 'exe', 'contrib');
|
2010-05-13 17:56:22 +02:00
|
|
|
$mf =~ s{\\\s*[\r\n]+}{}mg;
|
|
|
|
$mf =~ /^OBJS\s*=\s*(.*)$/gm || croak "Could not find objects in PROGRAM for $n\n";
|
2008-05-10 17:30:11 +02:00
|
|
|
my $objs = $1;
|
|
|
|
while ($objs =~ /\b([\w-]+\.o)\b/g)
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2010-04-09 15:05:58 +02:00
|
|
|
my $o = $1;
|
2007-03-17 14:50:42 +01:00
|
|
|
$o =~ s/\.o$/.c/;
|
|
|
|
$proj->AddFile('contrib\\' . $n . '\\' . $o);
|
|
|
|
}
|
|
|
|
AdjustContribProj($proj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
croak "Could not determine contrib module type for $n\n";
|
|
|
|
}
|
2007-03-23 10:53:33 +01:00
|
|
|
|
|
|
|
# Are there any output data files to build?
|
|
|
|
GenerateContribSqlFiles($n, $mf);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub GenerateContribSqlFiles
|
|
|
|
{
|
|
|
|
my $n = shift;
|
|
|
|
my $mf = shift;
|
|
|
|
if ($mf =~ /^DATA_built\s*=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
my $l = $1;
|
|
|
|
|
|
|
|
# Strip out $(addsuffix) rules
|
|
|
|
if (index($l, '$(addsuffix ') >= 0)
|
|
|
|
{
|
|
|
|
my $pcount = 0;
|
|
|
|
my $i;
|
|
|
|
for ($i = index($l, '$(addsuffix ') + 12; $i < length($l); $i++)
|
|
|
|
{
|
|
|
|
$pcount++ if (substr($l, $i, 1) eq '(');
|
|
|
|
$pcount-- if (substr($l, $i, 1) eq ')');
|
|
|
|
last if ($pcount < 0);
|
|
|
|
}
|
|
|
|
$l = substr($l, 0, index($l, '$(addsuffix ')) . substr($l, $i+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Special case for contrib/spi
|
|
|
|
$l = "autoinc.sql insert_username.sql moddatetime.sql refint.sql timetravel.sql"
|
|
|
|
if ($n eq 'spi');
|
|
|
|
|
|
|
|
foreach my $d (split /\s+/, $l)
|
|
|
|
{
|
|
|
|
my $in = "$d.in";
|
|
|
|
my $out = "$d";
|
|
|
|
|
|
|
|
if (Solution::IsNewer("contrib/$n/$out", "contrib/$n/$in"))
|
|
|
|
{
|
|
|
|
print "Building $out from $in (contrib/$n)...\n";
|
|
|
|
my $cont = Project::read_file("contrib/$n/$in");
|
2007-04-27 18:45:54 +02:00
|
|
|
my $dn = $out;
|
|
|
|
$dn =~ s/\.sql$//;
|
2007-03-24 15:13:27 +01:00
|
|
|
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/m) { $dn = $1 }
|
|
|
|
$cont =~ s/MODULE_PATHNAME/\$libdir\/$dn/g;
|
2007-03-23 10:53:33 +01:00
|
|
|
my $o;
|
|
|
|
open($o,">contrib/$n/$out") || croak "Could not write to contrib/$n/$d";
|
|
|
|
print $o $cont;
|
|
|
|
close($o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub AdjustContribProj
|
|
|
|
{
|
|
|
|
my $proj = shift;
|
|
|
|
my $n = $proj->{name};
|
|
|
|
|
|
|
|
if ($contrib_defines->{$n})
|
|
|
|
{
|
|
|
|
foreach my $d ($contrib_defines->{$n})
|
|
|
|
{
|
|
|
|
$proj->AddDefine($d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (grep {/^$n$/} @contrib_uselibpq)
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir('src\interfaces\libpq');
|
|
|
|
$proj->AddReference($libpq);
|
|
|
|
}
|
|
|
|
if (grep {/^$n$/} @contrib_uselibpgport)
|
|
|
|
{
|
|
|
|
$proj->AddReference($libpgport);
|
|
|
|
}
|
|
|
|
if ($contrib_extralibs->{$n})
|
|
|
|
{
|
|
|
|
foreach my $l (@{$contrib_extralibs->{$n}})
|
|
|
|
{
|
|
|
|
$proj->AddLibrary($l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($contrib_extraincludes->{$n})
|
|
|
|
{
|
|
|
|
foreach my $i (@{$contrib_extraincludes->{$n}})
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir($i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($contrib_extrasource->{$n})
|
|
|
|
{
|
|
|
|
$proj->AddFiles('contrib\\' . $n, @{$contrib_extrasource->{$n}});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|