]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[FreeSwitchConsole] -version option enabled in windows + read git revision
authorrucc <36731290+rucc@users.noreply.github.com>
Tue, 22 Dec 2020 16:50:27 +0000 (17:50 +0100)
committerGitHub <noreply@github.com>
Tue, 22 Dec 2020 16:50:27 +0000 (20:50 +0400)
src/switch.c
w32/switch_version.props

index 22f780db6347b94b2dfe3f7a711546d51e9cf41c..abb66ef86faec582c36f6140d2f0ac052342e30c 100644 (file)
@@ -686,11 +686,6 @@ int main(int argc, char *argv[])
                        reincarnate = SWITCH_TRUE;
                        reincarnate_reexec = SWITCH_TRUE;
                }
-
-               else if (!strcmp(local_argv[x], "-version")) {
-                       fprintf(stdout, "FreeSWITCH version: %s (%s)\n", switch_version_full(), switch_version_revision_human());
-                       exit(EXIT_SUCCESS);
-               }
 #endif
 #ifdef HAVE_SETRLIMIT
                else if (!strcmp(local_argv[x], "-core")) {
@@ -715,6 +710,11 @@ int main(int argc, char *argv[])
 #endif
                }
 #endif
+               else if (!strcmp(local_argv[x], "-version")) {
+                       fprintf(stdout, "FreeSWITCH version: %s (%s)\n", switch_version_full(), switch_version_revision_human());
+                       exit(EXIT_SUCCESS);
+               }
+
                else if (!strcmp(local_argv[x], "-hp") || !strcmp(local_argv[x], "-rp")) {
                        priority = 2;
                }
index c01de029ec2b711f032102b5b33f6ecc108695e8..c19b7c6a95114a9c7c6a2917f182dc8ab9dd7a77 100644 (file)
@@ -1,7 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" InitialTargets="GitVersion" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <GitSkipCache>true</GitSkipCache>
+  </PropertyGroup>
   <ImportGroup Label="PropertySheets">
     <Import Project="basedir.props" Condition=" '$(BaseDirImported)' == ''"/>
+    <Import Project="Setup\GitInfo\GitInfo.targets" />
   </ImportGroup>
 
   <PropertyGroup>
   <UsingTask TaskName="SwitchVersionTask" 
              TaskFactory="CodeTaskFactory"  
              AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
+             <ParameterGroup>
+                <commits Required="true" />
+                <revision Required="true" />
+             </ParameterGroup>
              <Task>  
                 <Reference Include="Microsoft.Build" />
                 <Reference Include="Microsoft.Build.Framework" />
@@ -24,6 +32,10 @@ using Microsoft.Build.Framework;
 
     public class SwitchVersionTask : Microsoft.Build.Utilities.Task
     {
+        [Required]
+        public string revision { get; set; }
+        public string commits { get; set; }
+
         private string basedir;
         private string TemplatePath;
         private string DestinationPath;
@@ -32,6 +44,9 @@ using Microsoft.Build.Framework;
         {
             basedir = Path.GetFullPath(@"$(BaseDir)");
 
+            int commit_count = 0;
+            Int32.TryParse(commits, out commit_count);
+
             Log.LogMessage(MessageImportance.High,
                   "Parsing FreeSWITCH version.");                    
 
@@ -49,9 +64,26 @@ using Microsoft.Build.Framework;
                    string[] tokens = value.Split('-');
                    value = tokens[0];
                }        
-               v.Add(m.Groups[1].Value.Trim(), value.Trim());
-               Log.LogMessage(MessageImportance.High,
-                    m.Groups[1].Value + " = '" + value.Trim() + "'");                    
+               var name = m.Groups[1].Value.Trim();
+               value = value.Trim();
+
+               if (name.StartsWith("SWITCH_VERSION_REVISION")) {
+                   if (string.IsNullOrWhiteSpace(value)) {
+                       value = revision;
+                   }
+
+                   if (name != "SWITCH_VERSION_REVISION_HUMAN") {
+                       value = "~" + value;
+                   
+                       if (commit_count > 0) {
+                           value = "-dev-"+ commits + value;
+                       } else {
+                           value = "-release" + value;
+                       }
+                   }
+               }
+               v.Add(name, value);
+               Log.LogMessage(MessageImportance.High, name + " = '" + value + "'");
             }
             
             //---------------------------------------------------------            
@@ -93,7 +125,7 @@ using Microsoft.Build.Framework;
   </UsingTask>  
 
   <Target Name="SwitchVersionTarget" BeforeTargets="CustomBuild;Build">  
-      <SwitchVersionTask>         
+      <SwitchVersionTask commits="$(GitCommits)" revision="$(GitCommit)">
       </SwitchVersionTask>         
   </Target>