diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/SystemConfig.h | 10 | ||||
-rw-r--r-- | src/shared/SystemConfig.h.in | 54 | ||||
-rw-r--r-- | src/shared/revision.h.in | 4 | ||||
-rw-r--r-- | src/tools/genrevision/genrevision.cpp | 206 | ||||
-rw-r--r-- | src/trinitycore/Main.cpp | 2 | ||||
-rw-r--r-- | src/trinityrealm/Main.cpp | 2 |
6 files changed, 181 insertions, 97 deletions
diff --git a/src/shared/SystemConfig.h b/src/shared/SystemConfig.h index aeb38891c11..9e7fe3e3045 100644 --- a/src/shared/SystemConfig.h +++ b/src/shared/SystemConfig.h @@ -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 diff --git a/src/shared/SystemConfig.h.in b/src/shared/SystemConfig.h.in deleted file mode 100644 index aeb38891c11..00000000000 --- a/src/shared/SystemConfig.h.in +++ /dev/null @@ -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 diff --git a/src/shared/revision.h.in b/src/shared/revision.h.in deleted file mode 100644 index a84170529eb..00000000000 --- a/src/shared/revision.h.in +++ /dev/null @@ -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__ diff --git a/src/tools/genrevision/genrevision.cpp b/src/tools/genrevision/genrevision.cpp index 1c58e82f85d..f9abc71b47a 100644 --- a/src/tools/genrevision/genrevision.cpp +++ b/src/tools/genrevision/genrevision.cpp @@ -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); } } diff --git a/src/trinitycore/Main.cpp b/src/trinitycore/Main.cpp index 4c85ecd6d68..d24ae02d426 100644 --- a/src/trinitycore/Main.cpp +++ b/src/trinitycore/Main.cpp @@ -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" diff --git a/src/trinityrealm/Main.cpp b/src/trinityrealm/Main.cpp index 3e2739ec6b5..274aabf0717 100644 --- a/src/trinityrealm/Main.cpp +++ b/src/trinityrealm/Main.cpp @@ -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" |