From 5618276f1884788f44c0f43d7a287e800ba8b5e8 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Thu, 28 Apr 2011 05:02:39 -0400 Subject: TOOLS: Add documentation to create_project installer/revision build scripts --- devtools/create_project/scripts/revision.vbs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'devtools/create_project/scripts/revision.vbs') diff --git a/devtools/create_project/scripts/revision.vbs b/devtools/create_project/scripts/revision.vbs index 9c29a88f2d..fb904856ec 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: @@ -216,7 +231,7 @@ Function DetermineGitVersion() 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 -- cgit v1.2.3 From 3f370629020d0d13c2612a55566b2c3480acc4eb Mon Sep 17 00:00:00 2001 From: Littleboy Date: Thu, 5 May 2011 13:53:32 -0400 Subject: CREATE_PROJECT: Generate the same revision numbers as the configure script The revision number now includes the number of commits since the last tag --- devtools/create_project/scripts/revision.vbs | 31 +++++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'devtools/create_project/scripts/revision.vbs') diff --git a/devtools/create_project/scripts/revision.vbs b/devtools/create_project/scripts/revision.vbs index fb904856ec..3e1212521c 100644 --- a/devtools/create_project/scripts/revision.vbs +++ b/devtools/create_project/scripts/revision.vbs @@ -97,14 +97,15 @@ Sub DetermineRevision() 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 @@ -115,7 +116,10 @@ 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 ' Output revision header file FSO.CopyFile rootFolder & "\\base\\internal_revision.h.in", targetFolder & "\\internal_revision.h" @@ -228,6 +232,7 @@ Function DetermineGitVersion() Err.Clear On Error Resume Next DetermineGitVersion = False + Dim line Wscript.StdErr.Write " Git... " tool = "git" @@ -265,10 +270,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 @@ -276,7 +281,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 @@ -294,14 +299,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 -- cgit v1.2.3 From a08158a004425afb89ca984379c6d27fa71e763b Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 13 May 2011 01:26:52 -0400 Subject: CREATE_PROJECT: Generate a default revision header when no revision can be determined --- devtools/create_project/scripts/revision.vbs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'devtools/create_project/scripts/revision.vbs') diff --git a/devtools/create_project/scripts/revision.vbs b/devtools/create_project/scripts/revision.vbs index 3e1212521c..e6fef57030 100644 --- a/devtools/create_project/scripts/revision.vbs +++ b/devtools/create_project/scripts/revision.vbs @@ -80,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 @@ -91,6 +92,7 @@ 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 @@ -121,9 +123,13 @@ Sub DetermineRevision() Wscript.StdErr.WriteLine outputInfo & vbCrLf - ' Output revision header file + OutputRevisionHeader revisionString +End Sub + +' 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() -- cgit v1.2.3