Version: Have year in copyright use the current time at building

This commit is contained in:
zilmar 2022-05-23 06:37:30 +09:30
parent cc0c139f7e
commit 9cc35bbe0e
8 changed files with 51 additions and 21 deletions

View File

@ -6,6 +6,7 @@
#define VERSION_REVISION 0 #define VERSION_REVISION 0
#define VERSION_BUILD 9999 #define VERSION_BUILD 9999
#define VERSION_PREFIX "Dev-" #define VERSION_PREFIX "Dev-"
#define VERSION_BUILD_YEAR 2022
#define GIT_REVISION "" #define GIT_REVISION ""
#define GIT_REVISION_SHORT "" #define GIT_REVISION_SHORT ""
@ -25,7 +26,7 @@
#define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR
#define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll" #define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll"
#define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR #define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR
#define VER_COPYRIGHT_STR "Copyright (C) 2021" #define VER_COPYRIGHT_STR "Copyright (C) " STRINGIZE(VERSION_BUILD_YEAR)
#ifdef _DEBUG #ifdef _DEBUG
#define VER_VER_DEBUG VS_FF_DEBUG #define VER_VER_DEBUG VS_FF_DEBUG

View File

@ -696,7 +696,7 @@
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="N64System\Recompiler\x64-86\x64RegInfo.h"> <ClInclude Include="N64System\Recompiler\x64-86\x64RegInfo.h">
<Filter>Header Files</Filter> <Filter>Header Files\N64 System\Recompiler</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Debugger.h"> <ClInclude Include="Debugger.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>

View File

@ -6,6 +6,7 @@
#define VERSION_REVISION 0 #define VERSION_REVISION 0
#define VERSION_BUILD 9999 #define VERSION_BUILD 9999
#define VERSION_PREFIX "Dev-" #define VERSION_PREFIX "Dev-"
#define VERSION_BUILD_YEAR 2022
#define GIT_REVISION "" #define GIT_REVISION ""
#define GIT_REVISION_SHORT "" #define GIT_REVISION_SHORT ""
@ -25,7 +26,7 @@
#define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR
#define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".exe" #define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".exe"
#define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR #define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR
#define VER_COPYRIGHT_STR "Copyright (C) 2021" #define VER_COPYRIGHT_STR "Copyright (C) " STRINGIZE(VERSION_BUILD_YEAR)
#ifdef _DEBUG #ifdef _DEBUG
#define VER_VER_DEBUG VS_FF_DEBUG #define VER_VER_DEBUG VS_FF_DEBUG

View File

@ -6,6 +6,7 @@
#define VERSION_REVISION 0 #define VERSION_REVISION 0
#define VERSION_BUILD 9999 #define VERSION_BUILD 9999
#define VERSION_PREFIX "Dev-" #define VERSION_PREFIX "Dev-"
#define VERSION_BUILD_YEAR 2022
#define GIT_REVISION "" #define GIT_REVISION ""
#define GIT_REVISION_SHORT "" #define GIT_REVISION_SHORT ""
@ -25,7 +26,7 @@
#define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR
#define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll" #define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll"
#define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR #define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR
#define VER_COPYRIGHT_STR "Copyright (C) 2021" #define VER_COPYRIGHT_STR "Copyright (C) " STRINGIZE(VERSION_BUILD_YEAR)
#ifdef _DEBUG #ifdef _DEBUG
#define VER_VER_DEBUG VS_FF_DEBUG #define VER_VER_DEBUG VS_FF_DEBUG

View File

@ -6,6 +6,7 @@
#define VERSION_REVISION 0 #define VERSION_REVISION 0
#define VERSION_BUILD 9999 #define VERSION_BUILD 9999
#define VERSION_PREFIX "Dev-" #define VERSION_PREFIX "Dev-"
#define VERSION_BUILD_YEAR 2022
#define GIT_REVISION "" #define GIT_REVISION ""
#define GIT_REVISION_SHORT "" #define GIT_REVISION_SHORT ""
@ -25,7 +26,7 @@
#define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR
#define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll" #define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll"
#define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR #define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR
#define VER_COPYRIGHT_STR "Copyright (C) 2021" #define VER_COPYRIGHT_STR "Copyright (C) " STRINGIZE(VERSION_BUILD_YEAR)
#ifdef _DEBUG #ifdef _DEBUG
#define VER_VER_DEBUG VS_FF_DEBUG #define VER_VER_DEBUG VS_FF_DEBUG

View File

@ -6,6 +6,7 @@
#define VERSION_REVISION 0 #define VERSION_REVISION 0
#define VERSION_BUILD 9999 #define VERSION_BUILD 9999
#define VERSION_PREFIX "Dev-" #define VERSION_PREFIX "Dev-"
#define VERSION_BUILD_YEAR 2022
#define GIT_REVISION "" #define GIT_REVISION ""
#define GIT_REVISION_SHORT "" #define GIT_REVISION_SHORT ""
@ -25,7 +26,7 @@
#define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR
#define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll" #define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll"
#define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR #define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR
#define VER_COPYRIGHT_STR "Copyright (C) 2021" #define VER_COPYRIGHT_STR "Copyright (C) " STRINGIZE(VERSION_BUILD_YEAR)
#ifdef _DEBUG #ifdef _DEBUG
#define VER_VER_DEBUG VS_FF_DEBUG #define VER_VER_DEBUG VS_FF_DEBUG

View File

@ -1,8 +1,10 @@
#include <stdlib.h>
#include <memory>
#include <Common/path.h> #include <Common/path.h>
#include <Common/File.h> #include <Common/File.h>
#include <Common/StdString.h> #include <Common/StdString.h>
#include <Common/md5.h>
#include <stdlib.h>
#include <memory>
#include <time.h>
bool GitCommand(CPath & SourceDirectory, const char * Command, std::string & Output) bool GitCommand(CPath & SourceDirectory, const char * Command, std::string & Output)
{ {
@ -23,10 +25,8 @@ bool GitCommand(CPath & SourceDirectory, const char * Command, std::string & Out
} }
char buffer[128]; char buffer[128];
while (!feof(pipe)) while (!feof(pipe))
{ {
// use buffer to read and add to result
if (fgets(buffer, 128, pipe) != NULL) if (fgets(buffer, 128, pipe) != NULL)
{ {
Output += buffer; Output += buffer;
@ -122,11 +122,18 @@ int main()
return 0; return 0;
} }
MD5Digest DestHash;
if (DestFile.Exists()) if (DestFile.Exists())
{ {
if (!DestFile.Delete()) CFile OutFile(DestFile, CFileBase::modeRead);
if (OutFile.IsOpen())
{ {
return 0; uint32_t OutFileLen = OutFile.GetLength();
std::unique_ptr<uint8_t[]> data(new uint8_t[OutFileLen]);
if (OutFile.Read(data.get(), OutFileLen) != 0)
{
MD5(data.get(), OutFileLen).get_digest(DestHash);
}
} }
} }
@ -147,12 +154,6 @@ int main()
InFile.Read(InputData.get(), FileLen); InFile.Read(InputData.get(), FileLen);
strvector VersionData = stdstr(std::string((char *)InputData.get(), FileLen)).Tokenize("\n"); strvector VersionData = stdstr(std::string((char *)InputData.get(), FileLen)).Tokenize("\n");
CFile OutFile(DestFile, CFileBase::modeWrite | CFileBase::modeCreate);
if (!OutFile.IsOpen())
{
return 0;
}
uint32_t VersionMajor = 0, VersionMinor = 0, VersionRevison = 0; uint32_t VersionMajor = 0, VersionMinor = 0, VersionRevison = 0;
std::string VersionPrefix; std::string VersionPrefix;
for (size_t i = 0, n = VersionData.size(); i < n; i++) for (size_t i = 0, n = VersionData.size(); i < n; i++)
@ -194,6 +195,7 @@ int main()
n -= 1; n -= 1;
} }
std::string OutData;
for (size_t i = 0, n = VersionData.size(); i < n; i++) for (size_t i = 0, n = VersionData.size(); i < n; i++)
{ {
stdstr &line = VersionData[i]; stdstr &line = VersionData[i];
@ -202,10 +204,17 @@ int main()
{ {
line.Format("#define GIT_VERSION \"%s%s%s\"\n", RevisionShort.c_str(), BuildDirty ? "-" : "", BuildDirty ? "Dirty" : ""); line.Format("#define GIT_VERSION \"%s%s%s\"\n", RevisionShort.c_str(), BuildDirty ? "-" : "", BuildDirty ? "Dirty" : "");
} }
else if (_strnicmp(line.c_str(), "#define VERSION_BUILD", 21) == 0) else if (_strnicmp(line.c_str(), "#define VERSION_BUILD ", 22) == 0)
{ {
line.Format("#define VERSION_BUILD %d\n", VersionBuild); line.Format("#define VERSION_BUILD %d\n", VersionBuild);
} }
else if (_strnicmp(line.c_str(), "#define VERSION_BUILD_YEAR ", 27) == 0)
{
time_t now = time(NULL);
struct tm * tnow = gmtime(&now);
line.Format("#define VERSION_BUILD_YEAR %d\n", tnow->tm_year + 1900);
}
else if (_strnicmp(line.c_str(), "#define GIT_REVISION ", 21) == 0) else if (_strnicmp(line.c_str(), "#define GIT_REVISION ", 21) == 0)
{ {
line.Format("#define GIT_REVISION \"%s\"\n", Revision.c_str()); line.Format("#define GIT_REVISION \"%s\"\n", Revision.c_str());
@ -231,10 +240,25 @@ int main()
} }
line += "\"\n"; line += "\"\n";
} }
if (!OutFile.Write(line.c_str(), (uint32_t)line.length())) OutData += line.c_str();
}
MD5Digest OutHash;
MD5((const uint8_t *)OutData.c_str(), (unsigned int)OutData.length()).get_digest(OutHash);
if (memcmp(OutHash.digest, DestHash.digest, sizeof(DestHash.digest)) != 0)
{
if (DestFile.Exists() && !DestFile.Delete())
{ {
return 0; return 0;
} }
CFile OutFile(DestFile, CFileBase::modeWrite | CFileBase::modeCreate);
if (!OutFile.IsOpen())
{
return 0;
}
OutFile.Write(OutData.c_str(), (uint32_t)OutData.length());
} }
return 0; return 0;
} }

View File

@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define VERSION_REVISION 0 #define VERSION_REVISION 0
#define VERSION_BUILD 9999 #define VERSION_BUILD 9999
#define VERSION_PREFIX "Dev-" #define VERSION_PREFIX "Dev-"
#define VERSION_BUILD_YEAR 2022
#define GIT_REVISION "" #define GIT_REVISION ""
#define GIT_REVISION_SHORT "" #define GIT_REVISION_SHORT ""
@ -47,7 +48,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR
#define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll" #define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll"
#define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR #define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR
#define VER_COPYRIGHT_STR "Copyright (C) 2021" #define VER_COPYRIGHT_STR "Copyright (C) " STRINGIZE(VERSION_BUILD_YEAR)
#ifdef _DEBUG #ifdef _DEBUG
#define VER_VER_DEBUG VS_FF_DEBUG #define VER_VER_DEBUG VS_FF_DEBUG