From 11813ff5f269bce2775576fb19dfb1ae8a0bad25 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 25 Apr 2021 20:18:30 +0930 Subject: [PATCH] Update version number --- Source/Installer/Installer.iss | 6 +- Source/Project64-audio/Version.h.in | 13 +- Source/Project64-core/Project64-core.vcxproj | 3 + .../Project64-core.vcxproj.filters | 8 + Source/Project64-core/Version.h.in | 19 ++- Source/Project64-input/Version.h.in | 11 +- Source/Project64-video/Version.h.in | 13 +- Source/RSP/Version.h.in | 19 ++- Source/Script/SetGitProperties.cmd | 15 +- Source/UpdateVersion/UpdateVersion.cpp | 141 ++++++++++++++++-- Source/nragev20/Version.h.in | 21 +-- 11 files changed, 205 insertions(+), 64 deletions(-) diff --git a/Source/Installer/Installer.iss b/Source/Installer/Installer.iss index 7d0c180d5..28fde4054 100644 --- a/Source/Installer/Installer.iss +++ b/Source/Installer/Installer.iss @@ -5,11 +5,11 @@ AppId={{BEB5FB69-4080-466F-96C4-F15DF271718B} AppName=Project64 AppVersion={#AppVersion} -DefaultDirName={pf32}\Project64 2.3 +DefaultDirName={pf32}\Project64 Dev 3.0 VersionInfoVersion={#AppVersion} OutputDir={#BaseDir}\Bin\{#Configuration} -OutputBaseFilename=Setup Project64 2.3 -VersionInfoDescription=Installation Setup of Project64 2.3 +OutputBaseFilename=Setup Project64 Dev 3.0 +VersionInfoDescription=Installation Setup of Project64 Dev 3.0 Compression=lzma2/ultra64 WizardImageFile=Installer-Sidebar.bmp WizardSmallImageFile=Pj64LogoSmallImage.bmp diff --git a/Source/Project64-audio/Version.h.in b/Source/Project64-audio/Version.h.in index 6b7191081..38b7cc5f9 100644 --- a/Source/Project64-audio/Version.h.in +++ b/Source/Project64-audio/Version.h.in @@ -1,15 +1,20 @@ #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) -#define VERSION_MAJOR 1 +#define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 1 +#define VERSION_REVISION 0 #define VERSION_BUILD 9999 -#define GIT_VERSION "" +#define VERSION_PREFIX "Dev-" + +#define GIT_REVISION "" +#define GIT_REVISION_SHORT "" +#define GIT_DIRTY "" +#define GIT_VERSION "Unknown" #define VER_FILE_DESCRIPTION_STR "Project64-audio" #define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD -#define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \ +#define VER_FILE_VERSION_STR VERSION_PREFIX STRINGIZE(VERSION_MAJOR) \ "." STRINGIZE(VERSION_MINOR) \ "." STRINGIZE(VERSION_REVISION) \ "." STRINGIZE(VERSION_BUILD) \ diff --git a/Source/Project64-core/Project64-core.vcxproj b/Source/Project64-core/Project64-core.vcxproj index 108b4ff60..b5ea8a949 100644 --- a/Source/Project64-core/Project64-core.vcxproj +++ b/Source/Project64-core/Project64-core.vcxproj @@ -247,4 +247,7 @@ {1968162c-0793-491d-91a1-81645a24d399} + + + \ No newline at end of file diff --git a/Source/Project64-core/Project64-core.vcxproj.filters b/Source/Project64-core/Project64-core.vcxproj.filters index 1800e122d..b4cc7a264 100644 --- a/Source/Project64-core/Project64-core.vcxproj.filters +++ b/Source/Project64-core/Project64-core.vcxproj.filters @@ -348,6 +348,9 @@ Source Files\N64 System\Enhancement + + Source Files + @@ -669,4 +672,9 @@ Header Files\N64 System\Enhancement + + + Resource Files + + \ No newline at end of file diff --git a/Source/Project64-core/Version.h.in b/Source/Project64-core/Version.h.in index 8c49cf055..17c7716c0 100644 --- a/Source/Project64-core/Version.h.in +++ b/Source/Project64-core/Version.h.in @@ -1,21 +1,20 @@ #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) -#ifdef ANDROID -#define VERSION_MAJOR 2 -#define VERSION_MINOR 3 -#define VERSION_REVISION 3 -#else -#define VERSION_MAJOR 2 -#define VERSION_MINOR 4 +#define VERSION_MAJOR 3 +#define VERSION_MINOR 0 #define VERSION_REVISION 0 -#endif #define VERSION_BUILD 9999 -#define GIT_VERSION "" +#define VERSION_PREFIX "Dev-" + +#define GIT_REVISION "" +#define GIT_REVISION_SHORT "" +#define GIT_DIRTY "" +#define GIT_VERSION "Unknown" #define VER_FILE_DESCRIPTION_STR "Project64" #define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD -#define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \ +#define VER_FILE_VERSION_STR VERSION_PREFIX STRINGIZE(VERSION_MAJOR) \ "." STRINGIZE(VERSION_MINOR) \ "." STRINGIZE(VERSION_REVISION) \ "." STRINGIZE(VERSION_BUILD) \ diff --git a/Source/Project64-input/Version.h.in b/Source/Project64-input/Version.h.in index 00c3dfcc5..79defbcec 100644 --- a/Source/Project64-input/Version.h.in +++ b/Source/Project64-input/Version.h.in @@ -1,15 +1,20 @@ #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) -#define VERSION_MAJOR 1 +#define VERSION_MAJOR 3 #define VERSION_MINOR 0 #define VERSION_REVISION 0 #define VERSION_BUILD 9999 -#define GIT_VERSION "" +#define VERSION_PREFIX "Dev-" + +#define GIT_REVISION "" +#define GIT_REVISION_SHORT "" +#define GIT_DIRTY "" +#define GIT_VERSION "Unknown" #define VER_FILE_DESCRIPTION_STR "Project64-input" #define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD -#define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \ +#define VER_FILE_VERSION_STR VERSION_PREFIX STRINGIZE(VERSION_MAJOR) \ "." STRINGIZE(VERSION_MINOR) \ "." STRINGIZE(VERSION_REVISION) \ "." STRINGIZE(VERSION_BUILD) \ diff --git a/Source/Project64-video/Version.h.in b/Source/Project64-video/Version.h.in index c58f21bee..e7e4552d5 100644 --- a/Source/Project64-video/Version.h.in +++ b/Source/Project64-video/Version.h.in @@ -1,15 +1,20 @@ #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) -#define VERSION_MAJOR 2 -#define VERSION_MINOR 2 +#define VERSION_MAJOR 3 +#define VERSION_MINOR 0 #define VERSION_REVISION 0 #define VERSION_BUILD 9999 -#define GIT_VERSION "" +#define VERSION_PREFIX "Dev-" + +#define GIT_REVISION "" +#define GIT_REVISION_SHORT "" +#define GIT_DIRTY "" +#define GIT_VERSION "Unknown" #define VER_FILE_DESCRIPTION_STR "Project64-video" #define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD -#define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \ +#define VER_FILE_VERSION_STR VERSION_PREFIX STRINGIZE(VERSION_MAJOR) \ "." STRINGIZE(VERSION_MINOR) \ "." STRINGIZE(VERSION_REVISION) \ "." STRINGIZE(VERSION_BUILD) \ diff --git a/Source/RSP/Version.h.in b/Source/RSP/Version.h.in index 998b3fcb4..eaf0830f6 100644 --- a/Source/RSP/Version.h.in +++ b/Source/RSP/Version.h.in @@ -1,21 +1,26 @@ #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) -#define VERSION_MAJOR 1 -#define VERSION_MINOR 7 -#define VERSION_REVISION 4 +#define VERSION_MAJOR 3 +#define VERSION_MINOR 0 +#define VERSION_REVISION 0 #define VERSION_BUILD 9999 -#define GIT_VERSION "" +#define VERSION_PREFIX "Dev-" -#define VER_FILE_DESCRIPTION_STR "RSP emulation plugin" +#define GIT_REVISION "" +#define GIT_REVISION_SHORT "" +#define GIT_DIRTY "" +#define GIT_VERSION "Unknown" + +#define VER_FILE_DESCRIPTION_STR "Project64-RSP" #define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD -#define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \ +#define VER_FILE_VERSION_STR VERSION_PREFIX STRINGIZE(VERSION_MAJOR) \ "." STRINGIZE(VERSION_MINOR) \ "." STRINGIZE(VERSION_REVISION) \ "." STRINGIZE(VERSION_BUILD) \ "-" GIT_VERSION -#define VER_PRODUCTNAME_STR "RSP" +#define VER_PRODUCTNAME_STR "Project64-RSP" #define VER_PRODUCT_VERSION VER_FILE_VERSION #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR #define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll" diff --git a/Source/Script/SetGitProperties.cmd b/Source/Script/SetGitProperties.cmd index b2aec39c7..bbd83c8a3 100644 --- a/Source/Script/SetGitProperties.cmd +++ b/Source/Script/SetGitProperties.cmd @@ -6,24 +6,21 @@ cd /d %~dp0..\.. set base_dir=%cd% cd /d %origdir% -for /f %%i in ('git describe --tags --long') do set GIT_DESCRIBE=%%i > nul +for /f %%i in ('git rev-parse --short HEAD') do set GIT_REVISION_SHORT=%%i > nul +for /f %%i in ('git rev-list --count HEAD') do set GIT_BUILD_VERSION=%%i > nul -for /F "tokens=1,2,3 delims=-" %%i in ("%GIT_DESCRIBE%") do call :process_git_desc %%i %%j %%k for /F "tokens=1,2,3" %%i in (%base_dir%\Source\Project64-core\version.h.in) do call :process_version %%i %%j %%k -set VERSION=v%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_REVISION%-%VERSION_BUILD%-%VERSION_COMMIT% +set GIT_REVISION_SHORT=%GIT_REVISION_SHORT: =% +set GIT_BUILD_VERSION=%GIT_BUILD_VERSION: =% +set VERSION=%VERSION_PREFIX%%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_REVISION%-%GIT_BUILD_VERSION%-%GIT_REVISION_SHORT% echo %VERSION% echo GIT_DESCRIBE = %VERSION% > "%base_dir%\git.properties" goto :EOF - -:process_git_desc -set VERSION_BUILD=%2 -set VERSION_COMMIT=%3 -goto :EOF - :process_version if "%1" == "#define" if "%2" == "VERSION_MAJOR" set VERSION_MAJOR=%3 if "%1" == "#define" if "%2" == "VERSION_MINOR" set VERSION_MINOR=%3 if "%1" == "#define" if "%2" == "VERSION_REVISION" set VERSION_REVISION=%3 +if "%1" == "#define" if "%2" == "VERSION_PREFIX" set VERSION_PREFIX=%~3 goto :EOF diff --git a/Source/UpdateVersion/UpdateVersion.cpp b/Source/UpdateVersion/UpdateVersion.cpp index 36e72e874..ba05b0204 100644 --- a/Source/UpdateVersion/UpdateVersion.cpp +++ b/Source/UpdateVersion/UpdateVersion.cpp @@ -4,6 +4,111 @@ #include #include +bool GitCommand(CPath & SourceDirectory, const char * Command, std::string & Output) +{ + CPath CurrentDir(CPath::CURRENT_DIRECTORY); + if (CurrentDir != SourceDirectory) + { + SourceDirectory.ChangeDirectory(); + } + Output.clear(); + FILE * pipe = _popen(stdstr_f("git %s", Command).c_str(), "r"); + if (pipe == nullptr) + { + if (CurrentDir != SourceDirectory) + { + CurrentDir.ChangeDirectory(); + } + return false; + } + + char buffer[128]; + + while (!feof(pipe)) + { + // use buffer to read and add to result + if (fgets(buffer, 128, pipe) != NULL) + { + Output += buffer; + } + } + if (CurrentDir != SourceDirectory) + { + CurrentDir.ChangeDirectory(); + } + if (feof(pipe)) + { + _pclose(pipe); + return true; + } + return false; +} + +uint32_t GitBuildVersion(CPath & SourceDirectory) +{ + enum + { + DefaultBuildVersion = 9999 + }; + std::string Result; + if (!GitCommand(SourceDirectory, "rev-list --count HEAD", Result)) + { + return DefaultBuildVersion; + } + if (Result.empty()) + { + return DefaultBuildVersion; + } + uint32_t BuildVersion = atoi(Result.c_str()); + if (BuildVersion != 0) + { + return BuildVersion; + } + return 9999; +} + +bool GitBuildDirty(CPath & SourceDirectory) +{ + std::string Result; + if (!GitCommand(SourceDirectory, "diff --stat", Result)) + { + return false; + } + return !Result.empty(); +} + +std::string GitRevision(CPath & SourceDirectory) +{ + stdstr Result; + if (!GitCommand(SourceDirectory, "rev-parse HEAD", Result)) + { + return ""; + } + Result.Replace("\r", ""); + strvector ResultVector = Result.Tokenize("\n"); + if (ResultVector.size() > 0) + { + return ResultVector[0]; + } + return ""; +} + +std::string GitRevisionShort(CPath & SourceDirectory) +{ + stdstr Result; + if (!GitCommand(SourceDirectory, "rev-parse --short HEAD", Result)) + { + return ""; + } + Result.Replace("\r", ""); + strvector ResultVector = Result.Tokenize("\n"); + if (ResultVector.size() > 0) + { + return ResultVector[0]; + } + return ""; +} + int main() { if (__argc < 4) @@ -25,6 +130,12 @@ int main() } } + CPath SourceDirectory(SourceFile.GetDriveDirectory(), ""); + uint32_t VersionBuild = GitBuildVersion(SourceDirectory); + bool BuildDirty = GitBuildDirty(SourceDirectory); + std::string Revision = GitRevision(SourceDirectory); + std::string RevisionShort = GitRevisionShort(SourceDirectory); + CFile InFile(SourceFile, CFileBase::modeRead); if (!InFile.IsOpen()) { @@ -36,16 +147,6 @@ int main() InFile.Read(InputData.get(), FileLen); strvector VersionData = stdstr(std::string((char *)InputData.get(), FileLen)).Tokenize("\n"); - strvector verinfo = stdstr(__argv[3]).Tokenize('-'); - if (verinfo.size() < 3 || verinfo.size() > 4) - { - return 0; - } - if (verinfo.size() == 4) - { - verinfo[2] += "-" + verinfo[3]; - } - CFile OutFile(DestFile, CFileBase::modeWrite | CFileBase::modeCreate); if (!OutFile.IsOpen()) { @@ -56,13 +157,25 @@ int main() { stdstr &line = VersionData[i]; line += "\n"; - if (_strnicmp(line.c_str(), "#define VERSION_BUILD", 21) == 0) + if (_strnicmp(line.c_str(), "#define GIT_VERSION ", 20) == 0) { - line = "#define VERSION_BUILD " + verinfo[1] + "\n"; + line.Format("#define GIT_VERSION \"%s%s%s\"\n", RevisionShort.c_str(), BuildDirty ? "-" : "", BuildDirty ? "Dirty" : ""); } - if (_strnicmp(line.c_str(), "#define GIT_VERSION", 18) == 0) + else if (_strnicmp(line.c_str(), "#define VERSION_BUILD", 21) == 0) { - line = "#define GIT_VERSION \"" + verinfo[2] + "\"\n"; + line.Format("#define VERSION_BUILD %d\n", VersionBuild); + } + else if (_strnicmp(line.c_str(), "#define GIT_REVISION ", 21) == 0) + { + line.Format("#define GIT_REVISION \"%s\"\n", Revision.c_str()); + } + else if (_strnicmp(line.c_str(), "#define GIT_REVISION_SHORT ", 26) == 0) + { + line.Format("#define GIT_REVISION_SHORT \"%s\"\n", RevisionShort.c_str()); + } + else if (_strnicmp(line.c_str(), "#define GIT_DIRTY ", 11) == 0) + { + line.Format("#define GIT_DIRTY \"%s\"\n", BuildDirty ? "Dirty" : ""); } if (!OutFile.Write(line.c_str(), (uint32_t)line.length())) { diff --git a/Source/nragev20/Version.h.in b/Source/nragev20/Version.h.in index 4dc7e828e..71f953022 100644 --- a/Source/nragev20/Version.h.in +++ b/Source/nragev20/Version.h.in @@ -23,19 +23,20 @@ #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) -#define VERSION_MAJOR 2 -#define VERSION_MINOR 5 -#define VERSION_REVISION 3 -#ifndef VERSION_BUILD +#define VERSION_MAJOR 3 +#define VERSION_MINOR 0 +#define VERSION_REVISION 0 #define VERSION_BUILD 9999 -#endif -#ifndef GIT_VERSION -#define GIT_VERSION "" -#endif +#define VERSION_PREFIX "Dev-" + +#define GIT_REVISION "" +#define GIT_REVISION_SHORT "" +#define GIT_DIRTY "" +#define GIT_VERSION "Unknown" #define VER_FILE_DESCRIPTION_STR "N-Rage for Project64" #define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD -#define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \ +#define VER_FILE_VERSION_STR VERSION_PREFIX STRINGIZE(VERSION_MAJOR) \ "." STRINGIZE(VERSION_MINOR) \ "." STRINGIZE(VERSION_REVISION) \ "." STRINGIZE(VERSION_BUILD) \ @@ -46,7 +47,7 @@ #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR #define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll" #define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR -#define VER_COPYRIGHT_STR "Copyright (C) 2017" +#define VER_COPYRIGHT_STR "Copyright (C) 2021" #ifdef _DEBUG #define VER_VER_DEBUG VS_FF_DEBUG