Skip to content

Commit aaef29b

Browse files
committed
More MSVC build fixes:
* New versions of OpenSSL come with proper debug versions, and use suffixed names on the LIBs for that. Adapts library handling to deal with that. * Fixes error where it incorrectly enabled Kerberos based on NLS configuration instead of Kerberos configuration * Specifies path of perl in config, instead of using current one. Required when using a 64-bit perl normally, but want to build pl/perl against 32-bit one (required) * Fix so pgevent generates win32ver.rc automatically Magnus Hagander
1 parent e2b1dbd commit aaef29b

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

src/tools/msvc/Project.pm

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ sub new {
1818
guid => Win32::GuidGen(),
1919
files => {},
2020
references => [],
21-
libraries => '',
21+
libraries => [],
22+
suffixlib => [],
2223
includes => '',
2324
defines => ';',
2425
solution => $solution,
@@ -86,12 +87,12 @@ sub AddReference {
8687
}
8788

8889
sub AddLibrary {
89-
my ($self, $lib) = @_;
90+
my ($self, $lib, $dbgsuffix) = @_;
9091

91-
if ($self->{libraries} ne '') {
92-
$self->{libraries} .= ' ';
92+
push @{$self->{libraries}}, $lib;
93+
if ($dbgsuffix) {
94+
push @{$self->{suffixlib}}, $lib;
9395
}
94-
$self->{libraries} .= $lib;
9596
}
9697

9798
sub AddIncludeDir {
@@ -351,7 +352,19 @@ sub WriteConfiguration
351352
{
352353
my ($self, $f, $cfgname, $p) = @_;
353354
my $cfgtype = ($self->{type} eq "exe")?1:($self->{type} eq "dll"?2:4);
354-
my $libs = $self->{libraries};
355+
my $libcfg = (uc $cfgname eq "RELEASE")?"MD":"MDd";
356+
my $libs = '';
357+
foreach my $lib (@{$self->{libraries}}) {
358+
my $xlib = $lib;
359+
foreach my $slib (@{$self->{suffixlib}}) {
360+
if ($slib eq $lib) {
361+
$xlib =~ s/\.lib$/$libcfg.lib/;
362+
last;
363+
}
364+
}
365+
$libs .= $xlib . " ";
366+
}
367+
$libs =~ s/ $//;
355368
$libs =~ s/__CFGNAME__/$cfgname/g;
356369
print $f <<EOF;
357370
<Configuration Name="$cfgname|Win32" OutputDirectory=".\\$cfgname\\$self->{name}" IntermediateDirectory=".\\$cfgname\\$self->{name}"

src/tools/msvc/Solution.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ sub GenerateFiles {
8383
print O "#define USE_SSL 1\n" if ($self->{options}->{openssl});
8484
print O "#define ENABLE_NLS 1\n" if ($self->{options}->{nls});
8585
print O "#define LOCALEDIR \"/usr/local/pgsql/share/locale\"\n" if ($self->{options}->{nls});
86-
if ($self->{options}->{nls}) {
86+
if ($self->{options}->{krb5}) {
8787
print O "#define KRB5 1\n";
8888
print O "#define HAVE_KRB5_ERROR_TEXT_DATA 1\n";
8989
print O "#define HAVE_KRB5_TICKET_ENC_PART2 1\n";
@@ -220,8 +220,8 @@ sub AddProject {
220220
}
221221
if ($self->{options}->{openssl}) {
222222
$proj->AddIncludeDir($self->{options}->{openssl} . '\include');
223-
$proj->AddLibrary($self->{options}->{openssl} . '\lib\VC\ssleay32.lib');
224-
$proj->AddLibrary($self->{options}->{openssl} . '\lib\VC\libeay32.lib');
223+
$proj->AddLibrary($self->{options}->{openssl} . '\lib\VC\ssleay32.lib', 1);
224+
$proj->AddLibrary($self->{options}->{openssl} . '\lib\VC\libeay32.lib', 1);
225225
}
226226
if ($self->{options}->{nls}) {
227227
$proj->AddIncludeDir($self->{options}->{nls} . '\include');

src/tools/msvc/config.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
asserts=>1, # --enable-cassert
77
nls=>undef, # --enable-nls=<path>
88
tcl=>'c:\tcl', # --with-tls=<path>
9-
perl=>1, # --with-perl
9+
perl=>'c:\perl', # --with-perl
1010
python=>'c:\python24', # --with-python=<path>
1111
krb5=>'c:\prog\pgsql\depend\krb5', # --with-krb5=<path>
1212
ldap=>1, # --with-ldap

src/tools/msvc/mkvcbuild.pl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,23 @@
4747
$plpgsql->AddReference($postgres);
4848

4949
if ($solution->{options}->{perl}) {
50-
# Already running in perl, so use the version that we already have information for.
51-
use Config;
5250
my $plperl = $solution->AddProject('plperl','dll','PLs','src\pl\plperl');
53-
$plperl->AddIncludeDir($Config{archlibexp} . '\CORE');
51+
$plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE');
5452
$plperl->AddDefine('PLPERL_HAVE_UID_GID');
5553
if (Solution::IsNewer('src\pl\plperl\SPI.c','src\pl\plperl\SPI.xs')) {
5654
print 'Building src\pl\plperl\SPI.c...' . "\n";
57-
system('perl ' . $Config{privlibexp} . '/ExtUtils/xsubpp -typemap ' . $Config{privlibexp} . '/ExtUtils/typemap src\pl\plperl\SPI.xs >src\pl\plperl\SPI.c');
55+
system($solution->{options}->{perl} . '/bin/perl ' . $solution->{options}->{perl} . '/lib/COREExtUtils/xsubpp -typemap ' . $solution->{options}->{perl} . '/lib/CORE/ExtUtils/typemap src\pl\plperl\SPI.xs >src\pl\plperl\SPI.c');
5856
die 'Failed to create SPI.c' . "\n" if ((!(-f 'src\pl\plperl\SPI.c')) || -z 'src\pl\plperl\SPI.c');
5957
}
6058
$plperl->AddReference($postgres);
61-
$plperl->AddLibrary($Config{archlibexp} . '\CORE\perl58.lib');
59+
$plperl->AddLibrary($solution->{options}->{perl} . '\lib\CORE\perl58.lib');
6260
}
6361

6462
if ($solution->{options}->{python}) {
6563
my $plpython = $solution->AddProject('plpython','dll','PLs','src\pl\plpython');
6664
$plpython->AddIncludeDir($solution->{options}->{python} . '\include');
67-
$plpython->AddLibrary($solution->{options}->{python} . '\Libs\python24.lib');
65+
$solution->{options}->{python} =~ /\\Python(\d{2})/i || croak "Could not determine python version from path";
66+
$plpython->AddLibrary($solution->{options}->{python} . "\\Libs\\python$1.lib");
6867
$plpython->AddReference($postgres);
6968
}
7069

@@ -125,6 +124,8 @@
125124

126125
my $pgevent = $solution->AddProject('pgevent','dll','bin');
127126
$pgevent->AddFiles('src\bin\pgevent','pgevent.c','pgmsgevent.rc');
127+
$pgevent->AddResourceFile('src\bin\pgevent','Eventlog message formatter');
128+
$pgevent->RemoveFile('src\bin\pgevent\win32ver.rc');
128129
$pgevent->UseDef('src\bin\pgevent\pgevent.def');
129130

130131
my $psql = AddSimpleFrontend('psql', 1);

0 commit comments

Comments
 (0)