From bac9b61b4a02f4acb8f665666cf81e201f6b9d55 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 4 Jan 2009 05:08:12 +0000 Subject: [PATCH] Make the current revision number available --- Makefile.in | 18 ++++++++---------- build-scripts/showrev.sh | 10 ++++++++++ build-scripts/snapshot.sh | 24 ++++++++++++++++++++++++ build-scripts/updaterev.sh | 17 +++++++++++++++++ include/SDL_version.h | 7 +++++++ src/SDL.c | 7 +++++++ 6 files changed, 73 insertions(+), 10 deletions(-) create mode 100755 build-scripts/showrev.sh create mode 100755 build-scripts/snapshot.sh create mode 100755 build-scripts/updaterev.sh diff --git a/Makefile.in b/Makefile.in index 59a7a7a16..76ac95353 100644 --- a/Makefile.in +++ b/Makefile.in @@ -42,7 +42,7 @@ SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@ DIST = acinclude.m4 autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS docs docs.html include INSTALL Makefile.dc Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.qpg.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-OS2.zip Watcom-Win32.zip WhatsNew Xcode -HDRS = SDL.h SDL_audio.h SDL_cdrom.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_pixels.h SDL_platform.h SDL_quit.h SDL_rect.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h +HDRS = SDL.h SDL_audio.h SDL_cdrom.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_pixels.h SDL_platform.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ @@ -63,7 +63,10 @@ Makefile: $(srcdir)/Makefile.in $(objects): $(SHELL) $(auxdir)/mkinstalldirs $@ -.PHONY: all depend install install-bin install-hdrs install-lib install-data install-man uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data uninstall-man clean distclean dist +update-revision: + $(SHELL) $(auxdir)/updaterev.sh + +.PHONY: all update-revision depend install install-bin install-hdrs install-lib install-data install-man uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data uninstall-man clean distclean dist depend: @SOURCES="$(SOURCES)" INCLUDE="$(INCLUDE)" output="$(depend)" \ $(SHELL) $(auxdir)/makedep.sh @@ -75,7 +78,7 @@ depend: include $(depend) -$(objects)/$(TARGET): $(OBJECTS) +$(objects)/$(TARGET): update-revision $(OBJECTS) $(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS) @@ -153,6 +156,7 @@ dist $(distfile): $(SHELL) $(auxdir)/mkinstalldirs $(distdir) tar cf - $(DIST) | (cd $(distdir); tar xf -) cp $(distdir)/include/SDL_config.h.default $(distdir)/include/SDL_config.h + $(SHELL) $(distdir)/build-scripts/updaterev.sh rm -rf `find $(distdir) -name .svn` find $(distdir) \( \ -name '*~' -o \ @@ -194,10 +198,4 @@ commit: indent # Create a SVN snapshot that people can run update on snapshot: - svn co http://svn.libsdl.org/trunk/SDL SDL-1.3 - (cd SDL-1.3 && ./autogen.sh && rm -rf autom4te.cache) - cp SDL-1.3/include/SDL_config.h.default SDL-1.3/include/SDL_config.h - tar zcf $(HOME)/SDL-1.3.tar.gz SDL-1.3 - rm -f $(HOME)/SDL-1.3.zip - zip -r $(HOME)/SDL-1.3.zip SDL-1.3 - rm -rf SDL-1.3 + $(SHELL) $(aux_dir)/snapshot.sh diff --git a/build-scripts/showrev.sh b/build-scripts/showrev.sh new file mode 100755 index 000000000..bf31e17a9 --- /dev/null +++ b/build-scripts/showrev.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# +# Print the current source revision, if available + +srcdir=`dirname $0`/.. + +if [ -d $srcdir/.svn ]; then + cd $srcdir + svnversion -c | sed -e 's,[0-9]*:\([0-9]*\)[A-Z]*,\1,' +fi diff --git a/build-scripts/snapshot.sh b/build-scripts/snapshot.sh new file mode 100755 index 000000000..9eba3b67b --- /dev/null +++ b/build-scripts/snapshot.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# Generate a current snapshot from source control + +svn co http://svn.libsdl.org/trunk/SDL +(cd SDL && ./autogen.sh && rm -rf autom4te.cache) +sh SDL/build-scripts/updaterev.sh +cp SDL/include/SDL_config.h.default SDL/include/SDL_config.h + +major=`fgrep "#define SDL_MAJOR_VERSION" SDL/include/SDL_version.h | \ + sed 's,[^0-9]*\([0-9]*\),\1,'` +minor=`fgrep "#define SDL_MINOR_VERSION" SDL/include/SDL_version.h | \ + sed 's,[^0-9]*\([0-9]*\),\1,'` +patch=`fgrep "#define SDL_PATCHLEVEL" SDL/include/SDL_version.h | \ + sed 's,[^0-9]*\([0-9]*\),\1,'` +rev=`fgrep "#define SDL_REVISION" SDL/include/SDL_revision.h | \ + sed 's,[^0-9]*\([0-9]*\),\1,'` +path="SDL-$major.$minor.$patch-$rev" + +mv SDL $path +tar zcf $path.tar.gz $path +rm -f $path.zip +zip -r $path.zip $path +rm -rf $path diff --git a/build-scripts/updaterev.sh b/build-scripts/updaterev.sh new file mode 100755 index 000000000..15ffb9574 --- /dev/null +++ b/build-scripts/updaterev.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# +# Generate a header file with the current source revision + +cd `dirname $0` +srcdir=.. +header=$srcdir/include/SDL_revision.h + +rev=`sh showrev.sh` +if [ "$rev" != "" ]; then + echo "#define SDL_REVISION $rev" >$header.new + if diff $header $header.new >/dev/null 2>&1; then + rm $header.new + else + mv $header.new $header + fi +fi diff --git a/include/SDL_version.h b/include/SDL_version.h index 7172da6e7..66627acd5 100644 --- a/include/SDL_version.h +++ b/include/SDL_version.h @@ -30,6 +30,7 @@ #define _SDL_version_h #include "SDL_stdinc.h" +#include "SDL_revision.h" #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -131,6 +132,12 @@ typedef struct SDL_version */ extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); +/** + * \fn int SDL_GetRevision() + * \brief Get the code revision of SDL that is linked against your program. + */ +extern DECLSPEC int SDLCALL SDL_GetRevision(); + /* Ends C function definitions when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ diff --git a/src/SDL.c b/src/SDL.c index 6d3d12510..567ccce28 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -296,6 +296,13 @@ SDL_GetVersion(SDL_version * ver) SDL_VERSION(ver); } +/* Get the library source revision */ +int +SDL_GetRevision() +{ + SDL_REVISION; +} + #if defined(__OS2__) /* Building for OS/2 */ #ifdef __WATCOMC__