Remove win32ver.rc from version_stamp.pl
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 10 Mar 2020 10:20:38 +0000 (11:20 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 10 Mar 2020 10:21:41 +0000 (11:21 +0100)
This removes another relic from the old nmake-based Windows build.
version_stamp.pl put version number information into win32ver.rc.  But
win32ver.rc already gets other version number information from the
preprocessor at build time, so it would make more sense if all version
number information would be handled in the same way and we don't have
two places that do it.

What we need for this is having the major version number and the minor
version number as separate integer symbols.  Both configure and
Solution.pm already have that logic, because they compute
PG_VERSION_NUM.  So we just keep all the logic there now.  Put the
minor version number into a new symbol PG_MINORVERSION_NUM.  Also, add
a symbol PG_MAJORVERSION_NUM, which is a number, alongside the
existing PG_MAJORVERSION, which is a string.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/1ee46ac4-a9b2-4531-bf54-5ec2e374634d@2ndquadrant.com

configure
configure.in
src/include/pg_config.h.in
src/port/win32ver.rc
src/tools/msvc/Solution.pm
src/tools/version_stamp.pl

index 45dbeb4d1986798a0189a1e773c807c4e0012604..d6d3f26d03d48456efca41ed8dbc1e15166fefc7 100755 (executable)
--- a/configure
+++ b/configure
@@ -2805,6 +2805,8 @@ _ACEOF
 
 
 PG_MAJORVERSION=`expr "$PACKAGE_VERSION" : '\([0-9][0-9]*\)'`
+PG_MINORVERSION=`expr "$PACKAGE_VERSION" : '.*\.\([0-9][0-9]*\)'`
+test -n "$PG_MINORVERSION" || PG_MINORVERSION=0
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2812,6 +2814,16 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+cat >>confdefs.h <<_ACEOF
+#define PG_MAJORVERSION_NUM $PG_MAJORVERSION
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PG_MINORVERSION_NUM $PG_MINORVERSION
+_ACEOF
+
+
 
 
 
@@ -18875,8 +18887,7 @@ _ACEOF
 
 # Supply a numeric version string for use by 3rd party add-ons
 # awk -F is a regex on some platforms, and not on others, so make "." a tab
-PG_VERSION_NUM="`echo "$PACKAGE_VERSION" | sed 's/[A-Za-z].*$//' |
-tr '.' '   ' |
+PG_VERSION_NUM="`echo "$PG_MAJORVERSION    $PG_MINORVERSION" |
 $AWK '{printf "%d%04d", $1, $2}'`"
 
 cat >>confdefs.h <<_ACEOF
index 22f096a5ac7a0742c7a72d838f1fd74a3c787d71..78902fb60dbc1a81828be03034027fc900b6a83c 100644 (file)
@@ -30,8 +30,12 @@ AC_PREFIX_DEFAULT(/usr/local/pgsql)
 AC_DEFINE_UNQUOTED(CONFIGURE_ARGS, ["$ac_configure_args"], [Saved arguments from configure])
 
 [PG_MAJORVERSION=`expr "$PACKAGE_VERSION" : '\([0-9][0-9]*\)'`]
+[PG_MINORVERSION=`expr "$PACKAGE_VERSION" : '.*\.\([0-9][0-9]*\)'`]
+test -n "$PG_MINORVERSION" || PG_MINORVERSION=0
 AC_SUBST(PG_MAJORVERSION)
 AC_DEFINE_UNQUOTED(PG_MAJORVERSION, "$PG_MAJORVERSION", [PostgreSQL major version as a string])
+AC_DEFINE_UNQUOTED(PG_MAJORVERSION_NUM, $PG_MAJORVERSION, [PostgreSQL major version number])
+AC_DEFINE_UNQUOTED(PG_MINORVERSION_NUM, $PG_MINORVERSION, [PostgreSQL minor version number])
 
 PGAC_ARG_REQ(with, extra-version, [STRING], [append STRING to version],
              [PG_VERSION="$PACKAGE_VERSION$withval"],
@@ -2318,8 +2322,7 @@ AC_DEFINE_UNQUOTED(PG_VERSION_STR,
 
 # Supply a numeric version string for use by 3rd party add-ons
 # awk -F is a regex on some platforms, and not on others, so make "." a tab
-[PG_VERSION_NUM="`echo "$PACKAGE_VERSION" | sed 's/[A-Za-z].*$//' |
-tr '.' '   ' |
+[PG_VERSION_NUM="`echo "$PG_MAJORVERSION   $PG_MINORVERSION" |
 $AWK '{printf "%d%04d", $1, $2}'`"]
 AC_DEFINE_UNQUOTED(PG_VERSION_NUM, $PG_VERSION_NUM, [PostgreSQL version as a number])
 AC_SUBST(PG_VERSION_NUM)
index d758dfd36ee164ac66ec386978a819cd495342a2..41ad20938064ab1aaaba15aacd9abc74fb133e86 100644 (file)
 /* PostgreSQL major version as a string */
 #undef PG_MAJORVERSION
 
+/* PostgreSQL major version number */
+#undef PG_MAJORVERSION_NUM
+
+/* PostgreSQL minor version number */
+#undef PG_MINORVERSION_NUM
+
 /* Define to best printf format archetype, usually gnu_printf if available. */
 #undef PG_PRINTF_ATTRIBUTE
 
index 7b88d4b36f6825d7d5570ef20bbfc9b20d4d88f0..5834b31ddcc0eb2dd83f0dc1f26bcdbd1f5af696 100644 (file)
@@ -4,8 +4,8 @@
 // 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
+ FILEVERSION    PG_MAJORVERSION_NUM,0,PG_MINORVERSION_NUM,0
+ PRODUCTVERSION PG_MAJORVERSION_NUM,0,PG_MINORVERSION_NUM,0
  FILEFLAGSMASK  VS_FFI_FILEFLAGSMASK
  FILEFLAGS      0x0L
  FILEOS         VOS_NT_WINDOWS32
index 4244a4a8ac11f31470f7cc705d682537f4ad3c3d..34d1f61dbaabbca1e4fa5262f5703f63f0908ec4 100644 (file)
@@ -19,7 +19,6 @@ sub _new
    my $self      = {
        projects                   => {},
        options                    => $options,
-       numver                     => '',
        VisualStudioVersion        => undef,
        MinimumVisualStudioVersion => undef,
        vcver                      => undef,
@@ -151,6 +150,7 @@ sub GenerateFiles
    my $package_version;
    my $package_bugreport;
    my $package_url;
+   my ($majorver, $minorver);
 
    # Parse configure.in to get version numbers
    open(my $c, '<', "configure.in")
@@ -171,8 +171,8 @@ sub GenerateFiles
            {
                confess "Bad format of version: $self->{strver}\n";
            }
-           $self->{numver} = sprintf("%d%04d", $1, $2 ? $2 : 0);
-           $self->{majorver} = sprintf("%d", $1);
+           $majorver = sprintf("%d", $1);
+           $minorver = sprintf("%d", $2 ? $2 : 0);
        }
    }
    close($c);
@@ -440,11 +440,13 @@ sub GenerateFiles
        PG_INT128_TYPE      => undef,
        PG_INT64_TYPE       => 'long long int',
        PG_KRB_SRVNAM       => qq{"postgres"},
-       PG_MAJORVERSION     => qq{"$self->{majorver}"},
+       PG_MAJORVERSION     => qq{"$majorver"},
+       PG_MAJORVERSION_NUM => $majorver,
+       PG_MINORVERSION_NUM => $minorver,
        PG_PRINTF_ATTRIBUTE => undef,
        PG_USE_STDBOOL      => 1,
        PG_VERSION          => qq{"$package_version$extraver"},
-       PG_VERSION_NUM      => $self->{numver},
+       PG_VERSION_NUM      => sprintf("%d%04d", $majorver, $minorver),
        PG_VERSION_STR =>
          qq{"PostgreSQL $package_version$extraver, compiled by Visual C++ build " CppAsString2(_MSC_VER) ", $bits-bit"},
        PROFILE_PID_DIR         => undef,
@@ -778,7 +780,7 @@ EOF
        chdir('src/backend/catalog');
        my $bki_srcs = join(' ../../../src/include/catalog/', @bki_srcs);
        system(
-           "perl genbki.pl --include-path ../../../src/include/ --set-version=$self->{majorver} $bki_srcs"
+           "perl genbki.pl --include-path ../../../src/include/ --set-version=$majorver $bki_srcs"
        );
        open(my $f, '>', 'bki-stamp')
          || confess "Could not touch bki-stamp";
@@ -813,7 +815,7 @@ EOF
      || croak "Could not write to version.sgml\n";
    print $o <<EOF;
 <!ENTITY version "$package_version">
-<!ENTITY majorversion "$self->{majorver}">
+<!ENTITY majorversion "$majorver">
 EOF
    close($o);
    return;
index d8ab8d9de8fcfdafb877ac837f4ef387c387bda2..cb59ad234ab558e179efdb1d4d8de944aacce07d 100755 (executable)
@@ -30,32 +30,27 @@ my $majorversion = 13;
 my $minor = shift;
 defined($minor) || die "$0: missing required argument: minor-version\n";
 
-my ($dotneeded, $numericminor);
+my ($dotneeded);
 
 if ($minor =~ m/^\d+$/)
 {
    $dotneeded    = 1;
-   $numericminor = $minor;
 }
 elsif ($minor eq "devel")
 {
    $dotneeded    = 0;
-   $numericminor = 0;
 }
 elsif ($minor =~ m/^alpha\d+$/)
 {
    $dotneeded    = 0;
-   $numericminor = 0;
 }
 elsif ($minor =~ m/^beta\d+$/)
 {
    $dotneeded    = 0;
-   $numericminor = 0;
 }
 elsif ($minor =~ m/^rc\d+$/)
 {
    $dotneeded    = 0;
-   $numericminor = 0;
 }
 else
 {
@@ -73,8 +68,6 @@ else
 {
    $fullversion = $majorversion . $minor;
 }
-my $numericversion = $majorversion . "." . $numericminor;
-my $padnumericversion = sprintf("%d%04d", $majorversion, $numericminor);
 
 # Get the autoconf version number for eventual nag message
 # (this also ensures we're in the right directory)
@@ -102,11 +95,6 @@ sed_file("configure.in",
    "-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'"
 );
 
-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/'"
-);
-
 print "Stamped these files with version number $fullversion:\n$fixedfiles";
 print "Don't forget to run autoconf $aconfver before committing.\n";