Some changes for genrevision

--HG--
branch : trunk
This commit is contained in:
Blaymoira committed 2009-01-18 13:08:42 +01:00
1 parent b5b109d3ff
commit 9c9311c781
11 files changed
+184 -275

No files matched your search

+5 -5
View File
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
*
* Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
@@ -25,7 +25,7 @@
#define TRINITY_SYSTEMCONFIG_H
#include "Platform/Define.h"
#include "revision.h" //-----here u are ------ _REVISION is the magic key
#include "revision.h"
#define _PACKAGENAME "TrinityCore "
@@ -39,12 +39,12 @@
#if PLATFORM == PLATFORM_WINDOWS
# ifdef _WIN64
# define _FULLVERSION _PACKAGENAME "Rev: " _REVISION " (Win64," _ENDIAN_STRING ")"
# define _FULLVERSION _PACKAGENAME "Rev: " _REVISION " Hash: " _HASH " (Win64," _ENDIAN_STRING ")"
# else
# define _FULLVERSION _PACKAGENAME "Rev: " _REVISION " (Win32," _ENDIAN_STRING ")"
# define _FULLVERSION _PACKAGENAME "Rev: " _REVISION " Hash: " _HASH " (Win32," _ENDIAN_STRING ")"
# endif
#else
# define _FULLVERSION _PACKAGENAME "Rev: " _REVISION " (Unix," _ENDIAN_STRING ")"
# define _FULLVERSION _PACKAGENAME "Rev: " _REVISION " Hash: " _HASH " (Unix," _ENDIAN_STRING ")"
#endif
#define DEFAULT_PLAYER_LIMIT 100
-54
View File
@@ -1,54 +0,0 @@
/*
* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
*
* Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
*
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// THIS FILE IS DEPRECATED
#ifndef TRINITY_SYSTEMCONFIG_H
#define TRINITY_SYSTEMCONFIG_H
#include "Platform/Define.h"
#include "revision.h" //-----here u are ------ _REVISION is the magic key
#define _PACKAGENAME "TrinityCore "
#define _CODENAME "YUME"
#if TRINITY_ENDIAN == TRINITY_BIGENDIAN
# define _ENDIAN_STRING "big-endian"
#else
# define _ENDIAN_STRING "little-endian"
#endif
#if PLATFORM == PLATFORM_WINDOWS
# ifdef _WIN64
# define _FULLVERSION _PACKAGENAME "Rev: " _REVISION " (Win64," _ENDIAN_STRING ")"
# else
# define _FULLVERSION _PACKAGENAME "Rev: " _REVISION " (Win32," _ENDIAN_STRING ")"
# endif
#else
# define _FULLVERSION _PACKAGENAME "Rev: " _REVISION " (Unix," _ENDIAN_STRING ")"
#endif
#define DEFAULT_PLAYER_LIMIT 100
#define DEFAULT_WORLDSERVER_PORT 8085 //8129
#define DEFAULT_REALMSERVER_PORT 3724
#define DEFAULT_SOCKET_SELECT_TIME 10000
#endif
-4
View File
@@ -1,4 +0,0 @@
#ifndef __SVN_REVISION_H__
#define __SVN_REVISION_H__
#define _REVISION "794" //change this to your current revision
#endif // __SVN_REVISION_H__
+174 -32
View File
@@ -24,9 +24,9 @@
#pragma warning(disable:4996)
/*
struct RawData
{
char hash_str[200];
char rev_str[200];
char date_str[200];
char time_str[200];
@@ -56,6 +56,45 @@ void extractDataFromSvn(FILE* EntriesFile, bool url, RawData& data)
strcpy(data.rev_str,num_str);
}
void extractDataFromHG(FILE* EntriesFile, std::string path, bool url, RawData& data)
{
char buf[200];
char hash_str[200];
char revision_str[200];
bool found = false;
while(fgets(buf,200,EntriesFile))
{
if(sscanf(buf,"%s %s",hash_str,revision_str)==2)
{
found = true;
break;
}
}
if(!found)
{
strcpy(data.hash_str,"*");
strcpy(data.rev_str,"*");
strcpy(data.date_str,"*");
strcpy(data.time_str,"*");
return;
}
char thash_str[200];
for(int i = 11;i >= 0; --i)
{
thash_str[i] = hash_str[i];
}
strcpy(data.hash_str,thash_str);
strcpy(data.rev_str,revision_str);
strcpy(data.date_str,"*");
strcpy(data.time_str,"*");
}
void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData& data)
{
char buf[200];
@@ -76,6 +115,7 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData&
if(!found)
{
strcpy(data.hash_str,"*");
strcpy(data.rev_str,"*");
strcpy(data.date_str,"*");
strcpy(data.time_str,"*");
@@ -117,6 +157,7 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData&
}
else
strcpy(data.rev_str,hash_str);
strcpy(data.hash_str,"*");
time_t rev_time = 0;
// extracting date/time
@@ -188,54 +229,154 @@ bool extractDataFromGit(std::string filename, std::string path, bool url, RawDat
return true;
}
std::string generateHeader(char const* rev_str, char const* date_str, char const* time_str)
bool extractDataFromHG(std::string filename, std::string path, bool url, RawData& data)
{
FILE* EntriesFile = fopen(filename.c_str(), "r");
if(!EntriesFile)
return false;
extractDataFromHG(EntriesFile,path,url,data);
fclose(EntriesFile);
return true;
}
std::string generateHeader(char const* rev_str, char const* date_str, char const* time_str, char const* hash_str)
{
std::ostringstream newData;
newData << "#ifndef __REVISION_H__" << std::endl;
newData << "#define __REVISION_H__" << std::endl;
newData << " #define REVISION_ID \"" << rev_str << "\"" << std::endl;
newData << " #define REVISION_DATE \"" << date_str << "\"" << std::endl;
newData << " #define REVISION_TIME \"" << time_str << "\""<< std::endl;
newData << " #define _REVISION \"" << rev_str << "\"" << std::endl;
newData << " #define _HASH \"" << hash_str << "\"" << std::endl;
newData << " #define _REVISION_DATE \"" << date_str << "\"" << std::endl;
newData << " #define _REVISION_TIME \"" << time_str << "\""<< std::endl;
newData << "#endif // __REVISION_H__" << std::endl;
return newData.str();
}
*/
int main(int argc, char **argv)
{
bool use_url = false;
bool hg_prefered = true;
bool git_prefered = false;
bool svn_prefered = false;
std::string path;
if(argc >= 1 && argv[1] )
// Call: tool {options} [path]
// -h use hg prefered (default)
// -g use git prefered
// -s use svn prefered
// -r use only revision (without repo URL) (default)
// -u include repositire URL as commit URL or "rev at URL"
for(int k = 1; k <= argc; ++k)
{
path = argv[1];
if(path.size() > 0 && (path[path.size()-1]!='/' || path[path.size()-1]!='\\'))
path += '/';
if(!argv[k] || !*argv[k])
break;
if(argv[k][0]!='-')
{
path = argv[k];
if(path.size() > 0 && (path[path.size()-1]!='/' || path[path.size()-1]!='\\'))
path += '/';
break;
}
switch(argv[k][1])
{
case 'h':
hg_prefered = true;
git_prefered = false;
svn_prefered = false;
continue;
case 'g':
hg_prefered = false;
git_prefered = true;
svn_prefered = false;
continue;
case 'r':
use_url = false;
continue;
case 's':
hg_prefered = false;
git_prefered = false;
svn_prefered = true;
continue;
case 'u':
use_url = true;
continue;
default:
printf("Unknown option %s",argv[k]);
return 1;
}
}
FILE* EntriesFile = fopen((path+".hg/branch.cache").c_str(), "r");
if(!EntriesFile)
EntriesFile = fopen((path+"_hg/branch.cache").c_str(), "r");
std::ostringstream newData;
/// new data extraction
std::string newData;
if(!EntriesFile)
{
newData << "#ifndef __SVN_REVISION_H__" << std::endl;
newData << "#define __SVN_REVISION_H__" << std::endl;
newData << " #define _REVISION \"Unknown\"" << std::endl;
newData << "#endif // __SVN_REVISION_H__" << std::endl;
}
else
{
char revision[100];
char temp[100];
fscanf(EntriesFile,"%s%s",temp, &revision);
newData << "#ifndef __SVN_REVISION_H__" << std::endl;
newData << "#define __SVN_REVISION_H__" << std::endl;
newData << " #define _REVISION \"" << revision << "\"" << std::endl;
newData << "#endif // __SVN_REVISION_H__" << std::endl;
fclose(EntriesFile);
RawData data;
bool res = false;
if(svn_prefered)
{
/// SVN data
res = extractDataFromSvn(path+".svn/entries",use_url,data);
if (!res)
res = extractDataFromSvn(path+"_svn/entries",use_url,data);
// HG data
if (!res)
res = extractDataFromHG(path+".hg/branch.cache",path,use_url,data);
if (!res)
res = extractDataFromHG(path+"_hg/branch.cache",path,use_url,data);
// GIT data
if (!res)
res = extractDataFromGit(path+".git/FETCH_HEAD",path,use_url,data);
if (!res)
res = extractDataFromGit(path+"_git/FETCH_HEAD",path,use_url,data);
}
else if(git_prefered)
{
// GIT data
res = extractDataFromGit(path+".git/FETCH_HEAD",path,use_url,data);
if (!res)
res = extractDataFromGit(path+"_git/FETCH_HEAD",path,use_url,data);
// HG data
if (!res)
res = extractDataFromHG(path+".hg/branch.cache",path,use_url,data);
if (!res)
res = extractDataFromHG(path+"_hg/branch.cache",path,use_url,data);
/// SVN data
if (!res)
res = extractDataFromSvn(path+".svn/entries",use_url,data);
if (!res)
res = extractDataFromSvn(path+"_svn/entries",use_url,data);
}
else if(hg_prefered)
{
// HG data
res = extractDataFromHG(path+".hg/branch.cache",path,use_url,data);
if (!res)
res = extractDataFromHG(path+"_hg/branch.cache",path,use_url,data);
/// SVN data
if (!res)
res = extractDataFromSvn(path+".svn/entries",use_url,data);
if (!res)
res = extractDataFromSvn(path+"_svn/entries",use_url,data);
// GIT data
if (!res)
res = extractDataFromGit(path+".git/FETCH_HEAD",path,use_url,data);
if (!res)
res = extractDataFromGit(path+"_git/FETCH_HEAD",path,use_url,data);
}
if(res)
newData = generateHeader(data.rev_str,data.date_str,data.time_str,data.hash_str);
else
newData = generateHeader("*", "*", "*", "*");
}
/// get existed header data for compare
std::string oldData;
if(FILE* HeaderFile = fopen("revision.h","rb"))
@@ -251,11 +392,12 @@ int main(int argc, char **argv)
fclose(HeaderFile);
}
if(newData.str() != oldData)
/// update header only if different data
if(newData != oldData)
{
if(FILE* OutputFile = fopen("revision.h","wb"))
{
fprintf(OutputFile,"%s",newData.str().c_str());
fprintf(OutputFile,"%s",newData.c_str());
fclose(OutputFile);
}
}
+1 -1
View File
@@ -64,7 +64,7 @@ uint32 realmID; ///< Id of the realm
void usage(const char *prog)
{
sLog.outString("Usage: \n %s [<options>]\n"
" --version print version and exist\n\r"
" --version print version and exit\n\r"
" -c config_file use config_file as configuration file\n\r"
#ifdef WIN32
" Running as service functions:\n\r"
+1 -1
View File
@@ -71,7 +71,7 @@ DatabaseType LoginDatabase; ///< Accessor to the
void usage(const char *prog)
{
sLog.outString("Usage: \n %s [<options>]\n"
" --version print version and exist\n\r"
" --version print version and exit\n\r"
" -c config_file use config_file as configuration file\n\r"
#ifdef WIN32
" Running as service functions:\n\r"
+1 -4
View File
@@ -8,6 +8,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "VC71\shared.vcpro
ProjectSection(ProjectDependencies) = postProject
{BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E} = {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
{803F488E-4C5A-4866-8D5C-1E6C03C007C2} = {803F488E-4C5A-4866-8D5C-1E6C03C007C2}
{7C74F49E-FECA-1BAD-6757-8A6348EA12C8} = {7C74F49E-FECA-1BAD-6757-8A6348EA12C8}
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
{DE0380F9-C910-4E99-A841-93550D0E61D7} = {DE0380F9-C910-4E99-A841-93550D0E61D7}
@@ -112,12 +113,8 @@ Global
{7C74F49E-FECA-1BAD-6757-8A6348EA12C8}.Release.Build.0 = Release|Win32
{803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug|Win32.ActiveCfg = Debug|Win32
{803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug|Win32.Build.0 = Debug|Win32
{803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug|x64.ActiveCfg = Debug|x64
{803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Debug|x64.Build.0 = Debug|x64
{803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release|Win32.ActiveCfg = Release|Win32
{803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release|Win32.Build.0 = Release|Win32
{803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release|x64.ActiveCfg = Release|x64
{803F488E-4C5A-4866-8D5C-1E6C03C007C2}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
+1
View File
@@ -9,6 +9,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "VC80\shared.vcpro
ProjectSection(ProjectDependencies) = postProject
{BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E} = {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}
{AD537C9A-FECA-1BAD-6757-8A6348EA12C8} = {AD537C9A-FECA-1BAD-6757-8A6348EA12C8}
{803F488E-4C5A-4866-8D5C-1E6C03C007C2} = {803F488E-4C5A-4866-8D5C-1E6C03C007C2}
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
{8072769E-CF10-48BF-B9E1-12752A5DAC6E} = {8072769E-CF10-48BF-B9E1-12752A5DAC6E}
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
+1
View File
@@ -9,6 +9,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "VC90\shared.vcpro
ProjectSection(ProjectDependencies) = postProject
{BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E} = {BF6F5D0E-33A5-4E23-9E7D-DD481B7B5B9E}
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
{803F488E-4C5A-4866-8D5C-1E6C03C007C2} = {803F488E-4C5A-4866-8D5C-1E6C03C007C2}
{BD537C9A-FECA-1BAD-6757-8A6348EA12C8} = {BD537C9A-FECA-1BAD-6757-8A6348EA12C8}
{8072769E-CF10-48BF-B9E1-12752A5DAC6E} = {8072769E-CF10-48BF-B9E1-12752A5DAC6E}
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
-152
View File
@@ -12,9 +12,6 @@
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
@@ -166,155 +163,6 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory=".\gensvnrevision__$(PlatformName)_$(ConfigurationName)"
IntermediateDirectory=".\gensvnrevision__$(PlatformName)_$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
CallingConvention="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory=".\gensvnrevision__$(PlatformName)_$(ConfigurationName)"
IntermediateDirectory=".\gensvnrevision__$(PlatformName)_$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
CallingConvention="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
-22
View File
@@ -444,28 +444,6 @@
Outputs="revision.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCustomBuildTool"
Description="Getting Version... :)"
CommandLine="cd $(InputDir)&#x0D;&#x0A;&quot;$(TargetDir)\..\genrevision__$(PlatformName)_$(ConfigurationName)\genrevision.exe&quot; &quot;..\..&quot;&#x0D;&#x0A;"
AdditionalDependencies="$(SolutionDir)../.hg/branch.cache"
Outputs="revision.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCustomBuildTool"
Description="Getting Version... :)"
CommandLine="cd $(InputDir)&#x0D;&#x0A;&quot;$(TargetDir)\..\genrevision__$(PlatformName)_$(ConfigurationName)\genrevision.exe&quot; &quot;..\..&quot;&#x0D;&#x0A;"
AdditionalDependencies="$(SolutionDir)../.hg/branch.cache"
Outputs="revision.h"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\shared\ServiceWin32.cpp">