@@ -29,6 +29,7 @@ my $libpgcommon;
29
29
my $postgres ;
30
30
my $libpq ;
31
31
32
+ # Set of variables for contrib modules
32
33
my $contrib_defines = { ' refint' => ' REFINT_VERBOSE' };
33
34
my @contrib_uselibpq =
34
35
(' dblink' , ' oid2name' , ' pgbench' , ' pg_upgrade' , ' postgres_fdw' , ' vacuumlo' );
@@ -48,11 +49,25 @@ my $contrib_extralibs = { 'pgbench' => ['ws2_32.lib'] };
48
49
my $contrib_extraincludes =
49
50
{ ' tsearch2' => [' contrib/tsearch2' ], ' dblink' => [' src/backend' ] };
50
51
my $contrib_extrasource = {
51
- ' cube' => [ ' cubescan.l' , ' cubeparse.y' ],
52
- ' pgbench' => [ ' exprscan.l' , ' exprparse.y' ],
53
- ' seg' => [ ' segscan.l' , ' segparse.y' ], };
52
+ ' cube' => [ ' contrib\cube\cubescan.l' , ' contrib\cube\cubeparse.y' ],
53
+ ' pgbench' =>
54
+ [ ' contrib\pgbench\exprscan.l' , ' contrib\pgbench\exprparse.y' ],
55
+ ' seg' => [ ' contrib\seg\segscan.l' , ' contrib\seg\segparse.y' ], };
54
56
my @contrib_excludes = (' pgcrypto' , ' intagg' , ' sepgsql' );
55
57
58
+ # Set of variables for frontend modules
59
+ my $frontend_defines = { ' initdb' => ' FRONTEND' };
60
+ my @frontend_uselibpq = (' pg_ctl' , ' psql' );
61
+ my $frontend_extralibs = {
62
+ ' initdb' => [' ws2_32.lib' ],
63
+ ' pg_restore' => [' ws2_32.lib' ],
64
+ ' psql' => [' ws2_32.lib' ] };
65
+ my $frontend_extraincludes = {
66
+ ' initdb' => [' src\timezone' ],
67
+ ' psql' => [ ' src\bin\pg_dump' , ' src\backend' ] };
68
+ my $frontend_extrasource = { ' psql' => [' src\bin\psql\psqlscan.l' ] };
69
+ my @frontend_excludes = (' pgevent' , ' pg_basebackup' , ' pg_dump' , ' scripts' );
70
+
56
71
sub mkvcbuild
57
72
{
58
73
our $config = shift ;
@@ -108,6 +123,7 @@ sub mkvcbuild
108
123
$postgres -> AddFiles(' src\port' , @pgportfiles );
109
124
$postgres -> AddFiles(' src\common' , @pgcommonbkndfiles );
110
125
$postgres -> AddDir(' src\timezone' );
126
+
111
127
# We need source files from src\timezone, but that directory's resource
112
128
# file pertains to "zic", not to the backend.
113
129
$postgres -> RemoveFile(' src\timezone\win32ver.rc' );
@@ -122,15 +138,17 @@ sub mkvcbuild
122
138
$postgres -> AddLibrary(' ws2_32.lib' );
123
139
$postgres -> AddLibrary(' wldap32.lib' ) if ($solution -> {options }-> {ldap });
124
140
$postgres -> FullExportDLL(' postgres.lib' );
125
- # The OBJS scraper doesn't know about ifdefs, so remove be-secure-openssl.c
126
- # if building without OpenSSL
141
+
142
+ # The OBJS scraper doesn't know about ifdefs, so remove be-secure-openssl.c
143
+ # if building without OpenSSL
127
144
if (!$solution -> {options }-> {openssl })
128
145
{
129
146
$postgres -> RemoveFile(' src\backend\libpq\be-secure-openssl.c' );
130
147
}
131
148
132
149
my $snowball = $solution -> AddProject(' dict_snowball' , ' dll' , ' ' ,
133
150
' src\backend\snowball' );
151
+
134
152
# This Makefile uses VPATH to find most source files in a subdirectory.
135
153
$snowball -> RelocateFiles(
136
154
' src\backend\snowball\libstemmer' ,
@@ -288,8 +306,9 @@ sub mkvcbuild
288
306
$libpq -> ReplaceFile(' src\interfaces\libpq\libpqrc.c' ,
289
307
' src\interfaces\libpq\libpq.rc' );
290
308
$libpq -> AddReference($libpgport );
291
- # The OBJS scraper doesn't know about ifdefs, so remove fe-secure-openssl.c
292
- # if building without OpenSSL
309
+
310
+ # The OBJS scraper doesn't know about ifdefs, so remove fe-secure-openssl.c
311
+ # if building without OpenSSL
293
312
if (!$solution -> {options }-> {openssl })
294
313
{
295
314
$libpq -> RemoveFile(' src\interfaces\libpq\fe-secure-openssl.c' );
@@ -380,11 +399,15 @@ sub mkvcbuild
380
399
$pgregress_isolation -> AddReference($libpgcommon , $libpgport );
381
400
382
401
# src/bin
383
- my $initdb = AddSimpleFrontend(' initdb' );
384
- $initdb -> AddIncludeDir(' src\interfaces\libpq' );
385
- $initdb -> AddIncludeDir(' src\timezone' );
386
- $initdb -> AddDefine(' FRONTEND' );
387
- $initdb -> AddLibrary(' ws2_32.lib' );
402
+ my $D ;
403
+ opendir ($D , ' src/bin' ) || croak " Could not opendir on src/bin!\n " ;
404
+ while (my $d = readdir ($D ))
405
+ {
406
+ next if ($d =~ / ^\. / );
407
+ next unless (-f " src/bin/$d /Makefile" );
408
+ next if (grep { / ^$d $ / } @frontend_excludes );
409
+ AddSimpleFrontend($d );
410
+ }
388
411
389
412
my $pgbasebackup = AddSimpleFrontend(' pg_basebackup' , 1);
390
413
$pgbasebackup -> AddFile(' src\bin\pg_basebackup\pg_basebackup.c' );
@@ -400,14 +423,6 @@ sub mkvcbuild
400
423
$pgrecvlogical -> AddFile(' src\bin\pg_basebackup\pg_recvlogical.c' );
401
424
$pgrecvlogical -> AddLibrary(' ws2_32.lib' );
402
425
403
- my $pgconfig = AddSimpleFrontend(' pg_config' );
404
-
405
- my $pgcontrol = AddSimpleFrontend(' pg_controldata' );
406
-
407
- my $pgctl = AddSimpleFrontend(' pg_ctl' , 1);
408
-
409
- my $pgreset = AddSimpleFrontend(' pg_resetxlog' );
410
-
411
426
my $pgevent = $solution -> AddProject(' pgevent' , ' dll' , ' bin' );
412
427
$pgevent -> AddFiles(' src\bin\pgevent' , ' pgevent.c' , ' pgmsgevent.rc' );
413
428
$pgevent -> AddResourceFile(' src\bin\pgevent' , ' Eventlog message formatter' ,
@@ -416,12 +431,6 @@ sub mkvcbuild
416
431
$pgevent -> UseDef(' src\bin\pgevent\pgevent.def' );
417
432
$pgevent -> DisableLinkerWarnings(' 4104' );
418
433
419
- my $psql = AddSimpleFrontend(' psql' , 1);
420
- $psql -> AddIncludeDir(' src\bin\pg_dump' );
421
- $psql -> AddIncludeDir(' src\backend' );
422
- $psql -> AddFile(' src\bin\psql\psqlscan.l' );
423
- $psql -> AddLibrary(' ws2_32.lib' );
424
-
425
434
my $pgdump = AddSimpleFrontend(' pg_dump' , 1);
426
435
$pgdump -> AddIncludeDir(' src\backend' );
427
436
$pgdump -> AddFile(' src\bin\pg_dump\pg_dump.c' );
@@ -532,7 +541,6 @@ sub mkvcbuild
532
541
my $mf = Project::read_file(' contrib/pgcrypto/Makefile' );
533
542
GenerateContribSqlFiles(' pgcrypto' , $mf );
534
543
535
- my $D ;
536
544
opendir ($D , ' contrib' ) || croak " Could not opendir on contrib!\n " ;
537
545
while (my $d = readdir ($D ))
538
546
{
@@ -652,6 +660,10 @@ sub AddSimpleFrontend
652
660
$p -> AddIncludeDir(' src\interfaces\libpq' );
653
661
$p -> AddReference($libpq );
654
662
}
663
+
664
+ # Adjust module definition using frontent variables
665
+ AdjustFrontendProj($p );
666
+
655
667
return $p ;
656
668
}
657
669
@@ -729,7 +741,7 @@ sub GenerateContribSqlFiles
729
741
print " Building $out from $in (contrib/$n )...\n " ;
730
742
my $cont = Project::read_file(" contrib/$n /$in " );
731
743
my $dn = $out ;
732
- $dn =~ s /\. sql$// ;
744
+ $dn =~ s /\. sql$// ;
733
745
$cont =~ s / MODULE_PATHNAME/ \$ libdir\/ $dn / g ;
734
746
my $o ;
735
747
open ($o , " >contrib/$n /$out " )
@@ -744,45 +756,74 @@ sub GenerateContribSqlFiles
744
756
sub AdjustContribProj
745
757
{
746
758
my $proj = shift ;
747
- my $n = $proj -> {name };
759
+ AdjustModule(
760
+ $proj , $contrib_defines ,
761
+ \@contrib_uselibpq , \@contrib_uselibpgport ,
762
+ \@contrib_uselibpgcommon , $contrib_extralibs ,
763
+ $contrib_extrasource , $contrib_extraincludes );
764
+ }
748
765
749
- if ($contrib_defines -> {$n })
766
+ sub AdjustFrontendProj
767
+ {
768
+ my $proj = shift ;
769
+ AdjustModule($proj , $frontend_defines , \@frontend_uselibpq , undef ,
770
+ undef , $frontend_extralibs ,
771
+ $frontend_extrasource , $frontend_extraincludes );
772
+ }
773
+
774
+ sub AdjustModule
775
+ {
776
+ my $proj = shift ;
777
+ my $module_defines = shift ;
778
+ my $module_uselibpq = shift ;
779
+ my $module_uselibpgport = shift ;
780
+ my $module_uselibpgcommon = shift ;
781
+ my $module_extralibs = shift ;
782
+ my $module_extrasource = shift ;
783
+ my $module_extraincludes = shift ;
784
+ my $n = $proj -> {name };
785
+
786
+ if ($module_defines -> {$n })
750
787
{
751
- foreach my $d ($contrib_defines -> {$n })
788
+ foreach my $d ($module_defines -> {$n })
752
789
{
753
790
$proj -> AddDefine($d );
754
791
}
755
792
}
756
- if (grep { / ^$n $ / } @contrib_uselibpq )
793
+ if (grep { / ^$n $ / } @{ $module_uselibpq } )
757
794
{
758
795
$proj -> AddIncludeDir(' src\interfaces\libpq' );
759
796
$proj -> AddReference($libpq );
760
797
}
761
- if (grep { / ^$n $ / } @contrib_uselibpgport )
798
+ if (grep { / ^$n $ / } @{ $module_uselibpgport } )
762
799
{
763
800
$proj -> AddReference($libpgport );
764
801
}
765
- if (grep { / ^$n $ / } @contrib_uselibpgcommon )
802
+ if (grep { / ^$n $ / } @{ $module_uselibpgcommon } )
766
803
{
767
804
$proj -> AddReference($libpgcommon );
768
805
}
769
- if ($contrib_extralibs -> {$n })
806
+ if ($module_extralibs -> {$n })
770
807
{
771
- foreach my $l (@{ $contrib_extralibs -> {$n } })
808
+ foreach my $l (@{ $module_extralibs -> {$n } })
772
809
{
773
810
$proj -> AddLibrary($l );
774
811
}
775
812
}
776
- if ($contrib_extraincludes -> {$n })
813
+ if ($module_extraincludes -> {$n })
777
814
{
778
- foreach my $i (@{ $contrib_extraincludes -> {$n } })
815
+ foreach my $i (@{ $module_extraincludes -> {$n } })
779
816
{
780
817
$proj -> AddIncludeDir($i );
781
818
}
782
819
}
783
- if ($contrib_extrasource -> {$n })
820
+ if ($module_extrasource -> {$n })
784
821
{
785
- $proj -> AddFiles(' contrib\\ ' . $n , @{ $contrib_extrasource -> {$n } });
822
+ foreach my $i (@{ $module_extrasource -> {$n } })
823
+ {
824
+ print " Files $i \n " ;
825
+ $proj -> AddFile($i );
826
+ }
786
827
}
787
828
}
788
829
0 commit comments