From fe68f19d795702acd1b97063b5747bd37311aa24 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 18 Nov 2008 02:28:38 -0600 Subject: [PATCH] Redid versioning for Mercurial. --HG-- rename : core-legacy/svn_version.h => core-legacy/version.h rename : core-legacy/svn_version.tpl => core-legacy/version.tpl --- core-legacy/concommands.cpp | 7 +- core-legacy/sourcemm.h | 2 +- core-legacy/svn_version.h | 13 --- core-legacy/svn_version.tpl | 13 --- core-legacy/version.h | 12 +++ core-legacy/version.tpl | 12 +++ core-legacy/vsp_bridge.cpp | 2 +- core-legacy/vsp_listener.cpp | 2 +- core/metamod.cpp | 4 +- core/metamod.h | 2 +- core/metamod_console.cpp | 5 +- core/provider/vsp_listener.cpp | 4 +- core/svn_version.h | 13 --- core/svn_version.tpl | 13 --- core/version.h | 12 +++ core/version.tpl | 12 +++ core/vsp_bridge.cpp | 2 +- modules.versions | 24 ++++-- support/buildbot/bootstrap.pl | 24 ++++++ support/buildbot/helpers.pm | 145 +++++++++++++++++++++++++++++++++ support/versionchanger.pl | 140 +++++++++++++++++++++++++++++++ 21 files changed, 388 insertions(+), 75 deletions(-) delete mode 100644 core-legacy/svn_version.h delete mode 100644 core-legacy/svn_version.tpl create mode 100644 core-legacy/version.h create mode 100644 core-legacy/version.tpl delete mode 100644 core/svn_version.h delete mode 100644 core/svn_version.tpl create mode 100644 core/version.h create mode 100644 core/version.tpl create mode 100755 support/buildbot/bootstrap.pl create mode 100644 support/buildbot/helpers.pm create mode 100755 support/versionchanger.pl diff --git a/core-legacy/concommands.cpp b/core-legacy/concommands.cpp index 06426f2..3b6a0c3 100644 --- a/core-legacy/concommands.cpp +++ b/core-legacy/concommands.cpp @@ -105,7 +105,7 @@ void SMConVarAccessor::Unregister(ConCommandBase *pCommand) } } -ConVar metamod_version("metamod_version", SOURCEMM_VERSION, FCVAR_SPONLY | FCVAR_NOTIFY, "Metamod:Source Version"); +ConVar metamod_version("metamod_version", SVN_FULL_VERSION, FCVAR_SPONLY | FCVAR_NOTIFY, "Metamod:Source Version"); #ifdef OS_WIN32 ConVar mm_pluginsfile("mm_pluginsfile", "addons\\metamod\\metaplugins.ini", FCVAR_SPONLY, "Metamod:Source Plugins File"); ConVar mm_basedir("mm_basedir", "addons\\metamod", FCVAR_SPONLY, "Metamod:Source base folder"); @@ -140,7 +140,8 @@ CON_COMMAND(meta, "Metamod:Source Menu") return; } else if (strcmp(command, "version") == 0) { - CONMSG("Metamod:Source version %s\n", SOURCEMM_VERSION); + CONMSG("Metamod:Source version %s\n", SVN_FULL_VERSION); + CONMSG("Build ID: %s\n", MMS_BUILD_UNIQUEID); if (g_bIsBridgedAsVsp) { CONMSG("Loaded As: Valve Server Plugin\n"); @@ -658,7 +659,7 @@ void ClientCommand_handler(edict_t *client) RETURN_META(MRES_SUPERCEDE); } else if(strcmp(subcmd, "version") == 0) { - CLIENT_CONMSG(client, "Metamod:Source version %s\n", SOURCEMM_VERSION); + CLIENT_CONMSG(client, "Metamod:Source version %s\n", SVN_FULL_VERSION); CLIENT_CONMSG(client, "Compiled on: %s\n", SOURCEMM_DATE); CLIENT_CONMSG(client, "Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION); CLIENT_CONMSG(client, "SourceHook version: %d:%d\n", g_SourceHook.GetIfaceVersion(), g_SourceHook.GetImplVersion()); diff --git a/core-legacy/sourcemm.h b/core-legacy/sourcemm.h index fd000e8..b29a92b 100644 --- a/core-legacy/sourcemm.h +++ b/core-legacy/sourcemm.h @@ -25,7 +25,7 @@ #include "CPlugin.h" #include "oslink.h" #include "util.h" -#include "svn_version.h" +#include "version.h" /** * Versioning diff --git a/core-legacy/svn_version.h b/core-legacy/svn_version.h deleted file mode 100644 index 4982418..0000000 --- a/core-legacy/svn_version.h +++ /dev/null @@ -1,13 +0,0 @@ -/** This file is autogenerated by build scripts */ - -#ifndef _INCLUDE_SVN_VERSION_H_ -#define _INCLUDE_SVN_VERSION_H_ - -#define SVN_PRODUCT_VERSION "1.7.0" - -#define SVN_REVISION 705 -#define SVN_REVISION_STRING "705" -#define SVN_FILE_VERSION 1,7,0,705 -#define SVN_FILE_VERSION_STRING "1.7.0.705" - -#endif //_INCLUDE_SVN_VERSION_H_ diff --git a/core-legacy/svn_version.tpl b/core-legacy/svn_version.tpl deleted file mode 100644 index 9b93d57..0000000 --- a/core-legacy/svn_version.tpl +++ /dev/null @@ -1,13 +0,0 @@ -/** This file is autogenerated by build scripts */ - -#ifndef _INCLUDE_SVN_VERSION_H_ -#define _INCLUDE_SVN_VERSION_H_ - -#define SVN_PRODUCT_VERSION "$PMAJOR$.$PMINOR$.$PREVISION$" - -#define SVN_REVISION $GLOBAL_BUILD$ -#define SVN_REVISION_STRING "$GLOBAL_BUILD$" -#define SVN_FILE_VERSION $PMAJOR$,$PMINOR$,$PREVISION$,$GLOBAL_BUILD$ -#define SVN_FILE_VERSION_STRING "$PMAJOR$.$PMINOR$.$PREVISION$.$GLOBAL_BUILD$" - -#endif //_INCLUDE_SVN_VERSION_H_ diff --git a/core-legacy/version.h b/core-legacy/version.h new file mode 100644 index 0000000..6482f61 --- /dev/null +++ b/core-legacy/version.h @@ -0,0 +1,12 @@ +/** This file is autogenerated by build scripts */ + +#ifndef _INCLUDE_SVN_VERSION_H_ +#define _INCLUDE_SVN_VERSION_H_ + +#define MMS_BUILD_STRING "-dev" +#define MMS_BUILD_UNIQUEID "556:b37a142ba881" MMS_BUILD_STRING +#define SVN_FULL_VERSION "1.7.0" MMS_BUILD_STRING +#define SVN_FILE_VERSION 1,7,0,0 + +#endif //_INCLUDE_SVN_VERSION_H_ + diff --git a/core-legacy/version.tpl b/core-legacy/version.tpl new file mode 100644 index 0000000..903ac50 --- /dev/null +++ b/core-legacy/version.tpl @@ -0,0 +1,12 @@ +/** This file is autogenerated by build scripts */ + +#ifndef _INCLUDE_SVN_VERSION_H_ +#define _INCLUDE_SVN_VERSION_H_ + +#define MMS_BUILD_STRING "$BUILD_STRING$" +#define MMS_BUILD_UNIQUEID "$BUILD_ID$" MMS_BUILD_STRING +#define SVN_FULL_VERSION "$PMAJOR$.$PMINOR$.$PREVISION$" MMS_BUILD_STRING +#define SVN_FILE_VERSION $PMAJOR$,$PMINOR$,$PREVISION$,0 + +#endif //_INCLUDE_SVN_VERSION_H_ + diff --git a/core-legacy/vsp_bridge.cpp b/core-legacy/vsp_bridge.cpp index cad98ac..e54aec2 100644 --- a/core-legacy/vsp_bridge.cpp +++ b/core-legacy/vsp_bridge.cpp @@ -67,7 +67,7 @@ class VspBridge : public IVspBridge virtual const char *GetDescription() { - return "Metamod:Source " SOURCEMM_VERSION; + return "Metamod:Source " SVN_FULL_VERSION; } }; diff --git a/core-legacy/vsp_listener.cpp b/core-legacy/vsp_listener.cpp index 41cf38a..64d39f6 100644 --- a/core-legacy/vsp_listener.cpp +++ b/core-legacy/vsp_listener.cpp @@ -58,7 +58,7 @@ void VSPListener::GameFrame(bool simulating) const char *VSPListener::GetPluginDescription() { - return "Metamod:Source Interface v" SOURCEMM_VERSION; + return "Metamod:Source Interface " SVN_FULL_VERSION; } bool VSPListener::IsLoaded() diff --git a/core/metamod.cpp b/core/metamod.cpp index 3fc01d2..e8290af 100644 --- a/core/metamod.cpp +++ b/core/metamod.cpp @@ -763,11 +763,11 @@ mm_StartupMetamod(bool is_vsp_load) UTIL_Format(buffer, sizeof(buffer), "%s%s", - SOURCEMM_VERSION, + SVN_FULL_VERSION, is_vsp_load ? "V" : ""); metamod_version = provider->CreateConVar("metamod_version", - SOURCEMM_VERSION, + SVN_FULL_VERSION, "Metamod:Source Version", ConVarFlag_Notify|ConVarFlag_SpOnly); diff --git a/core/metamod.h b/core/metamod.h index 99f507c..c71db54 100644 --- a/core/metamod.h +++ b/core/metamod.h @@ -41,7 +41,7 @@ #include #include #include "metamod_provider.h" -#include "svn_version.h" +#include "version.h" using namespace SourceMM; diff --git a/core/metamod_console.cpp b/core/metamod_console.cpp index f9a8d4a..6683605 100644 --- a/core/metamod_console.cpp +++ b/core/metamod_console.cpp @@ -70,7 +70,8 @@ bool Command_Meta(IMetamodSourceCommandInfo *info) } else if (strcmp(command, "version") == 0) { - CONMSG("Metamod:Source version %s\n", SOURCEMM_VERSION); + CONMSG("Metamod:Source version %s\n", SVN_FULL_VERSION); + CONMSG("Build ID: %s\n", MMS_BUILD_UNIQUEID); if (g_Metamod.IsLoadedAsGameDLL()) { @@ -687,7 +688,7 @@ bool Command_ClientMeta(edict_t *client, IMetamodSourceCommandInfo *info) } else if(strcmp(subcmd, "version") == 0) { - CLIENT_CONMSG(client, "Metamod:Source version %s\n", SOURCEMM_VERSION); + CLIENT_CONMSG(client, "Metamod:Source version %s\n", SVN_FULL_VERSION); CLIENT_CONMSG(client, "Compiled on: %s\n", SOURCEMM_DATE); CLIENT_CONMSG(client, "Plugin interface version: %d:%d\n", METAMOD_PLAPI_VERSION, PLAPI_MIN_VERSION); CLIENT_CONMSG(client, "SourceHook version: %d:%d\n", g_SHPtr->GetIfaceVersion(), g_SHPtr->GetImplVersion()); diff --git a/core/provider/vsp_listener.cpp b/core/provider/vsp_listener.cpp index 1a3d30b..4c7a498 100644 --- a/core/provider/vsp_listener.cpp +++ b/core/provider/vsp_listener.cpp @@ -33,7 +33,7 @@ #include #include "iplayerinfo.h" #include "vsp_listener.h" -#include "svn_version.h" +#include "version.h" #include "provider_ep2.h" using namespace SourceMM; @@ -80,7 +80,7 @@ void VSPListener::GameFrame(bool simulating) const char *VSPListener::GetPluginDescription() { - return "Metamod:Source Interface v" SVN_FILE_VERSION_STRING; + return "Metamod:Source Interface " SVN_FULL_VERSION; } bool VSPListener::IsLoaded() diff --git a/core/svn_version.h b/core/svn_version.h deleted file mode 100644 index df4cb8e..0000000 --- a/core/svn_version.h +++ /dev/null @@ -1,13 +0,0 @@ -/** This file is autogenerated by build scripts */ - -#ifndef _INCLUDE_SVN_VERSION_H_ -#define _INCLUDE_SVN_VERSION_H_ - -#define SVN_PRODUCT_VERSION "1.7.0" - -#define SVN_REVISION 703 -#define SVN_REVISION_STRING "703" -#define SVN_FILE_VERSION 1,7,0,703 -#define SVN_FILE_VERSION_STRING "1.7.0.703" - -#endif //_INCLUDE_SVN_VERSION_H_ diff --git a/core/svn_version.tpl b/core/svn_version.tpl deleted file mode 100644 index 9b93d57..0000000 --- a/core/svn_version.tpl +++ /dev/null @@ -1,13 +0,0 @@ -/** This file is autogenerated by build scripts */ - -#ifndef _INCLUDE_SVN_VERSION_H_ -#define _INCLUDE_SVN_VERSION_H_ - -#define SVN_PRODUCT_VERSION "$PMAJOR$.$PMINOR$.$PREVISION$" - -#define SVN_REVISION $GLOBAL_BUILD$ -#define SVN_REVISION_STRING "$GLOBAL_BUILD$" -#define SVN_FILE_VERSION $PMAJOR$,$PMINOR$,$PREVISION$,$GLOBAL_BUILD$ -#define SVN_FILE_VERSION_STRING "$PMAJOR$.$PMINOR$.$PREVISION$.$GLOBAL_BUILD$" - -#endif //_INCLUDE_SVN_VERSION_H_ diff --git a/core/version.h b/core/version.h new file mode 100644 index 0000000..6482f61 --- /dev/null +++ b/core/version.h @@ -0,0 +1,12 @@ +/** This file is autogenerated by build scripts */ + +#ifndef _INCLUDE_SVN_VERSION_H_ +#define _INCLUDE_SVN_VERSION_H_ + +#define MMS_BUILD_STRING "-dev" +#define MMS_BUILD_UNIQUEID "556:b37a142ba881" MMS_BUILD_STRING +#define SVN_FULL_VERSION "1.7.0" MMS_BUILD_STRING +#define SVN_FILE_VERSION 1,7,0,0 + +#endif //_INCLUDE_SVN_VERSION_H_ + diff --git a/core/version.tpl b/core/version.tpl new file mode 100644 index 0000000..903ac50 --- /dev/null +++ b/core/version.tpl @@ -0,0 +1,12 @@ +/** This file is autogenerated by build scripts */ + +#ifndef _INCLUDE_SVN_VERSION_H_ +#define _INCLUDE_SVN_VERSION_H_ + +#define MMS_BUILD_STRING "$BUILD_STRING$" +#define MMS_BUILD_UNIQUEID "$BUILD_ID$" MMS_BUILD_STRING +#define SVN_FULL_VERSION "$PMAJOR$.$PMINOR$.$PREVISION$" MMS_BUILD_STRING +#define SVN_FILE_VERSION $PMAJOR$,$PMINOR$,$PREVISION$,0 + +#endif //_INCLUDE_SVN_VERSION_H_ + diff --git a/core/vsp_bridge.cpp b/core/vsp_bridge.cpp index 650220b..248587a 100644 --- a/core/vsp_bridge.cpp +++ b/core/vsp_bridge.cpp @@ -96,7 +96,7 @@ public: virtual const char *GetDescription() { - return "Metamod:Source " SOURCEMM_VERSION; + return "Metamod:Source " SVN_FULL_VERSION; } }; diff --git a/modules.versions b/modules.versions index e5bd90b..ee350c7 100644 --- a/modules.versions +++ b/modules.versions @@ -1,9 +1,15 @@ -[PRODUCT] -major = 1 -minor = 7 -revision = 0 - -[sourcemm] -folder = sourcemm -in = svn_version.tpl -out = svn_version.h +[PRODUCT] +major = 1 +minor = 7 +revision = 0 + +[core] +folder = core +in = version.tpl +out = version.h + +[core-legacy] +folder = core-legacy +in = version.tpl +out = version.h + diff --git a/support/buildbot/bootstrap.pl b/support/buildbot/bootstrap.pl new file mode 100755 index 0000000..8885f6c --- /dev/null +++ b/support/buildbot/bootstrap.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl + +use strict; +use Cwd; +use File::Basename; + +my ($myself, $path) = fileparse($0); +chdir($path); + +require 'helpers.pm'; + +#Go to main source dir +chdir(Build::PathFormat('../..')); + +#Do the annoying revision bumping. +#Linux needs some help here. +if ($^O eq "linux") +{ + Build::Command("flip -u modules.versions"); + Build::Command("flip -u support/versionchanger.pl"); + Build::Command("chmod +x support/versionchanger.pl"); +} +Build::Command(Build::PathFormat('support/versionchanger.pl') . '--buildstring="-dev"'); + diff --git a/support/buildbot/helpers.pm b/support/buildbot/helpers.pm new file mode 100644 index 0000000..704a7b1 --- /dev/null +++ b/support/buildbot/helpers.pm @@ -0,0 +1,145 @@ +#!/usr/bin/perl + +use strict; +use Cwd; + +package Build; + +our $SVN = "/usr/bin/svn"; +our $SVN_USER = 'dvander'; +our $SVN_ARGS = ''; + +sub HgRevNum +{ + my ($path) = (@_); + my ($cd, $text, $rev); + + $cd = Cwd::cwd(); + chdir($path); + $text = `hg identify -n`; + chdir($cd); + + chomp $text; + if ($text =~ /^(\d+)/) + { + return $1; + } + + return 0; +} + +sub SvnRevNum +{ + my ($str)=(@_); + + my $data = Command('svnversion -c ' . $str); + if ($data =~ /(\d+):(\d+)/) + { + return $2; + } elsif ($data =~ /(\d+)/) { + return $1; + } else { + return 0; + } +} + +sub ProductVersion +{ + my ($file) = (@_); + my ($version); + open(FILE, $file) or die "Could not open $file: $!\n"; + $version = ; + close(FILE); + chomp $version; + return $version; +} + +sub Delete +{ + my ($str)=(@_); + if ($^O =~ /MSWin/) + { + Command("del /S /F /Q \"$str\""); + Command("rmdir /S /Q \"$str\""); + } else { + Command("rm -rf $str"); + } + return !(-e $str); +} + +sub Copy +{ + my ($src,$dest)=(@_); + if ($^O =~ /MSWin/) + { + Command("copy \"$src\" \"$dest\" /y"); + } else { + Command("cp \"$src\" \"$dest\""); + } + return (-e $dest); +} + +sub Move +{ + my ($src,$dest)=(@_); + if ($^O =~ /MSWin/) + { + Command("move \"$src\" \"$dest\""); + } else { + Command("mv \"$src\" \"$dest\""); + } + return (-e $dest); +} + +sub Command +{ + my($cmd)=(@_); + print "$cmd\n"; + return `$cmd`; +} + +sub PathFormat +{ + my ($str)=(@_); + if ($^O =~ /MSWin/) + { + $str =~ s#/#\\#g; + } else { + $str =~ s#\\#/#g; + } + return $str; +} + +sub SVN_Remove +{ + my ($file)=(@_); + my ($path, $name); + if ($^O =~ /MSWin/) + { + ($path, $name) = ($file =~ /(.+)\/([^\/]+)$/); + } else { + ($path, $name) = ($file =~ /(.+)\\([^\\]+)$/); + } + my $dir = Cwd::cwd(); + chdir($path); + Command($SVN . ' ' . $SVN_ARGS . ' delete ' . $name); + chdir($dir); +} + +sub SVN_Add +{ + my ($file)=(@_); + my ($path, $name); + if ($^O =~ /MSWin/) + { + ($path, $name) = ($file =~ /(.+)\/([^\/]+)$/); + } else { + ($path, $name) = ($file =~ /(.+)\\([^\\]+)$/); + } + my $dir = Cwd::cwd(); + chdir($path); + Command($SVN . ' ' . $SVN_ARGS . ' add ' . $name); + chdir($dir); +} + +return 1; diff --git a/support/versionchanger.pl b/support/versionchanger.pl new file mode 100755 index 0000000..ce5f6f6 --- /dev/null +++ b/support/versionchanger.pl @@ -0,0 +1,140 @@ +#!/usr/bin/perl + +our %arguments = +( + 'config' => 'modules.versions', + 'major' => '1', + 'minor' => '0', + 'revision' => '0', + 'build' => undef, + 'path' => '', + 'buildstring' => '', +); + +my $arg; +foreach $arg (@ARGV) +{ + $arg =~ s/--//; + @arg = split(/=/, $arg); + $arguments{$arg[0]} = $arg[1]; +} + +#Set up path info +if ($arguments{'path'} ne "") +{ + if (!(-d $arguments{'path'})) + { + die "Unable to find path: " . $arguments{'path'} ."\n"; + } + chdir($arguments{'path'}); +} + +if (!open(CONFIG, $arguments{'config'})) +{ + die "Unable to open config file for reading: " . $arguments{'config'} . "\n"; +} + +our %modules; +my $cur_module = undef; +my $line; +while () +{ + chomp; + $line = $_; + if ($line =~ /^\[([^\]]+)\]$/) + { + $cur_module = $1; + next; + } + if (!$cur_module) + { + next; + } + if ($line =~ /^([^=]+) = (.+)$/) + { + $modules{$cur_module}{$1} = $2; + } +} + +close(CONFIG); + +#Copy global configuration options... +if (exists($modules{'PRODUCT'})) +{ + if (exists($modules{'PRODUCT'}{'major'})) + { + $arguments{'major'} = $modules{'PRODUCT'}{'major'}; + } + if (exists($modules{'PRODUCT'}{'minor'})) + { + $arguments{'minor'} = $modules{'PRODUCT'}{'minor'}; + } + if (exists($modules{'PRODUCT'}{'revision'})) + { + $arguments{'revision'} = $modules{'PRODUCT'}{'revision'}; + } +} + +#Get the global SVN revision if we have none +my $rev; +if ($arguments{'build'} == undef) +{ + my ($text); + $text = `hg identif -n -i`; + chomp $text; + $text =~ s/\+//g; + my ($id,$num) = split(/ /, $text); + $rev = "$num:$id"; +} +else +{ + $rev = int($arguments{'build'}); +} + +my $major = $arguments{'major'}; +my $minor = $arguments{'minor'}; +my $revision = $arguments{'revision'}; +my $buildstr = $arguments{'buildstring'}; + +#Go through everything now +my $mod_i; +while ( ($cur_module, $mod_i) = each(%modules) ) +{ + #Skip the magic one + if ($cur_module eq "PRODUCT") + { + next; + } + #Prepare path + my %mod = %{$mod_i}; + my $infile = $mod{'in'}; + my $outfile = $mod{'out'}; + if ($mod{'folder'}) + { + if (!(-d $mod{'folder'})) + { + die "Folder " . $mod{'folder'} . " not found.\n"; + } + $infile = $mod{'folder'} . '/' . $infile; + $outfile = $mod{'folder'} . '/' . $outfile; + } + if (!(-f $infile)) + { + die "File $infile is not a file.\n"; + } + #Start rewriting + open(INFILE, $infile) or die "Could not open file for reading: $infile\n"; + open(OUTFILE, '>'.$outfile) or die "Could not open file for writing: $outfile\n"; + while () + { + s/\$PMAJOR\$/$major/g; + s/\$PMINOR\$/$minor/g; + s/\$PREVISION\$/$revision/g; + s/\$BUILD_ID\$/$rev/g; + s/\$BUILD_STRING\$/$buildstr/g; + print OUTFILE $_; + } + close(OUTFILE); + close(INFILE); +} +