diff --git a/Source/Core/Common/make_svnrev.h.vbs b/Source/Core/Common/make_svnrev.h.vbs index c16e4c8219..76d04a7f84 100644 --- a/Source/Core/Common/make_svnrev.h.vbs +++ b/Source/Core/Common/make_svnrev.h.vbs @@ -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 \ No newline at end of file