More cleanup of VersionInfo code gen

This commit is contained in:
YoshiRulz 2020-08-01 17:44:06 +10:00
parent 460613fba4
commit f6edd02195
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
10 changed files with 27 additions and 20 deletions

2
.gitignore vendored
View File

@ -25,7 +25,7 @@
/BizHawk.Client.EmuHawk/tools/TAStudio/HistoryBox.resx
/src/BizHawk.Common/SubWCRev.cs
/src/BizHawk.Common/VersionInfo.gen.cs

View File

@ -1,2 +1,2 @@
#!/bin/sh
cd "$(dirname "$0")/.." && printf "internal static class SubWCRev\n{\n\tpublic const string SVN_REV = \"%s\";\n\tpublic const string GIT_BRANCH = \"%s\";\n\tpublic const string GIT_SHORTHASH = \"%s\";\n}" "$(git rev-list HEAD --count)" "$(git rev-parse --abbrev-ref HEAD)" "$(git log -1 --format="%h")" >"$1"
sed -e "s;\\\$WCREV\\\$;$(git rev-list HEAD --count);" -e "s;\\\$WCBRANCH\\\$;$(git rev-parse --abbrev-ref HEAD);" -e "s;\\\$WCSHORTHASH\\\$;$(git log -1 --format="%h");" "$1" >"$2"

View File

@ -41,8 +41,8 @@ namespace BizHawk.Client.EmuHawk
DeveloperBuildLabel.Visible = VersionInfo.DeveloperBuild;
Text = VersionInfo.DeveloperBuild
? $" BizHawk (GIT {SubWCRev.GIT_BRANCH}#{SubWCRev.GIT_SHORTHASH})"
: $"Version {mainVersion} (GIT {SubWCRev.GIT_BRANCH}#{SubWCRev.GIT_SHORTHASH})";
? $" BizHawk (GIT {VersionInfo.GIT_BRANCH}#{VersionInfo.GIT_SHORTHASH})"
: $"Version {mainVersion} (GIT {VersionInfo.GIT_BRANCH}#{VersionInfo.GIT_SHORTHASH})";
VersionLabel.Text = $"Version {mainVersion}";
DateLabel.Text = VersionInfo.ReleaseDate;
@ -64,17 +64,17 @@ namespace BizHawk.Client.EmuHawk
});
}
linkLabel2.Text = $"Commit # {SubWCRev.GIT_SHORTHASH}";
linkLabel2.Text = $"Commit # {VersionInfo.GIT_SHORTHASH}";
}
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start($"https://github.com/TASVideos/BizHawk/commit/{SubWCRev.GIT_SHORTHASH}");
Process.Start($"https://github.com/TASVideos/BizHawk/commit/{VersionInfo.GIT_SHORTHASH}");
}
private void btnCopyHash_Click(object sender, EventArgs e)
{
Clipboard.SetText(SubWCRev.GIT_SHORTHASH);
Clipboard.SetText(VersionInfo.GIT_SHORTHASH);
}
private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

View File

@ -100,7 +100,6 @@
<ProjectReference Include="$(ProjectDir)../BizHawk.Client.Common/BizHawk.Client.Common.csproj" />
<ProjectReference Include="$(ProjectDir)../BizHawk.WinForms.Controls/BizHawk.WinForms.Controls.csproj" />
<Compile Include="$(ProjectDir)../BizHawk.Common/OSTailoredCode.cs" />
<Compile Include="$(ProjectDir)../BizHawk.Common/SubWCRev.cs" /><!-- bit of a hack - should this be public? -->
<Compile Remove="Properties/Settings.Designer.cs" />
<Content Include="images/logo.ico" />
<EmbeddedResource Include="images/**/*" />

View File

@ -12,6 +12,9 @@
<PackageReference Include="Menees.Analyzers" Version="2.0.4" Condition=" '$(MachineRunAnalyzersDuringBuild)' != '' " />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0" Condition=" '$(MachineRunAnalyzersDuringBuild)' != '' " />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164" Condition=" '$(MachineRunAnalyzersDuringBuild)' != '' " />
<ProjectReference Include="$(ProjectDir)../BizHawk.Version/BizHawk.Version.csproj" /><!-- generates SubWCRev.cs -->
<ProjectReference Include="$(ProjectDir)../BizHawk.Version/BizHawk.Version.csproj" /><!-- generates VersionInfo.gen.cs -->
</ItemGroup>
<ItemGroup>
<Compile Update="VersionInfo.gen.cs" DependentUpon="VersionInfo.cs" />
</ItemGroup>
</Project>

View File

@ -3,7 +3,7 @@ using System.Reflection;
namespace BizHawk.Common
{
public static class VersionInfo
public static partial class VersionInfo
{
// keep this updated at every major release
public const string MainVersion = "2.4.0"; // Use numbers only or the new version notification won't work
@ -16,7 +16,7 @@ namespace BizHawk.Common
public static string GetEmuVersion()
{
return DeveloperBuild
? "GIT " + SubWCRev.GIT_BRANCH + "#" + SubWCRev.GIT_SHORTHASH
? "GIT " + GIT_BRANCH + "#" + GIT_SHORTHASH
: "Version " + MainVersion;
}

View File

@ -6,10 +6,10 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<Target Name="PreBuild" AfterTargets="PreBuildEvent">
<Exec Condition=" '$(OS)' == 'Windows_NT' " Command='"$(ProjectDir)..\..\Build\BizHawk.Build.Tool.exe" GIT_REV --wc "$(ProjectDir).." --template "$(ProjectDir)svnrev_template" --out "$(ProjectDir)..\BizHawk.Common\SubWCRev.cs"' />
<Exec Condition=" '$(OS)' != 'Windows_NT' " Command='"$(ProjectDir)../../Build/standin.sh" "$(ProjectDir)..\BizHawk.Common\SubWCRev.cs"' />
<Exec Condition=" '$(OS)' == 'Windows_NT' " Command='"$(ProjectDir)..\..\Build\BizHawk.Build.Tool.exe" GIT_REV --wc "$(ProjectDir).." --template "$(ProjectDir)VersionInfo.gen_template.cs" --out "$(ProjectDir)..\BizHawk.Common\VersionInfo.gen.cs"' />
<Exec Condition=" '$(OS)' != 'Windows_NT' " Command='"$(ProjectDir)../../Build/standin.sh" "$(ProjectDir)VersionInfo.gen_template.cs" "$(ProjectDir)..\BizHawk.Common\VersionInfo.gen.cs"' />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Delete Files="$(OutputPath)BizHawk.Version.csproj" /><!-- no source files, generated svnrev.cs is included in BizHawk.Common -->
<Delete Files="$(OutputPath)BizHawk.Version.csproj" /><!-- no source files; VersionInfo.gen.cs is generated in BizHawk.Common -->
</Target>
</Project>

View File

@ -0,0 +1,11 @@
// This file (VersionInfo.gen.cs) is auto-generated. Any edits will be overwritten before compilation.
namespace BizHawk.Common
{
public static partial class VersionInfo
{
public const string SVN_REV = "$WCREV$";
public const string GIT_BRANCH = "$WCBRANCH$";
public const string GIT_SHORTHASH = "$WCSHORTHASH$";
}
}

View File

@ -1,6 +0,0 @@
static class SubWCRev
{
public const string SVN_REV = "$WCREV$";
public const string GIT_BRANCH = "$WCBRANCH$";
public const string GIT_SHORTHASH = "$WCSHORTHASH$";
}