Added a revision number for easy compile-time tests.
authorSam Lantinga <slouken@libsdl.org>
Sun, 20 Feb 2011 10:42:51 -0800
changeset 5359d5fe4ed3a28d
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
     1.1 --- a/build-scripts/updaterev.sh	Sun Feb 20 09:28:13 2011 -0800
     1.2 +++ b/build-scripts/updaterev.sh	Sun Feb 20 10:42:51 2011 -0800
     1.3 @@ -9,7 +9,9 @@
     1.4  
     1.5  rev=`sh showrev.sh 2>/dev/null`
     1.6  if [ "$rev" != "" -a "$rev" != "hg-0:baadf00d" ]; then
     1.7 +    revnum=`echo $rev | sed 's,hg-\([0-9]*\).*,\1,'`
     1.8      echo "#define SDL_REVISION \"$rev\"" >$header.new
     1.9 +    echo "#define SDL_REVISION_NUMBER $revnum" >>$header.new
    1.10      if diff $header $header.new >/dev/null 2>&1; then
    1.11          rm $header.new
    1.12      else
     2.1 --- a/include/SDL_revision.h	Sun Feb 20 09:28:13 2011 -0800
     2.2 +++ b/include/SDL_revision.h	Sun Feb 20 10:42:51 2011 -0800
     2.3 @@ -1,1 +1,2 @@
     2.4  #define SDL_REVISION "hg-0:aaaaaaaaaaah"
     2.5 +#define SDL_REVISION_NUMBER 0
     3.1 --- a/include/SDL_version.h	Sun Feb 20 09:28:13 2011 -0800
     3.2 +++ b/include/SDL_version.h	Sun Feb 20 10:42:51 2011 -0800
     3.3 @@ -144,6 +144,16 @@
     3.4   */
     3.5  extern DECLSPEC const char *SDLCALL SDL_GetRevision(void);
     3.6  
     3.7 +/**
     3.8 + *  \brief Get the revision number of SDL that is linked against your program.
     3.9 + *
    3.10 + *  Returns a number uniquely identifying the exact revision of the SDL
    3.11 + *  library in use. It is an incrementing number based on commits to
    3.12 + *  hg.libsdl.org.
    3.13 + */
    3.14 +extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void);
    3.15 +
    3.16 +
    3.17  /* Ends C function definitions when using C++ */
    3.18  #ifdef __cplusplus
    3.19  /* *INDENT-OFF* */
     4.1 --- a/src/SDL.c	Sun Feb 20 09:28:13 2011 -0800
     4.2 +++ b/src/SDL.c	Sun Feb 20 10:42:51 2011 -0800
     4.3 @@ -236,6 +236,13 @@
     4.4      return SDL_REVISION;
     4.5  }
     4.6  
     4.7 +/* Get the library source revision number */
     4.8 +int
     4.9 +SDL_GetRevisionNumber(void)
    4.10 +{
    4.11 +    return SDL_REVISION_NUMBER;
    4.12 +}
    4.13 +
    4.14  /* Get the name of the platform */
    4.15  const char *
    4.16  SDL_GetPlatform()
     5.1 --- a/test/testver.c	Sun Feb 20 09:28:13 2011 -0800
     5.2 +++ b/test/testver.c	Sun Feb 20 10:42:51 2011 -0800
     5.3 @@ -21,11 +21,13 @@
     5.4      printf("Compiled with SDL older than 1.3\n");
     5.5  #endif
     5.6      SDL_VERSION(&compiled);
     5.7 -    printf("Compiled version: %d.%d.%d (%s)\n",
     5.8 -           compiled.major, compiled.minor, compiled.patch, SDL_REVISION);
     5.9 +    printf("Compiled version: %d.%d.%d.%d (%s)\n",
    5.10 +           compiled.major, compiled.minor, compiled.patch,
    5.11 +           SDL_REVISION_NUMBER, SDL_REVISION);
    5.12      SDL_GetVersion(&linked);
    5.13 -    printf("Linked version: %d.%d.%d (%s)\n",
    5.14 -           linked.major, linked.minor, linked.patch, SDL_GetRevision());
    5.15 +    printf("Linked version: %d.%d.%d.%d (%s)\n",
    5.16 +           linked.major, linked.minor, linked.patch,
    5.17 +           SDL_GetRevisionNumber(), SDL_GetRevision());
    5.18      SDL_Quit();
    5.19      return (0);
    5.20  }