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

Commit 245de48

Browse files
committed
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 Visual Studio builds. One small anomaly that appeared as a result of this change is that the Makefile for the ltree contrib module defined LOWER_NODE, but this was not properly defined in the MSVC build scripts. This meant that MSVC builds would differ in case sensitivity in the ltree module when compared to builds using a make build environment. To maintain the same behavior here we remove the -DLOWER_NODE from the Makefile and just always define it in ltree.h for non-MSVC builds. We need to maintain the old behavior here as this affects the on-disk compatibility of GiST indexes when using the ltree type. The only other resulting change here is that REFINT_VERBOSE is now defined for the autoinc, insert_username and moddatetime contrib modules. Previously on MSVC, this was only defined for the refint module. This aligns the behavior to build environments using make as all 4 of these modules share the same Makefile. Reviewed-by: Tom Lane Discussion: https://postgr.es/m/CAApHDvpo6g5csCTjc_0C7DMvgFPomVb0Rh-AcW5afd=Ya=LRuw@mail.gmail.com
1 parent 15f16ec commit 245de48

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

contrib/ltree/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ OBJS = \
1212
ltree_op.o \
1313
ltxtquery_io.o \
1414
ltxtquery_op.o
15-
PG_CPPFLAGS = -DLOWER_NODE
1615

1716
EXTENSION = ltree
1817
DATA = ltree--1.1--1.2.sql ltree--1.1.sql ltree--1.0--1.1.sql

contrib/ltree/crc32.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include "postgres.h"
11+
#include "ltree.h"
1112

1213
#ifdef LOWER_NODE
1314
#include <ctype.h>

contrib/ltree/ltree.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@
1717
*/
1818
#define LTREE_LABEL_MAX_CHARS 255
1919

20+
/*
21+
* LOWER_NODE used to be defined in the Makefile via the compile flags.
22+
* However the MSVC build scripts neglected to do the same which resulted in
23+
* MSVC builds not using LOWER_NODE. Since then, the MSVC scripts have been
24+
* modified to look for -D compile flags in Makefiles, so here, in order to
25+
* get the historic behavior of LOWER_NODE not being defined on MSVC, we only
26+
* define it when not building in that environment. This is important as we
27+
* want to maintain the same LOWER_NODE behavior after a pg_update.
28+
*/
29+
#ifndef _MSC_VER
30+
#define LOWER_NODE
31+
#endif
32+
2033
typedef struct
2134
{
2235
uint16 len; /* label string length in bytes */

src/tools/msvc/Mkvcbuild.pm

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ my $libpq;
3535
my @unlink_on_exit;
3636

3737
# Set of variables for modules in contrib/ and src/test/modules/
38-
my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' };
38+
my $contrib_defines = {};
3939
my @contrib_uselibpq =
4040
('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo', 'libpq_pipeline');
4141
my @contrib_uselibpgport = ('libpq_pipeline', 'oid2name', 'vacuumlo');
@@ -964,13 +964,15 @@ sub AddContrib
964964
my $subdir = shift;
965965
my $n = shift;
966966
my $mf = Project::read_file("$subdir/$n/Makefile");
967+
my @projects = ();
967968

968969
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
969970
{
970971
my $dn = $1;
971972
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
972973
$proj->AddReference($postgres);
973974
AdjustContribProj($proj);
975+
push @projects, $proj;
974976
}
975977
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
976978
{
@@ -982,18 +984,35 @@ sub AddContrib
982984
$proj->AddFile("$subdir/$n/$filename");
983985
$proj->AddReference($postgres);
984986
AdjustContribProj($proj);
987+
push @projects, $proj;
985988
}
986989
}
987990
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
988991
{
989992
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
990993
AdjustContribProj($proj);
994+
push @projects, $proj;
991995
}
992996
else
993997
{
994998
croak "Could not determine contrib module type for $n\n";
995999
}
9961000

1001+
# Process custom compiler flags
1002+
if ($mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg || $mf =~ /^override\s*CPPFLAGS\s*[+:]?=\s*(.*)$/mg)
1003+
{
1004+
foreach my $flag (split /\s+/, $1)
1005+
{
1006+
if ($flag =~ /^-D(.*)$/)
1007+
{
1008+
foreach my $proj (@projects)
1009+
{
1010+
$proj->AddDefine($1);
1011+
}
1012+
}
1013+
}
1014+
}
1015+
9971016
# Are there any output data files to build?
9981017
GenerateContribSqlFiles($n, $mf);
9991018
return;

0 commit comments

Comments
 (0)