minimum work needed to get windows picking git's lamehash instead of svn's coolrev. thanks to dolphin for the script. other frontends shouldn't be affected.

This commit is contained in:
zeromus 2016-11-23 23:54:16 -06:00
parent e1d635c392
commit 2144f44c67
15 changed files with 112 additions and 25 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/desmume/src/frontend/windows/defaultconfig/scmrev.h
/desmume/src/frontend/windows/.libs
/desmume/src/frontend/windows/.obj
/desmume/src/frontend/windows/__bins

View File

@ -1,2 +0,0 @@
defaultconfig\SubWCRev.exe ..\.. ".\defaultconfig\svnrev_template.h" ".\userconfig\svnrev.h"
exit 0

View File

@ -0,0 +1,100 @@
var wshShell = new ActiveXObject("WScript.Shell")
var oFS = new ActiveXObject("Scripting.FileSystemObject");
var outfile = "./defaultconfig/scmrev.h";
var cmd_revision = " rev-parse HEAD";
var cmd_describe = " describe --always --long --dirty";
var cmd_branch = " rev-parse --abbrev-ref HEAD";
function GetGitExe()
{
try
{
gitexe = wshShell.RegRead("HKCU\\Software\\GitExtensions\\gitcommand");
wshShell.Exec(gitexe);
return gitexe;
}
catch (e)
{}
for (var gitexe in {"git.cmd":1, "git":1, "git.bat":1})
{
try
{
wshShell.Exec(gitexe);
return gitexe;
}
catch (e)
{}
}
// last try - msysgit not in path (vs2015 default)
msyspath = "\\Git\\cmd\\git.exe";
gitexe = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES(x86)%") + msyspath;
if (oFS.FileExists(gitexe)) {
return gitexe;
}
gitexe = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES%") + msyspath;
if (oFS.FileExists(gitexe)) {
return gitexe;
}
WScript.Echo("Cannot find git or git.cmd, check your PATH:\n" +
wshShell.ExpandEnvironmentStrings("%PATH%"));
WScript.Quit(1);
}
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
return "";
}
}
// 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 isStable = +("master" == branch || "stable" == branch);
// remove hash (and trailing "-0" if needed) from description
describe = describe.replace(/(-0)?-[^-]+(-dirty)?$/, '$2');
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 " + isStable + "\n";
// check if file needs updating
if (out_contents == GetFileContents(outfile))
{
WScript.Echo(outfile + " current at " + describe);
}
else
{
// needs updating - writeout current info
oFS.CreateTextFile(outfile, true).Write(out_contents);
WScript.Echo(outfile + " updated to " + describe);
}

View File

@ -1,5 +0,0 @@
//this should be overridden with one generated in userconfig
//but it is here just in case to prevent compiler errors
#define SVN_REV 0
#define SVN_REV_STR "0"

View File

@ -1,2 +0,0 @@
#define SVN_REV $WCREV$
#define SVN_REV_STR "$WCREV$"

View File

@ -82,7 +82,7 @@
<ItemDefinitionGroup>
<PreBuildEvent>
<Command>defaultconfig\SubWCRev.bat</Command>
<Command>"%windir%\Sysnative\cscript" /nologo /E:JScript "defaultconfig\make_scmrev.h.js"</Command>
</PreBuildEvent>
<ClCompile>

View File

@ -66,7 +66,7 @@ int lastSaveState = 0; //Keeps track of last savestate used for quick save/load
#define SS_INDIRECT 0x80000000
u32 _DESMUME_version = EMU_DESMUME_VERSION_NUMERIC();
u32 svn_rev = EMU_DESMUME_SUBVERSION_NUMERIC();
u32 svn_rev = 0; //EMU_DESMUME_VERSION_NUMERIC(); //sorry, not using this now
s64 save_time = 0;
NDS_SLOT1_TYPE slot1Type = NDS_SLOT1_RETAIL_AUTO;
NDS_SLOT2_TYPE slot2Type = NDS_SLOT2_AUTO;
@ -1044,7 +1044,7 @@ bool savestate_save (const char *file_name)
static void writechunks(EMUFILE* os) {
DateTime tm = DateTime::get_Now();
svn_rev = EMU_DESMUME_SUBVERSION_NUMERIC();
svn_rev = 0;
save_time = tm.get_Ticks();

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2009-2015 DeSmuME team
Copyright (C) 2009-2016 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -31,12 +31,15 @@
#define TOSTRING(x) STRINGIFY(x)
#endif
//todo - everyone will want to support this eventually, i suppose
#if defined(HOST_WINDOWS) || defined(DESMUME_COCOA)
//TODO - it isn't possible to build a core without a frontend, so really this belongs with frontend modules
//the only stuff that belongs in the core is major/minor/build versions which are (in principle) used for versioning savestates and movies and such..
#if defined(HOST_WINDOWS)
#include "scmrev.h"
#define SVN_REV_STR SCM_DESC_STR
#elif defined(DESMUME_COCOA)
#include "svnrev.h"
#else
#ifndef SVN_REV
#define SVN_REV 0
#define SVN_REV_STR "0"
#endif
#endif
@ -106,7 +109,7 @@
#elif defined(PUBLIC_RELEASE)
#define DESMUME_SUBVERSION_STRING ""
#else
#define DESMUME_SUBVERSION_STRING " svn" SVN_REV_STR
#define DESMUME_SUBVERSION_STRING " git#" SVN_REV_STR
#endif
#ifdef __INTEL_COMPILER
@ -140,12 +143,6 @@
#define DESMUME_JIT ""
#endif
#ifdef PUBLIC_RELEASE
const u32 DESMUME_SUBVERSION_NUMERIC = 0xFFFFFFFF;
#else
const u32 DESMUME_SUBVERSION_NUMERIC = SVN_REV;
#endif
const u8 DESMUME_VERSION_MAJOR = 0;
const u8 DESMUME_VERSION_MINOR = 9;
const u8 DESMUME_VERSION_BUILD = 12;
@ -155,7 +152,6 @@ const u8 DESMUME_VERSION_BUILD = 12;
#define DESMUME_NAME_AND_VERSION DESMUME_NAME DESMUME_VERSION_STRING
u32 EMU_DESMUME_VERSION_NUMERIC() { return DESMUME_VERSION_NUMERIC; }
u32 EMU_DESMUME_SUBVERSION_NUMERIC() { return DESMUME_SUBVERSION_NUMERIC; }
const char* EMU_DESMUME_VERSION_STRING() { return DESMUME_VERSION_STRING; }
const char* EMU_DESMUME_SUBVERSION_STRING() { return DESMUME_SUBVERSION_STRING; }
const char* EMU_DESMUME_NAME_AND_VERSION() { return DESMUME_NAME_AND_VERSION; }

View File

@ -23,7 +23,6 @@ extern const u8 DESMUME_VERSION_MINOR;
extern const u8 DESMUME_VERSION_BUILD;
u32 EMU_DESMUME_VERSION_NUMERIC();
u32 EMU_DESMUME_SUBVERSION_NUMERIC();
const char* EMU_DESMUME_VERSION_STRING();
const char* EMU_DESMUME_SUBVERSION_STRING();
const char* EMU_DESMUME_NAME_AND_VERSION();