[Rd] non-digits in svnversion output mess up windows build if USE_SVNVERSION=yes (PR#11339)

bill at insightful.com bill at insightful.com
Tue Apr 29 20:30:12 CEST 2008


Full_Name: Bill Dunlap
Version: 2.8.0dev
OS: Windows XP
Submission from: (NULL) (70.98.76.47)


I tried for the first time to build R from source on Windows, where I
got the source code via svn.  Per the Installation and Administration
manual, I altered src\gnuwin32\MkRules so it had the the locally
correct paths to HTML Help Workshop and Inno Setup 5.  I also set
USE_SVNVERSION=yes, as suggested in MkRules itself.  Then, while in
the directory src/gnuwin32 I ran 'make all recommended' and got an
error from windres very early in the build:

  E:\R\R-svn\r-devel\src\gnuwin32>make all recommended
  make --no-print-directory -C front-ends Rpwd
  make -C ../../include -f Makefile.win version
  make Rpwd.exe
  gcc  -std=gnu99 -I../../include  -O3 -Wall -pedantic  -c rpwd.c -o rpwd.o
  windres --preprocessor="gcc -E -xc -DRC_INVOKED"   -i rcico.rc -o rcico.o
  c:\Rtools\MinGW\bin\windres.exe: rcico.rc:9: syntax error
  make[3]: *** [rcico.o] Error 1
  make[2]: *** [Rpwd] Error 2
  make[1]: *** [front-ends/Rpwd.exe] Error 2
  make: *** [all] Error 2

Line 9 of src\gnuwin32\front-ends\rcico.rc is
  FILEVERSION R_FILEVERSION
The problem was that my change to MkRules caused 'svnversion' to put an
'M' (modified) on the end of the svn version it reports.  This svn
version number is used in the R_FILEVERSION macro, which is used in in
the *.rc files.  The resource file compiler, windres, appears to choke on
non-digits in R_FILEVERSION.  (A comment in tools\GETVERSION indicates
it might choke on leading 0's as well.)

svnversion can also output a string of the form "123:125"
to mean the current source is from a variety of svn revisions,
between 123 through 125.  An "M" or "S" may also be appended.
If you don't have Subversion installed then you might get
a svn version of "unknown".  None of these non-digits is
acceptble to windres.

I patched tools/GETVERSION to fix up this problem.  It removes
the trailing M or S and removes anything up to an including a
colon, so it reports the highest version in the range.  If there
are still non-digits in there it makes the version string "0"
(not useful, but doesn't kill the build with a noninformative
error message).

I ran into another problem with the trailing 'M' from svnversion
when doing 'make rinstaller' in R_HOME/src/gnuwin32:
   E:\R\R-svn\r-devel\src\gnuwin32\installer>type R-2.8.0dev.log
   Inno Setup 5 Command-Line Compiler
   ...
   Compiler engine version: Inno Setup 5.2.3 (ISPP 5.2.3.0)
   ...
   [ISPP] Preprocessing.
   ...
   [ISPP] Preprocessed.
   Parsing [Setup] section, line 10
   ...
   Parsing [Setup] section, line 20
   Error on line 12 in e:\R\R-svn\r-devel\src\gnuwin32\installer\R.iss: Value of
[Setup] section directive "VersionInfoVersion" is invalid.
   Compile aborted.
The offending line 12 in R.iss is
    12  VersionInfoVersion=2.8.0.45381M
and it is put there by src/gnuwin32/installer/JRins.pl.

I patched JRins.pl to ensure the svn revision consisted
of only digits.

Then I could build R on Windows (make distribution)
with USE_SVNVERSION=yes set in src/gnuwin32/MkRules
and with a variety of svn revision settings.

Index: src/gnuwin32/installer/JRins.pl
===================================================================
--- src/gnuwin32/installer/JRins.pl     (revision 45553)
+++ src/gnuwin32/installer/JRins.pl     (working copy)
@@ -44,6 +44,11 @@
 $SVN = <ver>;
 close ver;
 $SVN =~s/Revision: //;
+## inno setup requires that SVN be all numeric, not 123M, 120:123, "unknown",
or empty
+$SVN =~s/[MS]* *$//;
+$SVN =~s/^.*://;
+$SVN =~s/[^0-9]//g;
+$SVN =~s/^$/0/;
 $RVER0 .= "." . $SVN;

 open insfile, "> R.iss" || die "Cannot open R.iss\n";
Index: tools/GETVERSION
===================================================================
--- tools/GETVERSION    (revision 45479)
+++ tools/GETVERSION    (working copy)
@@ -24,6 +24,7 @@
     y1=6
     svn_rev=unknown
   fi
+  all_numeric_svn_rev=`echo ${svn_rev}|sed -e 's/[MS]*$//' -e 's/^.*://' -e
's/[^0-9]//g' -e 's/^$/0/'`
   echo "/* Rversion.h.  Generated automatically. */"
   echo "#ifndef R_VERSION_H"
   echo "#define R_VERSION_H"
@@ -43,7 +44,7 @@
   echo "#define R_SVN_REVISION \"${svn_rev}\""
 ## Using 1-digit year stops problems with leading zeros
 #  echo "#define R_FILEVERSION    ${maj},${pl}${sl},${y1}${m}${d},0"
-  echo "#define R_FILEVERSION    ${maj},${pl}${sl},${svn_rev},0"
+  echo "#define R_FILEVERSION    ${maj},${pl}${sl},${all_numeric_svn_rev},0"
   echo
   echo '#ifdef __cplusplus'
   echo '}'



More information about the R-devel mailing list