diff --git a/SConstruct b/SConstruct index acd46b8e2ad..ea4f82e0b86 100644 --- a/SConstruct +++ b/SConstruct @@ -46,15 +46,10 @@ opts.Add(PathOption('desktopdir', 'sets the desktop entry directory to a non-def # Setup # -# FIXME: Currently this will only work under Linux -svnrev = commands.getoutput("svnversion -n . 2>/dev/null") - env = Environment(options = opts) env.TargetSignatures('content') -env["CXXFLAGS"].append('-DSVNREV=\'"%s"\'' % svnrev) - # Omits the 'test' target all = env.Alias("all", ["wesnoth", "wesnoth_editor", "wesnothd", "campaignd", "cutter", "exploder"]) @@ -132,6 +127,9 @@ extralibs=[] # Link only on demand, so we don't need separate link lists for each binary env["LINKFLAGS"].append("-Wl,--as-needed") +# Later in the recipe we will guarantee that src/revision.hpp exists +env["CXXFLAGS"].append('-DHAVE_REVISION') + if env["debug"]: env["CXXFLAGS"] += Split("-O0 -DDEBUG -ggdb3 -W -Wall -ansi") else: @@ -453,12 +451,11 @@ env.Program("test", test_sources, LIBS = ['wesnoth_core', 'wesnoth_sdl', 'wesnothd'] + commonlibs + ['boost_unit_test_framework'], LIBPATH = [".", "/lib", "/usr/lib"]) -# FIXME: Include this in gameconfig.cpp when we switch over to scons. -# Because of the content check, scons will do the right thing. -# At that point the following line and -DSVNREV can be removed from CXXFLAGS. -env.Depends('src/game_config.o', 'revision_stamp.h') -r = env.Command("revision_stamp.h", [], - 'echo "#define REVISION \"%s\"" >revision_stamp.h' % svnrev) +# FIXME: Currently this will only work under Linux +svnrev = commands.getoutput("svnversion -n . 2>/dev/null") +env.Depends('src/game_config.o', 'src/revision.hpp') +r = env.Command("revision.h", [], + 'echo "#define REVISION \"%s\"" >src/revision.h' % svnrev) env.AlwaysBuild(r) # diff --git a/src/Makefile.am b/src/Makefile.am index 2d39c0f9e4a..9ec15373a51 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,3 @@ -SVNREV = $(shell svnversion -n $(topdir) 2>/dev/null) -CFLAGS += "-DSVNREV=\"$(SVNREV)\"" -CXXFLAGS += "-DSVNREV=\"$(SVNREV)\"" - AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = @@ -439,20 +435,25 @@ libwesnoth_a_SOURCES = \ wml_exception.cpp # Until game_config.cpp is removed, this will be needed to ensure that the -# SVNVER constant gets updated correctly. If and when that definition is +# REVISION constant gets updated correctly. If and when that definition is # moved elsewhere, this dependency must follow it. -game_config.o: revision-stamp +game_config.o: revision.hpp # Should be touched each time the SVN revision number goes up -revision-stamp: FORCE - if [ x"$(SVNREV)" != x`cat revision-stamp 2>/dev/null` ]; then echo -n $(SVNREV) >revision-stamp; fi +# Inclusion of this file should be guarded by HAVE_REVISION so checkouts +# into a Windows build environment won't break. +REVISION = $(shell svnversion -n $(topdir) 2>/dev/null) +.PRECIOUS: revision.hpp +revision.hpp: FORCE + echo '#define REVISION "$(REVISION)"' >/tmp/westemp$$$$; \ + if cmp -s revision.hpp /tmp/westemp$$$$ 2>/dev/null; then :; else cp /tmp/westemp$$ revision.hpp; fi FORCE: -AM_CXXFLAGS = -I../intl -I$(top_srcdir)/intl @SDL_CFLAGS@ -DWESNOTH_PATH=\"$(pkgdatadir)\" \ +AM_CXXFLAGS = -DHAVE_REVISION -I../intl -I$(top_srcdir)/intl @SDL_CFLAGS@ -DWESNOTH_PATH=\"$(pkgdatadir)\" \ -DLOCALEDIR=\"$(LOCALEDIR)\" -DHAS_RELATIVE_LOCALEDIR=$(HAS_RELATIVE_LOCALEDIR) -DFIFODIR=\"$(fifodir)\" -AM_CFLAGS = -I../intl -I$(top_srcdir)/intl @SDL_CFLAGS@ -DWESNOTH_PATH=\"$(pkgdatadir)\" \ +AM_CFLAGS = -DHAVE_REVISION -I../intl -I$(top_srcdir)/intl @SDL_CFLAGS@ -DWESNOTH_PATH=\"$(pkgdatadir)\" \ -DLOCALEDIR=\"$(LOCALEDIR)\" -DHAS_RELATIVE_LOCALEDIR=$(HAS_RELATIVE_LOCALEDIR) if PYTHON diff --git a/src/game_config.cpp b/src/game_config.cpp index 3ec2eafd1db..08a2f624fb1 100644 --- a/src/game_config.cpp +++ b/src/game_config.cpp @@ -21,6 +21,9 @@ #include "util.hpp" #include "serialization/string_utils.hpp" #include "wesconfig.h" +#ifdef HAVE_REVISION +#include "revision.hpp" +#endif /* HAVE_REVISION */ #include #include @@ -40,8 +43,8 @@ namespace game_config const int gold_carryover_percentage = 80; const bool gold_carryover_add = false; const std::string version = VERSION; -#ifdef SVNREV - const std::string revision = VERSION " (" SVNREV ")"; +#ifdef REVISION + const std::string revision = VERSION " (" REVISION ")"; #else const std::string revision = VERSION; #endif