mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r11334) -Codechange: add hg detection to MSVC
This commit is contained in:
parent
68a1fbd437
commit
4fdfd76b3b
|
@ -22,27 +22,33 @@ Sub UpdateFile(revision, version, cur_date, filename)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub UpdateFiles(version)
|
Sub UpdateFiles(version)
|
||||||
Dim cur_date
|
Dim WshShell, cur_date, revision, oExec
|
||||||
|
Set WshShell = CreateObject("WScript.Shell")
|
||||||
cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date)
|
cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date)
|
||||||
Dim revision
|
revision = 0
|
||||||
If version = "norev000" Then
|
Select Case Mid(version, 1, 1)
|
||||||
revision = 0
|
Case "r" ' svn
|
||||||
Else
|
revision = Mid(version, 2)
|
||||||
revision = Mid(version, 2)
|
If InStr(revision, "M") Then
|
||||||
If InStr(revision, "M") Then
|
revision = Mid(revision, 1, InStr(revision, "M") - 1)
|
||||||
revision = Mid(revision, 1, InStr(revision, "M") - 1)
|
End If
|
||||||
End If
|
If InStr(revision, "-") Then
|
||||||
If InStr(revision, "-") Then
|
revision = Mid(revision, 1, InStr(revision, "-") - 1)
|
||||||
revision = Mid(revision, 1, InStr(revision, "-") - 1)
|
End If
|
||||||
End If
|
Case "h" ' mercurial (hg)
|
||||||
End If
|
Set oExec = WshShell.Exec("hg log -k " & Chr(34) & "svn" & Chr(34) & " -l 1 --template " & Chr(34) & "{desc}\n" & Chr(34) & " ../src")
|
||||||
|
If Err.Number = 0 Then
|
||||||
|
revision = Mid(OExec.StdOut.ReadLine(), 7)
|
||||||
|
revision = Mid(revision, 1, InStr(revision, ")") - 1)
|
||||||
|
End If
|
||||||
|
End Select
|
||||||
|
|
||||||
UpdateFile revision, version, cur_date, "../src/rev.cpp"
|
UpdateFile revision, version, cur_date, "../src/rev.cpp"
|
||||||
UpdateFile revision, version, cur_date, "../src/ottdres.rc"
|
UpdateFile revision, version, cur_date, "../src/ottdres.rc"
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Function DetermineSVNVersion()
|
Function DetermineSVNVersion()
|
||||||
Dim WshShell, version, url, oExec
|
Dim WshShell, version, url, oExec, line
|
||||||
Set WshShell = CreateObject("WScript.Shell")
|
Set WshShell = CreateObject("WScript.Shell")
|
||||||
On Error Resume Next
|
On Error Resume Next
|
||||||
|
|
||||||
|
@ -92,7 +98,6 @@ Function DetermineSVNVersion()
|
||||||
' And use svn info to get the correct revision and branch information.
|
' And use svn info to get the correct revision and branch information.
|
||||||
Set oExec = WshShell.Exec("svn info ../src")
|
Set oExec = WshShell.Exec("svn info ../src")
|
||||||
If Err.Number = 0 Then
|
If Err.Number = 0 Then
|
||||||
Dim line
|
|
||||||
Do
|
Do
|
||||||
line = OExec.StdOut.ReadLine()
|
line = OExec.StdOut.ReadLine()
|
||||||
If InStr(line, "URL") Then
|
If InStr(line, "URL") Then
|
||||||
|
@ -112,6 +117,28 @@ Function DetermineSVNVersion()
|
||||||
url = Mid(url, 1, InStr(2, url, "/") - 1)
|
url = Mid(url, 1, InStr(2, url, "/") - 1)
|
||||||
version = version & Replace(url, "/", "-")
|
version = version & Replace(url, "/", "-")
|
||||||
End If
|
End If
|
||||||
|
Else
|
||||||
|
' svn detection failed, reset error and try mercurial (hg)
|
||||||
|
Err.Clear
|
||||||
|
Set oExec = WshShell.Exec("hg tip")
|
||||||
|
If Err.Number = 0 Then
|
||||||
|
version = "h" & Mid(OExec.StdOut.ReadLine(), 19, 8)
|
||||||
|
Set oExec = WshShell.Exec("hg status ../src")
|
||||||
|
If Err.Number = 0 Then
|
||||||
|
Do
|
||||||
|
line = OExec.StdOut.ReadLine()
|
||||||
|
If Mid(line, 1, 1) <> "?" Then
|
||||||
|
version = version & "M"
|
||||||
|
Exit Do
|
||||||
|
End If
|
||||||
|
Loop While Not OExec.StdOut.atEndOfStream
|
||||||
|
End If
|
||||||
|
Set oExec = WshShell.Exec("hg branch")
|
||||||
|
If Err.Number = 0 Then
|
||||||
|
line = OExec.StdOut.ReadLine()
|
||||||
|
If line <> "default" Then version = version & "-" & line
|
||||||
|
End If
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
DetermineSVNVersion = version
|
DetermineSVNVersion = version
|
||||||
|
|
Loading…
Reference in New Issue