From 7cc832b8f95c4ac6f515aa3933c59116db04f6b6 Mon Sep 17 00:00:00 2001 From: ennewalker Date: Sun, 4 Jan 2009 21:50:38 +0000 Subject: Addition of REVISION() macro for tracking SVN revision. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8213 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/makefile.obj | 1 + crawl-ref/source/version.cc | 24 ++++++++++++++++++++++++ crawl-ref/source/version.h | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 crawl-ref/source/version.cc diff --git a/crawl-ref/source/makefile.obj b/crawl-ref/source/makefile.obj index 8e02163420..9ef6148e86 100644 --- a/crawl-ref/source/makefile.obj +++ b/crawl-ref/source/makefile.obj @@ -85,6 +85,7 @@ transfor.o \ traps.o \ travel.o \ tutorial.o \ +version.o \ view.o \ xom.o \ Kills.o \ diff --git a/crawl-ref/source/version.cc b/crawl-ref/source/version.cc new file mode 100644 index 0000000000..3ab89fff41 --- /dev/null +++ b/crawl-ref/source/version.cc @@ -0,0 +1,24 @@ +/* + * File: version.cc + * Summary: Version (and revision) functionality. + * Written by: Enne Walker + * + * Modified for Crawl Reference by $Author$ on $Date$ + */ + +#include "AppHdr.h" +#include "version.h" + +REVISION("$Rev$") + +int check_revision::max_rev = 0; + +check_revision::check_revision(int rev) +{ + max_rev = std::max(rev, max_rev); +} + +int svn_revision() +{ + return check_revision::max_rev; +} diff --git a/crawl-ref/source/version.h b/crawl-ref/source/version.h index 73a776ac35..716a153222 100644 --- a/crawl-ref/source/version.h +++ b/crawl-ref/source/version.h @@ -53,4 +53,22 @@ #define VERSION_DETAIL BUILD_DATE #endif +// Returns the largest SVN revision number that a source file has been updated +// to. This is not perfectly accurate, but should be good enough for save +// files, as breaking a save almost always involves changing a source file. +int svn_revision(); + +class check_revision +{ +public: + check_revision(int rev); + static int max_rev; +}; + +// This macro is meant to be used once per source file, e.g. "REVISION($Rev$);" +// It can't be put in header files, as there's no way to generate a unique +// object name across includes. Blame the lack of cross-platform __COUNTER__. +//#define REVISION(rev) static check_revision check_this_source_file_revision(rev) +#define REVISION(rev) + #endif -- cgit v1.2.3-54-g00ecf