Change make_svnrev.h.vbs so that it won't cause svnrev.h to be regenerated if it's already at the current revision (saves re-linking all the time)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6065 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2010-08-07 21:22:15 +00:00
parent b2791b2d79
commit 521c7558bc

View File

@ -2,21 +2,38 @@ set wshShell = CreateObject("WScript.Shell")
basedir = wscript.arguments(0)
outfile = basedir & "/Src/svnrev.h"
svncmd = "SubWCRev ../../.. " & basedir & "/Src/svnrev_template.h " & outfile
svntestcmd = "SubWCRev ../../.."
hgcmd = "hg svn info"
const svn = 0
const hg = 1
ret = wshShell.run(svncmd, 0, true)
if ret <> 0 then ' Perhaps we should just check for 6? dunno/care...
set hgexec = wshShell.exec(hgcmd)
set oFS = CreateObject("Scripting.fileSystemObject")
if not oFS.FileExists(outfile) then
oFS.CreateTextFile(outfile)
file_rev = 0
else
set oFile = oFS.OpenTextFile(outfile)
set re = new regexp
re.pattern = "[0-9]+"
file_rev = re.execute(oFile.readline)(0)
end if
set testexec = wshShell.exec(svntestcmd)
do while testexec.status = 0 : wscript.sleep 100 : loop
if testexec.exitcode = 0 then
testout = testexec.stdout.readall
set re = new regexp
re.pattern = "Updated to revision [0-9]+"
cur_rev = split(re.execute(testout)(0))(3)
cur_cms = svn
else
set hgexec = wshShell.exec(hgcmd)
do while hgexec.status = 0 : wscript.sleep 100 : loop
do while true
line = hgexec.stdout.readline
if instr(line, "Revision") then
sline = split(line)
wscript.echo "Hg: Working copy at SVN revision " & sline(1)
set oFS = CreateObject("Scripting.fileSystemObject")
set oFile = oFS.CreateTextFile(outfile, true)
oFile.writeline("#define SVN_REV_STR """ & sline(1) & """")
set oFS = nothing
cur_rev = split(line)(1)
cur_cms = hg
exit do
end if
if hgexec.stdout.atEndofStream then
@ -25,3 +42,15 @@ if ret <> 0 then ' Perhaps we should just check for 6? dunno/care...
end if
loop
end if
if file_rev = cur_rev then
wscript.echo "svnrev.h doesn't need updating"
wscript.quit 0
elseif cur_cms = svn then
ret = wshShell.run(svncmd, 0, true)
elseif cur_cms = hg then
set oFile = CreateObject("Scripting.fileSystemObject").CreateTextFile(outfile, true)
oFile.writeline("#define SVN_REV_STR """ & cur_rev & """")
else
wscript.echo "WTF, shouldn't be here!"
end if