On 2020-01-09 10:56, Peter Eisentraut wrote:
On 2020-01-06 09:02, Michael Paquier wrote:
- FILEFLAGSMASK  0x17L
+ FILEFLAGSMASK  VS_FFI_FILEFLAGSMASK
Are you sure with the mapping here?  I would have thought that
VS_FF_DEBUG is not necessary when using release-quality builds, which
is something that can be configured with build.pl, and that it would
be better to not enforce VS_FF_PRERELEASE all the time.

Note that there is FILEFLAGSMASK and FILEFLAGS.  The first is just a
mask that says which bits in the second are valid.  Since both libpq.rc
and win32ver.rc use FILEFLAGS 0, it doesn't matter what we set
FILEFLAGSMASK to.  But currently libpq.rc uses 0x3fL and win32ver.rc
uses 0x17L, so in order to unify this sensibly I looked for a
well-recognized standard value, which led to VS_FFI_FILEFLAGSMASK.

Here is a rebased patch.

--
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From 53607c4344f098a6ea2460b9b21715433199a664 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Tue, 14 Jan 2020 21:18:29 +0100
Subject: [PATCH v2] 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.

Discussion: 
https://www.postgresql.org/message-id/flat/ad505e61-a923-e114-9f38-9867d1610...@2ndquadrant.com
---
 src/bin/pgevent/Makefile         |  1 -
 src/interfaces/libpq/.gitignore  |  1 -
 src/interfaces/libpq/Makefile    | 15 ++++-----------
 src/interfaces/libpq/libpq.rc.in | 31 -------------------------------
 src/makefiles/Makefile.win32     | 17 +++++++++++------
 src/port/win32ver.rc             | 10 +++++++---
 src/tools/copyright.pl           |  1 -
 src/tools/msvc/Mkvcbuild.pm      |  2 --
 src/tools/msvc/Project.pm        |  8 ++++++++
 src/tools/msvc/Solution.pm       | 21 ---------------------
 src/tools/msvc/clean.bat         |  1 -
 src/tools/version_stamp.pl       |  7 -------
 12 files changed, 30 insertions(+), 85 deletions(-)
 delete mode 100644 src/interfaces/libpq/libpq.rc.in

diff --git a/src/bin/pgevent/Makefile b/src/bin/pgevent/Makefile
index 215e343605..28c3078b01 100644
--- a/src/bin/pgevent/Makefile
+++ b/src/bin/pgevent/Makefile
@@ -9,7 +9,6 @@
 PGFILEDESC = "Eventlog message formatter"
 PGAPPICON=win32
 
-PGFILESHLIB = 1
 subdir = src/bin/pgevent
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
diff --git a/src/interfaces/libpq/.gitignore b/src/interfaces/libpq/.gitignore
index 9be338dec8..7b438f3765 100644
--- a/src/interfaces/libpq/.gitignore
+++ b/src/interfaces/libpq/.gitignore
@@ -1,5 +1,4 @@
 /exports.list
-/libpq.rc
 # .c files that are symlinked in from elsewhere
 /encnames.c
 /wchar.c
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 773ef2723d..f5f1c0c08d 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -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
diff --git a/src/interfaces/libpq/libpq.rc.in b/src/interfaces/libpq/libpq.rc.in
deleted file mode 100644
index 3669a17c3c..0000000000
--- a/src/interfaces/libpq/libpq.rc.in
+++ /dev/null
@@ -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
diff --git a/src/makefiles/Makefile.win32 b/src/makefiles/Makefile.win32
index 8a7d6fff3e..e72cb2db0e 100644
--- a/src/makefiles/Makefile.win32
+++ b/src/makefiles/Makefile.win32
@@ -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
diff --git a/src/port/win32ver.rc b/src/port/win32ver.rc
index 5531704966..7b88d4b36f 100644
--- a/src/port/win32ver.rc
+++ b/src/port/win32ver.rc
@@ -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
 
diff --git a/src/tools/copyright.pl b/src/tools/copyright.pl
index bd9f89d6ab..35ee846818 100755
--- a/src/tools/copyright.pl
+++ b/src/tools/copyright.pl
@@ -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";
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 3d6ef0de84..f6ab0d528b 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -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
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 16a7340b22..7d25704e2c 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -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 $_;
                }
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 909bded592..be02bd4524 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -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";
diff --git a/src/tools/msvc/clean.bat b/src/tools/msvc/clean.bat
index d034ec5765..235de93253 100755
--- a/src/tools/msvc/clean.bat
+++ b/src/tools/msvc/clean.bat
@@ -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
diff --git a/src/tools/version_stamp.pl b/src/tools/version_stamp.pl
index a92599d96f..d8ab8d9de8 100755
--- a/src/tools/version_stamp.pl
+++ b/src/tools/version_stamp.pl
@@ -102,13 +102,6 @@
        "-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/'"
-- 
2.24.1

Reply via email to