Add "ExtraVersion" version number information.
The "ExtraVersion" can be used for things like Git commit Id, release tag (version control), release date etc. If the string is empty, nothing is printed.
This commit is contained in:
parent
04d4215116
commit
9e2dd553fb
|
@ -24,6 +24,7 @@
|
|||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <cstdlib> // EXIT_SUCCESS and EXIT_FAILURE
|
||||
#include <cstring>
|
||||
#include "cmdlineparser.h"
|
||||
#include "filelister.h"
|
||||
#include "path.h"
|
||||
|
@ -50,7 +51,12 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
|||
{
|
||||
if (parser.GetShowVersion() && !parser.GetShowErrorMessages())
|
||||
{
|
||||
std::cout << "Cppcheck " << cppcheck->version() << std::endl;
|
||||
const char * extraVersion = cppcheck->extraVersion();
|
||||
if (strlen(extraVersion) > 0)
|
||||
std::cout << "Cppcheck " << cppcheck->version() << " ("
|
||||
<< extraVersion << ")" << std::endl;
|
||||
else
|
||||
std::cout << "Cppcheck " << cppcheck->version() << std::endl;
|
||||
}
|
||||
|
||||
if (parser.GetShowErrorMessages())
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
#include <pcre.h>
|
||||
#endif
|
||||
|
||||
static const char Version[] = "1.49";
|
||||
static const char ExtraVersion[] = "";
|
||||
|
||||
static TimerResults S_timerResults;
|
||||
|
||||
CppCheck::CppCheck(ErrorLogger &errorLogger, bool useGlobalSuppressions)
|
||||
|
@ -56,7 +59,12 @@ void CppCheck::settings(const Settings ¤tSettings)
|
|||
|
||||
const char * CppCheck::version()
|
||||
{
|
||||
return "1.49";
|
||||
return Version;
|
||||
}
|
||||
|
||||
const char * CppCheck::extraVersion()
|
||||
{
|
||||
return ExtraVersion;
|
||||
}
|
||||
|
||||
unsigned int CppCheck::check(const std::string &path)
|
||||
|
|
|
@ -105,6 +105,14 @@ public:
|
|||
*/
|
||||
static const char * version();
|
||||
|
||||
/**
|
||||
* @brief Returns extra version info as a string.
|
||||
* This is for returning extra version info, like Git commit id, build
|
||||
* time/date etc.
|
||||
* @return extra version info, e.g. "04d42151" (Git commit id).
|
||||
*/
|
||||
static const char * extraVersion();
|
||||
|
||||
virtual void reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue