Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e69f7f4

Browse files
committed
Generate SQL files for /contrib (based on .sql.in)
1 parent fb8155d commit e69f7f4

File tree

2 files changed

+63
-5
lines changed

2 files changed

+63
-5
lines changed

src/tools/msvc/Mkvcbuild.pm

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package Mkvcbuild;
2+
23
#
34
# Package that generates build files for msvc build
45
#
5-
# $PostgreSQL: pgsql/src/tools/msvc/Mkvcbuild.pm,v 1.4 2007/03/21 14:39:23 mha Exp $
6+
# $PostgreSQL: pgsql/src/tools/msvc/Mkvcbuild.pm,v 1.5 2007/03/23 09:53:33 mha Exp $
67
#
78
use Carp;
89
use Win32;
@@ -249,6 +250,8 @@ sub mkvcbuild
249250
}
250251
$pgcrypto->AddReference($postgres);
251252
$pgcrypto->AddLibrary('wsock32.lib');
253+
my $mf = Project::read_file('contrib/pgcrypto/Makefile');
254+
GenerateContribSqlFiles('pgcrypto', $mf);
252255

253256
my $D;
254257
opendir($D, 'contrib') || croak "Could not opendir on contrib!\n";
@@ -384,7 +387,6 @@ sub AddContrib
384387
}
385388
}
386389
AdjustContribProj($proj);
387-
return $proj;
388390
}
389391
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
390392
{
@@ -395,7 +397,6 @@ sub AddContrib
395397
$proj->AddReference($postgres);
396398
AdjustContribProj($proj);
397399
}
398-
return undef;
399400
}
400401
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
401402
{
@@ -407,12 +408,62 @@ sub AddContrib
407408
$proj->AddFile('contrib\\' . $n . '\\' . $o);
408409
}
409410
AdjustContribProj($proj);
410-
return $proj;
411411
}
412412
else
413413
{
414414
croak "Could not determine contrib module type for $n\n";
415415
}
416+
417+
# Are there any output data files to build?
418+
GenerateContribSqlFiles($n, $mf);
419+
}
420+
421+
sub GenerateContribSqlFiles
422+
{
423+
my $n = shift;
424+
my $mf = shift;
425+
if ($mf =~ /^DATA_built\s*=\s*(.*)$/mg)
426+
{
427+
my $l = $1;
428+
429+
# Strip out $(addsuffix) rules
430+
if (index($l, '$(addsuffix ') >= 0)
431+
{
432+
my $pcount = 0;
433+
my $i;
434+
for ($i = index($l, '$(addsuffix ') + 12; $i < length($l); $i++)
435+
{
436+
$pcount++ if (substr($l, $i, 1) eq '(');
437+
$pcount-- if (substr($l, $i, 1) eq ')');
438+
last if ($pcount < 0);
439+
}
440+
$l = substr($l, 0, index($l, '$(addsuffix ')) . substr($l, $i+1);
441+
}
442+
443+
# Special case for contrib/spi
444+
$l = "autoinc.sql insert_username.sql moddatetime.sql refint.sql timetravel.sql"
445+
if ($n eq 'spi');
446+
447+
foreach my $d (split /\s+/, $l)
448+
{
449+
my $in = "$d.in";
450+
my $out = "$d";
451+
452+
# tsearch2 uses inconsistent naming
453+
$in = "tsearch.sql.in" if ($in eq "tsearch2.sql.in");
454+
$in = "untsearch.sql.in" if ($in eq "uninstall_tsearch2.sql.in");
455+
if (Solution::IsNewer("contrib/$n/$out", "contrib/$n/$in"))
456+
{
457+
print "Building $out from $in (contrib/$n)...\n";
458+
my $cont = Project::read_file("contrib/$n/$in");
459+
$cont =~ s/MODULE_PATHNAME/\$libdir\/$n/g;
460+
my $o;
461+
open($o,">contrib/$n/$out") || croak "Could not write to contrib/$n/$d";
462+
print $o $cont;
463+
close($o);
464+
}
465+
}
466+
}
416467
}
417468

418469
sub AdjustContribProj

src/tools/msvc/clean.bat

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@echo off
2-
REM $PostgreSQL: pgsql/src/tools/msvc/clean.bat,v 1.3 2007/03/17 14:01:01 mha Exp $
2+
REM $PostgreSQL: pgsql/src/tools/msvc/clean.bat,v 1.4 2007/03/23 09:53:33 mha Exp $
33

44
set D=%CD%
55
if exist ..\msvc if exist ..\..\..\src cd ..\..\..
@@ -51,6 +51,13 @@ call :del contrib\spi\refint.dll
5151
call :del contrib\spi\autoinc.dll
5252
call :del src\test\regress\regress.dll
5353

54+
REM Clean up datafiles built with contrib
55+
cd contrib
56+
for /r %%f in (*.sql) do if exist %%f.in del %%f
57+
REM Clean up tsearch2 which uses inconsistent names
58+
call :del tsearch2\tsearch2.sql
59+
call :del tsearch2\uninstall_tsearch2.sql
60+
5461
cd %D%
5562
goto :eof
5663

0 commit comments

Comments
 (0)