aboutsummaryrefslogtreecommitdiff
path: root/devtools/create_project/scripts/revision.vbs
diff options
context:
space:
mode:
authorMatthew Hoops2011-05-18 18:23:37 -0400
committerMatthew Hoops2011-05-18 18:23:37 -0400
commitd4c92983920cfe3b25a22d91e12c750e591b917e (patch)
treec0b63318b9ba0e67528337cfaa21515def1c3962 /devtools/create_project/scripts/revision.vbs
parent7e2edf16b3e2bf1d2b31999979a60802514df6cb (diff)
parentcf107e24be28c7e6db65b5c7ffed120af4a7994b (diff)
downloadscummvm-rg350-d4c92983920cfe3b25a22d91e12c750e591b917e.tar.gz
scummvm-rg350-d4c92983920cfe3b25a22d91e12c750e591b917e.tar.bz2
scummvm-rg350-d4c92983920cfe3b25a22d91e12c750e591b917e.zip
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'devtools/create_project/scripts/revision.vbs')
-rw-r--r--devtools/create_project/scripts/revision.vbs58
1 files changed, 47 insertions, 11 deletions
diff --git a/devtools/create_project/scripts/revision.vbs b/devtools/create_project/scripts/revision.vbs
index 9c29a88f2d..e6fef57030 100644
--- a/devtools/create_project/scripts/revision.vbs
+++ b/devtools/create_project/scripts/revision.vbs
@@ -23,6 +23,21 @@
'
'/
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+' This script tries to determine a revision number based on the current working tree
+' by trying revision control tools in the following order:
+' - git (with hg-git detection)
+' - mercurial
+' - TortoiseSVN
+' - SVN
+'
+' It then writes a new header file to be included during build, with the revision
+' information, the current branch, the revision control system (when not git) and
+' a flag when the tree is dirty.
+'
+' This is called from the prebuild.cmd batch file
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
Option Explicit
' Working copy check priority:
@@ -65,6 +80,7 @@ Sub DetermineRevision()
If Not DetermineGitVersion() Then
If Not DetermineHgVersion() Then
Wscript.StdErr.WriteLine "Could not determine the current revision, skipping..."
+ OutputRevisionHeader ""
Exit Sub
End If
End If
@@ -76,20 +92,22 @@ Sub DetermineRevision()
If Not DetermineTortoiseSVNVersion() Then
If Not DetermineSVNVersion() Then
Wscript.StdErr.WriteLine "Could not determine the current revision, skipping..."
+ OutputRevisionHeader ""
Exit Sub
End If
End If
End If
End If
End If
-
- Wscript.StdErr.WriteLine "Found revision " & revision & " on branch " & branch & vbCrLf
-
+
+ Dim outputInfo : outputInfo = "Found revision " & revision & " on branch " & branch
+
' Setup our revision string
Dim revisionString : revisionString = revision
If (modified) Then
revisionString = revisionString & "-dirty"
+ outputInfo = outputInfo & " (dirty)"
End If
' If we are not on trunk, add the branch name to the revision string
@@ -100,11 +118,18 @@ Sub DetermineRevision()
' Add the DVCS name at the end (when not git)
If (tool <> "git") Then
revisionString = revisionString & "-" & tool
+ outputInfo = outputInfo & " using " & tool
End If
+
+ Wscript.StdErr.WriteLine outputInfo & vbCrLf
+
+ OutputRevisionHeader revisionString
+End Sub
- ' Output revision header file
+' Output revision header file
+Sub OutputRevisionHeader(str)
FSO.CopyFile rootFolder & "\\base\\internal_revision.h.in", targetFolder & "\\internal_revision.h"
- FindReplaceInFile targetFolder & "\\internal_revision.h", "@REVISION@", revisionString
+ FindReplaceInFile targetFolder & "\\internal_revision.h", "@REVISION@", str
End Sub
Function DetermineTortoiseSVNVersion()
@@ -213,10 +238,11 @@ Function DetermineGitVersion()
Err.Clear
On Error Resume Next
DetermineGitVersion = False
+ Dim line
Wscript.StdErr.Write " Git... "
tool = "git"
- ' First check if we have both a .git & .svn folders (in case hg-git has been set up to have the git folder at the working copy level)
+ ' First check if we have both a .git & .hg folders (in case hg-git has been set up to have the git folder at the working copy level)
If FSO.FolderExists(rootFolder & "/.git") And FSO.FolderExists(rootFolder & "/.hg") Then
Wscript.StdErr.WriteLine "Mercurial clone with git repository in tree!"
Exit Function
@@ -250,10 +276,10 @@ Function DetermineGitVersion()
End If
' Get the version hash
- Dim hash: hash = oExec.StdOut.ReadLine()
+ Dim hash : hash = oExec.StdOut.ReadLine()
' Make sure index is in sync with disk
- Set oExec = WshShell.Exec(gitPath & "update-index --refresh")
+ Set oExec = WshShell.Exec(gitPath & "update-index --refresh --unmerged")
If Err.Number = 0 Then
' Wait till the application is finished ...
Do While oExec.Status = 0
@@ -261,7 +287,7 @@ Function DetermineGitVersion()
Loop
End If
- Set oExec = WshShell.Exec(gitPath & "diff-index --exit-code --quiet HEAD " & rootFolder)
+ Set oExec = WshShell.Exec(gitPath & "diff-index --quiet HEAD " & rootFolder)
If oExec.ExitCode <> 0 Then
Wscript.StdErr.WriteLine "Error parsing git revision!"
Exit Function
@@ -279,14 +305,24 @@ Function DetermineGitVersion()
' Get branch name
Set oExec = WshShell.Exec(gitPath & "symbolic-ref HEAD")
If Err.Number = 0 Then
- Dim line: line = oExec.StdOut.ReadLine()
+ line = oExec.StdOut.ReadLine()
line = Mid(line, InStrRev(line, "/") + 1)
If line <> "master" Then
branch = line
End If
End If
- ' Fallback to abbreviated revision number
+ ' Get revision description
+ Set oExec = WshShell.Exec(gitPath & "describe --match desc/*")
+ If Err.Number = 0 Then
+ line = oExec.StdOut.ReadLine()
+ line = Mid(line, InStr(line, "-") + 1)
+ If line <> "" Then
+ revision = line
+ End If
+ End If
+
+ ' Fallback to abbreviated revision number if needed
If revision = "" Then
revision = Mid(hash, 1, 7)
End If