mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07: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:
parent
9613713e14
commit
fc12633055
3
.gitignore
vendored
3
.gitignore
vendored
@ -29,9 +29,8 @@ _ReSharper*/
|
|||||||
[Tt]est[Rr]esult*
|
[Tt]est[Rr]esult*
|
||||||
Binary/Win32
|
Binary/Win32
|
||||||
Binary/x64
|
Binary/x64
|
||||||
Source/Core/Common/Src/svnrev.h
|
Source/Core/Common/Src/scmrev.h
|
||||||
*.opensdf
|
*.opensdf
|
||||||
*.sdf
|
*.sdf
|
||||||
[Bb]uild
|
[Bb]uild
|
||||||
|
|
||||||
*.ipch
|
*.ipch
|
@ -7,19 +7,12 @@
|
|||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CustomBuild Include="make_svnrev.h.js">
|
<None Include="make_scmrev.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>
|
|
||||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">dummy</Outputs>
|
|
||||||
</CustomBuild>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="Src\svnrev.h" />
|
|
||||||
<ClInclude Include="Src\svnrev_template.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{69F00340-5C3D-449F-9A80-958435C6CF06}</ProjectGuid>
|
<ProjectGuid>{69F00340-5C3D-449F-9A80-958435C6CF06}</ProjectGuid>
|
||||||
<RootNamespace>SVNRevGen</RootNamespace>
|
<RootNamespace>SVNRevGen</RootNamespace>
|
||||||
|
<ProjectName>SCMRevGen</ProjectName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
@ -1 +0,0 @@
|
|||||||
#define SVN_REV_STR "$WCMODS?$WCREV$M:$WCREV$$"
|
|
Binary file not shown.
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 + ")");
|
||||||
|
}
|
@ -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 + ")");
|
|
@ -35,7 +35,7 @@ AboutDolphin::AboutDolphin(wxWindow *parent, wxWindowID id,
|
|||||||
"\n"
|
"\n"
|
||||||
"Branch: " SCM_BRANCH_STR "\n"
|
"Branch: " SCM_BRANCH_STR "\n"
|
||||||
"Revision: " SCM_REV_STR "\n"
|
"Revision: " SCM_REV_STR "\n"
|
||||||
"Date: " __DATE__ " @ " __TIME__ "\n"
|
"Compiled: " __DATE__ " @ " __TIME__ "\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Dolphin is a Gamecube/Wii emulator, which was\n"
|
"Dolphin is a Gamecube/Wii emulator, which was\n"
|
||||||
"originally written by F|RES and ector.\n"
|
"originally written by F|RES and ector.\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user