144144$pgrestore -> {name } = ' pg_restore' ;
145145$pgrestore -> AddFile(' src\bin\pg_dump\pg_restore.c' );
146146
147- open (MF,' src\backend\utils\mb\conversion_procs\Makefile' ) || die ' Could not open src\backend\utils\mb\conversion_procs\Makefile' ;
148- my $t = $/ ;undef $/ ;
149- my $mf = <MF>;
150- close (MF);
147+ my $zic = $solution -> AddProject(' zic' ,' exe' ,' utils' );
148+ $zic -> AddFiles(' src\timezone' ,' zic.c' ,' ialloc.c' ,' scheck.c' ,' localtime.c' );
149+ $zic -> AddReference($libpgport );
150+
151+ my $contrib_defines = {
152+ ' refint' => ' REFINT_VERBOSE'
153+ };
154+ my @contrib_uselibpq = (' dblink' , ' oid2name' , ' pgbench' , ' vacuumlo' );
155+ my @contrib_uselibpgport = (' oid2name' , ' pgbench' , ' vacuumlo' );
156+ my $contrib_extralibs = {
157+ ' pgbench' => [' wsock32.lib' ]
158+ };
159+ my $contrib_extraincludes = {
160+ ' tsearch2' => [' contrib/tsearch2' ]
161+ };
162+ my $contrib_extrasource = {
163+ ' cube' => [' cubescan.l' ,' cubeparse.y' ],
164+ ' seg' => [' segscan.l' ,' segparse.y' ]
165+ };
166+
167+ my @contrib_excludes = (' pgcrypto' );
168+
169+ if ($solution -> {options }-> {xml }) {
170+ $contrib_extraincludes -> {' xml2' } = [$solution -> {options }-> {xml } . ' \include' ,
171+ $solution -> {options }-> {xslt } . ' \include' ,
172+ $solution -> {options }-> {iconv } . ' \include' ];
173+
174+ $contrib_extralibs -> {' xml2' } = [$solution -> {options }-> {xml } . ' \lib\libxml2.lib' ,
175+ $solution -> {options }-> {xslt } . ' \lib\libxslt.lib' ];
176+ }
177+ else {
178+ push @contrib_excludes ,' xml2' ;
179+ }
180+
181+ # Pgcrypto makefile too complex to parse....
182+ my $pgcrypto = $solution -> AddProject(' pgcrypto' ,' dll' ,' crypto' );
183+ $pgcrypto -> AddFiles(' contrib\pgcrypto' ,' pgcrypto.c' ,' px.c' ,' px-hmac.c' ,' px-crypt.c' ,
184+ ' crypt-gensalt.c' ,' crypt-blowfish.c' ,' crypt-des.c' ,' crypt-md5.c' ,' mbuf.c' ,
185+ ' pgp.c' ,' pgp-armor.c' ,' pgp-cfb.c' ,' pgp-compress.c' ,' pgp-decrypt.c' ,' pgp-encrypt.c' ,
186+ ' pgp-info.c' ,' pgp-mpi.c' ,' pgp-pubdec.c' ,' pgp-pubenc.c' ,' pgp-pubkey.c' ,' pgp-s2k.c' ,
187+ ' pgp-pgsql.c' );
188+ if ($solution -> {options }-> {openssl }) {
189+ $pgcrypto -> AddFiles(' contrib\pgcrypto' , ' openssl.c' ,' pgp-mpi-openssl.c' );
190+ }
191+ else {
192+ $pgcrypto -> AddFiles(' contrib\pgcrypto' , ' md5.c' ,' sha1.c' ,' sha2.c' ,' internal.c' ,' internal-sha2.c' ,
193+ ' blf.c' ,' rijndael.c' ,' fortuna.c' ,' random.c' ,' pgp-mpi-internal.c' ,' imath.c' );
194+ }
195+ $pgcrypto -> AddReference($postgres );
196+ $pgcrypto -> AddLibrary(' wsock32.lib' );
197+
198+ my $D ;
199+ opendir ($D , ' contrib' ) || croak " Could not opendir on contrib!\n " ;
200+ while (my $d = readdir ($D )) {
201+ next if ($d =~ / ^\. / );
202+ next unless (-f " contrib/$d /Makefile" );
203+ next if (grep {/ ^$d $ / } @contrib_excludes );
204+ AddContrib($d );
205+ }
206+ closedir ($D );
207+
208+
209+ my $mf = Project::read_file(' src\backend\utils\mb\conversion_procs\Makefile' );
151210$mf =~ s {\\ s*[\r\n ]+} {} mg ;
152211$mf =~ m { DIRS\s *=\s *(.*)$} m || die ' Could not match in conversion makefile' . " \n " ;
153212foreach my $sub (split /\s +/,$1 ) {
154- open (MF,' src\backend\utils\mb\conversion_procs\\ ' . $sub . ' \Makefile' ) || die ' Could not open Makefile for $sub' ;
155- $mf = <MF>;
156- close (MF);
213+ my $mf = Project::read_file(' src\backend\utils\mb\conversion_procs\\ ' . $sub . ' \Makefile' );
157214 my $p = $solution -> AddProject($sub , ' dll' , ' conversion procs' );
158215 $p -> AddFile(' src\backend\utils\mb\conversion_procs\\ ' . $sub . ' \\ ' . $sub . ' .c' );
159216 if ($mf =~ m { ^SRCS\s *\+ =\s *(.*)$} m ) {
162219 $p -> AddReference($postgres );
163220}
164221
165- open (MF,' src\bin\scripts\Makefile' ) || die ' Could not open src\bin\scripts\Makefile' ;
166- $mf = <MF>;
167- close (MF);
222+ $mf = Project::read_file(' src\bin\scripts\Makefile' );
168223$mf =~ s {\\ s*[\r\n ]+} {} mg ;
169224$mf =~ m { PROGRAMS\s *=\s *(.*)$} m || die ' Could not match in bin\scripts\Makefile' . " \n " ;
170225foreach my $prg (split /\s +/,$1 ) {
194249 $proj -> AddReference($libpq ,$libpgport );
195250 $proj -> AddResourceFile(' src\bin\scripts' ,' PostgreSQL Utility' );
196251}
197- $/ = $t ;
198252
199253
200254# Regression DLLs
201255my $regress = $solution -> AddProject(' regress' ,' dll' ,' misc' );
202256$regress -> AddFile(' src\test\regress\regress.c' );
203257$regress -> AddReference($postgres );
204258
205- my $refint = $solution -> AddProject(' refint' ,' dll' ,' contrib' );
206- $refint -> AddFile(' contrib\spi\refint.c' );
207- $refint -> AddReference($postgres );
208- $refint -> AddDefine(' REFINT_VERBOSE' );
209-
210- my $autoinc = $solution -> AddProject(' autoinc' ,' dll' ,' contrib' );
211- $autoinc -> AddFile(' contrib\spi\autoinc.c' );
212- $autoinc -> AddReference($postgres );
213-
214-
215259$solution -> Save();
216260
217261# ####################
@@ -234,3 +278,86 @@ sub AddSimpleFrontend {
234278 return $p ;
235279}
236280
281+
282+ # Add a simple contrib project
283+ sub AddContrib {
284+ my $n = shift ;
285+ my $mf = Project::read_file(' contrib\\ ' . $n . ' \Makefile' );
286+
287+ if ($mf =~ / ^MODULE_big/mg ) {
288+ $mf =~ s {\\\s *[\r\n ]+} {} mg ;
289+ my $proj = $solution -> AddProject($n , ' dll' , ' contrib' );
290+ $mf =~ / ^OBJS\s *=\s *(.*)$ /gm || croak " Could not find objects in MODULE_big for $n \n " ;
291+ foreach my $o (split /\s +/, $1 ) {
292+ $o =~ s /\. o$/ .c/ ;
293+ $proj -> AddFile(' contrib\\ ' . $n . ' \\ ' . $o );
294+ }
295+ $proj -> AddReference($postgres );
296+ if ($mf =~ / ^SUBDIRS\s *:?=\s *(.*)$ /mg ) {
297+ foreach my $d (split /\s +/, $1 ) {
298+ my $mf2 = Project::read_file(' contrib\\ ' . $n . ' \\ ' . $d . ' \Makefile' );
299+ $mf2 =~ s {\\\s *[\r\n ]+} {} mg ;
300+ $mf2 =~ / ^SUBOBJS\s *=\s *(.*)$ /gm || croak " Could not find objects in MODULE_big for $n , subdir $d \n " ;
301+ foreach my $o (split /\s +/, $1 ) {
302+ $o =~ s /\. o$/ .c/ ;
303+ $proj -> AddFile(' contrib\\ ' . $n . ' \\ ' . $d . ' \\ ' . $o );
304+ }
305+ }
306+ }
307+ AdjustContribProj($proj );
308+ return $proj ;
309+ }
310+ elsif ($mf =~ / ^MODULES\s *=\s *(.*)$ /mg ) {
311+ foreach my $mod (split /\s +/, $1 ) {
312+ my $proj = $solution -> AddProject($mod , ' dll' , ' contrib' );
313+ $proj -> AddFile(' contrib\\ ' . $n . ' \\ ' . $mod . ' .c' );
314+ $proj -> AddReference($postgres );
315+ AdjustContribProj($proj );
316+ }
317+ return undef ;
318+ }
319+ elsif ($mf =~ / ^PROGRAM\s *=\s *(.*)$ /mg ) {
320+ my $proj = $solution -> AddProject($1 , ' exe' , ' contrib' );
321+ $mf =~ / ^OBJS\s *=\s *(.*)$ /gm || croak " Could not find objects in MODULE_big for $n \n " ;
322+ foreach my $o (split /\s +/, $1 ) {
323+ $o =~ s /\. o$/ .c/ ;
324+ $proj -> AddFile(' contrib\\ ' . $n . ' \\ ' . $o );
325+ }
326+ AdjustContribProj($proj );
327+ return $proj ;
328+ }
329+ else {
330+ croak " Could not determine contrib module type for $n \n " ;
331+ }
332+ }
333+
334+ sub AdjustContribProj {
335+ my $proj = shift ;
336+ my $n = $proj -> {name };
337+
338+ if ($contrib_defines -> {$n }) {
339+ foreach my $d ($contrib_defines -> {$n }) {
340+ $proj -> AddDefine($d );
341+ }
342+ }
343+ if (grep {/ ^$n $ / } @contrib_uselibpq ) {
344+ $proj -> AddIncludeDir(' src\interfaces\libpq' );
345+ $proj -> AddReference($libpq );
346+ }
347+ if (grep {/ ^$n $ / } @contrib_uselibpgport ) {
348+ $proj -> AddReference($libpgport );
349+ }
350+ if ($contrib_extralibs -> {$n }) {
351+ foreach my $l (@{$contrib_extralibs -> {$n }}) {
352+ $proj -> AddLibrary($l );
353+ }
354+ }
355+ if ($contrib_extraincludes -> {$n }) {
356+ foreach my $i (@{$contrib_extraincludes -> {$n }}) {
357+ $proj -> AddIncludeDir($i );
358+ }
359+ }
360+ if ($contrib_extrasource -> {$n }) {
361+ $proj -> AddFiles(' contrib\\ ' . $n , @{$contrib_extrasource -> {$n }});
362+ }
363+ }
0 commit comments