From 92693418d4a40c006e1f049b0a2f9beb0e988be5 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Sun, 27 Aug 2006 20:37:01 +0000 Subject: [PATCH] move creation of the version header file to use util.vbs git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2410 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- Freeswitch.sln | 7 ---- libs/win32/util.vbs | 62 +++++++++++++++++++++++++++++++++ w32/vsnet/FreeSwitchCore.vcproj | 30 ++++++++++++++++ 3 files changed, 92 insertions(+), 7 deletions(-) diff --git a/Freeswitch.sln b/Freeswitch.sln index c1479b4644..9b5d3da8ce 100644 --- a/Freeswitch.sln +++ b/Freeswitch.sln @@ -11,7 +11,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchConsole", "w32\vs EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchCoreLib", "w32\vsnet\FreeSwitchCore.vcproj", "{202D7A4E-760D-4D0E-AFA1-D7459CED30FF}" ProjectSection(ProjectDependencies) = postProject - {FE191916-DEDD-43B3-B28C-D09C9088C586} = {FE191916-DEDD-43B3-B28C-D09C9088C586} {50AD0E28-B8D7-4FCC-8FC3-599F6AC69761} = {50AD0E28-B8D7-4FCC-8FC3-599F6AC69761} {8D04B550-D240-4A44-8A18-35DA3F7038D9} = {8D04B550-D240-4A44-8A18-35DA3F7038D9} {F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3} @@ -154,8 +153,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{CBD81696-E EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "docs", "docs\docs.vcproj", "{1A1FF289-4FD6-4285-A422-D31DD67A4723}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchVersion", "w32\vsnet\FreeSwitchVersion.vcproj", "{FE191916-DEDD-43B3-B28C-D09C9088C586}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_xml", "src\mod\dialplans\mod_dialplan_xml\mod_dialplan_xml.vcproj", "{07113B25-D3AF-4E04-BA77-4CD1171F022C}" ProjectSection(ProjectDependencies) = postProject {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} @@ -592,10 +589,6 @@ Global {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.Build.0 = Release|Win32 {1A1FF289-4FD6-4285-A422-D31DD67A4723}.Debug|Win32.ActiveCfg = Debug|Win32 {1A1FF289-4FD6-4285-A422-D31DD67A4723}.Release|Win32.ActiveCfg = Release|Win32 - {FE191916-DEDD-43B3-B28C-D09C9088C586}.Debug|Win32.ActiveCfg = Debug|Win32 - {FE191916-DEDD-43B3-B28C-D09C9088C586}.Debug|Win32.Build.0 = Debug|Win32 - {FE191916-DEDD-43B3-B28C-D09C9088C586}.Release|Win32.ActiveCfg = Release|Win32 - {FE191916-DEDD-43B3-B28C-D09C9088C586}.Release|Win32.Build.0 = Release|Win32 {07113B25-D3AF-4E04-BA77-4CD1171F022C}.Debug|Win32.ActiveCfg = Debug|Win32 {07113B25-D3AF-4E04-BA77-4CD1171F022C}.Debug|Win32.Build.0 = Debug|Win32 {07113B25-D3AF-4E04-BA77-4CD1171F022C}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/libs/win32/util.vbs b/libs/win32/util.vbs index bec45b1b5d..b2cedcd6c7 100644 --- a/libs/win32/util.vbs +++ b/libs/win32/util.vbs @@ -45,6 +45,9 @@ If objArgs.Count >=3 Then Wget objArgs(1), Showpath(objArgs(2)) Case "GetUnzip" WgetUnCompress objArgs(1), Showpath(objArgs(2)) + Case "Version" + 'CreateVersion(tmpFolder, VersionDir, includebase, includedest) + CreateVersion Showpath(objArgs(1)), Showpath(objArgs(2)), objArgs(3), objArgs(4) End Select End If @@ -180,3 +183,62 @@ Function Showpath(folderspec) Set f = FSO.GetFolder(folderspec) showpath = f.path & "\" End Function + +Sub FindReplaceInFile(FileName, sFind, sReplace) + Const OpenAsASCII = 0 ' Opens the file as ASCII (TristateFalse) + Const OpenAsUnicode = -1 ' Opens the file as Unicode (TristateTrue) + Const OpenAsDefault = -2 ' Opens the file using the system default + + Const OverwriteIfExist = -1 + Const FailIfNotExist = 0 + Const ForReading = 1 + + Set fOrgFile = FSO.OpenTextFile(FileName, ForReading, FailIfNotExist, OpenAsASCII) + sText = fOrgFile.ReadAll + fOrgFile.Close + sText = Replace(sText, sFind, sReplace) + Set fNewFile = FSO.CreateTextFile(FileName, OverwriteIfExist, OpenAsASCII) + fNewFile.WriteLine sText + fNewFile.Close +End Sub + +Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest) + Dim oExec + If Right(tmpFolder, 1) <> "\" Then tmpFolder = tmpFolder & "\" End If + If Not FSO.FileExists(tmpFolder & "svnversion.exe") Then + Wget ToolsBase & "svnversion.exe", tmpFolder + End If + Dim sLastFile + Const OverwriteIfExist = -1 + Const ForReading = 1 + VersionCmd="svnversion " & quote & VersionDir & "." & quote & " -n" + Set MyFile = fso.CreateTextFile(tmpFolder & "tmpVersion.Bat", True) + MyFile.WriteLine("@" & "cd " & quote & tmpFolder & quote ) + MyFile.WriteLine("@" & VersionCmd) + MyFile.Close + Set oExec = WshShell.Exec(tmpFolder & "tmpVersion.Bat") + Do + strFromProc = OExec.StdOut.ReadLine() + VERSION=strFromProc + Loop While Not OExec.StdOut.atEndOfStream + sLastVersion = "" + Set sLastFile = FSO.OpenTextFile(tmpFolder & "lastversion", ForReading, true, OpenAsASCII) + If Not sLastFile.atEndOfStream Then + sLastVersion = sLastFile.ReadLine() + End If + sLastFile.Close + + If VERSION = "" Then + VERSION = "UNKNOWN" + End If + + If VERSION <> sLastVersion Then + Set MyFile = fso.CreateTextFile(tmpFolder & "lastversion", True) + MyFile.WriteLine(VERSION) + MyFile.Close + + FSO.CopyFile includebase, includedest, true + FindReplaceInFile includedest, "@SVN_VERSION@", VERSION + End If + +End Sub diff --git a/w32/vsnet/FreeSwitchCore.vcproj b/w32/vsnet/FreeSwitchCore.vcproj index c1e59911bd..6bf5a4d643 100644 --- a/w32/vsnet/FreeSwitchCore.vcproj +++ b/w32/vsnet/FreeSwitchCore.vcproj @@ -384,6 +384,36 @@ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > + + + + + + + + + +