[FreeSwitchConsole] -version option enabled in windows + read git revision

This commit is contained in:
rucc 2020-12-22 17:50:27 +01:00 committed by GitHub
parent 9908a9ac02
commit 7a3a8c4b70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 10 deletions

View 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;
}

View 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>
@ -11,6 +15,10 @@
<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>