Remove libpq.rc, use win32ver.rc for libpq

For historical reasons, libpq used a separate libpq.rc file for the
Windows builds while all other components use a common file
win32ver.rc.  With a bit of tweaking, the libpq build can also use the
win32ver.rc file.  This removes a bit of duplicative code.

Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/flat/ad505e61-a923-e114-9f38-9867d161073f@2ndquadrant.com
This commit is contained in:
Peter Eisentraut 2020-01-15 10:15:06 +01:00
parent ac5bdf6261
commit 16a4a3d59c
12 changed files with 30 additions and 85 deletions

View File

@ -9,7 +9,6 @@
PGFILEDESC = "Eventlog message formatter"
PGAPPICON=win32
PGFILESHLIB = 1
subdir = src/bin/pgevent
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global

View File

@ -1,5 +1,4 @@
/exports.list
/libpq.rc
# .c files that are symlinked in from elsewhere
/encnames.c
/wchar.c

View File

@ -14,6 +14,8 @@ top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
PGFILEDESC = "PostgreSQL Access Library"
# shared library parameters
NAME= pq
SO_MAJOR_VERSION= 5
@ -28,6 +30,7 @@ endif
# the conditional additions of files to OBJS, update Mkvcbuild.pm to match.
OBJS = \
$(WIN32RES) \
fe-auth-scram.o \
fe-connect.o \
fe-exec.o \
@ -65,12 +68,8 @@ endif
ifeq ($(PORTNAME), win32)
OBJS += \
libpqrc.o \
win32.o
libpqrc.o: libpq.rc
$(WINDRES) -i $< -o $@
ifeq ($(enable_thread_safety), yes)
OBJS += pthread-win32.o
endif
@ -113,12 +112,6 @@ encnames.c wchar.c: % : $(backend_src)/utils/mb/%
rm -f $@ && $(LN_S) $< .
libpq.rc: libpq.rc.in
sed -e 's/\(VERSION.*\),0 *$$/\1,'`date '+%y%j' | sed 's/^0*//'`'/' $< >$@
# Depend on Makefile.global to force rebuild on re-run of configure.
libpq.rc: $(top_builddir)/src/Makefile.global
# Make dependencies on pg_config_paths.h visible, too.
fe-connect.o: fe-connect.c $(top_builddir)/src/port/pg_config_paths.h
fe-misc.o: fe-misc.c $(top_builddir)/src/port/pg_config_paths.h
@ -148,7 +141,7 @@ uninstall: uninstall-lib
clean distclean: clean-lib
$(MAKE) -C test $@
rm -f $(OBJS) pthread.h libpq.rc
rm -f $(OBJS) pthread.h
# Might be left over from a Win32 client-only build
rm -f pg_config_paths.h
# Remove files we (may have) symlinked in from other places

View File

@ -1,31 +0,0 @@
#include <winver.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 13,0,0,0
PRODUCTVERSION 13,0,0,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "PostgreSQL Access Library\0"
VALUE "FileVersion", "13.0\0"
VALUE "InternalName", "libpq\0"
VALUE "LegalCopyright", "Copyright (C) 2020\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "libpq.dll\0"
VALUE "ProductName", "PostgreSQL\0"
VALUE "ProductVersion", "13.0\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

View File

@ -56,11 +56,7 @@ endif
# Build rules to add versioninfo resources to win32 binaries
WIN32RES += win32ver.o
ifeq ($(PGFILESHLIB),1)
PGFTYPE = VFT_DLL
else
PGFTYPE = VFT_APP
endif
PGFTYPE = $(if $(shlib),VFT_DLL,VFT_APP)
ifneq (,$(PGAPPICON))
PGICOSTR = $(subst /,\/,IDI_ICON ICON \"$(top_builddir)/src/port/$(PGAPPICON).ico\")
endif
@ -71,7 +67,16 @@ endif
# signal win32ver.rc availability to the dll build rule below.
ifndef PGXS
win32ver.rc: $(top_srcdir)/src/port/win32ver.rc
sed -e 's;FILEDESC;$(PGFILEDESC);' -e 's;VFT_APP;$(PGFTYPE);' -e 's;_ICO_;$(PGICOSTR);' -e 's;\(VERSION.*\),0 *$$;\1,'`date '+%y%j' | sed 's/^0*//'`';' $< >$@
sed -e 's;FILEDESC;$(PGFILEDESC);' \
-e 's;VFT_APP;$(PGFTYPE);' \
-e 's;_ICO_;$(PGICOSTR);' \
-e 's;\(VERSION.*\),0 *$$;\1,'`date '+%y%j' | sed 's/^0*//'`';' \
-e '/_INTERNAL_NAME_/$(if $(shlib),s;_INTERNAL_NAME_;"$(basename $(shlib))";,d)' \
-e '/_ORIGINAL_NAME_/$(if $(shlib),s;_ORIGINAL_NAME_;"$(shlib)";,d)' \
$< >$@
# Depend on Makefile.global to force rebuild on re-run of configure.
win32ver.rc: $(top_builddir)/src/Makefile.global
endif
win32ver.o: win32ver.rc

View File

@ -1,10 +1,12 @@
#include <winver.h>
#include "pg_config.h"
// https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
VS_VERSION_INFO VERSIONINFO
FILEVERSION 13,0,0,0
PRODUCTVERSION 13,0,0,0
FILEFLAGSMASK 0x17L
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0x0L
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
@ -12,19 +14,21 @@ VS_VERSION_INFO VERSIONINFO
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BLOCK "040904B0" // U.S. English, Unicode
BEGIN
VALUE "CompanyName", "PostgreSQL Global Development Group"
VALUE "FileDescription", FILEDESC
VALUE "FileVersion", PG_VERSION
VALUE "InternalName", _INTERNAL_NAME_
VALUE "LegalCopyright", "Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group. Portions Copyright (c) 1994, Regents of the University of California."
VALUE "OriginalFileName", _ORIGINAL_NAME_
VALUE "ProductName", "PostgreSQL"
VALUE "ProductVersion", PG_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
VALUE "Translation", 0x0409, 1200 // U.S. English, Unicode
END
END

View File

@ -66,6 +66,5 @@ sub wanted
}
print "Manually update:\n";
print " ./src/interfaces/libpq/libpq.rc.in in head\n";
print " ./doc/src/sgml/legal.sgml in head and back branches\n";
print " ./COPYRIGHT in back branches\n";

View File

@ -250,8 +250,6 @@ sub mkvcbuild
$libpq->AddLibrary('ws2_32.lib');
$libpq->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap});
$libpq->UseDef('src/interfaces/libpq/libpqdll.def');
$libpq->ReplaceFile('src/interfaces/libpq/libpqrc.c',
'src/interfaces/libpq/libpq.rc');
$libpq->AddReference($libpgcommon, $libpgport);
# The OBJS scraper doesn't know about ifdefs, so remove appropriate files

View File

@ -338,6 +338,14 @@ sub AddResourceFile
if ($self->{type} eq "dll")
{
s/VFT_APP/VFT_DLL/gm;
my $name = $self->{name};
s/_INTERNAL_NAME_/"$name"/;
s/_ORIGINAL_NAME_/"$name.dll"/;
}
else
{
/_INTERNAL_NAME_/ && next;
/_ORIGINAL_NAME_/ && next;
}
print $o $_;
}

View File

@ -668,27 +668,6 @@ sub GenerateFiles
);
}
if (IsNewer(
'src/interfaces/libpq/libpq.rc',
'src/interfaces/libpq/libpq.rc.in'))
{
print "Generating libpq.rc...\n";
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
my $d = ($year - 100) . "$yday";
open(my $i, '<', 'src/interfaces/libpq/libpq.rc.in')
|| confess "Could not open libpq.rc.in";
open(my $o, '>', 'src/interfaces/libpq/libpq.rc')
|| confess "Could not open libpq.rc";
while (<$i>)
{
s/(VERSION.*),0/$1,$d/;
print $o $_;
}
close($i);
close($o);
}
if (IsNewer('src/bin/psql/sql_help.h', 'src/bin/psql/create_help.pl'))
{
print "Generating sql_help.h...\n";

View File

@ -89,7 +89,6 @@ if %DIST%==1 if exist src\backend\replication\syncrep_scanner.c del /q src\backe
if %DIST%==1 if exist src\backend\replication\syncrep_gram.c del /q src\backend\replication\syncrep_gram.c
if exist src\interfaces\libpq\libpq.rc del /q src\interfaces\libpq\libpq.rc
if exist src\interfaces\libpq\libpqdll.def del /q src\interfaces\libpq\libpqdll.def
if exist src\interfaces\ecpg\compatlib\compatlib.def del /q src\interfaces\ecpg\compatlib\compatlib.def
if exist src\interfaces\ecpg\ecpglib\ecpglib.def del /q src\interfaces\ecpg\ecpglib\ecpglib.def

View File

@ -102,13 +102,6 @@ sed_file("configure.in",
"-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'"
);
sed_file("src/interfaces/libpq/libpq.rc.in",
"-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $majorversion,0,$numericminor,0/' "
. "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $majorversion,0,$numericminor,0/' "
. "-e 's/VALUE \"FileVersion\", \"[0-9.]*/VALUE \"FileVersion\", \"$numericversion/' "
. "-e 's/VALUE \"ProductVersion\", \"[0-9.]*/VALUE \"ProductVersion\", \"$numericversion/'"
);
sed_file("src/port/win32ver.rc",
"-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $majorversion,0,$numericminor,0/' "
. "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $majorversion,0,$numericminor,0/'"