Merge remote-tracking branch 'origin/semver' into 88-semantic-versioning

This commit is contained in:
/dev/urandom 2016-09-03 19:12:32 +02:00
commit ef07fb5f2a
No known key found for this signature in database
GPG Key ID: 41322B973E0F295E
10 changed files with 90 additions and 71 deletions

View File

@ -1,3 +1,5 @@
gitVersioningCommand = "git describe --tags --dirty --always"
-- Quote the given string input as a C string -- Quote the given string input as a C string
function cstrquote(value) function cstrquote(value)
result = value:gsub("\\", "\\\\") result = value:gsub("\\", "\\\\")
@ -11,6 +13,19 @@ function cstrquote(value)
return result return result
end end
-- Converts tags in "vX.X.X" format to X,X,X.
-- In the case where the format does not work fall back to old 4,2,REVISION.
function vertonum(value, vernumber)
vernum = {}
for num in string.gmatch(value, "%d+") do
table.insert(vernum, num)
end
if #vernum < 3 then
return "4,2," .. vernumber
end
return vernum[1] .. "," .. vernum[2] .. "," .. vernum[3]
end
-- Option to allow copying the DLL file to a custom folder after build -- Option to allow copying the DLL file to a custom folder after build
newoption { newoption {
trigger = "copy-to", trigger = "copy-to",
@ -57,10 +72,12 @@ newoption {
trigger = "disable-bitmessage", trigger = "disable-bitmessage",
description = "Disable use of BitMessage completely." description = "Disable use of BitMessage completely."
} }
newoption { newoption {
trigger = "disable-node-log", trigger = "disable-node-log",
description = "Disable debugging messages for Nodes in Debug builds." description = "Disable debugging messages for Nodes in Debug builds."
} }
newoption { newoption {
trigger = "disable-base128", trigger = "disable-base128",
description = "Disable debugging messages for Nodes in Debug builds." description = "Disable debugging messages for Nodes in Debug builds."
@ -70,12 +87,12 @@ newaction {
trigger = "version", trigger = "version",
description = "Returns the version string for the current commit of the source code.", description = "Returns the version string for the current commit of the source code.",
onWorkspace = function(wks) onWorkspace = function(wks)
-- get revision number via git -- get current version via git
local proc = assert(io.popen("git rev-list --count HEAD", "r")) local proc = assert(io.popen(gitVersioningCommand, "r"))
local revNumber = assert(proc:read('*a')):gsub("%s+", "") local gitDescribeOutput = assert(proc:read('*a')):gsub("%s+", "")
proc:close() proc:close()
print(revNumber) print(gitDescribeOutput)
os.exit(0) os.exit(0)
end end
} }
@ -87,60 +104,73 @@ newaction {
-- get revision number via git -- get revision number via git
local proc = assert(io.popen("git rev-list --count HEAD", "r")) local proc = assert(io.popen("git rev-list --count HEAD", "r"))
local revNumber = assert(proc:read('*a')):gsub("%s+", "") local revNumber = assert(proc:read('*a')):gsub("%s+", "")
-- get current version via git
local proc = assert(io.popen(gitVersioningCommand, "r"))
local gitDescribeOutput = assert(proc:read('*a')):gsub("%s+", "")
proc:close() proc:close()
-- get whether this is a clean revision (no uncommitted changes) -- get whether this is a clean revision (no uncommitted changes)
proc = assert(io.popen("git status --porcelain", "r")) proc = assert(io.popen("git status --porcelain", "r"))
local revClean = 1 local revDirty = (assert(proc:read('*a')) ~= "")
local revCleanSuffix = "" if revDirty then revDirty = 1 else revDirty = 0 end
if assert(proc:read('*a')) ~= "" then
revClean = 0
revCleanSuffix = " (unclean)"
end
proc:close() proc:close()
-- get current tag name (aka milestone for now) -- get current tag name (aka milestone for now)
proc = assert(io.popen("git tag")) proc = assert(io.popen("git describe --tags --abbrev=0"))
local tagName = assert(proc:read('*l')) local tagName = assert(proc:read('*l'))
-- get old version number from version.hpp if any -- get old version number from version.hpp if any
local oldRevNumber = "(none)" local oldVersion = "(none)"
local oldRevClean = 1 local oldVersionHeader = io.open(wks.location .. "/src/version.h", "r")
local oldRevCleanSuffix = "" if oldVersionHeader ~= nil then
local oldVersionHeader = io.open(wks.location .. "/src/version.hpp", "r") local oldVersionHeaderContent = assert(oldVersionHeader:read('*l'))
if oldVersionHeader ~=nil then while oldVersionHeaderContent do
local oldVersionHeaderContent = assert(oldVersionHeader:read('*a')) m = string.match(oldVersionHeaderContent, "#define GIT_DESCRIBE (.+)%s*$")
oldRevNumber = string.match(oldVersionHeaderContent, "#define REVISION (%d+)") if m ~= nil then
if oldRevNumber == nil then oldVersion = m
-- old version.hpp format?
oldRevNumber = "(none)"
end end
oldRevClean = string.match(oldVersionHeaderContent, "#define REVISION_CLEAN (%d+)")
if oldRevClean == nil then oldVersionHeaderContent = oldVersionHeader:read('*l')
-- old version.hpp format?
oldRevClean = 1
elseif oldRevClean ~= "1" then
oldRevClean = 0
else
oldRevClean = 1
end end
end end
if oldRevClean == 0 then
oldRevCleanSuffix = " (unclean)"
end
-- generate version.hpp with a revision number if not equal -- generate version.hpp with a revision number if not equal
if oldRevNumber ~= revNumber or oldRevClean ~= revClean then gitDescribeOutputQuoted = cstrquote(gitDescribeOutput)
print ("Update " .. oldRevNumber .. oldRevCleanSuffix .. " -> " .. revNumber .. revCleanSuffix) if oldVersion ~= gitDescribeOutputQuoted then
local versionHeader = assert(io.open(wks.location .. "/src/version.hpp", "w")) print ("Update " .. oldVersion .. " -> " .. gitDescribeOutputQuoted)
local versionHeader = assert(io.open(wks.location .. "/src/version.h", "w"))
versionHeader:write("/*\n") versionHeader:write("/*\n")
versionHeader:write(" * Automatically generated by premake5.\n") versionHeader:write(" * Automatically generated by premake5.\n")
versionHeader:write(" * Do not touch, you fucking moron!\n") versionHeader:write(" * Do not touch, you fucking moron!\n")
versionHeader:write(" */\n") versionHeader:write(" */\n")
versionHeader:write("\n") versionHeader:write("\n")
versionHeader:write("#define GIT_DESCRIBE " .. gitDescribeOutputQuoted .. "\n")
versionHeader:write("#define GIT_DIRTY " .. revDirty .. "\n")
versionHeader:write("#define GIT_TAG " .. cstrquote(tagName) .. "\n")
versionHeader:write("\n")
versionHeader:write("// Legacy definitions (needed for update check)\n")
versionHeader:write("#define REVISION " .. revNumber .. "\n") versionHeader:write("#define REVISION " .. revNumber .. "\n")
versionHeader:write("#define REVISION_CLEAN " .. revClean .. "\n") versionHeader:write("\n")
versionHeader:write("#define MILESTONE " .. cstrquote(tagName) .. "\n") versionHeader:write("// Version transformed for RC files\n")
versionHeader:write("#define VERSION_RC " .. vertonum(tagName, revNumber) .. "\n")
versionHeader:write("\n")
versionHeader:write("// Alias definitions\n")
versionHeader:write("#define VERSION GIT_DESCRIBE\n")
versionHeader:write("#define SHORTVERSION GIT_TAG\n")
versionHeader:close()
local versionHeader = assert(io.open(wks.location .. "/src/version.hpp", "w"))
versionHeader:write("/*\n")
versionHeader:write(" * Automatically generated by premake5.\n")
versionHeader:write(" * Do not touch, you fucking moron!\n")
versionHeader:write(" *\n")
versionHeader:write(" * This file exists for reasons of complying with our coding standards.\n")
versionHeader:write(" *\n")
versionHeader:write(" * The Resource Compiler will ignore any content from C++ header files if they're not from STDInclude.hpp.\n")
versionHeader:write(" * That's the reason why we now place all version info in version.h instead.\n")
versionHeader:write(" */\n")
versionHeader:write("\n")
versionHeader:write("#include \".\\version.h\"\n")
versionHeader:close() versionHeader:close()
end end
end end

View File

@ -77,14 +77,14 @@ namespace Components
} }
else if(IsWindow(*reinterpret_cast<HWND*>(0x64A3288)) != FALSE) else if(IsWindow(*reinterpret_cast<HWND*>(0x64A3288)) != FALSE)
{ {
SetWindowTextA(*reinterpret_cast<HWND*>(0x64A3288), Utils::String::VA("IW4x(r" REVISION_STR REVISION_SUFFIX ") : %s", hostname.data())); SetWindowTextA(*reinterpret_cast<HWND*>(0x64A3288), Utils::String::VA("IW4x(" VERSION ") : %s", hostname.data()));
} }
} }
void Console::ShowPrompt() void Console::ShowPrompt()
{ {
wattron(Console::InputWindow, COLOR_PAIR(10) | A_BOLD); wattron(Console::InputWindow, COLOR_PAIR(10) | A_BOLD);
wprintw(Console::InputWindow, "%s> ", VERSION_STR); wprintw(Console::InputWindow, "%s> ", VERSION);
} }
void Console::RefreshOutput() void Console::RefreshOutput()
@ -486,7 +486,7 @@ namespace Components
Console::Console() Console::Console()
{ {
// Console '%s: %s> ' string // Console '%s: %s> ' string
Utils::Hook::Set<char*>(0x5A44B4, "IW4x: r" REVISION_STR "> "); Utils::Hook::Set<char*>(0x5A44B4, "IW4x: " VERSION "> ");
// Internal console // Internal console
Utils::Hook(0x4F690C, Console::ToggleConsole, HOOK_CALL).Install()->Quick(); Utils::Hook(0x4F690C, Console::ToggleConsole, HOOK_CALL).Install()->Quick();

View File

@ -204,7 +204,7 @@ namespace Components
// Combine with queuedMinidumpsFolder // Combine with queuedMinidumpsFolder
char filename[MAX_PATH]; char filename[MAX_PATH];
PathCombineA(filename, MinidumpUpload::queuedMinidumpsFolder.data(), Utils::String::VA("%s-" VERSION_STR "-%s.dmp", exeFileName, filenameFriendlyTime)); PathCombineA(filename, MinidumpUpload::queuedMinidumpsFolder.data(), Utils::String::VA("%s-" VERSION "-%s.dmp", exeFileName, filenameFriendlyTime));
// Generate the dump // Generate the dump
return Minidump::Create(filename, exceptionInfo, minidumpType); return Minidump::Create(filename, exceptionInfo, minidumpType);
@ -372,7 +372,7 @@ namespace Components
if (extraHeaders.find("Encoding") == extraHeaders.end()) if (extraHeaders.find("Encoding") == extraHeaders.end())
extraHeaders["Encoding"] = "raw"; extraHeaders["Encoding"] = "raw";
extraHeaders["Version"] = VERSION_STR; extraHeaders["Version"] = VERSION;
output << "-----BEGIN " << marker << "-----\n"; output << "-----BEGIN " << marker << "-----\n";

View File

@ -309,7 +309,7 @@ namespace Components
info.Set("clients", fmt::sprintf("%i", clientCount)); info.Set("clients", fmt::sprintf("%i", clientCount));
info.Set("sv_maxclients", fmt::sprintf("%i", maxclientCount)); info.Set("sv_maxclients", fmt::sprintf("%i", maxclientCount));
info.Set("protocol", fmt::sprintf("%i", PROTOCOL)); info.Set("protocol", fmt::sprintf("%i", PROTOCOL));
info.Set("shortversion", VERSION_STR); info.Set("shortversion", SHORTVERSION);
info.Set("checksum", fmt::sprintf("%d", Game::Sys_Milliseconds())); info.Set("checksum", fmt::sprintf("%d", Game::Sys_Milliseconds()));
info.Set("mapname", Dvar::Var("mapname").Get<const char*>()); info.Set("mapname", Dvar::Var("mapname").Get<const char*>());
info.Set("isPrivate", (Dvar::Var("g_password").Get<std::string>().size() ? "1" : "0")); info.Set("isPrivate", (Dvar::Var("g_password").Get<std::string>().size() ? "1" : "0"));

View File

@ -173,26 +173,26 @@ namespace Components
Utils::Hook::Set<char*>(0x6431D1, BASEGAME); Utils::Hook::Set<char*>(0x6431D1, BASEGAME);
// UI version string // UI version string
Utils::Hook::Set<char*>(0x43F73B, "IW4x: r" REVISION_STR REVISION_SUFFIX "-" MILESTONE); Utils::Hook::Set<char*>(0x43F73B, "IW4x: " VERSION);
// console version string // console version string
Utils::Hook::Set<char*>(0x4B12BB, "IW4x r" REVISION_STR REVISION_SUFFIX "-" MILESTONE " (built " __DATE__ " " __TIME__ ")"); Utils::Hook::Set<char*>(0x4B12BB, "IW4x " VERSION " (built " __DATE__ " " __TIME__ ")");
// version string // version string
Utils::Hook::Set<char*>(0x60BD56, "IW4x (r" REVISION_STR REVISION_SUFFIX ")"); Utils::Hook::Set<char*>(0x60BD56, "IW4x (" VERSION ")");
// console title // console title
if (ZoneBuilder::IsEnabled()) if (ZoneBuilder::IsEnabled())
{ {
Utils::Hook::Set<char*>(0x4289E8, "IW4x (r" REVISION_STR REVISION_SUFFIX "): ZoneBuilder"); Utils::Hook::Set<char*>(0x4289E8, "IW4x (" VERSION "): ZoneBuilder");
} }
else if (Dedicated::IsEnabled()) else if (Dedicated::IsEnabled())
{ {
Utils::Hook::Set<char*>(0x4289E8, "IW4x (r" REVISION_STR REVISION_SUFFIX "): Dedicated"); Utils::Hook::Set<char*>(0x4289E8, "IW4x (r" VERSION "): Dedicated");
} }
else else
{ {
Utils::Hook::Set<char*>(0x4289E8, "IW4x (r" REVISION_STR REVISION_SUFFIX "): Console"); Utils::Hook::Set<char*>(0x4289E8, "IW4x (r" VERSION "): Console");
} }
// window title // window title
@ -202,7 +202,7 @@ namespace Components
Utils::Hook::Set<char*>(0x4D378B, "IW4Host"); Utils::Hook::Set<char*>(0x4D378B, "IW4Host");
// shortversion // shortversion
Utils::Hook::Set<char*>(0x60BD91, VERSION_STR); Utils::Hook::Set<char*>(0x60BD91, SHORTVERSION);
// console logo // console logo
Utils::Hook::Set<char*>(0x428A66, BASEGAME "/images/logo.bmp"); Utils::Hook::Set<char*>(0x428A66, BASEGAME "/images/logo.bmp");

View File

@ -115,7 +115,7 @@ namespace Components
info.Set("gamename", "IW4"); info.Set("gamename", "IW4");
info.Set("sv_maxclients", fmt::sprintf("%i", maxclientCount)); info.Set("sv_maxclients", fmt::sprintf("%i", maxclientCount));
info.Set("protocol", fmt::sprintf("%i", PROTOCOL)); info.Set("protocol", fmt::sprintf("%i", PROTOCOL));
info.Set("shortversion", VERSION_STR); info.Set("shortversion", SHORTVERSION);
info.Set("mapname", Dvar::Var("mapname").Get<const char*>()); info.Set("mapname", Dvar::Var("mapname").Get<const char*>());
info.Set("isPrivate", (Dvar::Var("g_password").Get<std::string>().empty() ? "0" : "1")); info.Set("isPrivate", (Dvar::Var("g_password").Get<std::string>().empty() ? "0" : "1"));
info.Set("checksum", fmt::sprintf("%X", Utils::Cryptography::JenkinsOneAtATime::Compute(fmt::sprintf("%u", Game::Sys_Milliseconds())))); info.Set("checksum", fmt::sprintf("%X", Utils::Cryptography::JenkinsOneAtATime::Compute(fmt::sprintf("%u", Game::Sys_Milliseconds()))));

View File

@ -449,7 +449,7 @@ namespace Components
if (info.Get("gamename") == "IW4" if (info.Get("gamename") == "IW4"
&& server.MatchType && server.MatchType
#ifndef DEBUG #ifndef DEBUG
&& server.Shortversion == VERSION_STR && server.Shortversion == SHORTVERSION
#endif #endif
) )
{ {

View File

@ -13,7 +13,7 @@ namespace Components
{ {
if (Flags::HasFlag("version")) if (Flags::HasFlag("version"))
{ {
printf("IW4x r" REVISION_STR "-" MILESTONE " (built " __DATE__ " " __TIME__ ")\n"); printf("IW4x " VERSION " (built " __DATE__ " " __TIME__ ")\n");
ExitProcess(0); ExitProcess(0);
} }

View File

@ -2,7 +2,6 @@
// //
#pragma code_page(65001) #pragma code_page(65001)
#define RESOURCE_DATA
#include "STDInclude.hpp" #include "STDInclude.hpp"
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
@ -47,8 +46,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION FILEVERSION VERSION_RC
PRODUCTVERSION VERSION PRODUCTVERSION VERSION_RC
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -69,12 +68,12 @@ BEGIN
#else #else
VALUE "FileDescription", "IW4 client modification" VALUE "FileDescription", "IW4 client modification"
#endif #endif
VALUE "FileVersion", VERSION_STR VALUE "FileVersion", SHORTVERSION
VALUE "InternalName", "iw4x" VALUE "InternalName", "iw4x"
VALUE "LegalCopyright", "No rights reserved." VALUE "LegalCopyright", "No rights reserved."
VALUE "OriginalFilename", "iw4x.dll" VALUE "OriginalFilename", "iw4x.dll"
VALUE "ProductName", "IW4x" VALUE "ProductName", "IW4x"
VALUE "ProductVersion", VERSION_STR VALUE "ProductVersion", SHORTVERSION
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
// Version number // Version number
#include <version.hpp> #include "version.h"
#ifndef RESOURCE_DATA #ifndef RC_INVOKED
#define VC_EXTRALEAN #define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
@ -120,22 +120,12 @@ using namespace std::literals;
#endif #endif
// Revision number
#define STRINGIZE_(x) #x #define STRINGIZE_(x) #x
#define STRINGIZE(x) STRINGIZE_(x) #define STRINGIZE(x) STRINGIZE_(x)
#define BASEGAME "iw4x" #define BASEGAME "iw4x"
#define CLIENT_CONFIG "iw4x_config.cfg" #define CLIENT_CONFIG "iw4x_config.cfg"
#define REVISION_STR STRINGIZE(REVISION)
#if !REVISION_CLEAN
#define REVISION_SUFFIX "*"
#else
#define REVISION_SUFFIX ""
#endif
#define VERSION 4,2,REVISION
#define VERSION_STR "4.2." REVISION_STR
#define Assert_Size(x, size) static_assert(sizeof(x) == size, STRINGIZE(x) " structure has an invalid size.") #define Assert_Size(x, size) static_assert(sizeof(x) == size, STRINGIZE(x) " structure has an invalid size.")
// Resource stuff // Resource stuff