diff --git a/.gitignore b/.gitignore index 22e80a5475..d40ea5abe2 100644 --- a/.gitignore +++ b/.gitignore @@ -29,9 +29,8 @@ _ReSharper*/ [Tt]est[Rr]esult* Binary/Win32 Binary/x64 -Source/Core/Common/Src/svnrev.h +Source/Core/Common/Src/scmrev.h *.opensdf *.sdf [Bb]uild - *.ipch \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 973adf6e0b..3aed637ae0 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 --dirty + 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 @@ -410,10 +418,20 @@ endif(NOT DISABLE_WX) ######################################## -# Pre-build events: Define configuration variables and write svnrev header +# Pre-build events: Define configuration variables and write SCM info header # -file(WRITE ${PROJECT_BINARY_DIR}/Source/Core/Common/Src/svnrev.h - "#define SVN_REV_STR \"" ${DOLPHIN_WC_REVISION} "-" ${CMAKE_BUILD_TYPE} "\"\n") +if(DOLPHIN_WC_BRANCH STREQUAL "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" + ) include_directories("${PROJECT_BINARY_DIR}/Source/Core/Common/Src") diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj index 705daae67d..d29043eb7d 100644 --- a/Source/Core/Common/Common.vcxproj +++ b/Source/Core/Common/Common.vcxproj @@ -259,8 +259,6 @@ - - diff --git a/Source/Core/Common/Common.vcxproj.filters b/Source/Core/Common/Common.vcxproj.filters index fecf4819f6..0922d00196 100644 --- a/Source/Core/Common/Common.vcxproj.filters +++ b/Source/Core/Common/Common.vcxproj.filters @@ -87,8 +87,6 @@ - - diff --git a/Source/Core/Common/SVNRevGen.vcxproj b/Source/Core/Common/SVNRevGen.vcxproj index 45d6d10368..b5c69660e9 100644 --- a/Source/Core/Common/SVNRevGen.vcxproj +++ b/Source/Core/Common/SVNRevGen.vcxproj @@ -7,19 +7,16 @@ - - cscript /nologo /E:JScript "make_svnrev.h.js" - Updating svnrev.h + + cscript /nologo /E:JScript "make_scmrev.h.js" + Updating scmrev.h dummy - - - - {69F00340-5C3D-449F-9A80-958435C6CF06} SVNRevGen + SCMRevGen 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/Common/Src/svnrev_template.h b/Source/Core/Common/Src/svnrev_template.h deleted file mode 100644 index 0d3e482e1b..0000000000 --- a/Source/Core/Common/Src/svnrev_template.h +++ /dev/null @@ -1 +0,0 @@ -#define SVN_REV_STR "$WCMODS?$WCREV$M:$WCREV$$" diff --git a/Source/Core/Common/SubWCRev.exe b/Source/Core/Common/SubWCRev.exe deleted file mode 100644 index 32a252b58b..0000000000 Binary files a/Source/Core/Common/SubWCRev.exe and /dev/null differ diff --git a/Source/Core/Common/make_scmrev.h.js b/Source/Core/Common/make_scmrev.h.js new file mode 100644 index 0000000000..a4b2369ca6 --- /dev/null +++ b/Source/Core/Common/make_scmrev.h.js @@ -0,0 +1,87 @@ +var wshShell = new ActiveXObject("WScript.Shell") +var oFS = new ActiveXObject("Scripting.FileSystemObject"); + +var outfile = "./Src/scmrev.h"; +var cmd_revision = " rev-parse HEAD"; +var cmd_describe = " describe --always --dirty"; +var cmd_branch = " rev-parse --abbrev-ref HEAD"; + +function GetGitExe() +{ + var gitexe = "git.cmd"; + try + { + wshShell.Exec(gitexe); + } + catch (e) + { + try + { + gitexe = "git"; + wshShell.Exec(gitexe); + } + catch (e) + { + WScript.Echo("Cannot find git or git.cmd, check your PATH:\n" + + wshShell.ExpandEnvironmentStrings("%PATH%")); + WScript.Quit(1); + } + } + return gitexe; +} + +function GetFirstStdOutLine(cmd) +{ + try + { + return wshShell.Exec(cmd).StdOut.ReadLine(); + } + catch (e) + { + // catch "the system cannot find the file specified" error + WScript.Echo("Failed to exec " + cmd + " this should never happen"); + WScript.Quit(1); + } +} + +function GetFileContents(f) +{ + try + { + return oFS.OpenTextFile(f).ReadAll(); + } + catch (e) + { + // file doesn't exist or string not found, (re)create it + oFS.CreateTextFile(f); + return 0; + } +} + +// get info from git +var gitexe = GetGitExe(); +var revision = GetFirstStdOutLine(gitexe + cmd_revision); +var describe = GetFirstStdOutLine(gitexe + cmd_describe); +var branch = GetFirstStdOutLine(gitexe + cmd_branch); +var isMaster = 0 + +if (branch == "master") + isMaster = 1 + +var out_contents = + "#define SCM_REV_STR \"" + revision + "\"\n" + + "#define SCM_DESC_STR \"" + describe + "\"\n" + + "#define SCM_BRANCH_STR \"" + branch + "\"\n" + + "#define SCM_IS_MASTER " + isMaster + "\n"; + +// check if file needs updating +if (out_contents == GetFileContents(outfile)) +{ + WScript.Echo(outfile + " doesn't need updating (already at " + revision + ")"); +} +else +{ + // needs updating - writeout current info + oFS.CreateTextFile(outfile, true).Write(out_contents); + WScript.Echo(outfile + " updated (" + revision + ")"); +} diff --git a/Source/Core/Common/make_svnrev.h.js b/Source/Core/Common/make_svnrev.h.js deleted file mode 100644 index a68485e0f6..0000000000 --- a/Source/Core/Common/make_svnrev.h.js +++ /dev/null @@ -1,87 +0,0 @@ -var wshShell = new ActiveXObject("WScript.Shell") -var oFS = new ActiveXObject("Scripting.FileSystemObject"); - -var outfile = "./Src/svnrev.h"; -var svncmd = "SubWCRev ../../.. ./Src/svnrev_template.h " + outfile; -var svntestcmd = "SubWCRev ../../.."; -var hgcmd = "hg svn info"; -var gitcmd = "git.cmd rev-parse HEAD"; - -var SVN = 1, HG = 2, git = 3; -var file_rev = 0, cur_rev = 0, cur_cms = 0; - -function RunCmdGetMatch(cmd, regex) -{ - // run the command - try - { - var cmdexec = wshShell.Exec(cmd); - } - catch (e) - { - // catch "the system cannot find the file specified" error - return 0; - } - // ReadLine is synchronous - while (!cmdexec.StdOut.AtEndOfStream) - { - var reg_exec = regex.exec(cmdexec.StdOut.ReadLine()) - if (reg_exec) - return reg_exec[1]; // return first capture group - } - // failed - return 0; -} - -try -{ - // read the value of SVN_REV_STR - file_rev = oFS.OpenTextFile(outfile).ReadLine().match(/\d+/); -} -catch (e) -{ - // file doesn't exist or string not found, (re)create it - oFS.CreateTextFile(outfile); -} - -// get the "Last commited at revision" from SubWCRev's output -cur_rev = RunCmdGetMatch(svntestcmd, /^Last .*?(\d+)/); -if (cur_rev) - cur_cms = SVN; -else -{ - // SubWCRev failed, try hg - cur_rev = RunCmdGetMatch(hgcmd, /Revision.*?(\d+)/); - if (cur_rev) - cur_cms = HG; - else - { - // hg failed, try git - cur_rev = RunCmdGetMatch(gitcmd, /(.*)/); - if (cur_rev) - cur_cms = git; - else - { - WScript.Echo("Trying to get SVN, Hg, and git info all failed"); - WScript.Quit(1); - } - } -} - -// check if svnrev.h needs updating -if (cur_rev == file_rev) -{ - WScript.Echo("svnrev.h doesn't need updating (already at " + cur_rev + ")"); - WScript.Quit(0); -} -else if (cur_cms == SVN) -{ - // update using SubWCRev and template file - var ret = wshShell.run(svncmd, 0, true); -} -else -{ - // manually create the file - oFS.CreateTextFile(outfile, true).WriteLine("#define SVN_REV_STR \"" + cur_rev + "\""); -} -WScript.Echo("svnrev.h updated (" + cur_rev + ")"); \ No newline at end of file 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..d13c12ee7f 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" + "Compiled: " __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); }