On Thu, Jun 21, 2007 at 05:24:12PM +0200, Uros Bizjak wrote:
> Hello!
>
> Is there a way to add automatically updated SVN revision number to gcc
> version string? Something similar to $Revision$ in RCS?
>
> I think it would be quite informative if during development phase "gcc
> --version" would report it like:
>
> gcc --version
> gcc (GCC) 4.3.0 20070621 (experimental) Revision X
>
> Perhaps it can also include branch name.
>
See
http://gcc.gnu.org/ml/gcc-testresults/2007-06/msg00966.html
I got
[EMAIL PROTECTED] applied]$ /usr/gcc-4.3/bin/gcc --version
gcc (GCC) 4.3.0 20070612 (experimental) [trunk revision 125661]
...
[EMAIL PROTECTED] result]$ /usr/gcc-4.2/bin/gcc --version
gcc (GCC) 4.2.1 20070619 (prerelease) [gcc-4_2-branch revision 125849]
...
I am enclosing 2 patches I have been using for more than a year.
H.J.
Index: contrib/gcc_update
===
--- contrib/gcc_update (revision 116299)
+++ contrib/gcc_update (working copy)
@@ -255,8 +255,18 @@ if [ $? -ne 0 ]; then
exit 1
fi
+rm -f info.$$ LAST_UPDATED gcc/REVISION
+
+svn info > info.$$
+revision=`grep Revision: info.$$ | awk '{ print $2 }'`
+branch=`grep URL: info.$$ | sed -e "s,.*/gcc/,,g" | sed -e "s,branches/,,"`
{
date
- echo "`TZ=UTC date` (revision `svnversion .`)"
+ echo "`TZ=UTC date` (revision $revision)"
} > LAST_UPDATED
+
+rm -f info.$$
+
+echo "[$branch revision $revision]" > gcc/REVISION
+
touch_files_reexec
2006-01-23 H.J. Lu <[EMAIL PROTECTED]>
* Makefile.in (REVISION): New.
(REVISION_c): New.
(REVISION_s): New.
(version.o): Also depend on $(REVISION). Add
-DREVISION=$(REVISION_s).
* version.c (version_string): Add REVISION.
--- gcc/Makefile.in.rev 2006-01-23 10:00:31.0 -0800
+++ gcc/Makefile.in 2006-01-23 10:29:38.0 -0800
@@ -710,11 +710,18 @@ TM_H = $(GTM_H) insn-constants.h in
BASEVER := $(srcdir)/BASE-VER # 4.x.y
DEVPHASE:= $(srcdir)/DEV-PHASE # experimental, prerelease, ""
DATESTAMP := $(srcdir)/DATESTAMP # MMDD or empty
+REVISION:= $(srcdir)/REVISION # [BRANCH revision XX]
BASEVER_c := $(shell cat $(BASEVER))
DEVPHASE_c := $(shell cat $(DEVPHASE))
DATESTAMP_c := $(shell cat $(DATESTAMP))
+ifeq (,$(wildcard $(REVISION)))
+REVISION:=
+else
+REVISION_c := $(shell cat $(REVISION))
+endif
+
version := $(BASEVER_c)
# For use in version.c - double quoted strings, with appropriate
@@ -726,6 +733,12 @@ BASEVER_s := "\"$(BASEVER_c)\""
DEVPHASE_s := "\"$(if $(DEVPHASE_c), ($(DEVPHASE_c)))\""
DATESTAMP_s := "\"$(if $(DEVPHASE_c), $(DATESTAMP_c))\""
+ifdef REVISION_c
+REVISION_s := "\"$(if $(DEVPHASE_c), $(REVISION_c))\""
+else
+REVISION_s :=
+endif
+
# Shorthand variables for dependency lists.
TARGET_H = $(TM_H) target.h insn-modes.h
MACHMODE_H = machmode.h mode-classes.def insn-modes.h
@@ -1742,9 +1755,10 @@ options.o: options.c $(CONFIG_H) $(SYSTE
dumpvers: dumpvers.c
-version.o: version.c version.h $(DATESTAMP) $(BASEVER) $(DEVPHASE)
+version.o: version.c version.h $(REVISION) $(DATESTAMP) $(BASEVER) $(DEVPHASE)
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
-DBASEVER=$(BASEVER_s) -DDATESTAMP=$(DATESTAMP_s) \
+ -DREVISION=$(REVISION_s) \
-DDEVPHASE=$(DEVPHASE_s) -c $(srcdir)/version.c $(OUTPUT_OPTION)
gtype-desc.o: gtype-desc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
--- gcc/version.c.rev 2005-11-04 14:14:18.0 -0800
+++ gcc/version.c 2006-01-23 10:30:19.0 -0800
@@ -20,6 +20,7 @@
const char bug_report_url[] = "http://gcc.gnu.org/bugs.html>";
/* The complete version string, assembled from several pieces.
- BASEVER, DATESTAMP, and DEVPHASE are defined by the Makefile. */
+ BASEVER, DATESTAMP, DEVPHASE, and REVISION are defined by the
+ Makefile. */
-const char version_string[] = BASEVER DATESTAMP DEVPHASE VERSUFFIX;
+const char version_string[] = BASEVER DATESTAMP DEVPHASE VERSUFFIX REVISION;