From a5e3944234ea000894ffe4f2f0926bfb8ed43f72 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 23 Aug 2009 06:19:15 +0200 Subject: [PATCH] Added script and command for dumping version and revision information. Also added define for enabling or disabling this until we have a windows script for updating hgversion.h.inc. --- .hgignore | 4 +++ Makefile | 2 ++ src/zombiereloaded.sp | 13 +++++++++ src/zr/commands.inc | 4 +++ src/zr/cvars.inc | 4 +++ src/zr/versioninfo.inc | 62 ++++++++++++++++++++++++++++++++++++++++++ updateversion.sh | 15 ++++++++++ 7 files changed, 104 insertions(+) create mode 100644 .hgignore create mode 100644 src/zr/versioninfo.inc create mode 100755 updateversion.sh diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..18448d6 --- /dev/null +++ b/.hgignore @@ -0,0 +1,4 @@ +# use glob syntax. +syntax: glob + +src/zr/hgversion.h.inc diff --git a/Makefile b/Makefile index c5eddd1..1e4fe54 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ SOURCEDIR=src BUILDDIR=build SPCOMP=bin/spcomp +VERSIONDUMP=./updateversion.sh vpath %.sp $(SOURCEDIR) vpath %.inc $(SOURCEDIR)/include @@ -24,6 +25,7 @@ prepare_builddir: @mkdir -p $(BUILDDIR) %.smx: %.sp + $(VERSIONDUMP) $(SPCOMP) -i$(SOURCEDIR) -i$(SOURCEDIR)/include -o$(BUILDDIR)/$@ $< clean: diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 59dc729..8c63409 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -34,11 +34,24 @@ #define VERSION "3.0.0-b2-dev" +// Comment this line to exclude version info command. Temporary solution until +// there is a windows script for updating hgversion.h.inc. +#define ADD_VERSION_INFO 1 + // Header includes. #include "zr/log.h" +#if defined ADD_VERSION_INFO +#include "zr/hgversion.h" +#endif + // Core includes. #include "zr/zombiereloaded" + +#if defined ADD_VERSION_INFO +#include "zr/versioninfo" +#endif + #include "zr/translation" #include "zr/cvars" #include "zr/admintools" diff --git a/src/zr/commands.inc b/src/zr/commands.inc index 4635133..7cd9e8b 100644 --- a/src/zr/commands.inc +++ b/src/zr/commands.inc @@ -46,6 +46,10 @@ CommandsInit() ZHPOnCommandsCreate(); VolOnCommandsCreate(); + #if defined ADD_VERSION_INFO + VersionOnCommandsCreate(); + #endif + DebugOnCommandsCreate(); // Forward event to modules. (hook commands) diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index faadd94..4e11dba 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -208,6 +208,10 @@ CvarsInit() Format(description, sizeof(description), "%s Current version of this plugin", TRANSLATION_PHRASE_PREFIX); CreateConVar("gs_zombiereloaded_version", VERSION, description, FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_UNLOGGED|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY); + #if defined ADD_VERSION_INFO + CreateConVar("zombiereloaded_revision", ZR_VER_REVISION, "Revision number for this plugin in source code repository.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_UNLOGGED|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY); + #endif + // Forward event to modules. VEffectsOnCvarInit(); } diff --git a/src/zr/versioninfo.inc b/src/zr/versioninfo.inc new file mode 100644 index 0000000..b83972e --- /dev/null +++ b/src/zr/versioninfo.inc @@ -0,0 +1,62 @@ +/* + * ============================================================================ + * + * Zombie:Reloaded + * + * File: version.inc + * Description: Command for version information. + * + * Copyright (C) 2009 Greyscale, Richard Helgeby + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * ============================================================================ + */ + +VersionOnCommandsCreate() +{ + RegConsoleCmd("zr_version", Command_Version, "Prints version info about this plugin."); +} + +public Action:Command_Version(client, argc) +{ + decl String:buffer[512]; + decl String:linebuffer[128]; + buffer[0] = 0; + linebuffer[0] = 0; + + Format(linebuffer, sizeof(linebuffer), "%s\n", ZR_VER_PRODUCT_NAME); + StrCat(buffer, sizeof(buffer), linebuffer); + + Format(linebuffer, sizeof(linebuffer), "%s\n\n", ZR_VER_COPYRIGHT); + StrCat(buffer, sizeof(buffer), linebuffer); + + Format(linebuffer, sizeof(linebuffer), "Version: %s\n", ZR_VER_VERSION); + StrCat(buffer, sizeof(buffer), linebuffer); + + Format(linebuffer, sizeof(linebuffer), "Development branch: %s\n", ZR_VER_BRANCH); + StrCat(buffer, sizeof(buffer), linebuffer); + + Format(linebuffer, sizeof(linebuffer), "Revision: %s\n", ZR_VER_REVISION); + StrCat(buffer, sizeof(buffer), linebuffer); + + Format(linebuffer, sizeof(linebuffer), "License: %s\n", ZR_VER_LICENSE); + StrCat(buffer, sizeof(buffer), linebuffer); + + Format(linebuffer, sizeof(linebuffer), "Compile date: %s", ZR_VER_DATE); + StrCat(buffer, sizeof(buffer), linebuffer); + + ReplyToCommand(client, buffer); + return Plugin_Handled; +} diff --git a/updateversion.sh b/updateversion.sh new file mode 100755 index 0000000..7f9793d --- /dev/null +++ b/updateversion.sh @@ -0,0 +1,15 @@ +#/bin/sh + +ZR_VERSION_FILE="src/zr/hgversion.h.inc" + +ZR_PRODUCT_NAME="Zombie:Reloaded" +ZR_COPYRIGHT="Copyright (C) 2009 Greyscale, Richard Helgeby" +ZR_LICENSE="GNU GPL, Version 3" + +echo "#define ZR_VER_PRODUCT_NAME \"$ZR_PRODUCT_NAME\"" > $ZR_VERSION_FILE +echo "#define ZR_VER_COPYRIGHT \"$ZR_COPYRIGHT\"" >> $ZR_VERSION_FILE +echo "#define ZR_VER_VERSION VERSION" >> $ZR_VERSION_FILE +echo "#define ZR_VER_BRANCH \"$(hg id -b)\"" >> $ZR_VERSION_FILE +echo "#define ZR_VER_REVISION \"$(hg id -n):$(hg id -i)\"" >> $ZR_VERSION_FILE +echo "#define ZR_VER_LICENSE \"$ZR_LICENSE\"" >> $ZR_VERSION_FILE +echo "#define ZR_VER_DATE \"$(date)\"" >> $ZR_VERSION_FILE