Added a revision number for easy compile-time tests.
authorSam Lantinga <slouken@libsdl.org>
Sun, 20 Feb 2011 10:42:51 -0800
changeset 5359 d5fe4ed3a28d
parent 5358 5b330ef7b8dd
child 5360 220d3af9121f
Added a revision number for easy compile-time tests.
build-scripts/updaterev.sh
include/SDL_revision.h
include/SDL_version.h
src/SDL.c
test/testver.c
--- a/build-scripts/updaterev.sh	Sun Feb 20 09:28:13 2011 -0800
+++ b/build-scripts/updaterev.sh	Sun Feb 20 10:42:51 2011 -0800
@@ -9,7 +9,9 @@
 
 rev=`sh showrev.sh 2>/dev/null`
 if [ "$rev" != "" -a "$rev" != "hg-0:baadf00d" ]; then
+    revnum=`echo $rev | sed 's,hg-\([0-9]*\).*,\1,'`
     echo "#define SDL_REVISION \"$rev\"" >$header.new
+    echo "#define SDL_REVISION_NUMBER $revnum" >>$header.new
     if diff $header $header.new >/dev/null 2>&1; then
         rm $header.new
     else
--- a/include/SDL_revision.h	Sun Feb 20 09:28:13 2011 -0800
+++ b/include/SDL_revision.h	Sun Feb 20 10:42:51 2011 -0800
@@ -1,1 +1,2 @@
 #define SDL_REVISION "hg-0:aaaaaaaaaaah"
+#define SDL_REVISION_NUMBER 0
--- a/include/SDL_version.h	Sun Feb 20 09:28:13 2011 -0800
+++ b/include/SDL_version.h	Sun Feb 20 10:42:51 2011 -0800
@@ -144,6 +144,16 @@
  */
 extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
 
+/**
+ *  \brief Get the revision number of SDL that is linked against your program.
+ *
+ *  Returns a number uniquely identifying the exact revision of the SDL
+ *  library in use. It is an incrementing number based on commits to
+ *  hg.libsdl.org.
+ */
+extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void);
+
+
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
 /* *INDENT-OFF* */
--- a/src/SDL.c	Sun Feb 20 09:28:13 2011 -0800
+++ b/src/SDL.c	Sun Feb 20 10:42:51 2011 -0800
@@ -236,6 +236,13 @@
     return SDL_REVISION;
 }
 
+/* Get the library source revision number */
+int
+SDL_GetRevisionNumber(void)
+{
+    return SDL_REVISION_NUMBER;
+}
+
 /* Get the name of the platform */
 const char *
 SDL_GetPlatform()
--- a/test/testver.c	Sun Feb 20 09:28:13 2011 -0800
+++ b/test/testver.c	Sun Feb 20 10:42:51 2011 -0800
@@ -21,11 +21,13 @@
     printf("Compiled with SDL older than 1.3\n");
 #endif
     SDL_VERSION(&compiled);
-    printf("Compiled version: %d.%d.%d (%s)\n",
-           compiled.major, compiled.minor, compiled.patch, SDL_REVISION);
+    printf("Compiled version: %d.%d.%d.%d (%s)\n",
+           compiled.major, compiled.minor, compiled.patch,
+           SDL_REVISION_NUMBER, SDL_REVISION);
     SDL_GetVersion(&linked);
-    printf("Linked version: %d.%d.%d (%s)\n",
-           linked.major, linked.minor, linked.patch, SDL_GetRevision());
+    printf("Linked version: %d.%d.%d.%d (%s)\n",
+           linked.major, linked.minor, linked.patch,
+           SDL_GetRevisionNumber(), SDL_GetRevision());
     SDL_Quit();
     return (0);
 }