From e8fe15c3f7e3471f49ea0423ac0fe652db90391a Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 21 Aug 2011 16:30:19 -0500 Subject: [PATCH] Make titlebar and about dialog fancy for cmake build. Windows needs fixing. --- CMakeLists.txt | 25 ++++++++++++++++--- Source/Core/Common/Src/Common.h | 2 +- Source/Core/Common/Src/Version.cpp | 22 ++++++++++------ Source/Core/Core/Src/Core.cpp | 4 +-- Source/Core/DolphinWX/Src/AboutDolphin.cpp | 7 +++++- Source/Core/DolphinWX/Src/FrameTools.cpp | 2 +- Source/Core/DolphinWX/Src/Main.cpp | 2 +- Source/Core/DolphinWX/Src/MainNoGUI.cpp | 4 +-- .../Src/OpenCL/OCLTextureDecoder.cpp | 2 +- Source/Plugins/Plugin_VideoDX11/Src/main.cpp | 2 +- Source/Plugins/Plugin_VideoDX9/Src/main.cpp | 2 +- Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp | 2 +- .../Plugin_VideoSoftware/Src/SWmain.cpp | 2 +- 13 files changed, 54 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ce4cf6b75..0a77035f5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,10 +49,18 @@ endfunction(enable_precompiled_headers) # for revision info include(FindGit OPTIONAL) if(GIT_FOUND AND NOT DOLPHIN_WC_REVISION) - # defines DOLPHIN_WC_REVISION +# defines DOLPHIN_WC_REVISION EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE DOLPHIN_WC_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE) +# defines DOLPHIN_WC_DESCRIBE + EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} describe --always + OUTPUT_VARIABLE DOLPHIN_WC_DESCRIBE + OUTPUT_STRIP_TRAILING_WHITESPACE) +# defines DOLPHIN_WC_BRANCH + EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD + OUTPUT_VARIABLE DOLPHIN_WC_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE) endif() # Various compile flags @@ -409,8 +417,19 @@ endif(NOT DISABLE_WX) ######################################## # Pre-build events: Define configuration variables and write svnrev header # -file(WRITE ${PROJECT_BINARY_DIR}/Source/Core/Common/Src/svnrev.h - "#define SVN_REV_STR \"" ${DOLPHIN_WC_REVISION} "-" ${CMAKE_BUILD_TYPE} "\"\n") +if(SCM_BRANCH_STR EQUAL "master") + set(DOLPHIN_WC_IS_MASTER "1") +else() + set(DOLPHIN_WC_IS_MASTER "0") +endif() + +file(WRITE ${PROJECT_BINARY_DIR}/Source/Core/Common/Src/scmrev.h + "#define SCM_REV_STR \"" ${DOLPHIN_WC_REVISION} "\"\n" + "#define SCM_DESC_STR \"" ${DOLPHIN_WC_DESCRIBE} "\"\n" + "#define SCM_BRANCH_STR \"" ${DOLPHIN_WC_BRANCH} "\"\n" + "#define SCM_IS_MASTER " ${DOLPHIN_WC_IS_MASTER} "\n" +# "#define BUILD_TYPE_STR \"" ${CMAKE_BUILD_TYPE} "\"\n" + ) include_directories("${PROJECT_BINARY_DIR}/Source/Core/Common/Src") diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h index 7618f5329b..bc9b4dc051 100644 --- a/Source/Core/Common/Src/Common.h +++ b/Source/Core/Common/Src/Common.h @@ -26,7 +26,7 @@ #include // SVN version number -extern const char *svn_rev_str; +extern const char *scm_rev_str; extern const char *netplay_dolphin_ver; // Force enable logging in the right modes. For some reason, something had changed diff --git a/Source/Core/Common/Src/Version.cpp b/Source/Core/Common/Src/Version.cpp index 4f2f0b1d77..f3d30398c8 100644 --- a/Source/Core/Common/Src/Version.cpp +++ b/Source/Core/Common/Src/Version.cpp @@ -16,15 +16,21 @@ // http://code.google.com/p/dolphin-emu/ #include "Common.h" -#include "svnrev.h" +#include "scmrev.h" #ifdef _DEBUG -const char *svn_rev_str = "Dolphin Debug r" SVN_REV_STR; + #define BUILD_TYPE_STR "Debug " #elif defined DEBUGFAST -const char *svn_rev_str = "Dolphin Debugfast r" SVN_REV_STR; + #define BUILD_TYPE_STR "DebugFast " #else -const char *svn_rev_str = "Dolphin r" SVN_REV_STR; -#endif + #define BUILD_TYPE_STR "" +#endif + +const char *scm_rev_str = "Dolphin " +#if !SCM_IS_MASTER + "[" SCM_BRANCH_STR "] " +#endif + BUILD_TYPE_STR SCM_DESC_STR; #ifdef _M_X64 #define NP_ARCH "x64" @@ -33,9 +39,9 @@ const char *svn_rev_str = "Dolphin r" SVN_REV_STR; #endif #ifdef _WIN32 -const char *netplay_dolphin_ver = SVN_REV_STR " W" NP_ARCH; +const char *netplay_dolphin_ver = SCM_DESC_STR " W" NP_ARCH; #elif __APPLE__ -const char *netplay_dolphin_ver = SVN_REV_STR " M" NP_ARCH; +const char *netplay_dolphin_ver = SCM_DESC_STR " M" NP_ARCH; #else -const char *netplay_dolphin_ver = SVN_REV_STR " L" NP_ARCH; +const char *netplay_dolphin_ver = SCM_DESC_STR " L" NP_ARCH; #endif diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 18ab457d92..06fe496eb6 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -608,7 +608,7 @@ void VideoThrottle() // This is our final "frame counter" string std::string SMessage = StringFromFormat("%s | %s", SSettings.c_str(), SFPS.c_str()); - std::string TMessage = StringFromFormat("%s | ", svn_rev_str) + + std::string TMessage = StringFromFormat("%s | ", scm_rev_str) + SMessage; // Show message @@ -617,7 +617,7 @@ void VideoThrottle() if (_CoreParameter.bRenderToMain && SConfig::GetInstance().m_InterfaceStatusbar) { Host_UpdateStatusBar(SMessage.c_str()); - Host_UpdateTitle(svn_rev_str); + Host_UpdateTitle(scm_rev_str); } else Host_UpdateTitle(TMessage.c_str()); diff --git a/Source/Core/DolphinWX/Src/AboutDolphin.cpp b/Source/Core/DolphinWX/Src/AboutDolphin.cpp index 27aba79aa4..11e8dbd98c 100644 --- a/Source/Core/DolphinWX/Src/AboutDolphin.cpp +++ b/Source/Core/DolphinWX/Src/AboutDolphin.cpp @@ -18,6 +18,7 @@ #include "Common.h" #include "AboutDolphin.h" #include "../resources/dolphin_logo.cpp" +#include "scmrev.h" AboutDolphin::AboutDolphin(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, @@ -29,9 +30,13 @@ AboutDolphin::AboutDolphin(wxWindow *parent, wxWindowID id, wxStaticBitmap* const sbDolphinLogo = new wxStaticBitmap(this, wxID_ANY, wxBitmap(iDolphinLogo)); - std::string Text = std::string(svn_rev_str) + "\n" + std::string Text = "Dolphin " SCM_DESC_STR "\n" "Copyright (c) 2003-2011+ Dolphin Team\n" "\n" + "Branch: " SCM_BRANCH_STR "\n" + "Revision: " SCM_REV_STR "\n" + "Date: " __DATE__ " @ " __TIME__ "\n" + "\n" "Dolphin is a Gamecube/Wii emulator, which was\n" "originally written by F|RES and ector.\n" "Today Dolphin is an open source project with many\n" diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 75d76a314e..a3798fe084 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -1073,7 +1073,7 @@ void CFrame::DoStop() X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()), X11Utils::XWindowFromHandle(GetHandle()), false); #endif - m_RenderFrame->SetTitle(wxString::FromAscii(svn_rev_str)); + m_RenderFrame->SetTitle(wxString::FromAscii(scm_rev_str)); // Destroy the renderer frame when not rendering to main m_RenderParent->Disconnect(wxID_ANY, wxEVT_SIZE, diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index fc6ef09695..c8b6d61fa1 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -274,7 +274,7 @@ bool DolphinApp::OnInit() #endif main_frame = new CFrame((wxFrame*)NULL, wxID_ANY, - wxString::FromAscii(svn_rev_str), + wxString::FromAscii(scm_rev_str), wxPoint(x, y), wxSize(w, h), UseDebugger, BatchMode, UseLogger); SetTopWindow(main_frame); diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index 537a7e5551..ffb511dc70 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -294,13 +294,13 @@ int main(int argc, char* argv[]) help = 1; break; case 'v': - fprintf(stderr, "%s\n", svn_rev_str); + fprintf(stderr, "%s\n", scm_rev_str); return 1; } } if (help == 1 || argc == optind) { - fprintf(stderr, "%s\n\n", svn_rev_str); + fprintf(stderr, "%s\n\n", scm_rev_str); fprintf(stderr, "A multi-platform Gamecube/Wii emulator\n\n"); fprintf(stderr, "Usage: %s [-e ] [-h] [-v]\n", argv[0]); fprintf(stderr, " -e, --exec Load the specified file\n"); diff --git a/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp b/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp index 1af47f5a4c..0f4809a6cc 100644 --- a/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp @@ -103,7 +103,7 @@ void TexDecoder_OpenCL_Initialize() char dolphin_rev[HEADER_SIZE]; filename = File::GetUserPath(D_OPENCL_IDX) + "kernel.bin"; - snprintf(dolphin_rev, HEADER_SIZE, "%-31s", svn_rev_str); + snprintf(dolphin_rev, HEADER_SIZE, "%-31s", scm_rev_str); { File::IOFile input(filename, "rb"); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp index 0c975f5fa4..ba93890e2b 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp @@ -69,7 +69,7 @@ unsigned int VideoBackend::PeekMessages() void VideoBackend::UpdateFPSDisplay(const char *text) { char temp[512]; - sprintf_s(temp, sizeof temp, "%s | DX11 | %s", svn_rev_str, text); + sprintf_s(temp, sizeof temp, "%s | DX11 | %s", scm_rev_str, text); SetWindowTextA(EmuWindow::GetWnd(), temp); } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index adb37f9f10..1d733f7dc3 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -77,7 +77,7 @@ unsigned int VideoBackend::PeekMessages() void VideoBackend::UpdateFPSDisplay(const char *text) { TCHAR temp[512]; - swprintf_s(temp, sizeof(temp)/sizeof(TCHAR), _T("%hs | DX9 | %hs"), svn_rev_str, text); + swprintf_s(temp, sizeof(temp)/sizeof(TCHAR), _T("%hs | DX9 | %hs"), scm_rev_str, text); SetWindowText(EmuWindow::GetWnd(), temp); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index 2dddbbb6ba..bedcaa6245 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -108,7 +108,7 @@ unsigned int VideoBackend::PeekMessages() void VideoBackend::UpdateFPSDisplay(const char *text) { char temp[100]; - snprintf(temp, sizeof temp, "%s | OpenGL | %s", svn_rev_str, text); + snprintf(temp, sizeof temp, "%s | OpenGL | %s", scm_rev_str, text); OpenGL_SetWindowText(temp); } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp index a33274d143..abfd9155f5 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp @@ -265,7 +265,7 @@ unsigned int VideoSoftware::PeekMessages() void VideoSoftware::UpdateFPSDisplay(const char *text) { char temp[100]; - snprintf(temp, sizeof temp, "%s | Software | %s", svn_rev_str, text); + snprintf(temp, sizeof temp, "%s | Software | %s", scm_rev_str, text); OpenGL_SetWindowText(temp); }