]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4219 -- resolve windows version string. thanks Peter
authorJeff Lenk <jeff@jefflenk.com>
Fri, 10 Aug 2012 12:47:10 +0000 (07:47 -0500)
committerJeff Lenk <jeff@jefflenk.com>
Fri, 10 Aug 2012 12:47:10 +0000 (07:47 -0500)
libs/win32/util.vbs

index 4f13e21ad0ddf77afe56a90f6525d291f5e647d0..a6f3cf835daa02d9ef3e967f10c8ec2a86a842da 100644 (file)
@@ -314,6 +314,31 @@ Function GetTimeUTC()
 \r
 End Function\r
 \r
+Function GetWeekDay(DateTime)\r
+\r
+       DayOfWeek = DatePart("w", DateTime)\r
+\r
+       Select Case DayOfWeek\r
+               Case 1 GetWeekDay = "Sun"\r
+               Case 2 GetWeekDay = "Mon"\r
+               Case 3 GetWeekDay = "Tue"\r
+               Case 4 GetWeekDay = "Wed"\r
+               Case 5 GetWeekDay = "Thu"\r
+               Case 6 GetWeekDay = "Fri"\r
+               Case 7 GetWeekDay = "Sat"\r
+       End Select\r
+\r
+End Function\r
+\r
+Function GetMonthName(DateTime)\r
+\r
+       Val = MonthName(Month(DateTime), True)\r
+       Val = UCase(Left(Val, 1)) & Mid(Val, 2, 4)\r
+       \r
+       GetMonthName = Val\r
+       \r
+End Function\r
+\r
 Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)\r
        Dim oExec\r
        \r
@@ -321,6 +346,7 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)
        strVerMinor = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_MINOR")\r
        strVerMicro = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_MICRO")\r
        strVerRev   = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_REVISION")\r
+       strVerHuman = FindVersionStringInConfigure(VersionDir & "configure.in", "SWITCH_VERSION_REVISION_HUMAN")\r
        \r
        'Set version to the one reported by configure.in\r
        If strVerRev <> "" Then\r
@@ -329,6 +355,7 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)
 \r
        Dim sLastFile\r
        Const ForReading = 1\r
+       Const ShowUnclean = False 'Don't show unclean state for now\r
 \r
        'Try To read revision from git\r
        If FSO.FolderExists(VersionDir & ".git") Then\r
@@ -337,30 +364,38 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)
                If IsNumeric(strFromProc) Then\r
                        lastChangedDateTime = DateAdd("s", strFromProc, "01/01/1970 00:00:00")\r
                        strLastCommit = YEAR(lastChangedDateTime) & Pd(Month(lastChangedDateTime), 2) & Pd(DAY(lastChangedDateTime), 2) & "T" & Pd(Hour(lastChangedDateTime), 2) & Pd(Minute(lastChangedDateTime), 2) & Pd(Second(lastChangedDateTime), 2) & "Z"\r
+                       strLastCommitHuman = GetWeekDay(lastChangedDateTime) & ", " & Pd(DAY(lastChangedDateTime), 2) & " " & GetMonthName(lastChangedDateTime) & " " & YEAR(lastChangedDateTime) & " " & Pd(Hour(lastChangedDateTime), 2) & ":" & Pd(Minute(lastChangedDateTime), 2) & ":" & Pd(Second(lastChangedDateTime), 2) & " Z"\r
                Else\r
-                       strLastCommit = "UNKNOWN"\r
+                       strLastCommit = ""\r
+                       strLastCommitHuman = ""\r
                End If\r
 \r
                'Get revision hash\r
                strRevision = ExecAndGetResult(tmpFolder, VersionDir, "git rev-list -n1 --abbrev=10 --abbrev-commit HEAD")\r
                \r
-               If strRevision = "" Then\r
-                       strRevision = "UNKNOWN"\r
-               End If\r
-\r
-               'Bild version string\r
-               strGitVer="git~" & strLastCommit & "~" & strRevision\r
-\r
-               'Check for local changes, if found, append to git revision string\r
-               If ExecAndGetExitCode(tmpFolder, VersionDir, "git diff-index --quiet HEAD") <> 0 Then\r
-                       lastChangedDateTime = GetTimeUTC()\r
-                       strGitVer = strGitVer & "+unclean~" & YEAR(lastChangedDateTime) & Pd(Month(lastChangedDateTime), 2) & Pd(DAY(lastChangedDateTime), 2) & "T" & Pd(Hour(lastChangedDateTime), 2) & Pd(Minute(lastChangedDateTime), 2) & Pd(Second(lastChangedDateTime), 2) & "Z"\r
+               If strLastCommit <> "" And strLastCommitHuman <> "" And strRevision <> "" Then\r
+                       'Bild version string\r
+                       strGitVer = "git~" & strLastCommit & "~" & strRevision\r
+                       strVerHuman = "; git at commit " & strRevision & " on " & strLastCommitHuman\r
+\r
+                       'Check for local changes, if found, append to git revision string\r
+                       If ShowUnclean Then\r
+                               If ExecAndGetExitCode(tmpFolder, VersionDir, "git diff-index --quiet HEAD") <> 0 Then\r
+                                       lastChangedDateTime = GetTimeUTC()\r
+                                       strGitVer = strGitVer & "+unclean~" & YEAR(lastChangedDateTime) & Pd(Month(lastChangedDateTime), 2) & Pd(DAY(lastChangedDateTime), 2) & "T" & Pd(Hour(lastChangedDateTime), 2) & Pd(Minute(lastChangedDateTime), 2) & Pd(Second(lastChangedDateTime), 2) & "Z"\r
+                               End If\r
+                       End If\r
+               Else\r
+                       strGitVer = ""\r
+                       strVerHuman = ""\r
                End If\r
 \r
                If strVerRev = "" Then\r
                        VERSION=strGitVer\r
                Else\r
-                       VERSION=VERSION & "+" & strGitVer\r
+                       If strGitVer <> "" Then\r
+                               VERSION=VERSION & "+" & strGitVer\r
+                       End If\r
                End If\r
 \r
                sLastVersion = ""\r
@@ -371,13 +406,9 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)
                sLastFile.Close\r
        End If\r
        \r
-       If VERSION = "" Then\r
-               VERSION = "-UNKNOWN"\r
-       End If\r
-\r
-       If VERSION <> sLastVersion Then\r
+       If VERSION & " " & strVerHuman <> sLastVersion Then\r
                Set MyFile = fso.CreateTextFile(tmpFolder & "lastversion", True)\r
-               MyFile.WriteLine(VERSION)\r
+               MyFile.WriteLine(VERSION & " " & strVerHuman)\r
                MyFile.Close\r
        \r
                FSO.CopyFile includebase, includedest, true\r
@@ -385,6 +416,7 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)
                FindReplaceInFile includedest, "@SWITCH_VERSION_MAJOR@", strVerMajor\r
                FindReplaceInFile includedest, "@SWITCH_VERSION_MINOR@", strVerMinor\r
                FindReplaceInFile includedest, "@SWITCH_VERSION_MICRO@", strVerMicro\r
+               FindReplaceInFile includedest, "@SWITCH_VERSION_REVISION_HUMAN@", strVerHuman\r
        End If\r
        \r
 End Sub\r