Remove libpq.rc, use win32ver.rc for libpq
authorPeter Eisentraut <peter@eisentraut.org>
Wed, 15 Jan 2020 09:15:06 +0000 (10:15 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Wed, 15 Jan 2020 14:06:12 +0000 (15:06 +0100)
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

12 files changed:
src/bin/pgevent/Makefile
src/interfaces/libpq/.gitignore
src/interfaces/libpq/Makefile
src/interfaces/libpq/libpq.rc.in [deleted file]
src/makefiles/Makefile.win32
src/port/win32ver.rc
src/tools/copyright.pl
src/tools/msvc/Mkvcbuild.pm
src/tools/msvc/Project.pm
src/tools/msvc/Solution.pm
src/tools/msvc/clean.bat
src/tools/version_stamp.pl

index 215e343605120c9b5b9a6f39454ef5ca824ca955..28c3078b01c0a561c39d0e04a0932f5e4c75a5ce 100644 (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
index 9be338dec89b468e2db15dcd0bcbc34ea5b2cc90..7b438f37650cf2f24a4cbb521afb6985f88af1b3 100644 (file)
@@ -1,5 +1,4 @@
 /exports.list
-/libpq.rc
 # .c files that are symlinked in from elsewhere
 /encnames.c
 /wchar.c
index 773ef2723d2a43010a20c328f4de2d33fd728a94..f5f1c0c08dac82dedca73c95b8fb10d270b8059f 100644 (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
diff --git a/src/interfaces/libpq/libpq.rc.in b/src/interfaces/libpq/libpq.rc.in
deleted file mode 100644 (file)
index 3669a17..0000000
+++ /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
index 8a7d6fff3e528a32f394ee2e265384cc2b28348d..e72cb2db0e5c1725854fae59ebc8dab246ee7048 100644 (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
index 55317049663ac9e5f34aa2a129d23790bcf62581..7b88d4b36f6825d7d5570ef20bbfc9b20d4d88f0 100644 (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
 
index bd9f89d6ab371675c504d78efb21ba2633d73c56..35ee8468186eedff90041e7f4ceec537e02d7acb 100755 (executable)
@@ -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";
index 3d6ef0de84b00c1c8d16f171f60f0963a316dcce..f6ab0d528b19b3ddfc0f3051ef6f2720bce7b561 100644 (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
index 16a7340b22d23ccee5916ba1f74fd393224493e5..7d25704e2c67272e8fc9129ab065460362516169 100644 (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 $_;
                }
index 909bded592065af9c99e3f05611e854ee89106d1..be02bd4524c3b350a3650300a1b779cd2951da54 100644 (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";
index d034ec5765963c64175e39d839edf7db4c8e34de..235de932532d08378c896ec5ebad5c3d183077ef 100755 (executable)
@@ -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
index a92599d96fbce146bc1720242702bc4b424b6d4f..d8ab8d9de8fcfdafb877ac837f4ef387c387bda2 100755 (executable)
@@ -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/'"