From c306e3b4bf952ae5a28ec5aa2ab242e0a9bec5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Wed, 1 Apr 2020 20:50:44 -0700 Subject: [PATCH] Added bgfx version number. --- scripts/genie.lua | 31 +++++++++++++++++++++++++++++++ src/bgfx.cpp | 9 ++++++++- src/version.h | 13 +++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/version.h diff --git a/scripts/genie.lua b/scripts/genie.lua index 24e53af1c..859fa50f0 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -80,6 +80,37 @@ newaction { end } +newaction { + trigger = "version", + description = "Generate bgfx version.h", + execute = function () + + local f = io.popen("git rev-list --count HEAD") + local rev = string.match(f:read("*a"), ".*%S") + f:close() + f = io.popen("git log --format=format:%H -1") + local sha1 = f:read("*a") + f:close() + io.output("../src/version.h") + io.write("/*\n") + io.write(" * Copyright 2011-2020 Branimir Karadzic. All rights reserved.\n") + io.write(" * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n") + io.write(" */\n") + io.write("\n") + io.write("/*\n") + io.write(" *\n") + io.write(" * AUTO GENERATED! DO NOT EDIT!\n") + io.write(" *\n") + io.write(" */\n") + io.write("\n") + io.write("#define BGFX_REV_NUMBER " .. rev .. "\n") + io.write("#define BGFX_REV_SHA1 \"" .. sha1 .. "\"\n") + io.close() + + os.exit() + end +} + solution "bgfx" configurations { "Debug", diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 94ea6753b..2977726f3 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -11,6 +11,7 @@ #include #include "topology.h" +#include "version.h" #if BX_PLATFORM_OSX || BX_PLATFORM_IOS # include @@ -3419,6 +3420,13 @@ namespace bgfx BX_TRACE("Init..."); + // bgfx 1.104.7082 + // ^ ^^^ ^^^^ + // | | +--- Commit number (https://github.com/bkaradzic/bgfx / git rev-list --count HEAD) + // | +------- API version (from https://github.com/bkaradzic/bgfx/blob/master/scripts/bgfx.idl#L4) + // +--------- Major revision (always 1) + BX_TRACE("Version 1.%d.%d (commit: " BGFX_REV_SHA1 ")", BGFX_API_VERSION, BGFX_REV_NUMBER); + errorState = ErrorState::ContextAllocated; s_ctx = BX_ALIGNED_NEW(g_allocator, Context, Context::kAlignment); @@ -3428,7 +3436,6 @@ namespace bgfx return true; } -//error: BX_TRACE("Init failed."); switch (errorState) diff --git a/src/version.h b/src/version.h new file mode 100644 index 000000000..f8a7250a2 --- /dev/null +++ b/src/version.h @@ -0,0 +1,13 @@ +/* + * Copyright 2011-2020 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + */ + +/* + * + * AUTO GENERATED! DO NOT EDIT! + * + */ + +#define BGFX_REV_NUMBER 7082 +#define BGFX_REV_SHA1 "23f9ba655235917b2e6c789d5aec11052ba2b9ec"