Generate ProductInfo based on git info
authorCarl Myers <cmyers@cmyers.org>
Sun, 27 Feb 2011 10:20:38 +0000 (02:20 -0800)
committerCarl Myers <cmyers@cmyers.org>
Sun, 27 Feb 2011 10:22:05 +0000 (02:22 -0800)
* Generates Version and Date info from git
* Encapsulates all that info in the ProductInfo class

src/DiagnosticsUtil.cpp
src/Makefile.am
src/NetworkSyncManager.cpp
src/PrefsManager.cpp
src/ProductInfo.cpp [new file with mode: 0644]
src/ProductInfo.h
src/ProductInfo.inc
src/ScreenTitleMenu.cpp
src/StepMania.cpp
src/archutils/Unix/CrashHandlerChild.cpp

index c50c114..d642bb9 100644 (file)
 #define PATCH_XML_PATH "Data/patch/patch.xml"
 #define STATS_XML_PATH "Data/MachineProfile/Stats.xml"
 
-// these should be defined in verstub.cpp across all platforms
-extern const bool VersionSVN;
-extern const char *const VersionDate;
-extern unsigned long VersionNumber;
-
 /* /stats/ is mounted to Data for arcade builds, so this should be okay. */
 int DiagnosticsUtil::GetNumCrashLogs()
 {
@@ -137,15 +132,12 @@ int DiagnosticsUtil::GetNumMachineScores()
 
 CString DiagnosticsUtil::GetProductName()
 {
-       if( VersionSVN )
-               return CString(PRODUCT_NAME_VER) + " " + ssprintf( "r%lu", VersionNumber);
-
-       return CString(PRODUCT_NAME_VER);
+       return CString(ProductInfo::getFullVersionString());
 }
 
 CString DiagnosticsUtil::GetProductVer()
 {
-       return CString(PRODUCT_VER);
+       return CString(ProductInfo::getVersion());
 }
 
 namespace
@@ -155,37 +147,7 @@ namespace
         * from verstub. */
        CString GenerateDebugSerial()
        {
-               char system, type;
-
-       // set the compilation OS
-       #if defined(WIN32)
-               system = 'W'; /* Windows */
-       #elif defined(LINUX)
-               if( VersionSVN )
-                       system = 'S'; /*nix, with SVN */
-               else
-                       system = 'L'; /*nix, no SVN */
-       #elif defined(DARWIN)
-               system = 'M'; /* Mac OS */
-       #else
-               system = 'U'; /* unknown */
-       #endif
-
-       // set the compilation arcade type
-       #ifdef ITG_ARCADE
-               type = 'A';
-       #else
-               type = 'P';
-       #endif
-
-               // if SVN, display revision: "OITG-W-20090409-600-P"
-               // if no SVN, display build in hex: "OITG-W-20090409-08A-P"
-               if( VersionSVN )
-                       return ssprintf( "OITG-%c-%s-%03lu-%c", system, 
-                               VersionDate, VersionNumber, type );
-               else
-                       return ssprintf( "OITG-%c-%s-%03lX-%c", system, 
-                               VersionDate, VersionNumber, type );
+               return CString(ProductInfo::getSerial());
        }
 }
 
@@ -229,7 +191,7 @@ void DiagnosticsUtil::SetInputType( const CString &sType )
 void SetProgramGlobals( lua_State* L )
 {
        LUA->SetGlobal( "OPENITG", true );
-       LUA->SetGlobal( "OPENITG_VERSION", PRODUCT_TOKEN );
+       LUA->SetGlobal( "OPENITG_VERSION", ProductInfo::getVersion() );
 }
 
 REGISTER_WITH_LUA_FUNCTION( SetProgramGlobals );
index 262addd..a8091a0 100755 (executable)
@@ -21,18 +21,7 @@ else
 LIBS += -nodefaultlibs -Wl,-Bstatic -lstdc++ $(LUA_LIBS) -lXrandr -lXrender -lmad -lgcc -lgcc_eh -Wl,-Bdynamic -lpthread -lusb -lc
 endif
 
-.PHONY: build_version
-
-all: build_version
-
-build_version: $(srcdir)/libresample/libresample.a $(srcdir)/crypto561/libcryptopp.a
-       $(CC) -O2 archutils/Unix/verinc.c -o archutils/Unix/verinc
-       chmod +x archutils/Unix/verinc
-       archutils/Unix/verinc `svnversion`
-       $(CXX) -c verstub.cpp
-
-verstub.cpp:
-       $(MAKE) build_version
+all: $(srcdir)/libresample/libresample.a $(srcdir)/crypto561/libcryptopp.a
 
 clean-local: clean_libresample
 
@@ -389,7 +378,8 @@ ScreenManager.h SongManager.cpp SongManager.h \
 StatsManager.cpp StatsManager.h \
 ThemeManager.cpp ThemeManager.h \
 UnlockManager.cpp UnlockManager.h \
-UserPackManager.cpp UserPackManager.h
+UserPackManager.cpp UserPackManager.h \
+ProductInfo.cpp ProductInfo.h
 
 if !WITHOUT_NETWORKING
 # Compile NetworkSyncManager even if networking is disabled; it'll stub itself.
@@ -455,7 +445,6 @@ main_LDADD = \
                  $(srcdir)/libresample/libresample.a \
                  $(srcdir)/crypto561/libcryptopp.a
 
-nodist_openitg_SOURCES = verstub.cpp
 openitg_SOURCES = $(main_SOURCES)
 openitg_LDADD = $(main_LDADD) \
        $(srcdir)/ffmpeg/lib/libavformat.a $(srcdir)/ffmpeg/lib/libavcodec.a
index 821bc09..2e8ce5f 100755 (executable)
@@ -169,7 +169,7 @@ void NetworkSyncManager::PostStartUp(const CString& ServerIP)
 
        m_packet.Write1(NETPROTOCOLVERSION);
 
-       m_packet.WriteNT(CString(PRODUCT_NAME_VER)); 
+       m_packet.WriteNT(ProductInfo::getFullVersionString()); 
 
        //Block until responce is received
        //Move mode to blocking in order to give CPU back to the 
index 22a37eb..a5af59a 100755 (executable)
@@ -238,7 +238,7 @@ PrefsManager::PrefsManager() :
        m_iEndlessBreakLength                   ( "EndlessBreakLength",                 5 ),
        m_bDisableScreenSaver                   ( "DisableScreenSaver",                 true ),
        m_sLanguage                                             ( "Language",                                   "" ),   // ThemeManager will deal with this invalid language
-       m_sMemoryCardProfileSubdir              ( "MemoryCardProfileSubdir",    PRODUCT_NAME ),
+       m_sMemoryCardProfileSubdir              ( "MemoryCardProfileSubdir",    ProductInfo::getName()),
        m_iProductID                                    ( "ProductID",                                  1 ),
        m_sDefaultLocalProfileIDP1              ( "DefaultLocalProfileIDP1",    "" ),
        m_sDefaultLocalProfileIDP2              ( "DefaultLocalProfileIDP2",    "" ),
diff --git a/src/ProductInfo.cpp b/src/ProductInfo.cpp
new file mode 100644 (file)
index 0000000..a312bde
--- /dev/null
@@ -0,0 +1,36 @@
+#include "StdString.h"
+#include "ProductInfo.h"
+
+CString ProductInfo::getName() {
+       return CString("OpenITG");
+}
+
+CString ProductInfo::getVersion() {
+       return CString(OITG_VERSION);
+}
+
+CString ProductInfo::getDate() {
+       return CString(OITG_DATE);
+}
+
+CString ProductInfo::getPlatform() {
+#if defined(ITG_ARCADE)
+       return CString("AC");
+#elif defined(XBOX)
+       return CString("CS");
+#else
+       return CString("PC");
+#endif
+}
+
+CString ProductInfo::getCrashReportUrl() {
+       return CString("http://wush.net/bugzilla/terabyte/");
+}
+
+CString ProductInfo::getFullVersionString() {
+       return getVersion() + CString("-") + getPlatform();
+}
+
+CString ProductInfo::getSerial() {
+       return CString("OITG-") + getVersion() + CString("-") + getPlatform();
+}
index 3b98d97..e31c7c1 100755 (executable)
 #undef OFFICIAL_RELEASE
 //#define OFFICIAL_RELEASE 1
 
-/* (x?)xyy - x is release type, y is release version */
-/* 101 - beta 1, 102 - beta 1.1, 103 - beta 2, 104 - beta 3 */
-#define PRODUCT_TOKEN 104
-
-/* The name of the build and its current version */
-#define PRODUCT_NAME "OpenITG"
-#define PRODUCT_VER "beta 3"
-
-#if defined(ITG_ARCADE)
-#define PRODUCT_PLATFORM "AC"
-#elif defined(XBOX)
-#define PRODUCT_PLATFORM "CS" 
-#else
-#define PRODUCT_PLATFORM "PC"
-#endif
-
-#ifndef OFFICIAL_RELEASE
-#define PRODUCT_NAME_VER PRODUCT_NAME " " PRODUCT_PLATFORM " " PRODUCT_VER " DEV"
-#else
-#define PRODUCT_NAME_VER PRODUCT_NAME " " PRODUCT_PLATFORM " " PRODUCT_VER
-#endif
-
-/* A central location from which we can update crash handler data... */
-#define CRASH_REPORT_URL "https://sourceforge.net/tracker2/?atid=1110556&group_id=239714"
+#include "StdString.h"
+#include "../version.h"
+
+class ProductInfo {
+
+       public:
+               static CString getName();
+               static CString getVersion();
+               static CString getDate();
+               static CString getPlatform();
+               static CString getCrashReportUrl();
+               static CString getFullVersionString();
+               static CString getSerial();
+};
 
 #endif
 
index 73c0c17..542ef60 100755 (executable)
@@ -1,3 +1,4 @@
+; TODO - delete this file?  this stuff is no longer up to date.
 ; Included by the NSIS installer script
 ; Don't forget to also change ProductInfo.h!
 
index 56f56ae..d29a454 100755 (executable)
@@ -20,6 +20,7 @@
 #include "CommonMetrics.h"
 #include "Game.h"
 #include "ScreenOptionsMasterPrefs.h"
+#include "ProductInfo.h"
 
 #define MAX_STAGES_TEXT                                THEME->GetMetric (m_sName,"MaxStagesText")
 #define COIN_MODE_CHANGE_SCREEN                THEME->GetMetric (m_sName,"CoinModeChangeScreen")
@@ -66,7 +67,7 @@ void ScreenTitleMenu::Init()
        m_textVersion.LoadFromFont( THEME->GetPathF("Common","normal") );
        m_textVersion.SetName( "Version" );
        /* easier debugging, plus product placement ;D */
-       m_textVersion.SetText( PRODUCT_NAME_VER );
+       m_textVersion.SetText( ProductInfo::getName() );
        this->AddChild( &m_textVersion );
        SET_XY_AND_ON_COMMAND( m_textVersion );
 
index 5cc513f..9c432f0 100755 (executable)
@@ -895,15 +895,10 @@ static void MountTreeOfZips( const CString &dir, bool recurse = true )
        }
 }
 
-extern const bool VersionSVN;
-extern unsigned long VersionNumber;
-extern const char *const VersionTime;
-
 static void WriteLogHeader()
 {
-       LOG->Info( PRODUCT_NAME_VER );
-       LOG->Info( "Compiled %s (%s %lu)", VersionTime, 
-               VersionSVN ? "revision" : "build", VersionNumber );
+       LOG->Info( ProductInfo::getFullVersionString());
+       LOG->Info( "Compiled %s (build %lu)", ProductInfo::getDate(), ProductInfo::getVersion() );
 
        time_t cur_time;
        time(&cur_time);
index f21a1a2..f6e6a27 100755 (executable)
 #include "archutils/Darwin/Crash.h"
 #endif
 
-#if defined(HAVE_VERSION_INFO)
-extern const unsigned version_num;
-#endif
-
 const char *g_pCrashHandlerArgv0 = NULL;
 
 
@@ -287,9 +283,9 @@ static void child_process()
                exit(1);
        }
 
-    fprintf(CrashDump, "%s crash report", PRODUCT_NAME_VER );
+    fprintf(CrashDump, "%s crash report", ProductInfo::getFullVersionString() );
 #if defined(HAVE_VERSION_INFO)
-    fprintf(CrashDump, " (build %u)", version_num);
+    fprintf(CrashDump, " (build %u)", ProductInfo::getVersion());
 #endif
     fprintf(CrashDump, "\n");
     fprintf(CrashDump, "--------------------------------------\n");
@@ -366,14 +362,15 @@ static void child_process()
         tty = stderr;
 
     fprintf(tty,
-            "\n"
-            PRODUCT_NAME " has crashed.  Debug information has been output to\n"
+                       "\n"
+            + CString(ProductInfo::getName())
+                       + " has crashed.  Debug information has been output to\n"
             "\n"
             "    " + sCrashInfoPath + "\n"
             "\n"
             "Please report a bug at:\n"
             "\n"
-            "    " CRASH_REPORT_URL "\n"
+            "    " + ProductInfo::getCrashReportUrl() + "\n"
             "\n"
             );