Reduce the number of special cases to build contrib modules on windows
Hi,
At the moment we do very basic parsing of makefiles to build the
visual studio project file in order to build our contrib modules on
MSVC. This parsing is quite basic and still requires a number of
special cases to get enough information into the project file in order
for the build to succeed. It might be nice if we could reduce some of
those special cases so that:
a) We reduce the amount of work specific to windows when we add new
contrib modules, and;
b) We can work towards a better way for people to build their own
extensions on windows.
I admit to not being much of an expert in either perl or make, but I
came up with the attached which does allow a good number of the
special cases to be removed.
I'm keen to get some feedback on this idea.
Patch attached.
David
Attachments:
reduce_contrib_build_special_cases_on_windows.patchtext/plain; charset=US-ASCII; name=reduce_contrib_build_special_cases_on_windows.patchDownload
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 90594bd41b..491a465e2f 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -32,16 +32,13 @@ my $libpq;
my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
-my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
-my @contrib_uselibpq = ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo');
-my @contrib_uselibpgport = ('oid2name', 'pg_standby', 'vacuumlo');
-my @contrib_uselibpgcommon = ('oid2name', 'pg_standby', 'vacuumlo');
+my $contrib_defines = undef;
+my @contrib_uselibpq = undef;
+my @contrib_uselibpgport = ('pg_standby');
+my @contrib_uselibpgcommon = ('pg_standby');
my $contrib_extralibs = undef;
my $contrib_extraincludes = { 'dblink' => ['src/backend'] };
-my $contrib_extrasource = {
- 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
- 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
-};
+my $contrib_extrasource = undef;
my @contrib_excludes = (
'bool_plperl', 'commit_ts',
'hstore_plperl', 'hstore_plpython',
@@ -163,7 +160,7 @@ sub mkvcbuild
$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->AddFile('src/backend/utils/fmgrtab.c', 1);
$postgres->ReplaceFile('src/backend/port/pg_sema.c',
'src/backend/port/win32_sema.c');
$postgres->ReplaceFile('src/backend/port/pg_shmem.c',
@@ -316,8 +313,8 @@ sub mkvcbuild
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->AddFile('src/interfaces/ecpg/test/pg_regress_ecpg.c', 1);
+ $pgregress_ecpg->AddFile('src/test/regress/pg_regress.c', 1);
$pgregress_ecpg->AddIncludeDir('src/port');
$pgregress_ecpg->AddIncludeDir('src/test/regress');
$pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
@@ -327,10 +324,10 @@ sub mkvcbuild
my $isolation_tester =
$solution->AddProject('isolationtester', 'exe', 'misc');
- $isolation_tester->AddFile('src/test/isolation/isolationtester.c');
- $isolation_tester->AddFile('src/test/isolation/specparse.y');
- $isolation_tester->AddFile('src/test/isolation/specscanner.l');
- $isolation_tester->AddFile('src/test/isolation/specparse.c');
+ $isolation_tester->AddFile('src/test/isolation/isolationtester.c', 1);
+ $isolation_tester->AddFile('src/test/isolation/specparse.y', 1);
+ $isolation_tester->AddFile('src/test/isolation/specscanner.l', 1);
+ $isolation_tester->AddFile('src/test/isolation/specparse.c', 1);
$isolation_tester->AddIncludeDir('src/test/isolation');
$isolation_tester->AddIncludeDir('src/port');
$isolation_tester->AddIncludeDir('src/test/regress');
@@ -342,8 +339,8 @@ sub mkvcbuild
my $pgregress_isolation =
$solution->AddProject('pg_isolation_regress', 'exe', 'misc');
- $pgregress_isolation->AddFile('src/test/isolation/isolation_main.c');
- $pgregress_isolation->AddFile('src/test/regress/pg_regress.c');
+ $pgregress_isolation->AddFile('src/test/isolation/isolation_main.c', 1);
+ $pgregress_isolation->AddFile('src/test/regress/pg_regress.c', 1);
$pgregress_isolation->AddIncludeDir('src/port');
$pgregress_isolation->AddIncludeDir('src/test/regress');
$pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
@@ -363,22 +360,22 @@ sub mkvcbuild
}
my $pgbasebackup = AddSimpleFrontend('pg_basebackup', 1);
- $pgbasebackup->AddFile('src/bin/pg_basebackup/pg_basebackup.c');
+ $pgbasebackup->AddFile('src/bin/pg_basebackup/pg_basebackup.c', 1);
$pgbasebackup->AddLibrary('ws2_32.lib');
my $pgreceivewal = AddSimpleFrontend('pg_basebackup', 1);
$pgreceivewal->{name} = 'pg_receivewal';
- $pgreceivewal->AddFile('src/bin/pg_basebackup/pg_receivewal.c');
+ $pgreceivewal->AddFile('src/bin/pg_basebackup/pg_receivewal.c', 1);
$pgreceivewal->AddLibrary('ws2_32.lib');
my $pgrecvlogical = AddSimpleFrontend('pg_basebackup', 1);
$pgrecvlogical->{name} = 'pg_recvlogical';
- $pgrecvlogical->AddFile('src/bin/pg_basebackup/pg_recvlogical.c');
+ $pgrecvlogical->AddFile('src/bin/pg_basebackup/pg_recvlogical.c', 1);
$pgrecvlogical->AddLibrary('ws2_32.lib');
my $pgrewind = AddSimpleFrontend('pg_rewind', 1);
$pgrewind->{name} = 'pg_rewind';
- $pgrewind->AddFile('src/backend/access/transam/xlogreader.c');
+ $pgrewind->AddFile('src/backend/access/transam/xlogreader.c', 1);
$pgrewind->AddLibrary('ws2_32.lib');
$pgrewind->AddDefine('FRONTEND');
@@ -392,9 +389,9 @@ sub mkvcbuild
my $pgdump = AddSimpleFrontend('pg_dump', 1);
$pgdump->AddIncludeDir('src/backend');
- $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');
+ $pgdump->AddFile('src/bin/pg_dump/pg_dump.c', 1);
+ $pgdump->AddFile('src/bin/pg_dump/common.c', 1);
+ $pgdump->AddFile('src/bin/pg_dump/pg_dump_sort.c', 1);
$pgdump->AddLibrary('ws2_32.lib');
my $pgdumpall = AddSimpleFrontend('pg_dump', 1);
@@ -408,14 +405,14 @@ sub mkvcbuild
delete @{ $pgdumpall->{files} }{@nodumpall};
$pgdumpall->{name} = 'pg_dumpall';
$pgdumpall->AddIncludeDir('src/backend');
- $pgdumpall->AddFile('src/bin/pg_dump/pg_dumpall.c');
- $pgdumpall->AddFile('src/bin/pg_dump/dumputils.c');
+ $pgdumpall->AddFile('src/bin/pg_dump/pg_dumpall.c', 1);
+ $pgdumpall->AddFile('src/bin/pg_dump/dumputils.c', 1);
$pgdumpall->AddLibrary('ws2_32.lib');
my $pgrestore = AddSimpleFrontend('pg_dump', 1);
$pgrestore->{name} = 'pg_restore';
$pgrestore->AddIncludeDir('src/backend');
- $pgrestore->AddFile('src/bin/pg_dump/pg_restore.c');
+ $pgrestore->AddFile('src/bin/pg_dump/pg_restore.c', 1);
$pgrestore->AddLibrary('ws2_32.lib');
my $zic = $solution->AddProject('zic', 'exe', 'utils');
@@ -795,7 +792,7 @@ sub mkvcbuild
{
my $dir = 'src/backend/utils/mb/conversion_procs/' . $sub;
my $p = $solution->AddProject($sub, 'dll', 'conversion procs', $dir);
- $p->AddFile("$dir/$sub.c"); # implicit source file
+ $p->AddFile("$dir/$sub.c", 1); # implicit source file
$p->AddReference($postgres);
}
@@ -814,7 +811,7 @@ sub mkvcbuild
$f =~ s/\.o$/\.c/;
if ($f =~ /\.c$/)
{
- $proj->AddFile('src/bin/scripts/' . $f);
+ $proj->AddFile('src/bin/scripts/' . $f, 1);
}
}
$proj->AddIncludeDir('src/interfaces/libpq');
@@ -825,13 +822,13 @@ sub mkvcbuild
# Regression DLL and EXE
my $regress = $solution->AddProject('regress', 'dll', 'misc');
- $regress->AddFile('src/test/regress/regress.c');
+ $regress->AddFile('src/test/regress/regress.c', 1);
$regress->AddDirResourceFile('src/test/regress');
$regress->AddReference($postgres);
my $pgregress = $solution->AddProject('pg_regress', 'exe', 'misc');
- $pgregress->AddFile('src/test/regress/pg_regress.c');
- $pgregress->AddFile('src/test/regress/pg_regress_main.c');
+ $pgregress->AddFile('src/test/regress/pg_regress.c', 1);
+ $pgregress->AddFile('src/test/regress/pg_regress_main.c', 1);
$pgregress->AddIncludeDir('src/port');
$pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
$pgregress->AddLibrary('ws2_32.lib');
@@ -844,9 +841,9 @@ sub mkvcbuild
$pg_waldump->AddDefine('FRONTEND');
foreach my $xf (glob('src/backend/access/rmgrdesc/*desc.c'))
{
- $pg_waldump->AddFile($xf);
+ $pg_waldump->AddFile($xf, 1);
}
- $pg_waldump->AddFile('src/backend/access/transam/xlogreader.c');
+ $pg_waldump->AddFile('src/backend/access/transam/xlogreader.c', 1);
$solution->Save();
return $solution->{vcver};
@@ -917,7 +914,7 @@ sub AddTransformModule
my $p = $solution->AddProject($n, 'dll', 'contrib', $n_src);
for my $file (glob("$n_src/*.c"))
{
- $p->AddFile($file);
+ $p->AddFile($file, 1);
}
$p->AddReference($postgres);
@@ -951,6 +948,7 @@ sub AddContrib
my $subdir = shift;
my $n = shift;
my $mf = Project::read_file("$subdir/$n/Makefile");
+ my @projects;
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
{
@@ -958,6 +956,7 @@ sub AddContrib
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
{
@@ -966,21 +965,95 @@ sub AddContrib
my $proj =
$solution->AddProject($mod, 'dll', 'contrib', "$subdir/$n");
my $filename = $mod . '.c';
- $proj->AddFile("$subdir/$n/$filename");
+ $proj->AddFile("$subdir/$n/$filename", 1);
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
}
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
{
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
AdjustContribProj($proj);
+ push @projects, $proj;
}
else
{
croak "Could not determine contrib module type for $n\n";
}
+ # Process custom compiler flags
+ if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg)
+ {
+ foreach my $flag (split /\s+/, $1)
+ {
+ if ($flag =~ /^-D(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddDefine($1);
+ }
+ }
+ elsif ($flag =~ /^-I(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ if ($1 eq '$(libpq_srcdir)')
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^SHLIB_LINK_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^PG_LIBS_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq_pgport)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddReference($libpgport);
+ $proj->AddReference($libpgcommon);
+ }
+ }
+ }
+ }
+
+ foreach my $line (split /\n/, $mf)
+ {
+ if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
+ {
+ foreach my $file (split /\s+/, $1)
+ {
+ foreach my $proj (@projects)
+ {
+ printf("Adding $subdir/$n/$file to project\n");
+ $proj->AddFile("$subdir/$n/$file", 0);
+ }
+ }
+
+ }
+ }
+
# Are there any output data files to build?
GenerateContribSqlFiles($n, $mf);
return;
@@ -1106,7 +1179,7 @@ sub AdjustModule
foreach my $i (@{ $module_extrasource->{$n} })
{
print "Files $i\n";
- $proj->AddFile($i);
+ $proj->AddFile($i, 1);
}
}
return;
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 20f79b382b..50e2cb529d 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -42,12 +42,16 @@ sub _new
sub AddFile
{
- my ($self, $filename) = @_;
+ my ($self, $filename, $alwaysAddOriginal) = @_;
- $self->{files}->{$filename} = 1;
+ if (AdditionalFileRules($self, $filename) != 1 || $alwaysAddOriginal == 1)
+ {
+ $self->{files}->{$filename} = 1;
+ }
return;
}
+
sub AddFiles
{
my $self = shift;
@@ -55,11 +59,40 @@ sub AddFiles
while (my $f = shift)
{
- $self->{files}->{ $dir . "/" . $f } = 1;
+ AddFile($self, $dir . "/" . $f, 1);
}
return;
}
+# Handle makefile rules for when file to be added to the project
+# does not exist. Returns 1 when the original file add should be
+# skipped.
+sub AdditionalFileRules
+{
+ my $self = shift;
+ my $fname = shift;
+ my ($ext) = $fname =~ /(\.[^.]+)$/;
+
+ # For missing .c files, check if a .l file of the same name
+ # exists and add that too.
+ if ($ext eq ".c")
+ {
+ my $filenoext = $fname;
+ $filenoext =~ s{\.[^.]+$}{};
+ if (-e "$filenoext.l")
+ {
+ AddFile($self, "$filenoext.l", 0);
+ return 1;
+ }
+ if (-e "$filenoext.y")
+ {
+ AddFile($self, "$filenoext.y", 0);
+ return 0;
+ }
+ }
+ return 0;
+}
+
sub ReplaceFile
{
my ($self, $filename, $newname) = @_;
@@ -74,14 +107,14 @@ sub ReplaceFile
if ($file eq $filename)
{
delete $self->{files}{$file};
- $self->{files}{$newname} = 1;
+ AddFile($self, $newname, 1);
return;
}
}
elsif ($file =~ m/($re)/)
{
delete $self->{files}{$file};
- $self->{files}{"$newname/$filename"} = 1;
+ AddFile($self, "$newname/$filename", 1);
return;
}
}
@@ -109,7 +142,7 @@ sub RelocateFiles
if ($r)
{
$self->RemoveFile($f);
- $self->AddFile($targetdir . '/' . basename($f));
+ $self->AddFile($targetdir . '/' . basename($f), 1);
}
}
return;
@@ -256,11 +289,11 @@ sub AddDir
if ($f =~ /^\$\(top_builddir\)\/(.*)/)
{
$f = $1;
- $self->{files}->{$f} = 1;
+ AddFile($self, $f, 1);
}
else
{
- $self->{files}->{"$reldir/$f"} = 1;
+ AddFile($self, "$reldir/$f", 1);
}
}
$mf =~ s{OBJS[^=]*=\s*(.*)$}{}m;
@@ -352,7 +385,7 @@ sub AddResourceFile
close($o);
close($i);
}
- $self->AddFile("$dir/win32ver.rc");
+ $self->AddFile("$dir/win32ver.rc", 1);
return;
}
Hi,
On 2020-11-02 20:34:28 +1300, David Rowley wrote:
It might be nice if we could reduce some of those special cases so
that:a) We reduce the amount of work specific to windows when we add new
contrib modules, and;
b) We can work towards a better way for people to build their own
extensions on windows.
A worthy goal.
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 90594bd41b..491a465e2f 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -32,16 +32,13 @@ my $libpq; my @unlink_on_exit;# Set of variables for modules in contrib/ and src/test/modules/ -my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' }; -my @contrib_uselibpq = ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo'); -my @contrib_uselibpgport = ('oid2name', 'pg_standby', 'vacuumlo'); -my @contrib_uselibpgcommon = ('oid2name', 'pg_standby', 'vacuumlo'); +my $contrib_defines = undef; +my @contrib_uselibpq = undef; +my @contrib_uselibpgport = ('pg_standby'); +my @contrib_uselibpgcommon = ('pg_standby'); my $contrib_extralibs = undef; my $contrib_extraincludes = { 'dblink' => ['src/backend'] }; -my $contrib_extrasource = { - 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ], - 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ], -}; +my $contrib_extrasource = undef;
Hm - Is that all the special case stuff we get rid of?
What's with the now unef'd arrays/hashes? First, wouldn't an empty array be
more appropriate? Second, can we just get rid of them?
And why is the special stuff for pg_standby still needed?
my @contrib_excludes = ( 'bool_plperl', 'commit_ts', 'hstore_plperl', 'hstore_plpython', @@ -163,7 +160,7 @@ sub mkvcbuild $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->AddFile('src/backend/utils/fmgrtab.c', 1); $postgres->ReplaceFile('src/backend/port/pg_sema.c', 'src/backend/port/win32_sema.c'); $postgres->ReplaceFile('src/backend/port/pg_shmem.c', @@ -316,8 +313,8 @@ sub mkvcbuild
Why do so many places need this new parameter? Looks like all explicit
calls use it? Can't we just use it by default, using a separate function
for the internal cases? Would make this a lot more readable...
my $isolation_tester = $solution->AddProject('isolationtester', 'exe', 'misc'); - $isolation_tester->AddFile('src/test/isolation/isolationtester.c'); - $isolation_tester->AddFile('src/test/isolation/specparse.y'); - $isolation_tester->AddFile('src/test/isolation/specscanner.l'); - $isolation_tester->AddFile('src/test/isolation/specparse.c'); + $isolation_tester->AddFile('src/test/isolation/isolationtester.c', 1); + $isolation_tester->AddFile('src/test/isolation/specparse.y', 1); + $isolation_tester->AddFile('src/test/isolation/specscanner.l', 1); + $isolation_tester->AddFile('src/test/isolation/specparse.c', 1); $isolation_tester->AddIncludeDir('src/test/isolation'); $isolation_tester->AddIncludeDir('src/port'); $isolation_tester->AddIncludeDir('src/test/regress'); @@ -342,8 +339,8 @@ sub mkvcbuild
Why aren't these dealth with using the .c->.l/.y logic you added?
+ # Process custom compiler flags + if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg)
Probably worth mentioning in pgxs.mk or such.
+ { + foreach my $flag (split /\s+/, $1) + { + if ($flag =~ /^-D(.*)$/) + { + foreach my $proj (@projects) + { + $proj->AddDefine($1); + } + } + elsif ($flag =~ /^-I(.*)$/) + { + foreach my $proj (@projects) + { + if ($1 eq '$(libpq_srcdir)') + { + $proj->AddIncludeDir('src\interfaces\libpq'); + $proj->AddReference($libpq); + }
Why just libpq?
+# Handle makefile rules for when file to be added to the project +# does not exist. Returns 1 when the original file add should be +# skipped. +sub AdditionalFileRules +{ + my $self = shift; + my $fname = shift; + my ($ext) = $fname =~ /(\.[^.]+)$/; + + # For missing .c files, check if a .l file of the same name + # exists and add that too. + if ($ext eq ".c") + { + my $filenoext = $fname; + $filenoext =~ s{\.[^.]+$}{}; + if (-e "$filenoext.l") + { + AddFile($self, "$filenoext.l", 0); + return 1; + } + if (-e "$filenoext.y") + { + AddFile($self, "$filenoext.y", 0); + return 0; + } + }
Aren't there related rules for .h?
Greetings,
Andres Freund
Thank you for looking at this.
On Tue, 3 Nov 2020 at 09:49, Andres Freund <andres@anarazel.de> wrote:
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 90594bd41b..491a465e2f 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -32,16 +32,13 @@ my $libpq; my @unlink_on_exit;# Set of variables for modules in contrib/ and src/test/modules/ -my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' }; -my @contrib_uselibpq = ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo'); -my @contrib_uselibpgport = ('oid2name', 'pg_standby', 'vacuumlo'); -my @contrib_uselibpgcommon = ('oid2name', 'pg_standby', 'vacuumlo'); +my $contrib_defines = undef; +my @contrib_uselibpq = undef; +my @contrib_uselibpgport = ('pg_standby'); +my @contrib_uselibpgcommon = ('pg_standby'); my $contrib_extralibs = undef; my $contrib_extraincludes = { 'dblink' => ['src/backend'] }; -my $contrib_extrasource = { - 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ], - 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ], -}; +my $contrib_extrasource = undef;Hm - Is that all the special case stuff we get rid of?
What else did you have in mind?
What's with the now unef'd arrays/hashes? First, wouldn't an empty array be
more appropriate? Second, can we just get rid of them?
Yes, those should be empty hashtables/arrays. I've changed that.
We could get rid of the variables too. I've just left them in there
for now as I wasn't sure if it might be a good idea to keep them for
if we really need to brute force something in the future. I found
parsing makefiles quite tedious, so it didn't seem unrealistic to me
that someone might struggle in the future to make something work.
And why is the special stuff for pg_standby still needed?
I'm not much of an expert, but I didn't see anything in the makefile
for pg_standby that indicates we should link libpgport or libpgcommon.
It would be good if someone could explain how that works.
my @contrib_excludes = ( 'bool_plperl', 'commit_ts', 'hstore_plperl', 'hstore_plpython', @@ -163,7 +160,7 @@ sub mkvcbuild $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->AddFile('src/backend/utils/fmgrtab.c', 1); $postgres->ReplaceFile('src/backend/port/pg_sema.c', 'src/backend/port/win32_sema.c'); $postgres->ReplaceFile('src/backend/port/pg_shmem.c', @@ -316,8 +313,8 @@ sub mkvcbuildWhy do so many places need this new parameter? Looks like all explicit
calls use it? Can't we just use it by default, using a separate function
for the internal cases? Would make this a lot more readable...
That makes sense. I've updated the patch to have AddFile() add any
additional files always then I've also added a new function named
AddFileConditional which does what AddFile(..., 0) did.
my $isolation_tester = $solution->AddProject('isolationtester', 'exe', 'misc'); - $isolation_tester->AddFile('src/test/isolation/isolationtester.c'); - $isolation_tester->AddFile('src/test/isolation/specparse.y'); - $isolation_tester->AddFile('src/test/isolation/specscanner.l'); - $isolation_tester->AddFile('src/test/isolation/specparse.c'); + $isolation_tester->AddFile('src/test/isolation/isolationtester.c', 1); + $isolation_tester->AddFile('src/test/isolation/specparse.y', 1); + $isolation_tester->AddFile('src/test/isolation/specscanner.l', 1); + $isolation_tester->AddFile('src/test/isolation/specparse.c', 1); $isolation_tester->AddIncludeDir('src/test/isolation'); $isolation_tester->AddIncludeDir('src/port'); $isolation_tester->AddIncludeDir('src/test/regress'); @@ -342,8 +339,8 @@ sub mkvcbuildWhy aren't these dealth with using the .c->.l/.y logic you added?
Yeah, some of those could be removed. I mostly only paid attention to
contrib though.
+ # Process custom compiler flags + if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg)Probably worth mentioning in pgxs.mk or such.
I'm not quite sure I understand what you mean here.
+ { + foreach my $flag (split /\s+/, $1) + { + if ($flag =~ /^-D(.*)$/) + { + foreach my $proj (@projects) + { + $proj->AddDefine($1); + } + } + elsif ($flag =~ /^-I(.*)$/) + { + foreach my $proj (@projects) + { + if ($1 eq '$(libpq_srcdir)') + { + $proj->AddIncludeDir('src\interfaces\libpq'); + $proj->AddReference($libpq); + }Why just libpq?
I've only gone as far as making the existing contrib modules build.
Likely there's more to be done there.
+# Handle makefile rules for when file to be added to the project +# does not exist. Returns 1 when the original file add should be +# skipped. +sub AdditionalFileRules +{ + my $self = shift; + my $fname = shift; + my ($ext) = $fname =~ /(\.[^.]+)$/; + + # For missing .c files, check if a .l file of the same name + # exists and add that too. + if ($ext eq ".c") + { + my $filenoext = $fname; + $filenoext =~ s{\.[^.]+$}{}; + if (-e "$filenoext.l") + { + AddFile($self, "$filenoext.l", 0); + return 1; + } + if (-e "$filenoext.y") + { + AddFile($self, "$filenoext.y", 0); + return 0; + } + }Aren't there related rules for .h?
I've only gone as far as making the existing contrib modules build.
Likely there's more to be done there.
David
Attachments:
reduce_contrib_build_special_cases_on_windows_v2.patchtext/plain; charset=US-ASCII; name=reduce_contrib_build_special_cases_on_windows_v2.patchDownload
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 90594bd41b..f8ab5f59f5 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -32,16 +32,13 @@ my $libpq;
my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
-my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
-my @contrib_uselibpq = ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo');
-my @contrib_uselibpgport = ('oid2name', 'pg_standby', 'vacuumlo');
-my @contrib_uselibpgcommon = ('oid2name', 'pg_standby', 'vacuumlo');
+my $contrib_defines = {};
+my @contrib_uselibpq = ();
+my @contrib_uselibpgport = ('pg_standby');
+my @contrib_uselibpgcommon = ('pg_standby');
my $contrib_extralibs = undef;
my $contrib_extraincludes = { 'dblink' => ['src/backend'] };
-my $contrib_extrasource = {
- 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
- 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
-};
+my $contrib_extrasource = {};
my @contrib_excludes = (
'bool_plperl', 'commit_ts',
'hstore_plperl', 'hstore_plpython',
@@ -951,6 +948,7 @@ sub AddContrib
my $subdir = shift;
my $n = shift;
my $mf = Project::read_file("$subdir/$n/Makefile");
+ my @projects;
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
{
@@ -958,6 +956,7 @@ sub AddContrib
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
{
@@ -969,18 +968,91 @@ sub AddContrib
$proj->AddFile("$subdir/$n/$filename");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
}
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
{
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
AdjustContribProj($proj);
+ push @projects, $proj;
}
else
{
croak "Could not determine contrib module type for $n\n";
}
+ # Process custom compiler flags
+ if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg)
+ {
+ foreach my $flag (split /\s+/, $1)
+ {
+ if ($flag =~ /^-D(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddDefine($1);
+ }
+ }
+ elsif ($flag =~ /^-I(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ if ($1 eq '$(libpq_srcdir)')
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^SHLIB_LINK_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^PG_LIBS_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq_pgport)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddReference($libpgport);
+ $proj->AddReference($libpgcommon);
+ }
+ }
+ }
+ }
+
+ foreach my $line (split /\n/, $mf)
+ {
+ if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
+ {
+ foreach my $file (split /\s+/, $1)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddFileConditional("$subdir/$n/$file");
+ }
+ }
+
+ }
+ }
+
# Are there any output data files to build?
GenerateContribSqlFiles($n, $mf);
return;
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 20f79b382b..3827e9e334 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -42,12 +42,25 @@ sub _new
sub AddFile
{
- my ($self, $filename) = @_;
+ my ($self, $filename, $alwaysAddOriginal) = @_;
+ FindAndAddAdditionalFiles($self, $filename);
+ # Add the original file regardless to the return value of
+ # FindAndAddAdditionalFiles
$self->{files}->{$filename} = 1;
return;
}
+sub AddFileConditional
+{
+ my ($self, $filename) = @_;
+ if (FindAndAddAdditionalFiles($self, $filename) != 1)
+ {
+ $self->{files}->{$filename} = 1;
+ }
+ return;
+}
+
sub AddFiles
{
my $self = shift;
@@ -55,11 +68,40 @@ sub AddFiles
while (my $f = shift)
{
- $self->{files}->{ $dir . "/" . $f } = 1;
+ AddFile($self, $dir . "/" . $f, 1);
}
return;
}
+# Handle makefile rules for when file to be added to the project
+# does not exist. Returns 1 when the original file add should be
+# skipped.
+sub FindAndAddAdditionalFiles
+{
+ my $self = shift;
+ my $fname = shift;
+ my ($ext) = $fname =~ /(\.[^.]+)$/;
+
+ # For .c files, check if a .l file of the same name exists and add that
+ # too.
+ if ($ext eq ".c")
+ {
+ my $filenoext = $fname;
+ $filenoext =~ s{\.[^.]+$}{};
+ if (-e "$filenoext.l")
+ {
+ AddFileConditional($self, "$filenoext.l");
+ return 1;
+ }
+ if (-e "$filenoext.y")
+ {
+ AddFileConditional($self, "$filenoext.y");
+ return 0;
+ }
+ }
+ return 0;
+}
+
sub ReplaceFile
{
my ($self, $filename, $newname) = @_;
@@ -74,14 +116,14 @@ sub ReplaceFile
if ($file eq $filename)
{
delete $self->{files}{$file};
- $self->{files}{$newname} = 1;
+ AddFile($self, $newname);
return;
}
}
elsif ($file =~ m/($re)/)
{
delete $self->{files}{$file};
- $self->{files}{"$newname/$filename"} = 1;
+ AddFile($self, "$newname/$filename");
return;
}
}
@@ -256,11 +298,11 @@ sub AddDir
if ($f =~ /^\$\(top_builddir\)\/(.*)/)
{
$f = $1;
- $self->{files}->{$f} = 1;
+ AddFile($self, $f);
}
else
{
- $self->{files}->{"$reldir/$f"} = 1;
+ AddFile($self, "$reldir/$f");
}
}
$mf =~ s{OBJS[^=]*=\s*(.*)$}{}m;
On 2020-Nov-06, David Rowley wrote:
+# Handle makefile rules for when file to be added to the project +# does not exist. Returns 1 when the original file add should be +# skipped. +sub FindAndAddAdditionalFiles +{ + my $self = shift; + my $fname = shift; + my ($ext) = $fname =~ /(\.[^.]+)$/; + + # For .c files, check if a .l file of the same name exists and add that + # too. + if ($ext eq ".c") + { + my $filenoext = $fname; + $filenoext =~ s{\.[^.]+$}{};
I think you can make this simpler by capturing both the basename and the
extension in one go. For example,
$fname =~ /(.*)(\.[^.]+)$/;
$filenoext = $1;
$ext = $2;
so you avoid the second =~ statement.
+ if (-e "$filenoext.l") + { + AddFileConditional($self, "$filenoext.l"); + return 1; + } + if (-e "$filenoext.y") + { + AddFileConditional($self, "$filenoext.y");
Maybe DRY like
for my $ext (".l", ".y") {
my $file = $filenoext . $ext;
AddFileConditional($self, $file) if -f $file;
return 1;
}
Note: comment says "check if a .l file" and then checks both .l and .y.
Probably want to update the comment ...
On Tue, 10 Nov 2020 at 03:07, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
On 2020-Nov-06, David Rowley wrote:
+# Handle makefile rules for when file to be added to the project +# does not exist. Returns 1 when the original file add should be +# skipped. +sub FindAndAddAdditionalFiles +{ + my $self = shift; + my $fname = shift; + my ($ext) = $fname =~ /(\.[^.]+)$/; + + # For .c files, check if a .l file of the same name exists and add that + # too. + if ($ext eq ".c") + { + my $filenoext = $fname; + $filenoext =~ s{\.[^.]+$}{};I think you can make this simpler by capturing both the basename and the
extension in one go. For example,$fname =~ /(.*)(\.[^.]+)$/;
$filenoext = $1;
$ext = $2;so you avoid the second =~ statement.
Thanks. That's neater.
+ if (-e "$filenoext.l") + { + AddFileConditional($self, "$filenoext.l"); + return 1; + } + if (-e "$filenoext.y") + { + AddFileConditional($self, "$filenoext.y");Maybe DRY like
for my $ext (".l", ".y") {
my $file = $filenoext . $ext;
AddFileConditional($self, $file) if -f $file;
return 1;
}
I did adapt that part of the code, but not exactly to what's above.
The return there would cause us to return from the function after the
first iteration.
Note: comment says "check if a .l file" and then checks both .l and .y.
Probably want to update the comment ...
Updated.
I've attached the v3 patch.
I'm still working through some small differences in some of the
.vcxproj files. I've been comparing these by copying *.vcxproj out to
another directory with patched and unpatched then diffing the
directory. See attached txt file with those diffs. Here's a summary of
some of them:
1. There are a few places that libpq gets linked where it previously did not.
2. REFINT_VERBOSE gets defined in a few more places than it did
previously. This makes it closer to what happens on Linux anyway, if
you look at the Make output from contrib/spi/Makefile you'll see
-DREFINT_VERBOSE in there for autoinc
3. LOWER_NODE gets defined in ltree now where it wasn't before. It's
defined on Linux. Unsure why it wasn't before on Windows.
David
Attachments:
reduce_contrib_build_special_cases_on_windows_v3.patchtext/plain; charset=US-ASCII; name=reduce_contrib_build_special_cases_on_windows_v3.patchDownload
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 90594bd41b..a97edeb6eb 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -32,16 +32,13 @@ my $libpq;
my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
-my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
-my @contrib_uselibpq = ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo');
-my @contrib_uselibpgport = ('oid2name', 'pg_standby', 'vacuumlo');
-my @contrib_uselibpgcommon = ('oid2name', 'pg_standby', 'vacuumlo');
+my $contrib_defines = {};
+my @contrib_uselibpq = ();
+my @contrib_uselibpgport = ('pg_standby');
+my @contrib_uselibpgcommon = ('pg_standby');
my $contrib_extralibs = undef;
my $contrib_extraincludes = { 'dblink' => ['src/backend'] };
-my $contrib_extrasource = {
- 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
- 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
-};
+my $contrib_extrasource = {};
my @contrib_excludes = (
'bool_plperl', 'commit_ts',
'hstore_plperl', 'hstore_plpython',
@@ -951,6 +948,7 @@ sub AddContrib
my $subdir = shift;
my $n = shift;
my $mf = Project::read_file("$subdir/$n/Makefile");
+ my @projects;
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
{
@@ -958,6 +956,7 @@ sub AddContrib
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
{
@@ -969,18 +968,90 @@ sub AddContrib
$proj->AddFile("$subdir/$n/$filename");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
}
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
{
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
AdjustContribProj($proj);
+ push @projects, $proj;
}
else
{
croak "Could not determine contrib module type for $n\n";
}
+ # Process custom compiler flags
+ if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg)
+ {
+ foreach my $flag (split /\s+/, $1)
+ {
+ if ($flag =~ /^-D(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddDefine($1);
+ }
+ }
+ elsif ($flag =~ /^-I(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ if ($1 eq '$(libpq_srcdir)')
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^SHLIB_LINK_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^PG_LIBS_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq_pgport)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddReference($libpgport);
+ $proj->AddReference($libpgcommon);
+ }
+ }
+ }
+ }
+
+ foreach my $line (split /\n/, $mf)
+ {
+ if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
+ {
+ foreach my $file (split /\s+/, $1)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddFileConditional("$subdir/$n/$file");
+ }
+ }
+ }
+ }
+
# Are there any output data files to build?
GenerateContribSqlFiles($n, $mf);
return;
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 20f79b382b..dc94f7c506 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -42,12 +42,25 @@ sub _new
sub AddFile
{
- my ($self, $filename) = @_;
+ my ($self, $filename, $alwaysAddOriginal) = @_;
+ FindAndAddAdditionalFiles($self, $filename);
+ # Add the original file regardless to the return value of
+ # FindAndAddAdditionalFiles
$self->{files}->{$filename} = 1;
return;
}
+sub AddFileConditional
+{
+ my ($self, $filename) = @_;
+ if (FindAndAddAdditionalFiles($self, $filename) != 1)
+ {
+ $self->{files}->{$filename} = 1;
+ }
+ return;
+}
+
sub AddFiles
{
my $self = shift;
@@ -55,11 +68,39 @@ sub AddFiles
while (my $f = shift)
{
- $self->{files}->{ $dir . "/" . $f } = 1;
+ AddFile($self, $dir . "/" . $f, 1);
}
return;
}
+# Handle makefile rules for when file to be added to the project
+# does not exist. Returns 1 when the original file add should be
+# skipped.
+sub FindAndAddAdditionalFiles
+{
+ my $self = shift;
+ my $fname = shift;
+ $fname =~ /(.*)(\.[^.]+)$/;
+ my $filenoext = $1;
+ my $fileext = $2;
+
+ # For .c files, check if either a .l or .y file of the same name
+ # exists and add that too.
+ if ($fileext eq ".c")
+ {
+ for my $ext (".l", ".y")
+ {
+ my $file = $filenoext . $ext;
+ if (-e $file)
+ {
+ AddFileConditional($self, $file);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
sub ReplaceFile
{
my ($self, $filename, $newname) = @_;
@@ -74,14 +115,14 @@ sub ReplaceFile
if ($file eq $filename)
{
delete $self->{files}{$file};
- $self->{files}{$newname} = 1;
+ AddFile($self, $newname);
return;
}
}
elsif ($file =~ m/($re)/)
{
delete $self->{files}{$file};
- $self->{files}{"$newname/$filename"} = 1;
+ AddFile($self, "$newname/$filename");
return;
}
}
@@ -256,11 +297,11 @@ sub AddDir
if ($f =~ /^\$\(top_builddir\)\/(.*)/)
{
$f = $1;
- $self->{files}->{$f} = 1;
+ AddFile($self, $f);
}
else
{
- $self->{files}->{"$reldir/$f"} = 1;
+ AddFile($self, "$reldir/$f");
}
}
$mf =~ s{OBJS[^=]*=\s*(.*)$}{}m;
vcxproj_diffs.patch.txttext/plain; charset=US-ASCII; name=vcxproj_diffs.patch.txtDownload
diff -u "L:\\proj_std/adminpack.vcxproj" "L:\\proj_mod/adminpack.vcxproj"
--- "L:\\proj_std/adminpack.vcxproj" 2020-11-10 13:40:24.856007800 +1300
+++ "L:\\proj_mod/adminpack.vcxproj" 2020-11-10 15:10:53.458754100 +1300
@@ -51,7 +51,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\adminpack\adminpack.dll</OutputFile>
- <AdditionalDependencies>Debug/postgres/postgres.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/postgres/postgres.lib;Debug/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -99,7 +99,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Full</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -118,7 +118,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\adminpack\adminpack.dll</OutputFile>
- <AdditionalDependencies>Release/postgres/postgres.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/postgres/postgres.lib;Release/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -154,6 +154,9 @@
<ProjectReference Include="postgres.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
+ <ProjectReference Include="libpq.vcxproj">
+ <Project>{00000000-0000-0000-0000-000000000000}</Project>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff -u "L:\\proj_std/autoinc.vcxproj" "L:\\proj_mod/autoinc.vcxproj"
--- "L:\\proj_std/autoinc.vcxproj" 2020-11-10 13:40:24.885336500 +1300
+++ "L:\\proj_mod/autoinc.vcxproj" 2020-11-10 15:10:53.487117100 +1300
@@ -52,7 +52,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
@@ -100,7 +100,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
diff -u "L:\\proj_std/dblink.vcxproj" "L:\\proj_mod/dblink.vcxproj"
--- "L:\\proj_std/dblink.vcxproj" 2020-11-10 13:40:24.959753900 +1300
+++ "L:\\proj_mod/dblink.vcxproj" 2020-11-10 15:10:53.566304400 +1300
@@ -51,7 +51,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;src/backend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src/backend;src\interfaces\libpq;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\dblink\dblink.dll</OutputFile>
- <AdditionalDependencies>Debug/postgres/postgres.lib;Debug/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/postgres/postgres.lib;Debug/libpq/libpq.lib;Debug/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -99,7 +99,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Full</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;src/backend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src/backend;src\interfaces\libpq;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -118,7 +118,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\dblink\dblink.dll</OutputFile>
- <AdditionalDependencies>Release/postgres/postgres.lib;Release/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/postgres/postgres.lib;Release/libpq/libpq.lib;Release/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -155,6 +155,9 @@
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
<ProjectReference Include="libpq.vcxproj">
+ <Project>{00000000-0000-0000-0000-000000000000}</Project>
+ </ProjectReference>
+ <ProjectReference Include="libpq.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
</ItemGroup>
diff -u "L:\\proj_std/insert_username.vcxproj" "L:\\proj_mod/insert_username.vcxproj"
--- "L:\\proj_std/insert_username.vcxproj" 2020-11-10 13:40:25.106396300 +1300
+++ "L:\\proj_mod/insert_username.vcxproj" 2020-11-10 15:10:53.709024700 +1300
@@ -52,7 +52,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
@@ -100,7 +100,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
diff -u "L:\\proj_std/ltree.vcxproj" "L:\\proj_mod/ltree.vcxproj"
--- "L:\\proj_std/ltree.vcxproj" 2020-11-10 13:40:25.206112700 +1300
+++ "L:\\proj_mod/ltree.vcxproj" 2020-11-10 15:10:53.817551400 +1300
@@ -52,7 +52,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LOWER_NODE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
@@ -100,7 +100,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LOWER_NODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
diff -u "L:\\proj_std/moddatetime.vcxproj" "L:\\proj_mod/moddatetime.vcxproj"
--- "L:\\proj_std/moddatetime.vcxproj" 2020-11-10 13:40:25.212956300 +1300
+++ "L:\\proj_mod/moddatetime.vcxproj" 2020-11-10 15:10:53.824381700 +1300
@@ -52,7 +52,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
@@ -100,7 +100,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
diff -u "L:\\proj_std/old_snapshot.vcxproj" "L:\\proj_mod/old_snapshot.vcxproj"
--- "L:\\proj_std/old_snapshot.vcxproj" 2020-11-10 13:40:25.228046200 +1300
+++ "L:\\proj_mod/old_snapshot.vcxproj" 2020-11-10 15:10:53.838392000 +1300
@@ -51,7 +51,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\old_snapshot\old_snapshot.dll</OutputFile>
- <AdditionalDependencies>Debug/postgres/postgres.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/postgres/postgres.lib;Debug/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -99,7 +99,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Full</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -118,7 +118,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\old_snapshot\old_snapshot.dll</OutputFile>
- <AdditionalDependencies>Release/postgres/postgres.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/postgres/postgres.lib;Release/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -154,6 +154,9 @@
<ProjectReference Include="postgres.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
+ <ProjectReference Include="libpq.vcxproj">
+ <Project>{00000000-0000-0000-0000-000000000000}</Project>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff -u "L:\\proj_std/postgres_fdw.vcxproj" "L:\\proj_mod/postgres_fdw.vcxproj"
--- "L:\\proj_std/postgres_fdw.vcxproj" 2020-11-10 13:40:25.538923800 +1300
+++ "L:\\proj_mod/postgres_fdw.vcxproj" 2020-11-10 15:10:54.145412300 +1300
@@ -51,7 +51,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\postgres_fdw\postgres_fdw.dll</OutputFile>
- <AdditionalDependencies>Debug/postgres/postgres.lib;Debug/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/postgres/postgres.lib;Debug/libpq/libpq.lib;Debug/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -99,7 +99,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Full</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -118,7 +118,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\postgres_fdw\postgres_fdw.dll</OutputFile>
- <AdditionalDependencies>Release/postgres/postgres.lib;Release/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/postgres/postgres.lib;Release/libpq/libpq.lib;Release/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -159,6 +159,9 @@
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
<ProjectReference Include="libpq.vcxproj">
+ <Project>{00000000-0000-0000-0000-000000000000}</Project>
+ </ProjectReference>
+ <ProjectReference Include="libpq.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
</ItemGroup>
On Wed, Nov 11, 2020 at 11:01:57AM +1300, David Rowley wrote:
I'm still working through some small differences in some of the
.vcxproj files. I've been comparing these by copying *.vcxproj out to
another directory with patched and unpatched then diffing the
directory. See attached txt file with those diffs. Here's a summary of
some of them:
Thanks. It would be good to not have those diffs if not necessary.
1. There are a few places that libpq gets linked where it previously did not.
It seems to me that your patch is doing the right thing for adminpack
and that its Makefile has no need to include a reference to libpq
source path, no?
For dblink and postgres_fdw, the duplication comes from PG_CPPFLAGS.
It does not matter much in practice, but it would be nice to not have
unnecessary data in the project files. One thing that could be done
is to make Project.pm more aware of the uniqueness of the elements
included. But, do we really need -I$(libpq_srcdir) there anyway?
From what I can see, we have all the paths in -I we'd actually need
with or without USE_PGXS.
2. REFINT_VERBOSE gets defined in a few more places than it did
previously. This makes it closer to what happens on Linux anyway, if
you look at the Make output from contrib/spi/Makefile you'll see
-DREFINT_VERBOSE in there for autoinc.
Indeed.
3. LOWER_NODE gets defined in ltree now where it wasn't before. It's
defined on Linux. Unsure why it wasn't before on Windows.
Your patch is grabbing the value of PG_CPPFLAGS from ltree's
Makefile, which is fine. We may be able to remove this flag and rely
on pg_tolower() instead in the long run? I am not sure about
FLG_CANLOOKSIGN() though.
--
Michael
On Wed, 11 Nov 2020 at 13:44, Michael Paquier <michael@paquier.xyz> wrote:
On Wed, Nov 11, 2020 at 11:01:57AM +1300, David Rowley wrote:
I'm still working through some small differences in some of the
.vcxproj files. I've been comparing these by copying *.vcxproj out to
another directory with patched and unpatched then diffing the
directory. See attached txt file with those diffs. Here's a summary of
some of them:Thanks. It would be good to not have those diffs if not necessary.
1. There are a few places that libpq gets linked where it previously did not.
It seems to me that your patch is doing the right thing for adminpack
and that its Makefile has no need to include a reference to libpq
source path, no?
Yeah. Likely a separate commit should remove the -I$(libpq_srcdir)
from adminpack and old_snapshot
For dblink and postgres_fdw, the duplication comes from PG_CPPFLAGS.
It does not matter much in practice, but it would be nice to not have
unnecessary data in the project files. One thing that could be done
is to make Project.pm more aware of the uniqueness of the elements
included. But, do we really need -I$(libpq_srcdir) there anyway?
From what I can see, we have all the paths in -I we'd actually need
with or without USE_PGXS.
I've changed the patch to do that for the includes. I'm now putting
the list of include directories in a hash table to get rid of the
duplicates. This does shuffle the order of them around a bit. I've
done the same for references too.
3. LOWER_NODE gets defined in ltree now where it wasn't before. It's
defined on Linux. Unsure why it wasn't before on Windows.Your patch is grabbing the value of PG_CPPFLAGS from ltree's
Makefile, which is fine. We may be able to remove this flag and rely
on pg_tolower() instead in the long run? I am not sure about
FLG_CANLOOKSIGN() though.
I didn't look in detail, but it looks like if we define LOWER_NODE on
Windows that it might break pg_upgrade. I guess you could say it's
partially broken now as the behaviour there will depend on if you
build using Visual Studio or cygwin. We'd define LOWER_NODE on cygwin
but not on VS. Looks like a pg_upgrade might be problematic there
today.
It feels a bit annoying to add some special case to the script to
maintain the status quo there. An alternative to that would be to
modify the .c code at #ifdef LOWER_NODE to also check we're not
building on VS. Neither option seems nice.
I've attached the updated patch and also a diff showing the changes in
the *.vcxproj files.
There are quite a few places where the hash table code for includes
and references gets rid of duplicates that already exist today. For
example pgbench.vcxproj references libpgport.vcxproj and
libpgcommon.vcxproj twice.
David
Attachments:
reduce_contrib_build_special_cases_on_windows_v4.patchtext/plain; charset=US-ASCII; name=reduce_contrib_build_special_cases_on_windows_v4.patchDownload
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index ebb169e201..2cf3fee65d 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -109,15 +109,13 @@ sub AddDefine
sub WriteReferences
{
my ($self, $f) = @_;
-
- my @references = @{ $self->{references} };
-
- if (scalar(@references))
+ # Add referenced projects, if any exist.
+ if (scalar(keys % { $self->{references} }) > 0)
{
print $f <<EOF;
<ItemGroup>
EOF
- foreach my $ref (@references)
+ foreach my $ref (values % { $self->{references} } )
{
print $f <<EOF;
<ProjectReference Include="$ref->{name}$ref->{filenameExtension}">
@@ -310,11 +308,12 @@ sub WriteItemDefinitionGroup
my $targetmachine =
$self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64';
- my $includes = $self->{includes};
- unless ($includes eq '' or $includes =~ /;$/)
+ my $includes = "";
+ foreach my $inc (keys %{ $self->{includes} } )
{
- $includes .= ';';
+ $includes .= $inc . ";";
}
+
print $f <<EOF;
<ItemDefinitionGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">
<ClCompile>
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index f92c14030d..8db5def9ce 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -32,16 +32,13 @@ my $libpq;
my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
-my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
-my @contrib_uselibpq = ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo');
-my @contrib_uselibpgport = ('oid2name', 'pg_standby', 'vacuumlo');
-my @contrib_uselibpgcommon = ('oid2name', 'pg_standby', 'vacuumlo');
+my $contrib_defines = {};
+my @contrib_uselibpq = ();
+my @contrib_uselibpgport = ('pg_standby');
+my @contrib_uselibpgcommon = ('pg_standby');
my $contrib_extralibs = undef;
-my $contrib_extraincludes = { 'dblink' => ['src/backend'] };
-my $contrib_extrasource = {
- 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
- 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
-};
+my $contrib_extraincludes = {};
+my $contrib_extrasource = {};
my @contrib_excludes = (
'bool_plperl', 'commit_ts',
'hstore_plperl', 'hstore_plpython',
@@ -925,8 +922,8 @@ sub AddTransformModule
# Add PL dependencies
$p->AddIncludeDir($pl_src);
$p->AddReference($pl_proj);
- $p->AddIncludeDir($pl_proj->{includes});
- foreach my $pl_lib (@{ $pl_proj->{libraries} })
+ $p->AddIncludeDir(join(";", $pl_proj->{includes}));
+ foreach my $pl_lib (keys %{ $pl_proj->{libraries} } )
{
$p->AddLibrary($pl_lib);
}
@@ -935,8 +932,8 @@ sub AddTransformModule
if ($type_proj)
{
$p->AddIncludeDir($type_src);
- $p->AddIncludeDir($type_proj->{includes});
- foreach my $type_lib (@{ $type_proj->{libraries} })
+ $p->AddIncludeDir(join(";", $type_proj->{includes}));
+ foreach my $type_lib (keys %{ $type_proj->{libraries} } )
{
$p->AddLibrary($type_lib);
}
@@ -952,6 +949,7 @@ sub AddContrib
my $subdir = shift;
my $n = shift;
my $mf = Project::read_file("$subdir/$n/Makefile");
+ my @projects;
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
{
@@ -959,6 +957,7 @@ sub AddContrib
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
{
@@ -970,18 +969,90 @@ sub AddContrib
$proj->AddFile("$subdir/$n/$filename");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
}
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
{
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
AdjustContribProj($proj);
+ push @projects, $proj;
}
else
{
croak "Could not determine contrib module type for $n\n";
}
+ # Process custom compiler flags
+ if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg || $mf =~ /^override\s*CPPFLAGS\s*(?:[\+\:])?=\s*(.*)$/mg)
+ {
+ foreach my $flag (split /\s+/, $1)
+ {
+ if ($flag =~ /^-D(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddDefine($1);
+ }
+ }
+ elsif ($flag =~ /^-I(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ if ($1 eq '$(libpq_srcdir)')
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^SHLIB_LINK_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^PG_LIBS_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq_pgport)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddReference($libpgport);
+ $proj->AddReference($libpgcommon);
+ }
+ }
+ }
+ }
+
+ foreach my $line (split /\n/, $mf)
+ {
+ if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
+ {
+ foreach my $file (split /\s+/, $1)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddFileConditional("$subdir/$n/$file");
+ }
+ }
+ }
+ }
+
# Are there any output data files to build?
GenerateContribSqlFiles($n, $mf);
return;
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 20f79b382b..ad9e4b6dcc 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -24,10 +24,10 @@ sub _new
type => $type,
guid => $^O eq "MSWin32" ? Win32::GuidGen() : 'FAKE',
files => {},
- references => [],
- libraries => [],
+ references => {},
+ libraries => {},
suffixlib => [],
- includes => '',
+ includes => {},
prefixincludes => '',
defines => ';',
solution => $solution,
@@ -42,12 +42,25 @@ sub _new
sub AddFile
{
- my ($self, $filename) = @_;
+ my ($self, $filename, $alwaysAddOriginal) = @_;
+ FindAndAddAdditionalFiles($self, $filename);
+ # Add the original file regardless to the return value of
+ # FindAndAddAdditionalFiles
$self->{files}->{$filename} = 1;
return;
}
+sub AddFileConditional
+{
+ my ($self, $filename) = @_;
+ if (FindAndAddAdditionalFiles($self, $filename) != 1)
+ {
+ $self->{files}->{$filename} = 1;
+ }
+ return;
+}
+
sub AddFiles
{
my $self = shift;
@@ -55,11 +68,39 @@ sub AddFiles
while (my $f = shift)
{
- $self->{files}->{ $dir . "/" . $f } = 1;
+ AddFile($self, $dir . "/" . $f, 1);
}
return;
}
+# Handle makefile rules for when file to be added to the project
+# does not exist. Returns 1 when the original file add should be
+# skipped.
+sub FindAndAddAdditionalFiles
+{
+ my $self = shift;
+ my $fname = shift;
+ $fname =~ /(.*)(\.[^.]+)$/;
+ my $filenoext = $1;
+ my $fileext = $2;
+
+ # For .c files, check if either a .l or .y file of the same name
+ # exists and add that too.
+ if ($fileext eq ".c")
+ {
+ for my $ext (".l", ".y")
+ {
+ my $file = $filenoext . $ext;
+ if (-e $file)
+ {
+ AddFileConditional($self, $file);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
sub ReplaceFile
{
my ($self, $filename, $newname) = @_;
@@ -74,14 +115,14 @@ sub ReplaceFile
if ($file eq $filename)
{
delete $self->{files}{$file};
- $self->{files}{$newname} = 1;
+ AddFile($self, $newname);
return;
}
}
elsif ($file =~ m/($re)/)
{
delete $self->{files}{$file};
- $self->{files}{"$newname/$filename"} = 1;
+ AddFile($self, "$newname/$filename");
return;
}
}
@@ -121,7 +162,8 @@ sub AddReference
while (my $ref = shift)
{
- push @{ $self->{references} }, $ref;
+ my $name = $ref->{name};
+ $self->{references}->{$name} = $ref;
$self->AddLibrary(
"__CFGNAME__/" . $ref->{name} . "/" . $ref->{name} . ".lib");
}
@@ -138,7 +180,7 @@ sub AddLibrary
$lib = '"' . $lib . """;
}
- push @{ $self->{libraries} }, $lib;
+ $self->{libraries}->{$lib} = 1;
if ($dbgsuffix)
{
push @{ $self->{suffixlib} }, $lib;
@@ -148,13 +190,12 @@ sub AddLibrary
sub AddIncludeDir
{
- my ($self, $inc) = @_;
+ my ($self, $incstr) = @_;
- if ($self->{includes} ne '')
+ foreach my $inc (split(/;/, $incstr))
{
- $self->{includes} .= ';';
+ $self->{includes}->{$inc} = 1;
}
- $self->{includes} .= $inc;
return;
}
@@ -256,11 +297,11 @@ sub AddDir
if ($f =~ /^\$\(top_builddir\)\/(.*)/)
{
$f = $1;
- $self->{files}->{$f} = 1;
+ AddFile($self, $f);
}
else
{
- $self->{files}->{"$reldir/$f"} = 1;
+ AddFile($self, "$reldir/$f");
}
}
$mf =~ s{OBJS[^=]*=\s*(.*)$}{}m;
@@ -397,7 +438,7 @@ sub GetAdditionalLinkerDependencies
my ($self, $cfgname, $separator) = @_;
my $libcfg = (uc $cfgname eq "RELEASE") ? "MD" : "MDd";
my $libs = '';
- foreach my $lib (@{ $self->{libraries} })
+ foreach my $lib (keys %{ $self->{libraries} })
{
my $xlib = $lib;
foreach my $slib (@{ $self->{suffixlib} })
On Tue, Dec 22, 2020 at 11:24:40PM +1300, David Rowley wrote:
On Wed, 11 Nov 2020 at 13:44, Michael Paquier <michael@paquier.xyz> wrote:
It seems to me that your patch is doing the right thing for adminpack
and that its Makefile has no need to include a reference to libpq
source path, no?Yeah. Likely a separate commit should remove the -I$(libpq_srcdir)
from adminpack and old_snapshot
I have begun a new thread about this point as that's a separate
topic. I did not see other places in need of a similar cleanup:
/messages/by-id/X+LQpfLyk7jgzUki@paquier.xyz
I didn't look in detail, but it looks like if we define LOWER_NODE on
Windows that it might break pg_upgrade. I guess you could say it's
partially broken now as the behaviour there will depend on if you
build using Visual Studio or cygwin. We'd define LOWER_NODE on cygwin
but not on VS. Looks like a pg_upgrade might be problematic there
today.It feels a bit annoying to add some special case to the script to
maintain the status quo there. An alternative to that would be to
modify the .c code at #ifdef LOWER_NODE to also check we're not
building on VS. Neither option seems nice.
Hmm. It seems that you are right here. This influences lquery
parsing so it may be nasty and this exists since ltree is present in
the tree (2002). I think that I would choose the update in the C code
and remove LOWER_NODE while keeping the scripts clean, and documenting
directly in the code why this compatibility issue exists.
REFINT_VERBOSE is no problem, fortunately.
I've attached the updated patch and also a diff showing the changes in
the *.vcxproj files.
Thanks!
There are quite a few places where the hash table code for includes
and references gets rid of duplicates that already exist today. For
example pgbench.vcxproj references libpgport.vcxproj and
libpgcommon.vcxproj twice.
The diffs look clean. dblink has lost src/backend/, there are the
additions of REFINT_VERBOSE and LOWER_NODE but the bulk of the diffs
comes from a change in the order of items listed, while removing
duplicates.
I have tested your patch, and this is causing compilation failures for
hstore_plpython, jsonb_plpython and ltree_plpython. So
AddTransformModule is missing something here when compiling with
Python.
--
Michael
On Wed, 23 Dec 2020 at 18:46, Michael Paquier <michael@paquier.xyz> wrote:
I have begun a new thread about this point as that's a separate
topic. I did not see other places in need of a similar cleanup:
/messages/by-id/X+LQpfLyk7jgzUki@paquier.xyz
Thanks. I'll look at that shortly.
I didn't look in detail, but it looks like if we define LOWER_NODE on
Windows that it might break pg_upgrade. I guess you could say it's
partially broken now as the behaviour there will depend on if you
build using Visual Studio or cygwin. We'd define LOWER_NODE on cygwin
but not on VS. Looks like a pg_upgrade might be problematic there
today.It feels a bit annoying to add some special case to the script to
maintain the status quo there. An alternative to that would be to
modify the .c code at #ifdef LOWER_NODE to also check we're not
building on VS. Neither option seems nice.Hmm. It seems that you are right here. This influences lquery
parsing so it may be nasty and this exists since ltree is present in
the tree (2002). I think that I would choose the update in the C code
and remove LOWER_NODE while keeping the scripts clean, and documenting
directly in the code why this compatibility issue exists.
REFINT_VERBOSE is no problem, fortunately.
I ended up modifying each place in the C code where we check
LOWER_NODE. I found 2 places, one in crc32.c and another in ltree.h.
I added the same comment to both to explain why there's a check for
!defined(_MSC_VER) there. I'm not particularly happy about this code,
but I don't really see what else to do right now.
I have tested your patch, and this is causing compilation failures for
hstore_plpython, jsonb_plpython and ltree_plpython. So
AddTransformModule is missing something here when compiling with
Python.
Oh thanks for finding that. That was due to some incorrect Perl code
I'd written to add the includes from one project into another. Fixed
by:
- $p->AddIncludeDir(join(";", $pl_proj->{includes}));
+ foreach my $inc (keys %{ $pl_proj->{includes} } )
+ {
+ $p->AddIncludeDir($inc);
+ }
+
David
Attachments:
reduce_contrib_build_special_cases_on_windows_v5.patchtext/plain; charset=US-ASCII; name=reduce_contrib_build_special_cases_on_windows_v5.patchDownload
diff --git a/contrib/ltree/crc32.c b/contrib/ltree/crc32.c
index 8fed3346e8..b035706c05 100644
--- a/contrib/ltree/crc32.c
+++ b/contrib/ltree/crc32.c
@@ -9,7 +9,15 @@
#include "postgres.h"
-#ifdef LOWER_NODE
+/*
+ * Below we ignore the fact that LOWER_NODE is defined when compiling with
+ * MSVC. The reason for this is that earlier versions of the MSVC build
+ * scripts failed to define LOWER_NODE. More recent version of the MSVC
+ * build scripts parse makefiles which results in LOWER_NODE now being
+ * defined. We check for _MSC_VER here so as not to break pg_upgrade when
+ * upgrading from versions MSVC versions where LOWER_NODE was not defined.
+ */
+#if defined(LOWER_NODE) && !defined(_MSC_VER)
#include <ctype.h>
#define TOLOWER(x) tolower((unsigned char) (x))
#else
diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h
index dc68a0c212..8c10384503 100644
--- a/contrib/ltree/ltree.h
+++ b/contrib/ltree/ltree.h
@@ -90,7 +90,15 @@ typedef struct
#define LQL_NOT 0x10 /* level has '!' (NOT) prefix */
#define LQL_COUNT 0x20 /* level is non-'*' and has repeat counts */
-#ifdef LOWER_NODE
+/*
+ * Below we ignore the fact that LOWER_NODE is defined when compiling with
+ * MSVC. The reason for this is that earlier versions of the MSVC build
+ * scripts failed to define LOWER_NODE. More recent version of the MSVC
+ * build scripts parse makefiles which results in LOWER_NODE now being
+ * defined. We check for _MSC_VER here so as not to break pg_upgrade when
+ * upgrading from versions MSVC versions where LOWER_NODE was not defined.
+ */
+#if defined(LOWER_NODE) && !defined(_MSC_VER)
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME ) ) == 0 )
#else
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME | LVAR_INCASE ) ) == 0 )
On Wed, 30 Dec 2020 at 10:03, David Rowley <dgrowleyml@gmail.com> wrote:
On Wed, 23 Dec 2020 at 18:46, Michael Paquier <michael@paquier.xyz> wrote:
I have tested your patch, and this is causing compilation failures for
hstore_plpython, jsonb_plpython and ltree_plpython. So
AddTransformModule is missing something here when compiling with
Python.Oh thanks for finding that. That was due to some incorrect Perl code
I'd written to add the includes from one project into another. Fixed
by:
I accidentally attached the wrong patch before. Now attaching the correct one.
David
Attachments:
reduce_contrib_build_special_cases_on_windows_v6.patchtext/plain; charset=US-ASCII; name=reduce_contrib_build_special_cases_on_windows_v6.patchDownload
diff --git a/contrib/ltree/crc32.c b/contrib/ltree/crc32.c
index 8fed3346e8..b035706c05 100644
--- a/contrib/ltree/crc32.c
+++ b/contrib/ltree/crc32.c
@@ -9,7 +9,15 @@
#include "postgres.h"
-#ifdef LOWER_NODE
+/*
+ * Below we ignore the fact that LOWER_NODE is defined when compiling with
+ * MSVC. The reason for this is that earlier versions of the MSVC build
+ * scripts failed to define LOWER_NODE. More recent version of the MSVC
+ * build scripts parse makefiles which results in LOWER_NODE now being
+ * defined. We check for _MSC_VER here so as not to break pg_upgrade when
+ * upgrading from versions MSVC versions where LOWER_NODE was not defined.
+ */
+#if defined(LOWER_NODE) && !defined(_MSC_VER)
#include <ctype.h>
#define TOLOWER(x) tolower((unsigned char) (x))
#else
diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h
index dc68a0c212..8c10384503 100644
--- a/contrib/ltree/ltree.h
+++ b/contrib/ltree/ltree.h
@@ -90,7 +90,15 @@ typedef struct
#define LQL_NOT 0x10 /* level has '!' (NOT) prefix */
#define LQL_COUNT 0x20 /* level is non-'*' and has repeat counts */
-#ifdef LOWER_NODE
+/*
+ * Below we ignore the fact that LOWER_NODE is defined when compiling with
+ * MSVC. The reason for this is that earlier versions of the MSVC build
+ * scripts failed to define LOWER_NODE. More recent version of the MSVC
+ * build scripts parse makefiles which results in LOWER_NODE now being
+ * defined. We check for _MSC_VER here so as not to break pg_upgrade when
+ * upgrading from versions MSVC versions where LOWER_NODE was not defined.
+ */
+#if defined(LOWER_NODE) && !defined(_MSC_VER)
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME ) ) == 0 )
#else
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME | LVAR_INCASE ) ) == 0 )
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index ebb169e201..2cf3fee65d 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -109,15 +109,13 @@ sub AddDefine
sub WriteReferences
{
my ($self, $f) = @_;
-
- my @references = @{ $self->{references} };
-
- if (scalar(@references))
+ # Add referenced projects, if any exist.
+ if (scalar(keys % { $self->{references} }) > 0)
{
print $f <<EOF;
<ItemGroup>
EOF
- foreach my $ref (@references)
+ foreach my $ref (values % { $self->{references} } )
{
print $f <<EOF;
<ProjectReference Include="$ref->{name}$ref->{filenameExtension}">
@@ -310,11 +308,12 @@ sub WriteItemDefinitionGroup
my $targetmachine =
$self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64';
- my $includes = $self->{includes};
- unless ($includes eq '' or $includes =~ /;$/)
+ my $includes = "";
+ foreach my $inc (keys %{ $self->{includes} } )
{
- $includes .= ';';
+ $includes .= $inc . ";";
}
+
print $f <<EOF;
<ItemDefinitionGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">
<ClCompile>
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index f92c14030d..e43978ca17 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -32,16 +32,13 @@ my $libpq;
my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
-my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
-my @contrib_uselibpq = ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo');
-my @contrib_uselibpgport = ('oid2name', 'pg_standby', 'vacuumlo');
-my @contrib_uselibpgcommon = ('oid2name', 'pg_standby', 'vacuumlo');
+my $contrib_defines = {};
+my @contrib_uselibpq = ();
+my @contrib_uselibpgport = ('pg_standby');
+my @contrib_uselibpgcommon = ('pg_standby');
my $contrib_extralibs = undef;
-my $contrib_extraincludes = { 'dblink' => ['src/backend'] };
-my $contrib_extrasource = {
- 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
- 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
-};
+my $contrib_extraincludes = {};
+my $contrib_extrasource = {};
my @contrib_excludes = (
'bool_plperl', 'commit_ts',
'hstore_plperl', 'hstore_plpython',
@@ -925,8 +922,12 @@ sub AddTransformModule
# Add PL dependencies
$p->AddIncludeDir($pl_src);
$p->AddReference($pl_proj);
- $p->AddIncludeDir($pl_proj->{includes});
- foreach my $pl_lib (@{ $pl_proj->{libraries} })
+ foreach my $inc (keys %{ $pl_proj->{includes} } )
+ {
+ $p->AddIncludeDir($inc);
+ }
+
+ foreach my $pl_lib (keys %{ $pl_proj->{libraries} } )
{
$p->AddLibrary($pl_lib);
}
@@ -935,8 +936,11 @@ sub AddTransformModule
if ($type_proj)
{
$p->AddIncludeDir($type_src);
- $p->AddIncludeDir($type_proj->{includes});
- foreach my $type_lib (@{ $type_proj->{libraries} })
+ foreach my $inc (keys %{ $type_proj->{includes} } )
+ {
+ $p->AddIncludeDir($inc);
+ }
+ foreach my $type_lib (keys %{ $type_proj->{libraries} } )
{
$p->AddLibrary($type_lib);
}
@@ -952,6 +956,7 @@ sub AddContrib
my $subdir = shift;
my $n = shift;
my $mf = Project::read_file("$subdir/$n/Makefile");
+ my @projects;
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
{
@@ -959,6 +964,7 @@ sub AddContrib
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
{
@@ -970,18 +976,90 @@ sub AddContrib
$proj->AddFile("$subdir/$n/$filename");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
}
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
{
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
AdjustContribProj($proj);
+ push @projects, $proj;
}
else
{
croak "Could not determine contrib module type for $n\n";
}
+ # Process custom compiler flags
+ if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg || $mf =~ /^override\s*CPPFLAGS\s*(?:[\+\:])?=\s*(.*)$/mg)
+ {
+ foreach my $flag (split /\s+/, $1)
+ {
+ if ($flag =~ /^-D(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddDefine($1);
+ }
+ }
+ elsif ($flag =~ /^-I(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ if ($1 eq '$(libpq_srcdir)')
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^SHLIB_LINK_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^PG_LIBS_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq_pgport)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddReference($libpgport);
+ $proj->AddReference($libpgcommon);
+ }
+ }
+ }
+ }
+
+ foreach my $line (split /\n/, $mf)
+ {
+ if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
+ {
+ foreach my $file (split /\s+/, $1)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddFileConditional("$subdir/$n/$file");
+ }
+ }
+ }
+ }
+
# Are there any output data files to build?
GenerateContribSqlFiles($n, $mf);
return;
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 20f79b382b..ad9e4b6dcc 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -24,10 +24,10 @@ sub _new
type => $type,
guid => $^O eq "MSWin32" ? Win32::GuidGen() : 'FAKE',
files => {},
- references => [],
- libraries => [],
+ references => {},
+ libraries => {},
suffixlib => [],
- includes => '',
+ includes => {},
prefixincludes => '',
defines => ';',
solution => $solution,
@@ -42,12 +42,25 @@ sub _new
sub AddFile
{
- my ($self, $filename) = @_;
+ my ($self, $filename, $alwaysAddOriginal) = @_;
+ FindAndAddAdditionalFiles($self, $filename);
+ # Add the original file regardless to the return value of
+ # FindAndAddAdditionalFiles
$self->{files}->{$filename} = 1;
return;
}
+sub AddFileConditional
+{
+ my ($self, $filename) = @_;
+ if (FindAndAddAdditionalFiles($self, $filename) != 1)
+ {
+ $self->{files}->{$filename} = 1;
+ }
+ return;
+}
+
sub AddFiles
{
my $self = shift;
@@ -55,11 +68,39 @@ sub AddFiles
while (my $f = shift)
{
- $self->{files}->{ $dir . "/" . $f } = 1;
+ AddFile($self, $dir . "/" . $f, 1);
}
return;
}
+# Handle makefile rules for when file to be added to the project
+# does not exist. Returns 1 when the original file add should be
+# skipped.
+sub FindAndAddAdditionalFiles
+{
+ my $self = shift;
+ my $fname = shift;
+ $fname =~ /(.*)(\.[^.]+)$/;
+ my $filenoext = $1;
+ my $fileext = $2;
+
+ # For .c files, check if either a .l or .y file of the same name
+ # exists and add that too.
+ if ($fileext eq ".c")
+ {
+ for my $ext (".l", ".y")
+ {
+ my $file = $filenoext . $ext;
+ if (-e $file)
+ {
+ AddFileConditional($self, $file);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
sub ReplaceFile
{
my ($self, $filename, $newname) = @_;
@@ -74,14 +115,14 @@ sub ReplaceFile
if ($file eq $filename)
{
delete $self->{files}{$file};
- $self->{files}{$newname} = 1;
+ AddFile($self, $newname);
return;
}
}
elsif ($file =~ m/($re)/)
{
delete $self->{files}{$file};
- $self->{files}{"$newname/$filename"} = 1;
+ AddFile($self, "$newname/$filename");
return;
}
}
@@ -121,7 +162,8 @@ sub AddReference
while (my $ref = shift)
{
- push @{ $self->{references} }, $ref;
+ my $name = $ref->{name};
+ $self->{references}->{$name} = $ref;
$self->AddLibrary(
"__CFGNAME__/" . $ref->{name} . "/" . $ref->{name} . ".lib");
}
@@ -138,7 +180,7 @@ sub AddLibrary
$lib = '"' . $lib . """;
}
- push @{ $self->{libraries} }, $lib;
+ $self->{libraries}->{$lib} = 1;
if ($dbgsuffix)
{
push @{ $self->{suffixlib} }, $lib;
@@ -148,13 +190,12 @@ sub AddLibrary
sub AddIncludeDir
{
- my ($self, $inc) = @_;
+ my ($self, $incstr) = @_;
- if ($self->{includes} ne '')
+ foreach my $inc (split(/;/, $incstr))
{
- $self->{includes} .= ';';
+ $self->{includes}->{$inc} = 1;
}
- $self->{includes} .= $inc;
return;
}
@@ -256,11 +297,11 @@ sub AddDir
if ($f =~ /^\$\(top_builddir\)\/(.*)/)
{
$f = $1;
- $self->{files}->{$f} = 1;
+ AddFile($self, $f);
}
else
{
- $self->{files}->{"$reldir/$f"} = 1;
+ AddFile($self, "$reldir/$f");
}
}
$mf =~ s{OBJS[^=]*=\s*(.*)$}{}m;
@@ -397,7 +438,7 @@ sub GetAdditionalLinkerDependencies
my ($self, $cfgname, $separator) = @_;
my $libcfg = (uc $cfgname eq "RELEASE") ? "MD" : "MDd";
my $libs = '';
- foreach my $lib (@{ $self->{libraries} })
+ foreach my $lib (keys %{ $self->{libraries} })
{
my $xlib = $lib;
foreach my $slib (@{ $self->{suffixlib} })
On Wed, Dec 30, 2020 at 10:07:29AM +1300, David Rowley wrote:
-#ifdef LOWER_NODE +/* + * Below we ignore the fact that LOWER_NODE is defined when compiling with + * MSVC. The reason for this is that earlier versions of the MSVC build + * scripts failed to define LOWER_NODE. More recent version of the MSVC + * build scripts parse makefiles which results in LOWER_NODE now being + * defined. We check for _MSC_VER here so as not to break pg_upgrade when + * upgrading from versions MSVC versions where LOWER_NODE was not defined. + */ +#if defined(LOWER_NODE) && !defined(_MSC_VER) #include <ctype.h> #define TOLOWER(x) tolower((unsigned char) (x)) #else
While on it, do you think that it would be more readable if we remove
completely LOWER_NODE and use only a check based on _MSC_VER for those
two files in ltree? This could also be handled as a separate change.
+ foreach my $line (split /\n/, $mf) + { + if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/) + { + foreach my $file (split /\s+/, $1) + { + foreach my $proj (@projects) + { + $proj->AddFileConditional("$subdir/$n/$file"); + } + } + } + }
Looking closer at this change, I don't think that this is completely
correct and that could become a trap. This is adding quite a bit of
complexity to take care of contrib_extrasource getting empty, and it
actually overlaps with the handling of OBJS done in AddDir(), no?
--
Michael
Thank you for having another look at this.
On Tue, 12 Jan 2021 at 20:18, Michael Paquier <michael@paquier.xyz> wrote:
On Wed, Dec 30, 2020 at 10:07:29AM +1300, David Rowley wrote:
-#ifdef LOWER_NODE +/* + * Below we ignore the fact that LOWER_NODE is defined when compiling with + * MSVC. The reason for this is that earlier versions of the MSVC build + * scripts failed to define LOWER_NODE. More recent version of the MSVC + * build scripts parse makefiles which results in LOWER_NODE now being + * defined. We check for _MSC_VER here so as not to break pg_upgrade when + * upgrading from versions MSVC versions where LOWER_NODE was not defined. + */ +#if defined(LOWER_NODE) && !defined(_MSC_VER) #include <ctype.h> #define TOLOWER(x) tolower((unsigned char) (x)) #elseWhile on it, do you think that it would be more readable if we remove
completely LOWER_NODE and use only a check based on _MSC_VER for those
two files in ltree? This could also be handled as a separate change.
I'm hesitant to touch that. If anyone is running an instance compiled
with a non-default LOWER_NODE then we might give them some trouble if
they pg_upgrade their database later.
+ foreach my $line (split /\n/, $mf) + { + if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/) + { + foreach my $file (split /\s+/, $1) + { + foreach my $proj (@projects) + { + $proj->AddFileConditional("$subdir/$n/$file"); + } + } + } + }Looking closer at this change, I don't think that this is completely
correct and that could become a trap. This is adding quite a bit of
complexity to take care of contrib_extrasource getting empty, and it
actually overlaps with the handling of OBJS done in AddDir(), no?
hmm. I'm not quite sure if I know what you mean by "trap" here.
contrib/cube/Makefile has an example of what this is trying to catch:
# cubescan is compiled as part of cubeparse
cubeparse.o: cubescan.c
I don't really see what other options there are apart from just not
get rid of $contrib_extrasource.
Can you give an example of what sort of scenario you've got in mind
where it'll cause issues?
I've attached a rebased patch.
David
Attachments:
reduce_contrib_build_special_cases_on_windows_v7.patchtext/plain; charset=US-ASCII; name=reduce_contrib_build_special_cases_on_windows_v7.patchDownload
diff --git a/contrib/ltree/crc32.c b/contrib/ltree/crc32.c
index 8fed3346e8..b035706c05 100644
--- a/contrib/ltree/crc32.c
+++ b/contrib/ltree/crc32.c
@@ -9,7 +9,15 @@
#include "postgres.h"
-#ifdef LOWER_NODE
+/*
+ * Below we ignore the fact that LOWER_NODE is defined when compiling with
+ * MSVC. The reason for this is that earlier versions of the MSVC build
+ * scripts failed to define LOWER_NODE. More recent version of the MSVC
+ * build scripts parse makefiles which results in LOWER_NODE now being
+ * defined. We check for _MSC_VER here so as not to break pg_upgrade when
+ * upgrading from versions MSVC versions where LOWER_NODE was not defined.
+ */
+#if defined(LOWER_NODE) && !defined(_MSC_VER)
#include <ctype.h>
#define TOLOWER(x) tolower((unsigned char) (x))
#else
diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h
index dc68a0c212..8c10384503 100644
--- a/contrib/ltree/ltree.h
+++ b/contrib/ltree/ltree.h
@@ -90,7 +90,15 @@ typedef struct
#define LQL_NOT 0x10 /* level has '!' (NOT) prefix */
#define LQL_COUNT 0x20 /* level is non-'*' and has repeat counts */
-#ifdef LOWER_NODE
+/*
+ * Below we ignore the fact that LOWER_NODE is defined when compiling with
+ * MSVC. The reason for this is that earlier versions of the MSVC build
+ * scripts failed to define LOWER_NODE. More recent version of the MSVC
+ * build scripts parse makefiles which results in LOWER_NODE now being
+ * defined. We check for _MSC_VER here so as not to break pg_upgrade when
+ * upgrading from versions MSVC versions where LOWER_NODE was not defined.
+ */
+#if defined(LOWER_NODE) && !defined(_MSC_VER)
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME ) ) == 0 )
#else
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME | LVAR_INCASE ) ) == 0 )
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index ebb169e201..2cf3fee65d 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -109,15 +109,13 @@ sub AddDefine
sub WriteReferences
{
my ($self, $f) = @_;
-
- my @references = @{ $self->{references} };
-
- if (scalar(@references))
+ # Add referenced projects, if any exist.
+ if (scalar(keys % { $self->{references} }) > 0)
{
print $f <<EOF;
<ItemGroup>
EOF
- foreach my $ref (@references)
+ foreach my $ref (values % { $self->{references} } )
{
print $f <<EOF;
<ProjectReference Include="$ref->{name}$ref->{filenameExtension}">
@@ -310,11 +308,12 @@ sub WriteItemDefinitionGroup
my $targetmachine =
$self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64';
- my $includes = $self->{includes};
- unless ($includes eq '' or $includes =~ /;$/)
+ my $includes = "";
+ foreach my $inc (keys %{ $self->{includes} } )
{
- $includes .= ';';
+ $includes .= $inc . ";";
}
+
print $f <<EOF;
<ItemDefinitionGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">
<ClCompile>
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 49614106dc..fd6e32c9ec 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -32,16 +32,13 @@ my $libpq;
my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
-my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
-my @contrib_uselibpq = ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo');
-my @contrib_uselibpgport = ('oid2name', 'vacuumlo');
-my @contrib_uselibpgcommon = ('oid2name', 'vacuumlo');
+my $contrib_defines = {};
+my @contrib_uselibpq = ();
+my @contrib_uselibpgport = ();
+my @contrib_uselibpgcommon = ();
my $contrib_extralibs = undef;
-my $contrib_extraincludes = { 'dblink' => ['src/backend'] };
-my $contrib_extrasource = {
- 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
- 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
-};
+my $contrib_extraincludes = {};
+my $contrib_extrasource = {};
my @contrib_excludes = (
'bool_plperl', 'commit_ts',
'hstore_plperl', 'hstore_plpython',
@@ -927,8 +924,12 @@ sub AddTransformModule
# Add PL dependencies
$p->AddIncludeDir($pl_src);
$p->AddReference($pl_proj);
- $p->AddIncludeDir($pl_proj->{includes});
- foreach my $pl_lib (@{ $pl_proj->{libraries} })
+ foreach my $inc (keys %{ $pl_proj->{includes} } )
+ {
+ $p->AddIncludeDir($inc);
+ }
+
+ foreach my $pl_lib (keys %{ $pl_proj->{libraries} } )
{
$p->AddLibrary($pl_lib);
}
@@ -937,8 +938,11 @@ sub AddTransformModule
if ($type_proj)
{
$p->AddIncludeDir($type_src);
- $p->AddIncludeDir($type_proj->{includes});
- foreach my $type_lib (@{ $type_proj->{libraries} })
+ foreach my $inc (keys %{ $type_proj->{includes} } )
+ {
+ $p->AddIncludeDir($inc);
+ }
+ foreach my $type_lib (keys %{ $type_proj->{libraries} } )
{
$p->AddLibrary($type_lib);
}
@@ -954,6 +958,7 @@ sub AddContrib
my $subdir = shift;
my $n = shift;
my $mf = Project::read_file("$subdir/$n/Makefile");
+ my @projects;
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
{
@@ -961,6 +966,7 @@ sub AddContrib
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
{
@@ -972,18 +978,90 @@ sub AddContrib
$proj->AddFile("$subdir/$n/$filename");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
}
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
{
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
AdjustContribProj($proj);
+ push @projects, $proj;
}
else
{
croak "Could not determine contrib module type for $n\n";
}
+ # Process custom compiler flags
+ if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg || $mf =~ /^override\s*CPPFLAGS\s*(?:[\+\:])?=\s*(.*)$/mg)
+ {
+ foreach my $flag (split /\s+/, $1)
+ {
+ if ($flag =~ /^-D(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddDefine($1);
+ }
+ }
+ elsif ($flag =~ /^-I(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ if ($1 eq '$(libpq_srcdir)')
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^SHLIB_LINK_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^PG_LIBS_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq_pgport)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddReference($libpgport);
+ $proj->AddReference($libpgcommon);
+ }
+ }
+ }
+ }
+
+ foreach my $line (split /\n/, $mf)
+ {
+ if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
+ {
+ foreach my $file (split /\s+/, $1)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddFileConditional("$subdir/$n/$file");
+ }
+ }
+ }
+ }
+
# Are there any output data files to build?
GenerateContribSqlFiles($n, $mf);
return;
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 20f79b382b..ad9e4b6dcc 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -24,10 +24,10 @@ sub _new
type => $type,
guid => $^O eq "MSWin32" ? Win32::GuidGen() : 'FAKE',
files => {},
- references => [],
- libraries => [],
+ references => {},
+ libraries => {},
suffixlib => [],
- includes => '',
+ includes => {},
prefixincludes => '',
defines => ';',
solution => $solution,
@@ -42,12 +42,25 @@ sub _new
sub AddFile
{
- my ($self, $filename) = @_;
+ my ($self, $filename, $alwaysAddOriginal) = @_;
+ FindAndAddAdditionalFiles($self, $filename);
+ # Add the original file regardless to the return value of
+ # FindAndAddAdditionalFiles
$self->{files}->{$filename} = 1;
return;
}
+sub AddFileConditional
+{
+ my ($self, $filename) = @_;
+ if (FindAndAddAdditionalFiles($self, $filename) != 1)
+ {
+ $self->{files}->{$filename} = 1;
+ }
+ return;
+}
+
sub AddFiles
{
my $self = shift;
@@ -55,11 +68,39 @@ sub AddFiles
while (my $f = shift)
{
- $self->{files}->{ $dir . "/" . $f } = 1;
+ AddFile($self, $dir . "/" . $f, 1);
}
return;
}
+# Handle makefile rules for when file to be added to the project
+# does not exist. Returns 1 when the original file add should be
+# skipped.
+sub FindAndAddAdditionalFiles
+{
+ my $self = shift;
+ my $fname = shift;
+ $fname =~ /(.*)(\.[^.]+)$/;
+ my $filenoext = $1;
+ my $fileext = $2;
+
+ # For .c files, check if either a .l or .y file of the same name
+ # exists and add that too.
+ if ($fileext eq ".c")
+ {
+ for my $ext (".l", ".y")
+ {
+ my $file = $filenoext . $ext;
+ if (-e $file)
+ {
+ AddFileConditional($self, $file);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
sub ReplaceFile
{
my ($self, $filename, $newname) = @_;
@@ -74,14 +115,14 @@ sub ReplaceFile
if ($file eq $filename)
{
delete $self->{files}{$file};
- $self->{files}{$newname} = 1;
+ AddFile($self, $newname);
return;
}
}
elsif ($file =~ m/($re)/)
{
delete $self->{files}{$file};
- $self->{files}{"$newname/$filename"} = 1;
+ AddFile($self, "$newname/$filename");
return;
}
}
@@ -121,7 +162,8 @@ sub AddReference
while (my $ref = shift)
{
- push @{ $self->{references} }, $ref;
+ my $name = $ref->{name};
+ $self->{references}->{$name} = $ref;
$self->AddLibrary(
"__CFGNAME__/" . $ref->{name} . "/" . $ref->{name} . ".lib");
}
@@ -138,7 +180,7 @@ sub AddLibrary
$lib = '"' . $lib . """;
}
- push @{ $self->{libraries} }, $lib;
+ $self->{libraries}->{$lib} = 1;
if ($dbgsuffix)
{
push @{ $self->{suffixlib} }, $lib;
@@ -148,13 +190,12 @@ sub AddLibrary
sub AddIncludeDir
{
- my ($self, $inc) = @_;
+ my ($self, $incstr) = @_;
- if ($self->{includes} ne '')
+ foreach my $inc (split(/;/, $incstr))
{
- $self->{includes} .= ';';
+ $self->{includes}->{$inc} = 1;
}
- $self->{includes} .= $inc;
return;
}
@@ -256,11 +297,11 @@ sub AddDir
if ($f =~ /^\$\(top_builddir\)\/(.*)/)
{
$f = $1;
- $self->{files}->{$f} = 1;
+ AddFile($self, $f);
}
else
{
- $self->{files}->{"$reldir/$f"} = 1;
+ AddFile($self, "$reldir/$f");
}
}
$mf =~ s{OBJS[^=]*=\s*(.*)$}{}m;
@@ -397,7 +438,7 @@ sub GetAdditionalLinkerDependencies
my ($self, $cfgname, $separator) = @_;
my $libcfg = (uc $cfgname eq "RELEASE") ? "MD" : "MDd";
my $libs = '';
- foreach my $lib (@{ $self->{libraries} })
+ foreach my $lib (keys %{ $self->{libraries} })
{
my $xlib = $lib;
foreach my $slib (@{ $self->{suffixlib} })
On Wed, 3 Mar 2021 at 22:37, David Rowley <dgrowleyml@gmail.com> wrote:
I've attached a rebased patch.
I've rebased this again.
I also moved away from using hash tables for storing references and
libraries. I was having some problems getting psql to compile due to
the order of the dependencies being reversed due to the order being at
the mercy of Perl's hash function. There's mention of this in
Makefile.global.in:
# libpq_pgport is for use by client executables (not libraries) that use libpq.
# We force clients to pull symbols from the non-shared libraries libpgport
# and libpgcommon rather than pulling some libpgport symbols from libpq just
# because libpq uses those functions too. This makes applications less
# dependent on changes in libpq's usage of pgport (on platforms where we
# don't have symbol export control for libpq). To do this we link to
# pgport before libpq. This does cause duplicate -lpgport's to appear
# on client link lines, since that also appears in $(LIBS).
# libpq_pgport_shlib is the same idea, but for use in client shared libraries.
I switched these back to arrays but added an additional check to only
add new items to the array if we don't already have an element with
the same value.
I've attached the diffs in the *.vcxproj files between patched and unpatched.
David
Attachments:
vcxproj_file.diff.txttext/plain; charset=US-ASCII; name=vcxproj_file.diff.txtDownload
diff -u "L:\\proj_std/autoinc.vcxproj" "L:\\proj_mod/autoinc.vcxproj"
--- "L:\\proj_std/autoinc.vcxproj" 2021-04-19 23:05:12.549209700 +1200
+++ "L:\\proj_mod/autoinc.vcxproj" 2021-04-19 23:02:23.365767000 +1200
@@ -52,7 +52,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
@@ -100,7 +100,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
diff -u "L:\\proj_std/dblink.vcxproj" "L:\\proj_mod/dblink.vcxproj"
--- "L:\\proj_std/dblink.vcxproj" 2021-04-19 23:05:12.757441500 +1200
+++ "L:\\proj_mod/dblink.vcxproj" 2021-04-19 23:02:23.571066000 +1200
@@ -51,7 +51,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;src/backend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src/backend;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -99,7 +99,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Full</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src\interfaces\libpq;src/backend;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src/backend;src\interfaces\libpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
diff -u "L:\\proj_std/hstore_plpython3.vcxproj" "L:\\proj_mod/hstore_plpython3.vcxproj"
--- "L:\\proj_std/hstore_plpython3.vcxproj" 2021-04-19 23:05:12.944178400 +1200
+++ "L:\\proj_mod/hstore_plpython3.vcxproj" 2021-04-19 23:02:23.750051600 +1200
@@ -51,7 +51,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src/pl/plpython;C:\python-3.9.1-embed/include;contrib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;C:\python-3.9.1-embed/include;contrib;src/pl/plpython;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;PLPYTHON_LIBNAME="plpython3";_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\hstore_plpython3\hstore_plpython3.dll</OutputFile>
- <AdditionalDependencies>Debug/postgres/postgres.lib;Debug/plpython3/plpython3.lib;C:\python-3.9.1-embed/Libs/python39.lib;Debug/postgres/postgres.lib;Debug/postgres/postgres.lib;Debug/hstore/hstore.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/plpython3/plpython3.lib;Debug/postgres/postgres.lib;C:\python-3.9.1-embed/Libs/python39.lib;Debug/hstore/hstore.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -99,7 +99,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Full</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src/pl/plpython;C:\python-3.9.1-embed/include;contrib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;C:\python-3.9.1-embed/include;contrib;src/pl/plpython;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;PLPYTHON_LIBNAME="plpython3";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -118,7 +118,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\hstore_plpython3\hstore_plpython3.dll</OutputFile>
- <AdditionalDependencies>Release/postgres/postgres.lib;Release/plpython3/plpython3.lib;C:\python-3.9.1-embed/Libs/python39.lib;Release/postgres/postgres.lib;Release/postgres/postgres.lib;Release/hstore/hstore.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/plpython3/plpython3.lib;Release/postgres/postgres.lib;C:\python-3.9.1-embed/Libs/python39.lib;Release/hstore/hstore.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -151,15 +151,15 @@
<ResourceCompile Include="contrib/hstore_plpython/win32ver.rc" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="postgres.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
<ProjectReference Include="plpython3.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
<ProjectReference Include="hstore.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
+ <ProjectReference Include="postgres.vcxproj">
+ <Project>{00000000-0000-0000-0000-000000000000}</Project>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff -u "L:\\proj_std/insert_username.vcxproj" "L:\\proj_mod/insert_username.vcxproj"
--- "L:\\proj_std/insert_username.vcxproj" 2021-04-19 23:05:12.957866100 +1200
+++ "L:\\proj_mod/insert_username.vcxproj" 2021-04-19 23:02:23.763737600 +1200
@@ -52,7 +52,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
@@ -100,7 +100,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
diff -u "L:\\proj_std/jsonb_plpython3.vcxproj" "L:\\proj_mod/jsonb_plpython3.vcxproj"
--- "L:\\proj_std/jsonb_plpython3.vcxproj" 2021-04-19 23:05:12.979373800 +1200
+++ "L:\\proj_mod/jsonb_plpython3.vcxproj" 2021-04-19 23:02:23.783290300 +1200
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\jsonb_plpython3\jsonb_plpython3.dll</OutputFile>
- <AdditionalDependencies>Debug/postgres/postgres.lib;Debug/plpython3/plpython3.lib;C:\python-3.9.1-embed/Libs/python39.lib;Debug/postgres/postgres.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>C:\python-3.9.1-embed/Libs/python39.lib;Debug/postgres/postgres.lib;Debug/plpython3/plpython3.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -118,7 +118,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\jsonb_plpython3\jsonb_plpython3.dll</OutputFile>
- <AdditionalDependencies>Release/postgres/postgres.lib;Release/plpython3/plpython3.lib;C:\python-3.9.1-embed/Libs/python39.lib;Release/postgres/postgres.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>C:\python-3.9.1-embed/Libs/python39.lib;Release/postgres/postgres.lib;Release/plpython3/plpython3.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
diff -u "L:\\proj_std/libpq_pipeline.vcxproj" "L:\\proj_mod/libpq_pipeline.vcxproj"
--- "L:\\proj_std/libpq_pipeline.vcxproj" 2021-04-19 23:05:13.048784200 +1200
+++ "L:\\proj_mod/libpq_pipeline.vcxproj" 2021-04-19 23:02:23.850745200 +1200
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\libpq_pipeline\libpq_pipeline.exe</OutputFile>
- <AdditionalDependencies>Debug/libpq/libpq.lib;Debug/libpgport/libpgport.lib;Debug/libpgcommon/libpgcommon.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/libpgport/libpgport.lib;Debug/libpgcommon/libpgcommon.lib;ws2_32.lib;Debug/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -112,7 +112,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\libpq_pipeline\libpq_pipeline.exe</OutputFile>
- <AdditionalDependencies>Release/libpq/libpq.lib;Release/libpgport/libpgport.lib;Release/libpgcommon/libpgcommon.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/libpgport/libpgport.lib;Release/libpgcommon/libpgcommon.lib;ws2_32.lib;Release/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -136,15 +136,15 @@
<ClCompile Include="src/test/modules/libpq_pipeline/libpq_pipeline.c" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="libpq.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
<ProjectReference Include="libpgport.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
<ProjectReference Include="libpgcommon.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
+ <ProjectReference Include="libpq.vcxproj">
+ <Project>{00000000-0000-0000-0000-000000000000}</Project>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff -u "L:\\proj_std/ltree.vcxproj" "L:\\proj_mod/ltree.vcxproj"
--- "L:\\proj_std/ltree.vcxproj" 2021-04-19 23:05:13.071269700 +1200
+++ "L:\\proj_mod/ltree.vcxproj" 2021-04-19 23:02:23.873230700 +1200
@@ -52,7 +52,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LOWER_NODE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
@@ -100,7 +100,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LOWER_NODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
diff -u "L:\\proj_std/ltree_plpython3.vcxproj" "L:\\proj_mod/ltree_plpython3.vcxproj"
--- "L:\\proj_std/ltree_plpython3.vcxproj" 2021-04-19 23:05:13.079090100 +1200
+++ "L:\\proj_mod/ltree_plpython3.vcxproj" 2021-04-19 23:02:23.881051600 +1200
@@ -51,7 +51,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src/pl/plpython;C:\python-3.9.1-embed/include;contrib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;C:\python-3.9.1-embed/include;src/pl/plpython;contrib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;PLPYTHON_LIBNAME="plpython3";_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\ltree_plpython3\ltree_plpython3.dll</OutputFile>
- <AdditionalDependencies>Debug/postgres/postgres.lib;Debug/plpython3/plpython3.lib;C:\python-3.9.1-embed/Libs/python39.lib;Debug/postgres/postgres.lib;Debug/postgres/postgres.lib;Debug/ltree/ltree.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>C:\python-3.9.1-embed/Libs/python39.lib;Debug/ltree/ltree.lib;Debug/postgres/postgres.lib;Debug/plpython3/plpython3.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -99,7 +99,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Full</Optimization>
- <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;src/pl/plpython;C:\python-3.9.1-embed/include;contrib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;C:\python-3.9.1-embed/include;src/pl/plpython;contrib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;PLPYTHON_LIBNAME="plpython3";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -118,7 +118,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\ltree_plpython3\ltree_plpython3.dll</OutputFile>
- <AdditionalDependencies>Release/postgres/postgres.lib;Release/plpython3/plpython3.lib;C:\python-3.9.1-embed/Libs/python39.lib;Release/postgres/postgres.lib;Release/postgres/postgres.lib;Release/ltree/ltree.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>C:\python-3.9.1-embed/Libs/python39.lib;Release/ltree/ltree.lib;Release/postgres/postgres.lib;Release/plpython3/plpython3.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -151,13 +151,13 @@
<ResourceCompile Include="contrib/ltree_plpython/win32ver.rc" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="postgres.vcxproj">
+ <ProjectReference Include="ltree.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
- <ProjectReference Include="plpython3.vcxproj">
+ <ProjectReference Include="postgres.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
- <ProjectReference Include="ltree.vcxproj">
+ <ProjectReference Include="plpython3.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
</ItemGroup>
diff -u "L:\\proj_std/moddatetime.vcxproj" "L:\\proj_mod/moddatetime.vcxproj"
--- "L:\\proj_std/moddatetime.vcxproj" 2021-04-19 23:05:13.085933300 +1200
+++ "L:\\proj_mod/moddatetime.vcxproj" 2021-04-19 23:02:23.888872900 +1200
@@ -52,7 +52,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;_DEBUG;DEBUG=1%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
@@ -100,7 +100,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>src/include;src/include/port/win32;src/include/port/win32_msvc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;REFINT_VERBOSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<DisableSpecificWarnings>4018;4244;4273;4102;4090;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
diff -u "L:\\proj_std/pg_amcheck.vcxproj" "L:\\proj_mod/pg_amcheck.vcxproj"
--- "L:\\proj_std/pg_amcheck.vcxproj" 2021-04-19 23:05:13.121127400 +1200
+++ "L:\\proj_mod/pg_amcheck.vcxproj" 2021-04-19 23:02:23.924066600 +1200
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\pg_amcheck\pg_amcheck.exe</OutputFile>
- <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;Debug/libpq/libpq.lib;Debug/libpgport/libpgport.lib;Debug/libpgcommon/libpgcommon.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;Debug/libpq/libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -112,7 +112,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\pg_amcheck\pg_amcheck.exe</OutputFile>
- <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;Release/libpq/libpq.lib;Release/libpgport/libpgport.lib;Release/libpgcommon/libpgcommon.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;Release/libpq/libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -151,12 +151,6 @@
<ProjectReference Include="libpq.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
- <ProjectReference Include="libpgport.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
- <ProjectReference Include="libpgcommon.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff -u "L:\\proj_std/pg_archivecleanup.vcxproj" "L:\\proj_mod/pg_archivecleanup.vcxproj"
--- "L:\\proj_std/pg_archivecleanup.vcxproj" 2021-04-19 23:05:13.127971500 +1200
+++ "L:\\proj_mod/pg_archivecleanup.vcxproj" 2021-04-19 23:02:23.930909700 +1200
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\pg_archivecleanup\pg_archivecleanup.exe</OutputFile>
- <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;Debug/libpgport/libpgport.lib;Debug/libpgcommon/libpgcommon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -112,7 +112,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\pg_archivecleanup\pg_archivecleanup.exe</OutputFile>
- <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;Release/libpgport/libpgport.lib;Release/libpgcommon/libpgcommon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -148,12 +148,6 @@
<ProjectReference Include="libpgport.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
- <ProjectReference Include="libpgport.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
- <ProjectReference Include="libpgcommon.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff -u "L:\\proj_std/pg_test_fsync.vcxproj" "L:\\proj_mod/pg_test_fsync.vcxproj"
--- "L:\\proj_std/pg_test_fsync.vcxproj" 2021-04-19 23:05:13.285274000 +1200
+++ "L:\\proj_mod/pg_test_fsync.vcxproj" 2021-04-19 23:02:24.084557600 +1200
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\pg_test_fsync\pg_test_fsync.exe</OutputFile>
- <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;Debug/libpgport/libpgport.lib;Debug/libpgcommon/libpgcommon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -112,7 +112,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\pg_test_fsync\pg_test_fsync.exe</OutputFile>
- <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;Release/libpgport/libpgport.lib;Release/libpgcommon/libpgcommon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -148,12 +148,6 @@
<ProjectReference Include="libpgport.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
- <ProjectReference Include="libpgport.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
- <ProjectReference Include="libpgcommon.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff -u "L:\\proj_std/pg_test_timing.vcxproj" "L:\\proj_mod/pg_test_timing.vcxproj"
--- "L:\\proj_std/pg_test_timing.vcxproj" 2021-04-19 23:05:13.292123000 +1200
+++ "L:\\proj_mod/pg_test_timing.vcxproj" 2021-04-19 23:02:24.091401200 +1200
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\pg_test_timing\pg_test_timing.exe</OutputFile>
- <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;Debug/libpgport/libpgport.lib;Debug/libpgcommon/libpgcommon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -112,7 +112,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\pg_test_timing\pg_test_timing.exe</OutputFile>
- <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;Release/libpgport/libpgport.lib;Release/libpgcommon/libpgcommon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -148,12 +148,6 @@
<ProjectReference Include="libpgport.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
- <ProjectReference Include="libpgport.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
- <ProjectReference Include="libpgcommon.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff -u "L:\\proj_std/pg_upgrade.vcxproj" "L:\\proj_mod/pg_upgrade.vcxproj"
--- "L:\\proj_std/pg_upgrade.vcxproj" 2021-04-19 23:05:13.305385900 +1200
+++ "L:\\proj_mod/pg_upgrade.vcxproj" 2021-04-19 23:02:24.104752000 +1200
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\pg_upgrade\pg_upgrade.exe</OutputFile>
- <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;Debug/libpq/libpq.lib;Debug/libpgport/libpgport.lib;Debug/libpgcommon/libpgcommon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;Debug/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -112,7 +112,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\pg_upgrade\pg_upgrade.exe</OutputFile>
- <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;Release/libpq/libpq.lib;Release/libpgport/libpgport.lib;Release/libpgcommon/libpgcommon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;Release/libpq/libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -165,12 +165,6 @@
<ProjectReference Include="libpq.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
- <ProjectReference Include="libpgport.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
- <ProjectReference Include="libpgcommon.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff -u "L:\\proj_std/pg_waldump.vcxproj" "L:\\proj_mod/pg_waldump.vcxproj"
--- "L:\\proj_std/pg_waldump.vcxproj" 2021-04-19 23:05:13.325915900 +1200
+++ "L:\\proj_mod/pg_waldump.vcxproj" 2021-04-19 23:02:24.124304700 +1200
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\pg_waldump\pg_waldump.exe</OutputFile>
- <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;Debug/libpgport/libpgport.lib;Debug/libpgcommon/libpgcommon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -112,7 +112,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\pg_waldump\pg_waldump.exe</OutputFile>
- <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;Release/libpgport/libpgport.lib;Release/libpgcommon/libpgcommon.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -172,12 +172,6 @@
<ProjectReference Include="libpgport.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
- <ProjectReference Include="libpgport.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
- <ProjectReference Include="libpgcommon.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff -u "L:\\proj_std/pgbench.vcxproj" "L:\\proj_mod/pgbench.vcxproj"
--- "L:\\proj_std/pgbench.vcxproj" 2021-04-19 23:05:13.332759100 +1200
+++ "L:\\proj_mod/pgbench.vcxproj" 2021-04-19 23:02:24.131134000 +1200
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\pgbench\pgbench.exe</OutputFile>
- <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;Debug/libpq/libpq.lib;Debug/libpgport/libpgport.lib;Debug/libpgcommon/libpgcommon.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/libpgfeutils/libpgfeutils.lib;Debug/libpgcommon/libpgcommon.lib;Debug/libpgport/libpgport.lib;Debug/libpq/libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -112,7 +112,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\pgbench\pgbench.exe</OutputFile>
- <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;Release/libpq/libpq.lib;Release/libpgport/libpgport.lib;Release/libpgcommon/libpgcommon.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/libpgfeutils/libpgfeutils.lib;Release/libpgcommon/libpgcommon.lib;Release/libpgport/libpgport.lib;Release/libpq/libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -174,12 +174,6 @@
<ProjectReference Include="libpq.vcxproj">
<Project>{00000000-0000-0000-0000-000000000000}</Project>
</ProjectReference>
- <ProjectReference Include="libpgport.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
- <ProjectReference Include="libpgcommon.vcxproj">
- <Project>{00000000-0000-0000-0000-000000000000}</Project>
- </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff -u "L:\\proj_std/plpython3.vcxproj" "L:\\proj_mod/plpython3.vcxproj"
--- "L:\\proj_std/plpython3.vcxproj" 2021-04-19 23:05:13.379490400 +1200
+++ "L:\\proj_mod/plpython3.vcxproj" 2021-04-19 23:02:24.179051000 +1200
@@ -70,7 +70,7 @@
</ClCompile>
<Link>
<OutputFile>.\Debug\plpython3\plpython3.dll</OutputFile>
- <AdditionalDependencies>C:\python-3.9.1-embed/Libs/python39.lib;Debug/postgres/postgres.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Debug/postgres/postgres.lib;C:\python-3.9.1-embed/Libs/python39.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -118,7 +118,7 @@
</ClCompile>
<Link>
<OutputFile>.\Release\plpython3\plpython3.dll</OutputFile>
- <AdditionalDependencies>C:\python-3.9.1-embed/Libs/python39.lib;Release/postgres/postgres.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Release/postgres/postgres.lib;C:\python-3.9.1-embed/Libs/python39.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
reduce_contrib_build_special_cases_on_windows_v8.patchapplication/octet-stream; name=reduce_contrib_build_special_cases_on_windows_v8.patchDownload
diff --git a/contrib/ltree/crc32.c b/contrib/ltree/crc32.c
index 8fed3346e8..b035706c05 100644
--- a/contrib/ltree/crc32.c
+++ b/contrib/ltree/crc32.c
@@ -9,7 +9,15 @@
#include "postgres.h"
-#ifdef LOWER_NODE
+/*
+ * Below we ignore the fact that LOWER_NODE is defined when compiling with
+ * MSVC. The reason for this is that earlier versions of the MSVC build
+ * scripts failed to define LOWER_NODE. More recent version of the MSVC
+ * build scripts parse makefiles which results in LOWER_NODE now being
+ * defined. We check for _MSC_VER here so as not to break pg_upgrade when
+ * upgrading from versions MSVC versions where LOWER_NODE was not defined.
+ */
+#if defined(LOWER_NODE) && !defined(_MSC_VER)
#include <ctype.h>
#define TOLOWER(x) tolower((unsigned char) (x))
#else
diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h
index dc68a0c212..8c10384503 100644
--- a/contrib/ltree/ltree.h
+++ b/contrib/ltree/ltree.h
@@ -90,7 +90,15 @@ typedef struct
#define LQL_NOT 0x10 /* level has '!' (NOT) prefix */
#define LQL_COUNT 0x20 /* level is non-'*' and has repeat counts */
-#ifdef LOWER_NODE
+/*
+ * Below we ignore the fact that LOWER_NODE is defined when compiling with
+ * MSVC. The reason for this is that earlier versions of the MSVC build
+ * scripts failed to define LOWER_NODE. More recent version of the MSVC
+ * build scripts parse makefiles which results in LOWER_NODE now being
+ * defined. We check for _MSC_VER here so as not to break pg_upgrade when
+ * upgrading from versions MSVC versions where LOWER_NODE was not defined.
+ */
+#if defined(LOWER_NODE) && !defined(_MSC_VER)
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME ) ) == 0 )
#else
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME | LVAR_INCASE ) ) == 0 )
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index ebb169e201..68606a296d 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -310,11 +310,12 @@ sub WriteItemDefinitionGroup
my $targetmachine =
$self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64';
- my $includes = $self->{includes};
- unless ($includes eq '' or $includes =~ /;$/)
+ my $includes = "";
+ foreach my $inc (@{ $self->{includes} })
{
- $includes .= ';';
+ $includes .= $inc . ";";
}
+
print $f <<EOF;
<ItemDefinitionGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">
<ClCompile>
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 58a99e4f10..995b6a410b 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -32,17 +32,13 @@ my $libpq;
my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
-my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
-my @contrib_uselibpq =
- ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo', 'libpq_pipeline');
-my @contrib_uselibpgport = ('libpq_pipeline', 'oid2name', 'vacuumlo');
-my @contrib_uselibpgcommon = ('libpq_pipeline', 'oid2name', 'vacuumlo');
+my $contrib_defines = {};
+my @contrib_uselibpq = ();
+my @contrib_uselibpgport = ('libpq_pipeline');
+my @contrib_uselibpgcommon = ('libpq_pipeline');
my $contrib_extralibs = { 'libpq_pipeline' => ['ws2_32.lib'] };
my $contrib_extraincludes = { 'dblink' => ['src/backend'] };
-my $contrib_extrasource = {
- 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
- 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
-};
+my $contrib_extrasource = {};
my @contrib_excludes = (
'bool_plperl', 'commit_ts',
'hstore_plperl', 'hstore_plpython',
@@ -931,7 +927,11 @@ sub AddTransformModule
# Add PL dependencies
$p->AddIncludeDir($pl_src);
$p->AddReference($pl_proj);
- $p->AddIncludeDir($pl_proj->{includes});
+ foreach my $inc (@{ $pl_proj->{includes} })
+ {
+ $p->AddIncludeDir($inc);
+ }
+
foreach my $pl_lib (@{ $pl_proj->{libraries} })
{
$p->AddLibrary($pl_lib);
@@ -941,7 +941,10 @@ sub AddTransformModule
if ($type_proj)
{
$p->AddIncludeDir($type_src);
- $p->AddIncludeDir($type_proj->{includes});
+ foreach my $inc (@{ $type_proj->{includes} })
+ {
+ $p->AddIncludeDir($inc);
+ }
foreach my $type_lib (@{ $type_proj->{libraries} })
{
$p->AddLibrary($type_lib);
@@ -958,6 +961,7 @@ sub AddContrib
my $subdir = shift;
my $n = shift;
my $mf = Project::read_file("$subdir/$n/Makefile");
+ my @projects;
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
{
@@ -965,6 +969,7 @@ sub AddContrib
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
{
@@ -976,18 +981,90 @@ sub AddContrib
$proj->AddFile("$subdir/$n/$filename");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
}
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
{
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
AdjustContribProj($proj);
+ push @projects, $proj;
}
else
{
croak "Could not determine contrib module type for $n\n";
}
+ # Process custom compiler flags
+ if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg || $mf =~ /^override\s*CPPFLAGS\s*(?:[\+\:])?=\s*(.*)$/mg)
+ {
+ foreach my $flag (split /\s+/, $1)
+ {
+ if ($flag =~ /^-D(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddDefine($1);
+ }
+ }
+ elsif ($flag =~ /^-I(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ if ($1 eq '$(libpq_srcdir)')
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^SHLIB_LINK_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^PG_LIBS_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq_pgport)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddReference($libpgport);
+ $proj->AddReference($libpgcommon);
+ }
+ }
+ }
+ }
+
+ foreach my $line (split /\n/, $mf)
+ {
+ if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
+ {
+ foreach my $file (split /\s+/, $1)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddFileConditional("$subdir/$n/$file");
+ }
+ }
+ }
+ }
+
# Are there any output data files to build?
GenerateContribSqlFiles($n, $mf);
return;
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 20f79b382b..7329eafcb7 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -27,7 +27,7 @@ sub _new
references => [],
libraries => [],
suffixlib => [],
- includes => '',
+ includes => [],
prefixincludes => '',
defines => ';',
solution => $solution,
@@ -42,12 +42,25 @@ sub _new
sub AddFile
{
- my ($self, $filename) = @_;
+ my ($self, $filename, $alwaysAddOriginal) = @_;
+ FindAndAddAdditionalFiles($self, $filename);
+ # Add the original file regardless to the return value of
+ # FindAndAddAdditionalFiles
$self->{files}->{$filename} = 1;
return;
}
+sub AddFileConditional
+{
+ my ($self, $filename) = @_;
+ if (FindAndAddAdditionalFiles($self, $filename) != 1)
+ {
+ $self->{files}->{$filename} = 1;
+ }
+ return;
+}
+
sub AddFiles
{
my $self = shift;
@@ -55,11 +68,39 @@ sub AddFiles
while (my $f = shift)
{
- $self->{files}->{ $dir . "/" . $f } = 1;
+ AddFile($self, $dir . "/" . $f, 1);
}
return;
}
+# Handle makefile rules for when file to be added to the project
+# does not exist. Returns 1 when the original file add should be
+# skipped.
+sub FindAndAddAdditionalFiles
+{
+ my $self = shift;
+ my $fname = shift;
+ $fname =~ /(.*)(\.[^.]+)$/;
+ my $filenoext = $1;
+ my $fileext = $2;
+
+ # For .c files, check if either a .l or .y file of the same name
+ # exists and add that too.
+ if ($fileext eq ".c")
+ {
+ for my $ext (".l", ".y")
+ {
+ my $file = $filenoext . $ext;
+ if (-e $file)
+ {
+ AddFileConditional($self, $file);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
sub ReplaceFile
{
my ($self, $filename, $newname) = @_;
@@ -74,14 +115,14 @@ sub ReplaceFile
if ($file eq $filename)
{
delete $self->{files}{$file};
- $self->{files}{$newname} = 1;
+ AddFile($self, $newname);
return;
}
}
elsif ($file =~ m/($re)/)
{
delete $self->{files}{$file};
- $self->{files}{"$newname/$filename"} = 1;
+ AddFile($self, "$newname/$filename");
return;
}
}
@@ -121,7 +162,10 @@ sub AddReference
while (my $ref = shift)
{
- push @{ $self->{references} }, $ref;
+ if (! grep { $_ eq $ref} @{ $self->{references} })
+ {
+ push @{ $self->{references} }, $ref;
+ }
$self->AddLibrary(
"__CFGNAME__/" . $ref->{name} . "/" . $ref->{name} . ".lib");
}
@@ -138,7 +182,11 @@ sub AddLibrary
$lib = '"' . $lib . """;
}
- push @{ $self->{libraries} }, $lib;
+ if (! grep { $_ eq $lib} @{ $self->{libraries} })
+ {
+ push @{ $self->{libraries} }, $lib;
+ }
+
if ($dbgsuffix)
{
push @{ $self->{suffixlib} }, $lib;
@@ -148,13 +196,15 @@ sub AddLibrary
sub AddIncludeDir
{
- my ($self, $inc) = @_;
+ my ($self, $incstr) = @_;
- if ($self->{includes} ne '')
+ foreach my $inc (split(/;/, $incstr))
{
- $self->{includes} .= ';';
+ if (! grep { $_ eq $inc} @{ $self->{includes} })
+ {
+ push @{ $self->{includes} }, $inc;
+ }
}
- $self->{includes} .= $inc;
return;
}
@@ -256,11 +306,11 @@ sub AddDir
if ($f =~ /^\$\(top_builddir\)\/(.*)/)
{
$f = $1;
- $self->{files}->{$f} = 1;
+ AddFile($self, $f);
}
else
{
- $self->{files}->{"$reldir/$f"} = 1;
+ AddFile($self, "$reldir/$f");
}
}
$mf =~ s{OBJS[^=]*=\s*(.*)$}{}m;
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm index ebb169e201..68606a296d 100644 --- a/src/tools/msvc/MSBuildProject.pm +++ b/src/tools/msvc/MSBuildProject.pm @@ -310,11 +310,12 @@ sub WriteItemDefinitionGroup my $targetmachine = $self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64';- my $includes = $self->{includes}; - unless ($includes eq '' or $includes =~ /;$/) + my $includes = ""; + foreach my $inc (@{ $self->{includes} }) { - $includes .= ';'; + $includes .= $inc . ";"; }
Perl note: you can do this more easily as
my $includes = join ';', @{$self->{includes}};
$includes .= ';' unless $includes eq '';
--
�lvaro Herrera 39�49'30"S 73�17'W
Are you not unsure you want to delete Firefox?
[Not unsure] [Not not unsure] [Cancel]
http://smylers.hates-software.com/2008/01/03/566e45b2.html
On 4/19/21 12:24 PM, Alvaro Herrera wrote:
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm index ebb169e201..68606a296d 100644 --- a/src/tools/msvc/MSBuildProject.pm +++ b/src/tools/msvc/MSBuildProject.pm @@ -310,11 +310,12 @@ sub WriteItemDefinitionGroup my $targetmachine = $self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64';- my $includes = $self->{includes}; - unless ($includes eq '' or $includes =~ /;$/) + my $includes = ""; + foreach my $inc (@{ $self->{includes} }) { - $includes .= ';'; + $includes .= $inc . ";"; }Perl note: you can do this more easily as
my $includes = join ';', @{$self->{includes}};
$includes .= ';' unless $includes eq '';
or even more simply:
my $includes = join ';', @{$self->{includes}}, "";
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
On Tue, 20 Apr 2021 at 09:28, Andrew Dunstan <andrew@dunslane.net> wrote:
On 4/19/21 12:24 PM, Alvaro Herrera wrote:
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm index ebb169e201..68606a296d 100644 --- a/src/tools/msvc/MSBuildProject.pm +++ b/src/tools/msvc/MSBuildProject.pm @@ -310,11 +310,12 @@ sub WriteItemDefinitionGroup my $targetmachine = $self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64';- my $includes = $self->{includes}; - unless ($includes eq '' or $includes =~ /;$/) + my $includes = ""; + foreach my $inc (@{ $self->{includes} }) { - $includes .= ';'; + $includes .= $inc . ";"; }Perl note: you can do this more easily as
my $includes = join ';', @{$self->{includes}};
$includes .= ';' unless $includes eq '';or even more simply:
my $includes = join ';', @{$self->{includes}}, "";
Both look more compact. Thanks. I'll include this for the next version.
David
On Mon, Apr 19, 2021 at 5:18 PM David Rowley <dgrowleyml@gmail.com> wrote:
On Wed, 3 Mar 2021 at 22:37, David Rowley <dgrowleyml@gmail.com> wrote:
I've attached a rebased patch.
I've rebased this again.
I also moved away from using hash tables for storing references and
libraries. I was having some problems getting psql to compile due to
the order of the dependencies being reversed due to the order being at
the mercy of Perl's hash function. There's mention of this in
Makefile.global.in:# libpq_pgport is for use by client executables (not libraries) that use libpq.
# We force clients to pull symbols from the non-shared libraries libpgport
# and libpgcommon rather than pulling some libpgport symbols from libpq just
# because libpq uses those functions too. This makes applications less
# dependent on changes in libpq's usage of pgport (on platforms where we
# don't have symbol export control for libpq). To do this we link to
# pgport before libpq. This does cause duplicate -lpgport's to appear
# on client link lines, since that also appears in $(LIBS).
# libpq_pgport_shlib is the same idea, but for use in client shared libraries.I switched these back to arrays but added an additional check to only
add new items to the array if we don't already have an element with
the same value.I've attached the diffs in the *.vcxproj files between patched and unpatched.
The patch does not apply on Head anymore, could you rebase and post a
patch. I'm changing the status to "Waiting for Author".
Regards,
Vignesh
On Thu, 15 Jul 2021 at 04:01, vignesh C <vignesh21@gmail.com> wrote:
The patch does not apply on Head anymore, could you rebase and post a
patch. I'm changing the status to "Waiting for Author".
I've rebased this patch and broken it down into 6 individual patches.
0001: Removes an include directory for dblink. This appears like it's
not needed. It was added in ee3b4188a (Jan 2010), but an earlier
commit, 320c7eb8c (June 2008) seems to have made it pointless. It's
still a mystery to me why ee3b4188a would have been required in the
first place.
0002: Parses -D in the CPPFLAGS of Makefiles and uses those in the
MSVC script. It also adjusts the ltree contrib module so that we do
the same LOWER_NODE behaviour as we did before. The MSVC scripts
appear to have mistakenly forgotten to define LOWER_NODE as it is in
the Makefiles.
0003: Is a tidy up patch to make the 'includes' field an array rather
than a string
0004: Adds code to check for duplicate references and libraries before
adding new ones of the same name to the project.
0005: Is mostly a tidy up so that we use AddFile consistently instead
of sometimes doing $self->{files}->{<name>} = 1;
0006: I'm not so sure about. It attempts to do a bit more Makefile
parsing to get rid of contrib_extrasource and the majority of
contrib_uselibpgport and contrib_uselibpgcommon usages.
David
Attachments:
v9-0001-Remove-unneeded-include-directory-in-MSVC-scripts.patchapplication/octet-stream; name=v9-0001-Remove-unneeded-include-directory-in-MSVC-scripts.patchDownload
From 56d485427f744fc7a60f7dbafbf9e7a29c804ea2 Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 21:57:08 +1200
Subject: [PATCH v9 1/6] Remove unneeded include directory in MSVC scripts
This appears to have been added way back in ee3b4188a but its a little
unclear why it's even needed given that 320c7eb8c dated 18 months earlier
added code to copy fmgroids.h to src/include/utils.
In any case, amcheck seems to get away without adding the additional
include directory.
---
src/tools/msvc/Mkvcbuild.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 233ddbf4c2..4c36e482fb 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -41,7 +41,7 @@ my @contrib_uselibpq =
my @contrib_uselibpgport = ('libpq_pipeline', 'oid2name', 'vacuumlo');
my @contrib_uselibpgcommon = ('libpq_pipeline', 'oid2name', 'vacuumlo');
my $contrib_extralibs = { 'libpq_pipeline' => ['ws2_32.lib'] };
-my $contrib_extraincludes = { 'dblink' => ['src/backend'] };
+my $contrib_extraincludes = {};
my $contrib_extrasource = {
'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
--
2.21.0.windows.1
v9-0002-Adjust-MSVC-build-scripts-to-parse-Makefiles-for-.patchapplication/octet-stream; name=v9-0002-Adjust-MSVC-build-scripts-to-parse-Makefiles-for-.patchDownload
From 8acdd51fa7a6cfb86dd5886be71ff173c6bafbe8 Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 22:02:36 +1200
Subject: [PATCH v9 2/6] Adjust MSVC build scripts to parse Makefiles for
defines
This adjusts the MSVC build scripts to look at the compile flags mentioned
in the Makefile to look for -D arguments in order to determine which
constants should be defined in the Visual Studio build.
---
contrib/ltree/crc32.c | 10 +++++++++-
contrib/ltree/ltree.h | 10 +++++++++-
src/tools/msvc/Mkvcbuild.pm | 21 ++++++++++++++++++++-
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/contrib/ltree/crc32.c b/contrib/ltree/crc32.c
index 8fed3346e8..b035706c05 100644
--- a/contrib/ltree/crc32.c
+++ b/contrib/ltree/crc32.c
@@ -9,7 +9,15 @@
#include "postgres.h"
-#ifdef LOWER_NODE
+/*
+ * Below we ignore the fact that LOWER_NODE is defined when compiling with
+ * MSVC. The reason for this is that earlier versions of the MSVC build
+ * scripts failed to define LOWER_NODE. More recent version of the MSVC
+ * build scripts parse makefiles which results in LOWER_NODE now being
+ * defined. We check for _MSC_VER here so as not to break pg_upgrade when
+ * upgrading from versions MSVC versions where LOWER_NODE was not defined.
+ */
+#if defined(LOWER_NODE) && !defined(_MSC_VER)
#include <ctype.h>
#define TOLOWER(x) tolower((unsigned char) (x))
#else
diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h
index dc68a0c212..8c10384503 100644
--- a/contrib/ltree/ltree.h
+++ b/contrib/ltree/ltree.h
@@ -90,7 +90,15 @@ typedef struct
#define LQL_NOT 0x10 /* level has '!' (NOT) prefix */
#define LQL_COUNT 0x20 /* level is non-'*' and has repeat counts */
-#ifdef LOWER_NODE
+/*
+ * Below we ignore the fact that LOWER_NODE is defined when compiling with
+ * MSVC. The reason for this is that earlier versions of the MSVC build
+ * scripts failed to define LOWER_NODE. More recent version of the MSVC
+ * build scripts parse makefiles which results in LOWER_NODE now being
+ * defined. We check for _MSC_VER here so as not to break pg_upgrade when
+ * upgrading from versions MSVC versions where LOWER_NODE was not defined.
+ */
+#if defined(LOWER_NODE) && !defined(_MSC_VER)
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME ) ) == 0 )
#else
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME | LVAR_INCASE ) ) == 0 )
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 4c36e482fb..dbe2b4c5ac 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -35,7 +35,7 @@ my $libpq;
my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
-my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
+my $contrib_defines = {};
my @contrib_uselibpq =
('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo', 'libpq_pipeline');
my @contrib_uselibpgport = ('libpq_pipeline', 'oid2name', 'vacuumlo');
@@ -964,6 +964,7 @@ sub AddContrib
my $subdir = shift;
my $n = shift;
my $mf = Project::read_file("$subdir/$n/Makefile");
+ my @projects;
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
{
@@ -971,6 +972,7 @@ sub AddContrib
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
{
@@ -982,18 +984,35 @@ sub AddContrib
$proj->AddFile("$subdir/$n/$filename");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
}
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
{
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
AdjustContribProj($proj);
+ push @projects, $proj;
}
else
{
croak "Could not determine contrib module type for $n\n";
}
+ # Process custom compiler flags
+ if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg || $mf =~ /^override\s*CPPFLAGS\s*(?:[\+\:])?=\s*(.*)$/mg)
+ {
+ foreach my $flag (split /\s+/, $1)
+ {
+ if ($flag =~ /^-D(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddDefine($1);
+ }
+ }
+ }
+ }
+
# Are there any output data files to build?
GenerateContribSqlFiles($n, $mf);
return;
--
2.21.0.windows.1
v9-0003-Make-the-includes-field-an-array-in-MSVC-build-sc.patchapplication/octet-stream; name=v9-0003-Make-the-includes-field-an-array-in-MSVC-build-sc.patchDownload
From d5eae4bca8214f40238c84a95bfc96f4925bd970 Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 22:21:08 +1200
Subject: [PATCH v9 3/6] Make the includes field an array in MSVC build scripts
Previously the 'includes' field was a string. It's slightly nicer to
manage this when it's defined as an array instead.
---
src/tools/msvc/MSBuildProject.pm | 7 ++-----
src/tools/msvc/Mkvcbuild.pm | 11 +++++++++--
src/tools/msvc/Project.pm | 12 +++++++-----
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index ebe6530ba5..fdd22e89eb 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -313,11 +313,8 @@ sub WriteItemDefinitionGroup
my $targetmachine =
$self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64';
- my $includes = $self->{includes};
- unless ($includes eq '' or $includes =~ /;$/)
- {
- $includes .= ';';
- }
+ my $includes = join ';', @{$self->{includes}}, "";
+
print $f <<EOF;
<ItemDefinitionGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">
<ClCompile>
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index dbe2b4c5ac..f344ac661e 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -937,7 +937,11 @@ sub AddTransformModule
# Add PL dependencies
$p->AddIncludeDir($pl_src);
$p->AddReference($pl_proj);
- $p->AddIncludeDir($pl_proj->{includes});
+ foreach my $inc (@{ $pl_proj->{includes} })
+ {
+ $p->AddIncludeDir($inc);
+ }
+
foreach my $pl_lib (@{ $pl_proj->{libraries} })
{
$p->AddLibrary($pl_lib);
@@ -947,7 +951,10 @@ sub AddTransformModule
if ($type_proj)
{
$p->AddIncludeDir($type_src);
- $p->AddIncludeDir($type_proj->{includes});
+ foreach my $inc (@{ $type_proj->{includes} })
+ {
+ $p->AddIncludeDir($inc);
+ }
foreach my $type_lib (@{ $type_proj->{libraries} })
{
$p->AddLibrary($type_lib);
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 2f1679ab44..e8095dbd0e 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -30,7 +30,7 @@ sub _new
references => [],
libraries => [],
suffixlib => [],
- includes => '',
+ includes => [],
prefixincludes => '',
defines => ';',
solution => $solution,
@@ -151,13 +151,15 @@ sub AddLibrary
sub AddIncludeDir
{
- my ($self, $inc) = @_;
+ my ($self, $incstr) = @_;
- if ($self->{includes} ne '')
+ foreach my $inc (split(/;/, $incstr))
{
- $self->{includes} .= ';';
+ if (! grep { $_ eq $inc} @{ $self->{includes} })
+ {
+ push @{ $self->{includes} }, $inc;
+ }
}
- $self->{includes} .= $inc;
return;
}
--
2.21.0.windows.1
v9-0004-Don-t-duplicate-references-and-libraries-in-MSVC-.patchapplication/octet-stream; name=v9-0004-Don-t-duplicate-references-and-libraries-in-MSVC-.patchDownload
From b9ca373e019296207195a9272cf85d75849dbe59 Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 22:26:55 +1200
Subject: [PATCH v9 4/6] Don't duplicate references and libraries in MSVC
scripts
In order not to duplicate references and libraries in the Visual Studio
project files produced by the MSVC build scripts, have them check if a
particular reference or library already exists before adding the same one
again.
---
src/tools/msvc/Project.pm | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index e8095dbd0e..137990ca65 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -124,7 +124,10 @@ sub AddReference
while (my $ref = shift)
{
- push @{ $self->{references} }, $ref;
+ if (! grep { $_ eq $ref} @{ $self->{references} })
+ {
+ push @{ $self->{references} }, $ref;
+ }
$self->AddLibrary(
"__CFGNAME__/" . $ref->{name} . "/" . $ref->{name} . ".lib");
}
@@ -141,7 +144,11 @@ sub AddLibrary
$lib = '"' . $lib . """;
}
- push @{ $self->{libraries} }, $lib;
+ if (! grep { $_ eq $lib} @{ $self->{libraries} })
+ {
+ push @{ $self->{libraries} }, $lib;
+ }
+
if ($dbgsuffix)
{
push @{ $self->{suffixlib} }, $lib;
--
2.21.0.windows.1
v9-0005-Use-AddFile-consistently-in-MSVC-scripts.patchapplication/octet-stream; name=v9-0005-Use-AddFile-consistently-in-MSVC-scripts.patchDownload
From 1fd6974d0c2932a23deb55ef4f1baf0ccb564e14 Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 22:06:18 +1200
Subject: [PATCH v9 5/6] Use AddFile consistently in MSVC scripts
---
src/tools/msvc/Project.pm | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 137990ca65..f633ec90af 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -58,7 +58,7 @@ sub AddFiles
while (my $f = shift)
{
- $self->{files}->{ $dir . "/" . $f } = 1;
+ AddFile($self, $dir . "/" . $f, 1);
}
return;
}
@@ -77,14 +77,14 @@ sub ReplaceFile
if ($file eq $filename)
{
delete $self->{files}{$file};
- $self->{files}{$newname} = 1;
+ AddFile($self, $newname);
return;
}
}
elsif ($file =~ m/($re)/)
{
delete $self->{files}{$file};
- $self->{files}{"$newname/$filename"} = 1;
+ AddFile($self, "$newname/$filename");
return;
}
}
@@ -268,11 +268,11 @@ sub AddDir
if ($f =~ /^\$\(top_builddir\)\/(.*)/)
{
$f = $1;
- $self->{files}->{$f} = 1;
+ AddFile($self, $f);
}
else
{
- $self->{files}->{"$reldir/$f"} = 1;
+ AddFile($self, "$reldir/$f");
}
}
$mf =~ s{OBJS[^=]*=\s*(.*)$}{}m;
--
2.21.0.windows.1
v9-0006-Remove-some-special-cases-from-MSVC-build-scripts.patchapplication/octet-stream; name=v9-0006-Remove-some-special-cases-from-MSVC-build-scripts.patchDownload
From fd19f6f5f0c833a28e2db64d745450bdea640c36 Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 22:45:08 +1200
Subject: [PATCH v9 6/6] Remove some special cases from MSVC build scripts
Here we add additional parsing of Makefiles to determine when to add
references to libpgport and libpgcommon. We also remove the need for
adding the current contrib_extrasource by adding very basic Makefile rules
which add .l and .y files when they exist for a given .o file in the
Makefile.
---
src/tools/msvc/Mkvcbuild.pm | 71 +++++++++++++++++++++++++++++++------
src/tools/msvc/Project.pm | 38 ++++++++++++++++++++
2 files changed, 99 insertions(+), 10 deletions(-)
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index f344ac661e..f1cb923a75 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -36,16 +36,12 @@ my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
my $contrib_defines = {};
-my @contrib_uselibpq =
- ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo', 'libpq_pipeline');
-my @contrib_uselibpgport = ('libpq_pipeline', 'oid2name', 'vacuumlo');
-my @contrib_uselibpgcommon = ('libpq_pipeline', 'oid2name', 'vacuumlo');
-my $contrib_extralibs = { 'libpq_pipeline' => ['ws2_32.lib'] };
-my $contrib_extraincludes = {};
-my $contrib_extrasource = {
- 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
- 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
-};
+my @contrib_uselibpq = ();
+my @contrib_uselibpgport = ('libpq_pipeline');
+my @contrib_uselibpgcommon = ('libpq_pipeline');
+my $contrib_extralibs = { 'libpq_pipeline' => ['ws2_32.lib'] };
+my $contrib_extraincludes = {};
+my $contrib_extrasource = {};
my @contrib_excludes = (
'bool_plperl', 'commit_ts',
'hstore_plperl', 'hstore_plpython',
@@ -1017,6 +1013,61 @@ sub AddContrib
$proj->AddDefine($1);
}
}
+ elsif ($flag =~ /^-I(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ if ($1 eq '$(libpq_srcdir)')
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^SHLIB_LINK_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^PG_LIBS_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq_pgport)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddReference($libpgport);
+ $proj->AddReference($libpgcommon);
+ }
+ }
+ }
+ }
+
+ foreach my $line (split /\n/, $mf)
+ {
+ if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
+ {
+ foreach my $file (split /\s+/, $1)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddFileAndAdditionalFiles("$subdir/$n/$file");
+ }
+ }
}
}
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index f633ec90af..204d3cea1b 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -51,6 +51,16 @@ sub AddFile
return;
}
+sub AddFileAndAdditionalFiles
+{
+ my ($self, $filename) = @_;
+ if (FindAndAddAdditionalFiles($self, $filename) != 1)
+ {
+ $self->{files}->{$filename} = 1;
+ }
+ return;
+}
+
sub AddFiles
{
my $self = shift;
@@ -63,6 +73,34 @@ sub AddFiles
return;
}
+# Handle special Makefile rules by searching for other files which exist with
+# the same name but a different file extension and add those files too.
+sub FindAndAddAdditionalFiles
+{
+ my $self = shift;
+ my $fname = shift;
+ $fname =~ /(.*)(\.[^.]+)$/;
+ my $filenoext = $1;
+ my $fileext = $2;
+
+ # For .c files, check if either a .l or .y file of the same name
+ # exists and add that too.
+ if ($fileext eq ".c")
+ {
+ for my $ext (".l", ".y")
+ {
+ my $file = $filenoext . $ext;
+ if (-e $file)
+ {
+ # Add file and recursively search for others
+ AddFileAndAdditionalFiles($self, $file);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
sub ReplaceFile
{
my ($self, $filename, $newname) = @_;
--
2.21.0.windows.1
David Rowley <dgrowleyml@gmail.com> writes:
On Thu, 15 Jul 2021 at 04:01, vignesh C <vignesh21@gmail.com> wrote:
The patch does not apply on Head anymore, could you rebase and post a
patch. I'm changing the status to "Waiting for Author".I've rebased this patch and broken it down into 6 individual patches.
I don't know anything about the MSVC build process, but I figured I
could do a general Perl code review.
--- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm
[…]
+ # Process custom compiler flags + if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg || $mf =~ /^override\s*CPPFLAGS\s*(?:[\+\:])?=\s*(.*)$/mg)
^^^^^^^^^^^
This is a very convoluted way of writing [+:]?
--- a/src/tools/msvc/Project.pm +++ b/src/tools/msvc/Project.pm @@ -58,7 +58,7 @@ sub AddFileswhile (my $f = shift) { - $self->{files}->{ $dir . "/" . $f } = 1; + AddFile($self, $dir . "/" . $f, 1);
AddFile is a method, so should be called as $self->AddFile(…).
--- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -36,16 +36,12 @@ my @unlink_on_exit;
[…]
+ elsif ($flag =~ /^-I(.*)$/) + { + foreach my $proj (@projects) + { + if ($1 eq '$(libpq_srcdir)') + { + $proj->AddIncludeDir('src\interfaces\libpq'); + $proj->AddReference($libpq); + } + } + }
It would be better to do the if check outside the for loop.
--- a/src/tools/msvc/Project.pm +++ b/src/tools/msvc/Project.pm @@ -51,6 +51,16 @@ sub AddFile return; }+sub AddFileAndAdditionalFiles +{ + my ($self, $filename) = @_; + if (FindAndAddAdditionalFiles($self, $filename) != 1)
Again, FindAndAddAdditionalFiles is a method and should be called as
$self->FindAndAddAdditionalFiles($filename).
+ { + $self->{files}->{$filename} = 1; + } + return; +}
- ilmari
David Rowley <dgrowleyml@gmail.com> writes:
0001: Removes an include directory for dblink. This appears like it's
not needed. It was added in ee3b4188a (Jan 2010), but an earlier
commit, 320c7eb8c (June 2008) seems to have made it pointless. It's
still a mystery to me why ee3b4188a would have been required in the
first place.
FWIW, I poked around in the mailing list archives around that date
and couldn't find any supporting discussion. It does seem like it
shouldn't be needed, given that dblink's Makefile does no such thing.
I'd suggest just pushing your 0001 and seeing if the buildfarm
complains.
0002: Parses -D in the CPPFLAGS of Makefiles and uses those in the
MSVC script. It also adjusts the ltree contrib module so that we do
the same LOWER_NODE behaviour as we did before. The MSVC scripts
appear to have mistakenly forgotten to define LOWER_NODE as it is in
the Makefiles.
The LOWER_NODE situation seems like a mess, but I think the right fix
is to remove -DLOWER_NODE from the Makefile altogether and move the
responsibility into the C code. You could have ltree.h do
#if !defined(_MSC_VER)
#define LOWER_NODE 1
#endif
and put the explanatory comment on that, not on the uses of the flag.
Haven't looked at the rest.
regards, tom lane
On 2021-Jul-28, David Rowley wrote:
0003: Is a tidy up patch to make the 'includes' field an array rather
than a string
In this one, you can avoid turning one line into four with map,
- $p->AddIncludeDir($pl_proj->{includes});
+ foreach my $inc (@{ $pl_proj->{includes} })
+ {
+ $p->AddIncludeDir($inc);
+ }
Instead of that you can do something like this:
+ map { $p->AddIncludeDir($_); } @{$pl_proj->{includes}};
0004: Adds code to check for duplicate references and libraries before
adding new ones of the same name to the project.
I think using the return value of grep as a boolean is confusing. It
seems more legible to compare to 0. So instead of this:
+ if (! grep { $_ eq $ref} @{ $self->{references} })
+ {
+ push @{ $self->{references} }, $ref;
+ }
use something like:
+ if (grep { $_ eq $ref} @{ $self->{references} } == 0)
0006: I'm not so sure about. It attempts to do a bit more Makefile
parsing to get rid of contrib_extrasource and the majority of
contrib_uselibpgport and contrib_uselibpgcommon usages.
I wonder if we could fix up libpq_pipeline's Makefile somehow to get rid
of the remaining ones.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
On 7/27/21 11:01 AM, Alvaro Herrera wrote:
On 2021-Jul-28, David Rowley wrote:
0003: Is a tidy up patch to make the 'includes' field an array rather
than a stringIn this one, you can avoid turning one line into four with map,
- $p->AddIncludeDir($pl_proj->{includes}); + foreach my $inc (@{ $pl_proj->{includes} }) + { + $p->AddIncludeDir($inc); + }Instead of that you can do something like this:
+ map { $p->AddIncludeDir($_); } @{$pl_proj->{includes}};
using map() for a side effect like this is generally frowned upon. See
<https://metacpan.org/pod/Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap>
do { $p->AddIncludeDir($_); } foreach @{$pl_proj->{includes}};
would be an ok one-liner.
0004: Adds code to check for duplicate references and libraries before
adding new ones of the same name to the project.I think using the return value of grep as a boolean is confusing. It
seems more legible to compare to 0. So instead of this:+ if (! grep { $_ eq $ref} @{ $self->{references} }) + { + push @{ $self->{references} }, $ref; + }use something like:
+ if (grep { $_ eq $ref} @{ $self->{references} } == 0)
But I believe that's a widely used idiom :-)
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
On 2021-Jul-28, David Rowley wrote:
0003: Is a tidy up patch to make the 'includes' field an array rather
than a stringIn this one, you can avoid turning one line into four with map,
- $p->AddIncludeDir($pl_proj->{includes}); + foreach my $inc (@{ $pl_proj->{includes} }) + { + $p->AddIncludeDir($inc); + }Instead of that you can do something like this:
+ map { $p->AddIncludeDir($_); } @{$pl_proj->{includes}};
map (and grep) should never be used void context for side effects. Our
perlcritic policy doesn't currently forbid that, but it should (and
there is one violation of that in contrib/intarray). I'll submit a
patch for that separately.
The acceptable one-liner version would be a postfix for loop:
$p->AddIncludeDir($_) for @{$pl_proj->{includes}};
0004: Adds code to check for duplicate references and libraries before
adding new ones of the same name to the project.I think using the return value of grep as a boolean is confusing. It
seems more legible to compare to 0. So instead of this:+ if (! grep { $_ eq $ref} @{ $self->{references} }) + { + push @{ $self->{references} }, $ref; + }use something like:
+ if (grep { $_ eq $ref} @{ $self->{references} } == 0)
I disagree. Using grep in boolean context is perfectly idiomatic perl.
What would be more idiomatic is List::Util::any, but that's not availble
without upgrading List::Util from CPAN on Perls older than 5.20, so we
can't use that.
- ilmari
On 2021-Jul-27, Dagfinn Ilmari Mannsåker wrote:
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
+ if (grep { $_ eq $ref} @{ $self->{references} } == 0)
I disagree. Using grep in boolean context is perfectly idiomatic perl.
What would be more idiomatic is List::Util::any, but that's not availble
without upgrading List::Util from CPAN on Perls older than 5.20, so we
can't use that.
I was wondering if instead of grepping the whole list for each addition
it would make sense to push always, and do a unique-ification step at
the end.
--
Álvaro Herrera Valdivia, Chile — https://www.EnterpriseDB.com/
On Wed, 28 Jul 2021 at 02:33, Tom Lane <tgl@sss.pgh.pa.us> wrote:
David Rowley <dgrowleyml@gmail.com> writes:
0001: Removes an include directory for dblink. This appears like it's
not needed. It was added in ee3b4188a (Jan 2010), but an earlier
commit, 320c7eb8c (June 2008) seems to have made it pointless. It's
still a mystery to me why ee3b4188a would have been required in the
first place.FWIW, I poked around in the mailing list archives around that date
and couldn't find any supporting discussion. It does seem like it
shouldn't be needed, given that dblink's Makefile does no such thing.
I think the reason is that src/backend/utils/Makefile symlinks
fmgroids.h into src/include/utils. The copy you added in 320c7eb8c
seems to be the MSVC build's equivalent of that.
David
On Wed, 28 Jul 2021 at 01:44, Dagfinn Ilmari Mannsåker
<ilmari@ilmari.org> wrote:
I don't know anything about the MSVC build process, but I figured I
could do a general Perl code review.
Thanks for looking at this. Perl review is very useful as it's
certainly not my native tongue, as you might have noticed.
--- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm[…]
+ # Process custom compiler flags + if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg || $mf =~ /^override\s*CPPFLAGS\s*(?:[\+\:])?=\s*(.*)$/mg)^^^^^^^^^^^
This is a very convoluted way of writing [+:]?
I've replaced the (?:[\+\:])? with [+:]? It's a bit of a blind
adjustment. I see that the resulting vcxproj files have not changed as
a result of that.
--- a/src/tools/msvc/Project.pm +++ b/src/tools/msvc/Project.pm @@ -58,7 +58,7 @@ sub AddFileswhile (my $f = shift) { - $self->{files}->{ $dir . "/" . $f } = 1; + AddFile($self, $dir . "/" . $f, 1);AddFile is a method, so should be called as $self->AddFile(…).
Adjusted thanks.
--- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -36,16 +36,12 @@ my @unlink_on_exit;[…]
+ elsif ($flag =~ /^-I(.*)$/) + { + foreach my $proj (@projects) + { + if ($1 eq '$(libpq_srcdir)') + { + $proj->AddIncludeDir('src\interfaces\libpq'); + $proj->AddReference($libpq); + } + } + }It would be better to do the if check outside the for loop.
Agreed.
--- a/src/tools/msvc/Project.pm +++ b/src/tools/msvc/Project.pm @@ -51,6 +51,16 @@ sub AddFile return; }+sub AddFileAndAdditionalFiles +{ + my ($self, $filename) = @_; + if (FindAndAddAdditionalFiles($self, $filename) != 1)Again, FindAndAddAdditionalFiles is a method and should be called as
$self->FindAndAddAdditionalFiles($filename).+ { + $self->{files}->{$filename} = 1; + } + return; +}
Adjusted.
I'll send updated patches once I look at the other reviews.
David
On Wed, 28 Jul 2021 at 03:52, Dagfinn Ilmari Mannsåker
<ilmari@ilmari.org> wrote:
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
On 2021-Jul-28, David Rowley wrote:
0003: Is a tidy up patch to make the 'includes' field an array rather
than a stringIn this one, you can avoid turning one line into four with map,
- $p->AddIncludeDir($pl_proj->{includes}); + foreach my $inc (@{ $pl_proj->{includes} }) + { + $p->AddIncludeDir($inc); + }Instead of that you can do something like this:
+ map { $p->AddIncludeDir($_); } @{$pl_proj->{includes}};
map (and grep) should never be used void context for side effects. Our
perlcritic policy doesn't currently forbid that, but it should (and
there is one violation of that in contrib/intarray). I'll submit a
patch for that separately.The acceptable one-liner version would be a postfix for loop:
$p->AddIncludeDir($_) for @{$pl_proj->{includes}};
I'm not sure if this is all just getting overly smart about it.
There's already a loop next to this doing:
foreach my $type_lib (@{ $type_proj->{libraries} })
{
$p->AddLibrary($type_lib);
}
I don't object to changing mine, if that's what people think who are
more familiar with Perl than I am, but I do think consistency is a
good thing. TBH, I kinda prefer the multi-line loop. I think most
people that look at these scripts are going to be primarily C coders,
so assuming each of the variations do the same job, then I'd rather
see us stick to the most C like version.
In the meantime, I'll just change it to $p->AddIncludeDir($_) for
@{$pl_proj->{includes}};. I just wanted to note my thoughts.
David
On Wed, 28 Jul 2021 at 04:01, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
On 2021-Jul-27, Dagfinn Ilmari Mannsåker wrote:
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
+ if (grep { $_ eq $ref} @{ $self->{references} } == 0)
I disagree. Using grep in boolean context is perfectly idiomatic perl.
What would be more idiomatic is List::Util::any, but that's not availble
without upgrading List::Util from CPAN on Perls older than 5.20, so we
can't use that.I was wondering if instead of grepping the whole list for each addition
it would make sense to push always, and do a unique-ification step at
the end.
I see [1]https://www.oreilly.com/library/view/perl-cookbook/1565922433/ch04s07.html has some thoughts on this, I don't think performance will
matter much here though. I think the order of the final array is
likely more important. I didn't test, but I imagine using one of
those hash solutions might end up having the array elements in some
hashtable like order.
I'm not quite sure if I can tell here if it's ok to leave the grep
as-is or if I should be changing it to:
if (grep { $_ eq $ref} @{ $self->{references} } == 0)
David
[1]: https://www.oreilly.com/library/view/perl-cookbook/1565922433/ch04s07.html
On Wed, 28 Jul 2021 at 03:52, Dagfinn Ilmari Mannsåker
<ilmari@ilmari.org> wrote:
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
I think using the return value of grep as a boolean is confusing. It
seems more legible to compare to 0. So instead of this:+ if (! grep { $_ eq $ref} @{ $self->{references} }) + { + push @{ $self->{references} }, $ref; + }use something like:
+ if (grep { $_ eq $ref} @{ $self->{references} } == 0)
I disagree. Using grep in boolean context is perfectly idiomatic perl.
What would be more idiomatic is List::Util::any, but that's not availble
without upgrading List::Util from CPAN on Perls older than 5.20, so we
can't use that.
Ok, if the grep stuff is ok as is with the boolean comparison then I'd
say 0002 and 0003 of the attached are ok to go.
I pushed the v9 0001 and 0005 patch after adjusting the AddFile($self,
...) to become $self->AddFile(...)
I've adjusted the attached 0001 patch (previously 0002) to define
LOWER_NODE in ltree.h as mentioned by Tom.
0004 still needs work.
Thanks for all the reviews.
David
Attachments:
v10-0001-Adjust-MSVC-build-scripts-to-parse-Makefiles-for.patchapplication/octet-stream; name=v10-0001-Adjust-MSVC-build-scripts-to-parse-Makefiles-for.patchDownload
From 877842183b2f20dc8de309e72d7bc97931e7a662 Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 22:02:36 +1200
Subject: [PATCH v10 1/4] Adjust MSVC build scripts to parse Makefiles for
defines
This adjusts the MSVC build scripts to look at the compile flags mentioned
in the Makefile to look for -D arguments in order to determine which
constants should be defined in the Visual Studio build.
---
contrib/ltree/Makefile | 1 -
contrib/ltree/crc32.c | 1 +
contrib/ltree/ltree.h | 13 +++++++++++++
src/tools/msvc/Mkvcbuild.pm | 21 ++++++++++++++++++++-
4 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/contrib/ltree/Makefile b/contrib/ltree/Makefile
index b16a566852..770769a730 100644
--- a/contrib/ltree/Makefile
+++ b/contrib/ltree/Makefile
@@ -12,7 +12,6 @@ OBJS = \
ltree_op.o \
ltxtquery_io.o \
ltxtquery_op.o
-PG_CPPFLAGS = -DLOWER_NODE
EXTENSION = ltree
DATA = ltree--1.1--1.2.sql ltree--1.1.sql ltree--1.0--1.1.sql
diff --git a/contrib/ltree/crc32.c b/contrib/ltree/crc32.c
index 8fed3346e8..134f46a805 100644
--- a/contrib/ltree/crc32.c
+++ b/contrib/ltree/crc32.c
@@ -8,6 +8,7 @@
*/
#include "postgres.h"
+#include "ltree.h"
#ifdef LOWER_NODE
#include <ctype.h>
diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h
index dc68a0c212..615a3631f2 100644
--- a/contrib/ltree/ltree.h
+++ b/contrib/ltree/ltree.h
@@ -17,6 +17,19 @@
*/
#define LTREE_LABEL_MAX_CHARS 255
+/*
+ * LOWER_NODE used to be defined in the Makefile via the compile flags.
+ * However the MSVC build scripts neglected to do the same which resulted in
+ * MSVC builds not using LOWER_NODE. Since then, the MSVC scripts have been
+ * modified to look for -D compile flags in Makefiles, so here, in order to
+ * get the historic behavior of LOWER_NODE not being defined on MSVC, we only
+ * define it when not building in that environment. This is important as we
+ * want to maintain the same behavior after a pg_update.
+ */
+#ifndef _MSC_VER
+#define LOWER_NODE
+#endif
+
typedef struct
{
uint16 len; /* label string length in bytes */
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 4c36e482fb..fd9b93b4de 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -35,7 +35,7 @@ my $libpq;
my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
-my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
+my $contrib_defines = {};
my @contrib_uselibpq =
('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo', 'libpq_pipeline');
my @contrib_uselibpgport = ('libpq_pipeline', 'oid2name', 'vacuumlo');
@@ -964,6 +964,7 @@ sub AddContrib
my $subdir = shift;
my $n = shift;
my $mf = Project::read_file("$subdir/$n/Makefile");
+ my @projects;
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
{
@@ -971,6 +972,7 @@ sub AddContrib
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
{
@@ -982,18 +984,35 @@ sub AddContrib
$proj->AddFile("$subdir/$n/$filename");
$proj->AddReference($postgres);
AdjustContribProj($proj);
+ push @projects, $proj;
}
}
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
{
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
AdjustContribProj($proj);
+ push @projects, $proj;
}
else
{
croak "Could not determine contrib module type for $n\n";
}
+ # Process custom compiler flags
+ if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg || $mf =~ /^override\s*CPPFLAGS\s*[+:]?=\s*(.*)$/mg)
+ {
+ foreach my $flag (split /\s+/, $1)
+ {
+ if ($flag =~ /^-D(.*)$/)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddDefine($1);
+ }
+ }
+ }
+ }
+
# Are there any output data files to build?
GenerateContribSqlFiles($n, $mf);
return;
--
2.21.0.windows.1
v10-0002-Make-the-includes-field-an-array-in-MSVC-build-s.patchapplication/octet-stream; name=v10-0002-Make-the-includes-field-an-array-in-MSVC-build-s.patchDownload
From 1213838db67ec555aecd13e5799bb3106e29497f Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 22:21:08 +1200
Subject: [PATCH v10 2/4] Make the includes field an array in MSVC build
scripts
Previously the 'includes' field was a string. It's slightly nicer to
manage this when it's defined as an array instead.
---
src/tools/msvc/MSBuildProject.pm | 7 ++-----
src/tools/msvc/Mkvcbuild.pm | 4 ++--
src/tools/msvc/Project.pm | 12 +++++++-----
3 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index ebe6530ba5..fdd22e89eb 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -313,11 +313,8 @@ sub WriteItemDefinitionGroup
my $targetmachine =
$self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64';
- my $includes = $self->{includes};
- unless ($includes eq '' or $includes =~ /;$/)
- {
- $includes .= ';';
- }
+ my $includes = join ';', @{$self->{includes}}, "";
+
print $f <<EOF;
<ItemDefinitionGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">
<ClCompile>
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index fd9b93b4de..06b8525218 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -937,7 +937,7 @@ sub AddTransformModule
# Add PL dependencies
$p->AddIncludeDir($pl_src);
$p->AddReference($pl_proj);
- $p->AddIncludeDir($pl_proj->{includes});
+ $p->AddIncludeDir($_) for @{$pl_proj->{includes}};
foreach my $pl_lib (@{ $pl_proj->{libraries} })
{
$p->AddLibrary($pl_lib);
@@ -947,7 +947,7 @@ sub AddTransformModule
if ($type_proj)
{
$p->AddIncludeDir($type_src);
- $p->AddIncludeDir($type_proj->{includes});
+ $p->AddIncludeDir($_) for @{$type_proj->{includes}};
foreach my $type_lib (@{ $type_proj->{libraries} })
{
$p->AddLibrary($type_lib);
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index e1a5d139d3..a6c3aa0d68 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -30,7 +30,7 @@ sub _new
references => [],
libraries => [],
suffixlib => [],
- includes => '',
+ includes => [],
prefixincludes => '',
defines => ';',
solution => $solution,
@@ -151,13 +151,15 @@ sub AddLibrary
sub AddIncludeDir
{
- my ($self, $inc) = @_;
+ my ($self, $incstr) = @_;
- if ($self->{includes} ne '')
+ foreach my $inc (split(/;/, $incstr))
{
- $self->{includes} .= ';';
+ if (! grep { $_ eq $inc} @{ $self->{includes} })
+ {
+ push @{ $self->{includes} }, $inc;
+ }
}
- $self->{includes} .= $inc;
return;
}
--
2.21.0.windows.1
v10-0003-Don-t-duplicate-references-and-libraries-in-MSVC.patchapplication/octet-stream; name=v10-0003-Don-t-duplicate-references-and-libraries-in-MSVC.patchDownload
From f357ddc23000fe89eeda0ef2d32d220125de0087 Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 22:26:55 +1200
Subject: [PATCH v10 3/4] Don't duplicate references and libraries in MSVC
scripts
In order not to duplicate references and libraries in the Visual Studio
project files produced by the MSVC build scripts, have them check if a
particular reference or library already exists before adding the same one
again.
---
src/tools/msvc/Project.pm | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index a6c3aa0d68..f1c93a3fa3 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -124,7 +124,10 @@ sub AddReference
while (my $ref = shift)
{
- push @{ $self->{references} }, $ref;
+ if (! grep { $_ eq $ref} @{ $self->{references} })
+ {
+ push @{ $self->{references} }, $ref;
+ }
$self->AddLibrary(
"__CFGNAME__/" . $ref->{name} . "/" . $ref->{name} . ".lib");
}
@@ -141,7 +144,11 @@ sub AddLibrary
$lib = '"' . $lib . """;
}
- push @{ $self->{libraries} }, $lib;
+ if (! grep { $_ eq $lib} @{ $self->{libraries} })
+ {
+ push @{ $self->{libraries} }, $lib;
+ }
+
if ($dbgsuffix)
{
push @{ $self->{suffixlib} }, $lib;
--
2.21.0.windows.1
v10-0004-Remove-some-special-cases-from-MSVC-build-script.patchapplication/octet-stream; name=v10-0004-Remove-some-special-cases-from-MSVC-build-script.patchDownload
From bbbad3d8a33388ff3ecb1815addb43479b9a1e95 Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 22:45:08 +1200
Subject: [PATCH v10 4/4] Remove some special cases from MSVC build scripts
Here we add additional parsing of Makefiles to determine when to add
references to libpgport and libpgcommon. We also remove the need for
adding the current contrib_extrasource by adding very basic Makefile rules
which add .l and .y files when they exist for a given .o file in the
Makefile.
---
src/tools/msvc/Mkvcbuild.pm | 71 +++++++++++++++++++++++++++++++------
src/tools/msvc/Project.pm | 38 ++++++++++++++++++++
2 files changed, 99 insertions(+), 10 deletions(-)
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 06b8525218..019731ba3f 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -36,16 +36,12 @@ my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
my $contrib_defines = {};
-my @contrib_uselibpq =
- ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo', 'libpq_pipeline');
-my @contrib_uselibpgport = ('libpq_pipeline', 'oid2name', 'vacuumlo');
-my @contrib_uselibpgcommon = ('libpq_pipeline', 'oid2name', 'vacuumlo');
-my $contrib_extralibs = { 'libpq_pipeline' => ['ws2_32.lib'] };
-my $contrib_extraincludes = {};
-my $contrib_extrasource = {
- 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
- 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
-};
+my @contrib_uselibpq = ();
+my @contrib_uselibpgport = ('libpq_pipeline');
+my @contrib_uselibpgcommon = ('libpq_pipeline');
+my $contrib_extralibs = { 'libpq_pipeline' => ['ws2_32.lib'] };
+my $contrib_extraincludes = {};
+my $contrib_extrasource = {};
my @contrib_excludes = (
'bool_plperl', 'commit_ts',
'hstore_plperl', 'hstore_plpython',
@@ -1010,6 +1006,61 @@ sub AddContrib
$proj->AddDefine($1);
}
}
+ elsif ($flag =~ /^-I(.*)$/)
+ {
+ if ($1 eq '$(libpq_srcdir)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^SHLIB_LINK_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^PG_LIBS_INTERNAL\s*=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq_pgport)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddReference($libpgport);
+ $proj->AddReference($libpgcommon);
+ }
+ }
+ }
+ }
+
+ foreach my $line (split /\n/, $mf)
+ {
+ if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
+ {
+ foreach my $file (split /\s+/, $1)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddFileAndAdditionalFiles("$subdir/$n/$file");
+ }
+ }
}
}
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index f1c93a3fa3..e1f1b054ba 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -51,6 +51,16 @@ sub AddFile
return;
}
+sub AddFileAndAdditionalFiles
+{
+ my ($self, $filename) = @_;
+ if ($self->FindAndAddAdditionalFiles($filename) != 1)
+ {
+ $self->{files}->{$filename} = 1;
+ }
+ return;
+}
+
sub AddFiles
{
my $self = shift;
@@ -63,6 +73,34 @@ sub AddFiles
return;
}
+# Handle special Makefile rules by searching for other files which exist with
+# the same name but a different file extension and add those files too.
+sub FindAndAddAdditionalFiles
+{
+ my $self = shift;
+ my $fname = shift;
+ $fname =~ /(.*)(\.[^.]+)$/;
+ my $filenoext = $1;
+ my $fileext = $2;
+
+ # For .c files, check if either a .l or .y file of the same name
+ # exists and add that too.
+ if ($fileext eq ".c")
+ {
+ for my $ext (".l", ".y")
+ {
+ my $file = $filenoext . $ext;
+ if (-e $file)
+ {
+ # Add file and recursively search for others
+ $self->AddFileAndAdditionalFiles($file);
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
sub ReplaceFile
{
my ($self, $filename, $newname) = @_;
--
2.21.0.windows.1
On Thu, 29 Jul 2021 at 00:05, David Rowley <dgrowleyml@gmail.com> wrote:
I pushed the v9 0001 and 0005 patch after adjusting the AddFile($self,
...) to become $self->AddFile(...)
I pushed all the patches, apart from the 0004 patch.
One weird thing I noticed with the -D define patch (245de4845) and the
LOWER_NODE adjustment is that in crc32.c we do:
#ifdef LOWER_NODE
#include <ctype.h>
#define TOLOWER(x) tolower((unsigned char) (x))
#else
#define TOLOWER(x) (x)
#endif
meaning when LOWER_NODE Is defined that the CRC is hashed all in lower
case, effectively making it case-insensitive. Whereas in ltree.h we
do:
#ifdef LOWER_NODE
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND |
LVAR_SUBLEXEME ) ) == 0 )
#else
#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND |
LVAR_SUBLEXEME | LVAR_INCASE ) ) == 0 )
#endif
So effectively if LOWER_NODE is defined then we *don't* pass the
LVAR_INCASE which makes the comparisons case-sensitive! I've never
used ltree before, so might just be misunderstanding something, but
this does smell quite buggy to me. However, I just made it work how it
always has worked.
0004 still needs work.
I adjusted this one so that it does the right thing for all the
existing .l and .y files and correctly adds the relevant .c file when
required, but to be honest, I just made this work by checking that the
each of the vcxproj files match before and after the change.
There is code that parses the likes of the following in the cube
contrib module's Makefile:
# cubescan is compiled as part of cubeparse
cubeparse.o: cubescan.c
Here, since cubescan.c is not added to the project files for
compilation, I made that just call the: AddDependantFiles function,
which just searches for .l and .y files that exist with the same name,
but does not add the actual file passed to the function. This means
that we add cubescan.l to the project but not cubscan.c.
This is different from what happens with ecpg with pgc.l. We also add
pgc.c to the project in that case because it's mentioned in OBJS in
src/interfaces/ecpg/preproc/Makefile.
The only change in the outputted vcxproj files that the attached
produces is an order change in the AdditionalDependencies of
libpq_pipeline.vcxproj
I also managed to remove libpq_pipeline from contrib_uselibpgport and
contrib_uselibpgcommon. The parsing for SHLIB_LINK_INTERNAL and
PG_LIBS_INTERNAL only allowed for = not +=.
Does anyone have any thoughts on where we should draw the line on
parsing Makefiles? I'm a little worried that I'm adding pasing just
for exactly how the Makefiles are today and that it could easily be
broken if something is adjusted later. I'm not all that skilled with
make, so I'm struggling to judge this for myself.
David
Attachments:
v10-0001-Remove-some-special-cases-from-MSVC-build-script.patchapplication/octet-stream; name=v10-0001-Remove-some-special-cases-from-MSVC-build-script.patchDownload
From 2bcf4047a1e268e75a269896bf327f602e94f56b Mon Sep 17 00:00:00 2001
From: David Rowley <dgrowley@gmail.com>
Date: Tue, 27 Jul 2021 22:45:08 +1200
Subject: [PATCH v10] Remove some special cases from MSVC build scripts
Here we add additional parsing of Makefiles to determine when to add
references to libpgport and libpgcommon. We also remove the need for
adding the current contrib_extrasource by adding very basic Makefile rules
which add .l and .y files when they exist for a given .o file in the
Makefile.
---
src/tools/msvc/Mkvcbuild.pm | 69 ++++++++++++++++++++++++++++++++-----
src/tools/msvc/Project.pm | 37 ++++++++++++++++++++
2 files changed, 97 insertions(+), 9 deletions(-)
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index aab559e3ef..4210dec726 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -36,16 +36,12 @@ my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
my $contrib_defines = {};
-my @contrib_uselibpq =
- ('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo', 'libpq_pipeline');
-my @contrib_uselibpgport = ('libpq_pipeline', 'oid2name', 'vacuumlo');
-my @contrib_uselibpgcommon = ('libpq_pipeline', 'oid2name', 'vacuumlo');
+my @contrib_uselibpq = ();
+my @contrib_uselibpgport = ();
+my @contrib_uselibpgcommon = ();
my $contrib_extralibs = { 'libpq_pipeline' => ['ws2_32.lib'] };
-my $contrib_extraincludes = {};
-my $contrib_extrasource = {
- 'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
- 'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
-};
+my $contrib_extraincludes = {};
+my $contrib_extrasource = {};
my @contrib_excludes = (
'bool_plperl', 'commit_ts',
'hstore_plperl', 'hstore_plpython',
@@ -1010,6 +1006,61 @@ sub AddContrib
$proj->AddDefine($1);
}
}
+ elsif ($flag =~ /^-I(.*)$/)
+ {
+ if ($1 eq '$(libpq_srcdir)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^SHLIB_LINK_INTERNAL\s*[+:]?=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddIncludeDir('src\interfaces\libpq');
+ $proj->AddReference($libpq);
+ }
+ }
+ }
+ }
+
+ if ($mf =~ /^PG_LIBS_INTERNAL\s*[+:]?=\s*(.*)$/mg)
+ {
+ foreach my $lib (split /\s+/, $1)
+ {
+ if ($lib eq '$(libpq_pgport)')
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddReference($libpgport);
+ $proj->AddReference($libpgcommon);
+ }
+ }
+ }
+ }
+
+ foreach my $line (split /\n/, $mf)
+ {
+ if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
+ {
+ foreach my $file (split /\s+/, $1)
+ {
+ foreach my $proj (@projects)
+ {
+ $proj->AddDependantFiles("$subdir/$n/$file");
+ }
+ }
}
}
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index f1c93a3fa3..3af31d2a72 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -47,10 +47,19 @@ sub AddFile
{
my ($self, $filename) = @_;
+ $self->FindAndAddAdditionalFiles($filename);
$self->{files}->{$filename} = 1;
return;
}
+sub AddDependantFiles
+{
+ my ($self, $filename) = @_;
+
+ $self->FindAndAddAdditionalFiles($filename);
+ return;
+}
+
sub AddFiles
{
my $self = shift;
@@ -63,6 +72,34 @@ sub AddFiles
return;
}
+# Handle special Makefile rules by searching for other files which exist with
+# the same name but a different file extension and add those files too.
+sub FindAndAddAdditionalFiles
+{
+ my $self = shift;
+ my $fname = shift;
+ $fname =~ /(.*)(\.[^.]+)$/;
+ my $filenoext = $1;
+ my $fileext = $2;
+
+ # For .c files, check if either a .l or .y file of the same name
+ # exists and add that too.
+ if ($fileext eq ".c")
+ {
+ my $file = $filenoext . ".l";
+ if (-e $file)
+ {
+ $self->AddFile($file);
+ }
+
+ $file = $filenoext . ".y";
+ if (-e $file)
+ {
+ $self->AddFile($file);
+ }
+ }
+}
+
sub ReplaceFile
{
my ($self, $filename, $newname) = @_;
--
2.21.0.windows.1
On Fri, 30 Jul 2021 at 15:05, David Rowley <dgrowleyml@gmail.com> wrote:
Does anyone have any thoughts on where we should draw the line on
parsing Makefiles? I'm a little worried that I'm adding pasing just
for exactly how the Makefiles are today and that it could easily be
broken if something is adjusted later. I'm not all that skilled with
make, so I'm struggling to judge this for myself.
After thinking about this some more, I think since we're never going
to make these Perl scripts do everything that make can do, that if the
parsing that's being added seems reasonable and works for what we have
today, there I don't think there is much reason not to just go with
this.
The v10 patch I attached previously output almost identical *.vcxproj
files. The only change was in libpq_pipeline.vcxproj where the order
of the AdditionalDependencies changed to have ws2_32.lib first rather
than somewhere in the middle.
I've now pushed the final patch in this series.
Thank you to everyone who looked at one or more of these patches.
David