made SVNREV not to recompile all everytime

This commit is contained in:
Pauli Nieminen 2008-01-27 19:08:20 +00:00
parent 94c680127b
commit e5fa47807b
13 changed files with 128 additions and 12 deletions

View file

@ -47,6 +47,7 @@ Version 1.3.14+svn:
* fixed adjacent units to update if unit affects them
* converted NO_MAP_DATA to new map format
* fixed unchecked vector access
* made SVNREV not to recompile all everytime
* make sure the python campaign client list shows a space between the
headers if the size of the column is smaller than the header (eg uploads)
* make sure a unit with more hitpoints than its maximum doesn't terminate

3
src/.gitignore vendored
View file

@ -12,7 +12,8 @@ Makefile
Makefile.in
libwesnoth-core.a
libwesnoth.a
revision-stamp
revision_stamp
revision_stamp.cpp
tags
test
wmllint

View file

@ -1,7 +1,7 @@
if USESVN
SVNREV = $(shell svnversion -n $(topdir) 2>/dev/null)
CFLAGS += "-DSVNREV=\"$(SVNREV)\""
CXXFLAGS += "-DSVNREV=\"$(SVNREV)\""
CFLAGS += "-DSVNREV"
CXXFLAGS += "-DSVNREV"
endif
AUTOMAKE_OPTIONS = subdir-objects
@ -88,6 +88,7 @@ wesnoth_source = \
playturn.cpp \
publish_campaign.cpp \
replay.cpp \
revision_stamp.cpp \
replay_controller.cpp \
sha1.cpp \
settings.cpp \
@ -436,7 +437,6 @@ libwesnoth_a_SOURCES = \
sdl_ttf/SDL_ttf.c \
wml_exception.cpp
if USESVN
# 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
# moved elsewhere, this dependency must follow it.
@ -444,10 +444,10 @@ game_config.o: revision-stamp
# 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
g++ -O2 tools/revision_compiler.cpp -o tools/revision_compiler
tools/revision_compiler $(shell svnversion -n $(topdir) 2>/dev/null || unknown) < revision_stamp.tpl > revision_stamp.cpp
FORCE:
endif
AM_CXXFLAGS = -I $(srcdir)/sdl_ttf -I../intl -I$(top_srcdir)/intl @SDL_CFLAGS@ -DWESNOTH_PATH=\"$(pkgdatadir)\" \
-DLOCALEDIR=\"$(LOCALEDIR)\" -DHAS_RELATIVE_LOCALEDIR=$(HAS_RELATIVE_LOCALEDIR) -DFIFODIR=\"$(fifodir)\"\

View file

@ -543,6 +543,9 @@ namespace {
int main(int argc, char**argv)
{
#ifdef SVNREV
game_config::svnrev = get_svn_revision();
#endif
lg::timestamps(true);
try {
printf("argc %d argv[0] %s 1 %s\n",argc,argv[0],argv[1]);

View file

@ -47,6 +47,9 @@ namespace {
int main(int argc, char** argv)
{
#ifdef SVNREV
game_config::svnrev = get_svn_revision();
#endif
const std::string rev = game_config::svnrev.empty() ? "" :
" (" + game_config::svnrev + ")";

View file

@ -2328,6 +2328,9 @@ int main(int argc, char** argv)
#endif
try {
#ifdef SVNREV
game_config::svnrev = get_svn_revision();
#endif
const std::string rev = game_config::svnrev.empty() ? "" :
" (" + game_config::svnrev + ")";

View file

@ -40,11 +40,7 @@ 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 svnrev = SVNREV;
#else
const std::string svnrev = "";
#endif
std::string svnrev = "";
bool debug = false, editor = false, ignore_replay_errors = false, mp_debug = false, exit_at_end = false, no_delay = false, disable_autosave = false;
std::string game_icon = "wesnoth-icon.png", game_title, game_logo, title_music;

View file

@ -18,6 +18,7 @@ class config;
#include "color_range.hpp"
#include "tstring.hpp"
#include "revision_stamp.hpp"
#include <string>
#include <vector>
@ -34,7 +35,7 @@ namespace game_config
extern int kill_experience;
extern unsigned lobby_refresh;
extern const std::string version;
extern const std::string svnrev;
extern std::string svnrev;
//! Default percentage gold carried over to the next scenario.
extern const int gold_carryover_percentage;

18
src/revision_stamp.hpp Normal file
View file

@ -0,0 +1,18 @@
/*
Copyright (C) 2003 - 2008 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
or at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef REVISON_STAMP_HPP_INCLUDE
#define REVISON_STAMP_HPP_INCLUDE
#include <string>
const std::string& get_svn_revision();
#endif

20
src/revision_stamp.tpl Normal file
View file

@ -0,0 +1,20 @@
/*
Copyright (C) 2003 - 2008 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
or at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#include "revision_stamp.hpp"
const std::string& get_svn_revision()
{
static const std::string revision = "SVN_REVISION";
return revision;
}

View file

@ -1288,6 +1288,9 @@ void server::delete_game(std::vector<game>::iterator game_it) {
}
int main(int argc, char** argv) {
#ifdef SVNREV
game_config::svnrev = get_svn_revision();
#endif
int port = 15000;
size_t min_threads = 5;
size_t max_threads = 0;

3
src/tools/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
.deps
.dirstamp
revision_compiler

View file

@ -0,0 +1,64 @@
/*
Copyright (C) 2003 - 2008 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
or at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#include <iostream>
#include <string>
const int BUFFER_SIZE = 64;
const std::string replace = "SVN_REVISION";
void output(char buf[], int bufi, int matchi)
{
for (int i = 0;i <= matchi; --matchi)
{
std::cout << buf[bufi - matchi + i];
}
}
int main(int argc, char ** argv)
{
if (argc != 2)
{
std::cout << argc;
return -1;
}
std::string replace_with(argv[1]);
char * buffer = new char[BUFFER_SIZE];
int bufi;
int matchi = 0;
int read = 0;
std::cin.read(buffer, BUFFER_SIZE);
while( read = std::cin.gcount() )
{
for(bufi = 0; bufi < read; ++bufi)
{
if (buffer[bufi] == replace[matchi] )
{
++matchi;
if (matchi == replace.size())
{
matchi = 0;
std::cout << replace_with;
}
}
else
{
output(buffer,bufi,matchi);
matchi = 0;
}
}
std::cin.read(buffer, BUFFER_SIZE);
}
return 0;
}