On Thu, Dec 18, 2014 at 10:37 AM, Michael Paquier <michael.paqu...@gmail.com> wrote: > On Thu, Dec 18, 2014 at 4:02 AM, Alvaro Herrera > <alvhe...@2ndquadrant.com> wrote: >> >> I know this is how it currently works, but it looks way too messy to me: >> >> + my $pgarchivecleanup = AddSimpleFrontend('pg_archivecleanup'); >> + my $pgstandby = AddSimpleFrontend('pg_standby'); >> + my $pgtestfsync = AddSimpleFrontend('pg_test_fsync'); >> + my $pgtesttiming = AddSimpleFrontend('pg_test_timing'); >> + my $pgbench = AddSimpleFrontend('pgbench', 1); >> >> ISTM we should be something like >> >> for each $elem in src/bin/Makefile:$(SUBDIRS) >> AddSimpleFrontend($elem) >> >> and avoid having to list the modules one by one. > > If we take this road, I'd like to avoid a huge if/elseif scanning the > names of the submodules to do the necessary adjustments (Some need > FRONTEND defined, others ws2_32, etc.). Also, there is the case of > pg_basebackup where multiple binaries are included with pg_basebackup, > pg_recvlogical and pg_receivexlog. So I think that we'd need something > similar to what contrib does, aka: > my @frontend_excludes = ('pg_basebackup', 'pg_dump', 'pg_dumpall', > 'pg_xlogdump', 'initdb' ...); > my frontend_extralibs = ('pgbench' => 'ws2_32.lib'); > my @frontend_uselibpq = ('pgbench', 'pg_ctl', 'pg_upgrade'); > And for each frontend name excluded we have an individual project > declaration with its own exceptions. With this way of doing when a new > frontend is added by default in src/bin it will be automatically > compiled. How does that sound? And here is an updated patch following those lines. Similarly to the things in contrib/, a set of variables are used to define for each module what are the extra libraries, include dirs, etc. This refactors quite a bit of code, even if there are a couple of exceptions like pg_xlogdump/ or pg_basebackup/. -- Michael
From 894ed2d918b142727661055d1ef60dd3ba9f6022 Mon Sep 17 00:00:00 2001 From: Michael Paquier <mich...@otacoo.com> Date: Mon, 15 Dec 2014 22:16:36 -0800 Subject: [PATCH] Add MSVC support for new modules in src/bin
--- src/tools/msvc/Mkvcbuild.pm | 158 +++++++++++++++++++++++++------------------- src/tools/msvc/clean.bat | 4 +- src/tools/msvc/vcregress.pl | 6 +- 3 files changed, 96 insertions(+), 72 deletions(-) diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 004942c..d4fd03f 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -29,29 +29,37 @@ my $libpgcommon; my $postgres; my $libpq; +# Set of variables for contrib modules my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' }; -my @contrib_uselibpq = - ('dblink', 'oid2name', 'pgbench', 'pg_upgrade', 'postgres_fdw', 'vacuumlo'); -my @contrib_uselibpgport = ( - 'oid2name', 'pgbench', - 'pg_standby', 'pg_archivecleanup', - 'pg_test_fsync', 'pg_test_timing', - 'pg_upgrade', 'pg_xlogdump', - 'vacuumlo'); -my @contrib_uselibpgcommon = ( - 'oid2name', 'pgbench', - 'pg_standby', 'pg_archivecleanup', - 'pg_test_fsync', 'pg_test_timing', - 'pg_upgrade', 'pg_xlogdump', - 'vacuumlo'); -my $contrib_extralibs = { 'pgbench' => ['ws2_32.lib'] }; +my @contrib_uselibpq = ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo'); +my @contrib_uselibpgport = ('oid2name', 'vacuumlo'); +my @contrib_uselibpgcommon = ('oid2name', 'vacuumlo'); +my $contrib_extralibs = {}; my $contrib_extraincludes = - { 'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend'] }; -my $contrib_extrasource = { - 'cube' => [ 'cubescan.l', 'cubeparse.y' ], - 'seg' => [ 'segscan.l', 'segparse.y' ], }; + { 'tsearch2' => ['contrib\tsearch2'], 'dblink' => ['src\backend'] }; +my $contrib_extrafiles = { + 'cube' => [ 'contrib\cube\cubescan.l', 'contrib\cube\cubeparse.y' ], + 'seg' => [ 'contrib\seg\segscan.l', 'contrib\seg\segparse.y' ], }; my @contrib_excludes = ('pgcrypto', 'intagg', 'sepgsql'); +# Set of variables for frontend modules +my $frontend_defines = { 'initdb' => 'FRONTEND' }; +my @frontend_uselibpq = ('pg_ctl', 'pg_upgrade', 'pgbench', 'psql'); +my @frontend_uselibpgport = ('pg_ctl', 'pg_upgrade', 'psql'); +my @frontend_uselibpgcommon = ('pg_ctl', 'psql'); +my $frontend_extralibs = {'initdb' => ['ws2_32.lib'], + 'pg_dump' => ['ws2_32.lib'], + 'pg_restore' => ['ws2_32.lib'], + 'pgbench' => ['ws2_32.lib'], + 'psql' => ['ws2_32.lib'] }; +my $frontend_extraincludes = { + 'initdb' => ['src\timezone'], + 'psql' => ['src\bin\pg_dump', 'src\backend'] }; +my $frontend_extrafiles = { + 'psql' => [ 'src\bin\psql\psqlscan.l' ] }; +my @frontend_excludes = ('pgevent', 'pg_basebackup', 'pg_dump', 'pg_dumpall', + 'pg_restore', 'pg_xlogdump', 'pgevent', 'scripts'); + sub mkvcbuild { our $config = shift; @@ -376,11 +384,15 @@ sub mkvcbuild $pgregress_isolation->AddReference($libpgcommon, $libpgport); # src/bin - my $initdb = AddSimpleFrontend('initdb'); - $initdb->AddIncludeDir('src\interfaces\libpq'); - $initdb->AddIncludeDir('src\timezone'); - $initdb->AddDefine('FRONTEND'); - $initdb->AddLibrary('ws2_32.lib'); + my $D; + opendir($D, 'src/bin') || croak "Could not opendir on src/bin!\n"; + while (my $d = readdir($D)) + { + next if ($d =~ /^\./); + next unless (-f "src/bin/$d/Makefile"); + next if (grep { /^$d$/ } @frontend_excludes); + AddSimpleFrontend($d); + } my $pgbasebackup = AddSimpleFrontend('pg_basebackup', 1); $pgbasebackup->AddFile('src\bin\pg_basebackup\pg_basebackup.c'); @@ -396,14 +408,6 @@ sub mkvcbuild $pgrecvlogical->AddFile('src\bin\pg_basebackup\pg_recvlogical.c'); $pgrecvlogical->AddLibrary('ws2_32.lib'); - 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', @@ -412,12 +416,6 @@ sub mkvcbuild $pgevent->UseDef('src\bin\pgevent\pgevent.def'); $pgevent->DisableLinkerWarnings('4104'); - my $psql = AddSimpleFrontend('psql', 1); - $psql->AddIncludeDir('src\bin\pg_dump'); - $psql->AddIncludeDir('src\backend'); - $psql->AddFile('src\bin\psql\psqlscan.l'); - $psql->AddLibrary('ws2_32.lib'); - my $pgdump = AddSimpleFrontend('pg_dump', 1); $pgdump->AddIncludeDir('src\backend'); $pgdump->AddFile('src\bin\pg_dump\pg_dump.c'); @@ -452,6 +450,19 @@ sub mkvcbuild $pgrestore->AddFile('src\backend\parser\kwlookup.c'); $pgrestore->AddLibrary('ws2_32.lib'); + # Get necessary files for pg_xlogdump as files symlinked + # on Linux are copied on Windows. + my $pgxlogdump = AddSimpleFrontend('pg_xlogdump'); + $pgxlogdump->AddDefine('FRONTEND'); + foreach my $xf (glob('src/backend/access/rmgrdesc/*desc.c')) + { + my $bf = basename $xf; + copy($xf, "src/bin/pg_xlogdump/$bf"); + $pgxlogdump->AddFile("src\\bin\\pg_xlogdump\\$bf"); + } + copy('src/backend/access/transam/xlogreader.c', + 'src/bin/pg_xlogdump/xlogreader.c'); + my $zic = $solution->AddProject('zic', 'exe', 'utils'); $zic->AddFiles('src\timezone', 'zic.c', 'ialloc.c', 'scheck.c', 'localtime.c'); @@ -528,7 +539,6 @@ sub mkvcbuild my $mf = Project::read_file('contrib/pgcrypto/Makefile'); GenerateContribSqlFiles('pgcrypto', $mf); - my $D; opendir($D, 'contrib') || croak "Could not opendir on contrib!\n"; while (my $d = readdir($D)) { @@ -608,22 +618,6 @@ sub mkvcbuild $pgregress->AddDirResourceFile('src\test\regress'); $pgregress->AddReference($libpgcommon, $libpgport); - # fix up pg_xlogdump once it's been set up - # files symlinked on Unix are copied on windows - my $pg_xlogdump = - (grep { $_->{name} eq 'pg_xlogdump' } - @{ $solution->{projects}->{contrib} })[0]; - $pg_xlogdump->AddDefine('FRONTEND'); - foreach my $xf (glob('src/backend/access/rmgrdesc/*desc.c')) - { - my $bf = basename $xf; - copy($xf, "contrib/pg_xlogdump/$bf"); - $pg_xlogdump->AddFile("contrib\\pg_xlogdump\\$bf"); - } - copy( - 'src/backend/access/transam/xlogreader.c', - 'contrib/pg_xlogdump/xlogreader.c'); - $solution->Save(); return $solution->{vcver}; } @@ -646,6 +640,10 @@ sub AddSimpleFrontend $p->AddIncludeDir('src\interfaces\libpq'); $p->AddReference($libpq); } + + # Adjust module definition using frontent variables + AdjustFrontendProj($p); + return $p; } @@ -738,45 +736,71 @@ sub GenerateContribSqlFiles sub AdjustContribProj { my $proj = shift; - my $n = $proj->{name}; + AdjustModule($proj, $contrib_defines, \@contrib_uselibpq, + \@contrib_uselibpgport, \@contrib_uselibpgcommon, $contrib_extralibs, + $contrib_extrafiles, $contrib_extraincludes); +} + +sub AdjustFrontendProj +{ + my $proj = shift; + AdjustModule($proj, $frontend_defines, \@frontend_uselibpq, + \@frontend_uselibpgport, \@frontend_uselibpgcommon, $frontend_extralibs, + $frontend_extrafiles, $frontend_extraincludes); +} - if ($contrib_defines->{$n}) +sub AdjustModule +{ + my $proj = shift; + my $module_defines = shift; + my $module_uselibpq = shift; + my $module_uselibpgport = shift; + my $module_uselibpgcommon = shift; + my $module_extralibs = shift; + my $module_extrafiles = shift; + my $module_extraincludes = shift; + my $n = $proj->{name}; + + if ($module_defines->{$n}) { - foreach my $d ($contrib_defines->{$n}) + foreach my $d ($module_defines->{$n}) { $proj->AddDefine($d); } } - if (grep { /^$n$/ } @contrib_uselibpq) + if (grep { /^$n$/ } @{ $module_uselibpq }) { $proj->AddIncludeDir('src\interfaces\libpq'); $proj->AddReference($libpq); } - if (grep { /^$n$/ } @contrib_uselibpgport) + if (grep { /^$n$/ } @{ $module_uselibpgport }) { $proj->AddReference($libpgport); } - if (grep { /^$n$/ } @contrib_uselibpgcommon) + if (grep { /^$n$/ } @{ $module_uselibpgcommon }) { $proj->AddReference($libpgcommon); } - if ($contrib_extralibs->{$n}) + if ($module_extralibs->{$n}) { - foreach my $l (@{ $contrib_extralibs->{$n} }) + foreach my $l (@{ $module_extralibs->{$n} }) { $proj->AddLibrary($l); } } - if ($contrib_extraincludes->{$n}) + if ($module_extraincludes->{$n}) { - foreach my $i (@{ $contrib_extraincludes->{$n} }) + foreach my $i (@{ $module_extraincludes->{$n} }) { $proj->AddIncludeDir($i); } } - if ($contrib_extrasource->{$n}) + if ($module_extrafiles->{$n}) { - $proj->AddFiles('contrib\\' . $n, @{ $contrib_extrasource->{$n} }); + foreach my $i (@{ $module_extrafiles->{$n} }) + { + $proj->AddFile($i); + } } } diff --git a/src/tools/msvc/clean.bat b/src/tools/msvc/clean.bat index 9c7ea42..c48fb25 100755 --- a/src/tools/msvc/clean.bat +++ b/src/tools/msvc/clean.bat @@ -93,8 +93,8 @@ REM cd contrib REM for /r %%f in (*.sql) do if exist %%f.in del %%f REM clean up files copied into contrib\pg_xlogdump -if exist contrib\pg_xlogdump\xlogreader.c del /q contrib\pg_xlogdump\xlogreader.c -for %%f in (contrib\pg_xlogdump\*desc.c) do if not %%f==contrib\pg_xlogdump\rmgrdesc.c del /q %%f +if exist src\bin\pg_xlogdump\xlogreader.c del /q src\bin\pg_xlogdump\xlogreader.c +for %%f in (src\bin\pg_xlogdump\*desc.c) do if not %%f==src\bin\pg_xlogdump\rmgrdesc.c del /q %%f cd %D% diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl index 699c286..36689ad 100644 --- a/src/tools/msvc/vcregress.pl +++ b/src/tools/msvc/vcregress.pl @@ -259,7 +259,7 @@ sub upgradecheck # what pg_upgrade's "make check" does. $ENV{PGPORT} ||= 50432; - my $tmp_root = "$topdir/contrib/pg_upgrade/tmp_check"; + my $tmp_root = "$topdir/src/bin/pg_upgrade/tmp_check"; (mkdir $tmp_root || die $!) unless -d $tmp_root; my $tmp_install = "$tmp_root/install"; print "Setting up temp install\n\n"; @@ -272,7 +272,7 @@ sub upgradecheck $ENV{PATH} = "$bindir;$ENV{PATH}"; my $data = "$tmp_root/data"; $ENV{PGDATA} = "$data.old"; - my $logdir = "$topdir/contrib/pg_upgrade/log"; + my $logdir = "$topdir/src/bin/pg_upgrade/log"; (mkdir $logdir || die $!) unless -d $logdir; print "\nRunning initdb on old cluster\n\n"; system("initdb") == 0 or exit 1; @@ -282,7 +282,7 @@ sub upgradecheck installcheck(); # now we can chdir into the source dir - chdir "$topdir/contrib/pg_upgrade"; + chdir "$topdir/src/bin/pg_upgrade"; print "\nDumping old cluster\n\n"; system("pg_dumpall -f $tmp_root/dump1.sql") == 0 or exit 1; print "\nStopping old cluster\n\n"; -- 1.9.2.msysgit.0
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers