Merge branch 'new-rev-string'

This commit is contained in:
Shawn Hoffman 2011-08-22 08:43:32 -07:00
commit 0090c9db9e
21 changed files with 146 additions and 126 deletions

3
.gitignore vendored
View File

@ -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

View File

@ -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")

View File

@ -259,8 +259,6 @@
<ClInclude Include="Src\StdMutex.h" />
<ClInclude Include="Src\StdThread.h" />
<ClInclude Include="Src\StringUtil.h" />
<ClInclude Include="Src\svnrev.h" />
<ClInclude Include="Src\svnrev_template.h" />
<ClInclude Include="Src\SymbolDB.h" />
<ClInclude Include="Src\SysConf.h" />
<ClInclude Include="Src\Thread.h" />

View File

@ -87,8 +87,6 @@
<ClInclude Include="Src\stdafx.h" />
<ClInclude Include="Src\StdThread.h" />
<ClInclude Include="Src\StringUtil.h" />
<ClInclude Include="Src\svnrev.h" />
<ClInclude Include="Src\svnrev_template.h" />
<ClInclude Include="Src\SymbolDB.h" />
<ClInclude Include="Src\SysConf.h" />
<ClInclude Include="Src\Thread.h" />

View File

@ -7,19 +7,16 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="make_svnrev.h.js">
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cscript /nologo /E:JScript "make_svnrev.h.js"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Updating svnrev.h</Message>
<CustomBuild Include="make_scmrev.h.js">
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cscript /nologo /E:JScript "make_scmrev.h.js"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Updating scmrev.h</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">dummy</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Src\svnrev.h" />
<ClInclude Include="Src\svnrev_template.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{69F00340-5C3D-449F-9A80-958435C6CF06}</ProjectGuid>
<RootNamespace>SVNRevGen</RootNamespace>
<ProjectName>SCMRevGen</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">

View File

@ -26,7 +26,7 @@
#include <string.h>
// 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

View File

@ -16,16 +16,22 @@
// 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;
#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"
#else
@ -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

View File

@ -1 +0,0 @@
#define SVN_REV_STR "$WCMODS?$WCREV$M:$WCREV$$"

Binary file not shown.

View File

@ -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 + ")");
}

View File

@ -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 + ")");

View File

@ -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());

View File

@ -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"

View File

@ -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,

View File

@ -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);

View File

@ -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 <file>] [-h] [-v]\n", argv[0]);
fprintf(stderr, " -e, --exec Load the specified file\n");

View File

@ -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");

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}