Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 76ad244

Browse files
committed
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 sine very basic logic to implement the Makefile rules which add .l and .y files when they exist for a given .o file in the Makefile. This is just some very basic additional parsing of Makefiles to try to keep things more consistent between builds using make and MSVC builds. This happens to work with how our current Makefiles are laid out, but it could easily be broken in the future if someone chooses do something in the Makefile that we don't have parsing support for. We will cross that bridge when we come to it. Author: David Rowley Discussion: https://postgr.es/m/CAApHDvoPULi5JW3933NxgwxOmu9Ncvpcyt87UhEHAUX16QqmpA@mail.gmail.com
1 parent deb6ffd commit 76ad244

File tree

2 files changed

+97
-9
lines changed

2 files changed

+97
-9
lines changed

src/tools/msvc/Mkvcbuild.pm

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,12 @@ my @unlink_on_exit;
3636

3737
# Set of variables for modules in contrib/ and src/test/modules/
3838
my $contrib_defines = {};
39-
my @contrib_uselibpq =
40-
('dblink', 'oid2name', 'postgres_fdw', 'vacuumlo', 'libpq_pipeline');
41-
my @contrib_uselibpgport = ('libpq_pipeline', 'oid2name', 'vacuumlo');
42-
my @contrib_uselibpgcommon = ('libpq_pipeline', 'oid2name', 'vacuumlo');
39+
my @contrib_uselibpq = ();
40+
my @contrib_uselibpgport = ();
41+
my @contrib_uselibpgcommon = ();
4342
my $contrib_extralibs = { 'libpq_pipeline' => ['ws2_32.lib'] };
44-
my $contrib_extraincludes = {};
45-
my $contrib_extrasource = {
46-
'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
47-
'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ],
48-
};
43+
my $contrib_extraincludes = {};
44+
my $contrib_extrasource = {};
4945
my @contrib_excludes = (
5046
'bool_plperl', 'commit_ts',
5147
'hstore_plperl', 'hstore_plpython',
@@ -1010,6 +1006,61 @@ sub AddContrib
10101006
$proj->AddDefine($1);
10111007
}
10121008
}
1009+
elsif ($flag =~ /^-I(.*)$/)
1010+
{
1011+
if ($1 eq '$(libpq_srcdir)')
1012+
{
1013+
foreach my $proj (@projects)
1014+
{
1015+
$proj->AddIncludeDir('src/interfaces/libpq');
1016+
$proj->AddReference($libpq);
1017+
}
1018+
}
1019+
}
1020+
}
1021+
}
1022+
1023+
if ($mf =~ /^SHLIB_LINK_INTERNAL\s*[+:]?=\s*(.*)$/mg)
1024+
{
1025+
foreach my $lib (split /\s+/, $1)
1026+
{
1027+
if ($lib eq '$(libpq)')
1028+
{
1029+
foreach my $proj (@projects)
1030+
{
1031+
$proj->AddIncludeDir('src/interfaces/libpq');
1032+
$proj->AddReference($libpq);
1033+
}
1034+
}
1035+
}
1036+
}
1037+
1038+
if ($mf =~ /^PG_LIBS_INTERNAL\s*[+:]?=\s*(.*)$/mg)
1039+
{
1040+
foreach my $lib (split /\s+/, $1)
1041+
{
1042+
if ($lib eq '$(libpq_pgport)')
1043+
{
1044+
foreach my $proj (@projects)
1045+
{
1046+
$proj->AddReference($libpgport);
1047+
$proj->AddReference($libpgcommon);
1048+
}
1049+
}
1050+
}
1051+
}
1052+
1053+
foreach my $line (split /\n/, $mf)
1054+
{
1055+
if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
1056+
{
1057+
foreach my $file (split /\s+/, $1)
1058+
{
1059+
foreach my $proj (@projects)
1060+
{
1061+
$proj->AddDependantFiles("$subdir/$n/$file");
1062+
}
1063+
}
10131064
}
10141065
}
10151066

src/tools/msvc/Project.pm

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,19 @@ sub AddFile
4747
{
4848
my ($self, $filename) = @_;
4949

50+
$self->FindAndAddAdditionalFiles($filename);
5051
$self->{files}->{$filename} = 1;
5152
return;
5253
}
5354

55+
sub AddDependantFiles
56+
{
57+
my ($self, $filename) = @_;
58+
59+
$self->FindAndAddAdditionalFiles($filename);
60+
return;
61+
}
62+
5463
sub AddFiles
5564
{
5665
my $self = shift;
@@ -63,6 +72,34 @@ sub AddFiles
6372
return;
6473
}
6574

75+
# Handle Makefile rules by searching for other files which exist with the same
76+
# name but a different file extension and add those files too.
77+
sub FindAndAddAdditionalFiles
78+
{
79+
my $self = shift;
80+
my $fname = shift;
81+
$fname =~ /(.*)(\.[^.]+)$/;
82+
my $filenoext = $1;
83+
my $fileext = $2;
84+
85+
# For .c files, check if either a .l or .y file of the same name
86+
# exists and add that too.
87+
if ($fileext eq ".c")
88+
{
89+
my $file = $filenoext . ".l";
90+
if (-e $file)
91+
{
92+
$self->AddFile($file);
93+
}
94+
95+
$file = $filenoext . ".y";
96+
if (-e $file)
97+
{
98+
$self->AddFile($file);
99+
}
100+
}
101+
}
102+
66103
sub ReplaceFile
67104
{
68105
my ($self, $filename, $newname) = @_;

0 commit comments

Comments
 (0)