mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Make the jscript for writing out scmrev.h work on windows.
Add scmrev.h to .gitignore Remove some SubWCRev.exe and it's template
This commit is contained in:
88
Source/Core/Common/make_scmrev.h.js
Normal file
88
Source/Core/Common/make_scmrev.h.js
Normal file
@ -0,0 +1,88 @@
|
||||
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 GetRevFromFile(f)
|
||||
{
|
||||
try
|
||||
{
|
||||
// read the current hash
|
||||
return oFS.OpenTextFile(f).ReadAll().match(/SCM_REV_STR\s+"([0-9a-f]+)/)[1];
|
||||
}
|
||||
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 (revision == GetRevFromFile(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 + ")");
|
||||
}
|
Reference in New Issue
Block a user