From 7a3a8c4b70141f48647f92f37e2addd22cce0e5c Mon Sep 17 00:00:00 2001 From: rucc <36731290+rucc@users.noreply.github.com> Date: Tue, 22 Dec 2020 17:50:27 +0100 Subject: [PATCH] [FreeSwitchConsole] -version option enabled in windows + read git revision --- src/switch.c | 10 +++++----- w32/switch_version.props | 42 +++++++++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/switch.c b/src/switch.c index 22f780db63..abb66ef86f 100644 --- a/src/switch.c +++ b/src/switch.c @@ -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; } diff --git a/w32/switch_version.props b/w32/switch_version.props index c01de029ec..c19b7c6a95 100644 --- a/w32/switch_version.props +++ b/w32/switch_version.props @@ -1,7 +1,11 @@ - + + + true + + @@ -11,6 +15,10 @@ + + + + @@ -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; - +