From 7a33b8a44ad753ac335ccd35fb0f52562d1df471 Mon Sep 17 00:00:00 2001 From: "Ben \"root\" Anderson" Date: Wed, 28 Jan 2015 19:21:24 -0600 Subject: [PATCH] Program version is now in a const from a generated file, not a static macro. Plus all the mess I had to make to get that to work. --- src/CommandLineActions.cpp | 7 ++--- src/LuaManager.cpp | 3 +- src/Makefile.am | 35 +++++++++++------------ src/NetworkSyncManager.cpp | 2 +- src/ProductInfo.h | 27 ----------------- src/ProductInfo.inc | 5 ++-- src/StepMania.cpp | 2 +- src/archutils/Win32/CrashHandlerChild.cpp | 5 ++-- 8 files changed, 29 insertions(+), 57 deletions(-) diff --git a/src/CommandLineActions.cpp b/src/CommandLineActions.cpp index 3e69058303..3aac6f784e 100644 --- a/src/CommandLineActions.cpp +++ b/src/CommandLineActions.cpp @@ -17,10 +17,7 @@ #include "Preference.h" #include "JsonUtil.h" #include "ScreenInstallOverlay.h" - -#if defined(HAVE_VERSION_INFO) #include "ver.h" -#endif // only used for Version() #if defined(_WINDOWS) @@ -73,7 +70,7 @@ static void LuaInformation() pNode->AppendAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); pNode->AppendAttr("xsi:schemaLocation", "http://www.stepmania.com Lua.xsd"); - pNode->AppendChild("Version", PRODUCT_ID_VER); + pNode->AppendChild("Version", string(PRODUCT_FAMILY) + product_version); pNode->AppendChild("Date", DateTime::GetNowDate().GetString()); XmlFileUtil::SaveToFile(pNode, "Lua.xml", "Lua.xsl"); @@ -90,7 +87,7 @@ static void LuaInformation() static void Version() { #if defined(WIN32) - RString sProductID = ssprintf("%s", PRODUCT_ID_VER); + RString sProductID = ssprintf("%s", (string(PRODUCT_FAMILY) + product_version).c_str() ); RString sVersion = "(StepMania was built without HAVE_VERSION_INFO)"; #if defined(HAVE_VERSION_INFO) sVersion = ssprintf("build %lu\nCompile Date: %s @ %s", version_num, version_date, version_time); diff --git a/src/LuaManager.cpp b/src/LuaManager.cpp index 116e9d8d1b..3d2f12e50b 100644 --- a/src/LuaManager.cpp +++ b/src/LuaManager.cpp @@ -12,6 +12,7 @@ #include "RageLog.h" #include "RageTypes.h" #include "MessageManager.h" +#include "ver.h" #include // conversion for lua functions. #include @@ -1040,7 +1041,7 @@ void LuaHelpers::PushValueFunc( lua_State *L, int iArgs ) #include "ProductInfo.h" LuaFunction( ProductFamily, (RString) PRODUCT_FAMILY ); -LuaFunction( ProductVersion, (RString) PRODUCT_VER ); +LuaFunction( ProductVersion, (RString) product_version ); LuaFunction( ProductID, (RString) PRODUCT_ID ); extern const char *const version_date; diff --git a/src/Makefile.am b/src/Makefile.am index bd1d0a172d..af79145ad2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,7 +19,6 @@ AM_CFLAGS = noinst_LIBRARIES = EXTRA_DIST = - AM_CXXFLAGS += -fno-exceptions # Relax inlining; the default of 600 takes way too long to compile and @@ -28,31 +27,31 @@ AM_CXXFLAGS += -finline-limit=300 AM_CXXFLAGS += $(GL_CFLAGS) -.PHONY: increment_version gitversion +.PHONY: update_version -increment_version: +update_version: if test -e ver.cpp; then \ - build=`sed -rs 's/.*version_num = ([[:digit:]]+);/\1/;q' ver.cpp`; \ + build=`sed -rs 's/.*version_num = ([[:digit:]]+);/\1/;2q;d' ver.cpp`; \ build=`expr $$build + 1`; \ else \ build=0; \ fi; \ - echo "const unsigned long version_num = $$build;" > ver.cpp; \ - echo "const char *const version_time = \"`date +"%X %Z (UTC%:z)"`\";" >> ver.cpp; - echo "const char *const version_date = \"`date +"%Y%m%d"`\";" >> ver.cpp; - -ver.cpp: increment_version - -gitversion: - rm -f gitversion.h - touch gitversion.h + echo "#include \"ver.h\"" > ver.cpp; \ + echo "const unsigned long version_num = $$build;" >> ver.cpp +# Header inclusion necessary to get linker symbols right + echo "const char *const version_time = \"`date +"%X %Z (UTC%:z)"`\";" >> ver.cpp + echo "const char *const version_date = \"`date +"%Y%m%d"`\";" >> ver.cpp if git rev-parse --short HEAD; then \ - echo "#define PRODUCT_VER_BARE 5.0-git-`git rev-parse --short HEAD`" > gitversion.h; \ + echo "const char *const product_version = \"5.0-git-`git rev-parse --short HEAD`\";" >> ver.cpp; \ + else \ + echo "const char *const product_version = \"5.0-UNKNOWN\";" >> ver.cpp; \ fi -gitversion.h: gitversion - -BUILT_SOURCES = gitversion.h ver.cpp +ver.cpp: update_version +# make doesn't recognize a file it updated during the current invocation +# (in this case ver.cpp) as being updated. So remake and delete stepmania-ver.o +# every time. +.INTERMEDIATE: stepmania-ver.o PNG = \ ../extern/libpng/include/png.c ../extern/libpng/include/.png.h \ @@ -745,7 +744,7 @@ main_LDADD = \ $(GL_LIBS) \ libtomcrypt.a libtommath.a -nodist_stepmania_SOURCES = ver.cpp gitversion.h +nodist_stepmania_SOURCES = ver.cpp stepmania_CPPFLAGS = $(main_CPPFLAGS) stepmania_SOURCES = $(main_SOURCES) diff --git a/src/NetworkSyncManager.cpp b/src/NetworkSyncManager.cpp index ae232d52eb..047eda4332 100644 --- a/src/NetworkSyncManager.cpp +++ b/src/NetworkSyncManager.cpp @@ -166,7 +166,7 @@ void NetworkSyncManager::PostStartUp( const RString& ServerIP ) m_packet.Write1( NETPROTOCOLVERSION ); - m_packet.WriteNT( RString(PRODUCT_ID_VER) ); + m_packet.WriteNT( RString( string(PRODUCT_FAMILY) + product_version ) ); /* Block until response is received. * Move mode to blocking in order to give CPU back to the system, diff --git a/src/ProductInfo.h b/src/ProductInfo.h index a09e70ccfc..ec2eff2910 100644 --- a/src/ProductInfo.h +++ b/src/ProductInfo.h @@ -5,9 +5,6 @@ // XXX: VC doesn't generate this yet. Hack around it for now #include "config.h" -#ifdef USE_GITVERSION -#include "gitversion.h" -#endif /** * @brief A friendly string to refer to the product in crash dialogs, etc. @@ -24,36 +21,12 @@ */ #define PRODUCT_ID_BARE StepMania 5.0 -/** - * @brief Version info displayed to the user. - * - * These are the 'official' version designations: - *
    - *
  • "v5.0 alpha #": Alpha versions (bug squashing, polishing until we reach beta)
  • - *
  • "v5.0 beta #": Beta versions (bug squashing, _focus_ is on high priority bugs)
  • - *
  • "v5.0 rc#": Release Candidates (if there are no problems, move on to final)
  • - *
  • "v5.0.0": Final Releases
  • - *
- */ -#ifndef PRODUCT_VER_BARE -#define PRODUCT_VER_BARE 5.0-UNKNOWN -#endif - -/** - * @brief A unique ID for a build of an application. - * - * This is used in crash reports and in the network code's version handling. - */ -#define PRODUCT_ID_VER_BARE PRODUCT_FAMILY_BARE PRODUCT_VER_BARE - // These cannot be #undef'd so make them unlikely to conflict with anything #define PRODUCT_STRINGIFY(x) #x #define PRODUCT_XSTRINGIFY(x) PRODUCT_STRINGIFY(x) #define PRODUCT_FAMILY PRODUCT_XSTRINGIFY(PRODUCT_FAMILY_BARE) #define PRODUCT_ID PRODUCT_XSTRINGIFY(PRODUCT_ID_BARE) -#define PRODUCT_VER PRODUCT_XSTRINGIFY(PRODUCT_VER_BARE) -#define PRODUCT_ID_VER PRODUCT_XSTRINGIFY(PRODUCT_ID_VER_BARE) #define VIDEO_TROUBLESHOOTING_URL "http://old.stepmania.com/stepmaniawiki.php?title=Video_Driver_Troubleshooting" /** @brief The URL to report bugs on the program. */ diff --git a/src/ProductInfo.inc b/src/ProductInfo.inc index bb271ea572..eb9079f405 100644 --- a/src/ProductInfo.inc +++ b/src/ProductInfo.inc @@ -6,8 +6,9 @@ ; PRODUCT_ID must NOT be "StepMania" unless you want people to uninstall 3.9 ; when they install StepMania 5. (not recommended) -!define PRODUCT_ID "StepMania 5" -!define PRODUCT_VER "v5.0 beta 4a" +!define PRODUCT_ID "StepMania 5.0" +; TODO: This needs to be updated with the git rev hash +!define PRODUCT_VER "5.0-UNKNOWN" !define PRODUCT_DISPLAY "${PRODUCT_FAMILY} ${PRODUCT_VER}" !define PRODUCT_BITMAP "sm5" diff --git a/src/StepMania.cpp b/src/StepMania.cpp index bc117771cc..fe412d7f62 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -914,7 +914,7 @@ static void MountTreeOfZips( const RString &dir ) static void WriteLogHeader() { - LOG->Info( PRODUCT_ID_VER ); + LOG->Info( RString(PRODUCT_FAMILY) + product_version ); #if defined(HAVE_VERSION_INFO) LOG->Info( "Compiled %s @ %s (build %lu)", version_date, version_time, version_num ); diff --git a/src/archutils/Win32/CrashHandlerChild.cpp b/src/archutils/Win32/CrashHandlerChild.cpp index 5dd70744b9..98c1c2f350 100644 --- a/src/archutils/Win32/CrashHandlerChild.cpp +++ b/src/archutils/Win32/CrashHandlerChild.cpp @@ -25,6 +25,7 @@ #include "XmlFileUtil.h" #include "LocalizedString.h" #include "RageFileDriverDeflate.h" +#include "ver.h" #if defined(_MSC_VER) #pragma comment(lib, "archutils/Win32/ddk/dbghelp.lib") @@ -434,7 +435,7 @@ static void MakeCrashReport( const CompleteCrashData &Data, RString &sOut ) sOut += ssprintf( "%s crash report (build %d, %s @ %s)\n" "--------------------------------------\n\n", - PRODUCT_ID_VER, version_num, version_date, version_time ); + (string(PRODUCT_FAMILY) + product_version).c_str(), version_num, version_date, version_time ); sOut += ssprintf( "Crash reason: %s\n", Data.m_CrashInfo.m_CrashReason ); sOut += ssprintf( "\n" ); @@ -737,7 +738,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) // Create the form data to send. m_pPost = new NetworkPostData; m_pPost->SetData( "Product", PRODUCT_ID ); - m_pPost->SetData( "Version", PRODUCT_VER ); + m_pPost->SetData( "Version", product_version ); m_pPost->SetData( "Arch", HOOKS->GetArchName().c_str() ); m_pPost->SetData( "Report", m_sCrashReport ); m_pPost->SetData( "Reason", m_CrashData.m_CrashInfo.m_CrashReason );