Cleanup VersionInfo and code gen

This commit is contained in:
YoshiRulz 2020-08-01 11:34:16 +10:00
parent ebd9645c1e
commit e5de63ea94
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
26 changed files with 73 additions and 89 deletions

4
.gitignore vendored
View File

@ -1,7 +1,6 @@
/snes9xgit
svnrev.cs
**/.vs/**
**/bin/**
**/obj/**
@ -26,7 +25,7 @@ svnrev.cs
/BizHawk.Client.EmuHawk/tools/TAStudio/HistoryBox.resx
/BizHawk.Emulation.DiscSystem/Properties/svnrev.cs
/src/BizHawk.Common/SubWCRev.cs
@ -37,7 +36,6 @@ svnrev.cs
/LuaInterface/LuaInterface/Properties
/Version/bin
/Version/obj
/Version/svnrev.cs
/attic/PsxHawk.API/Release
/attic/PsxHawk.Core/Debug
/attic/PsxHawk.Core/Release

View File

@ -1,2 +1,2 @@
#!/bin/sh
cd "$(dirname "$0")/../src/BizHawk.Version" && printf "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")" >svnrev.cs
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"

View File

@ -7,7 +7,5 @@
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="all" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Common/BizHawk.Common.csproj" />
<Compile Include="$(ProjectDir)../BizHawk.Version/svnrev.cs" />
<Compile Include="$(ProjectDir)../BizHawk.Version/VersionInfo.cs" />
</ItemGroup>
</Project>

View File

@ -9,8 +9,6 @@
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="OpenTK" Version="3.0.1" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Common/BizHawk.Common.csproj" />
<Compile Include="$(ProjectDir)../BizHawk.Version/svnrev.cs" />
<Compile Include="$(ProjectDir)../BizHawk.Version/VersionInfo.cs" />
</ItemGroup>
<ItemGroup>
<Compile Update="IGuiRenderer.cs" SubType="Code" />

View File

@ -11,8 +11,6 @@
<PackageReference Include="SharpZipLib" Version="1.1.0" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Bizware.BizwareGL/BizHawk.Bizware.BizwareGL.csproj" />
<Compile Include="$(ProjectDir)../BizHawk.Version/svnrev.cs" />
<Compile Include="$(ProjectDir)../BizHawk.Version/VersionInfo.cs" />
</ItemGroup>
<ItemGroup>
<Compile Update="movie/bk2/Bk2Movie.HeaderApi.cs" DependentUpon="Bk2Movie.cs" />

View File

@ -3,6 +3,8 @@
using System.Collections.Generic;
using System.Linq;
using BizHawk.Common;
namespace BizHawk.Client.Common
{
public sealed class FilesystemFilter

View File

@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using BizHawk.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Emulation.Cores.Nintendo.GBHawk;

View File

@ -1,6 +1,8 @@
using System;
using System.IO;
using BizHawk.Common;
namespace BizHawk.Client.Common
{
public class ZipStateSaver : IDisposable

View File

@ -65,8 +65,6 @@
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Emulation.DiscSystem/BizHawk.Emulation.DiscSystem.csproj" />
<Compile Include="$(ProjectDir)../BizHawk.Version/svnrev.cs" />
<Compile Include="$(ProjectDir)../BizHawk.Version/VersionInfo.cs" />
<Content Include="discohawk.ico" />
</ItemGroup>
<ItemGroup>

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Reflection;
using System.Windows.Forms;
using BizHawk.Client.EmuHawk.Properties;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk

View File

@ -100,8 +100,7 @@
<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.Version/svnrev.cs" />
<Compile Include="$(ProjectDir)../BizHawk.Version/VersionInfo.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

@ -4,6 +4,7 @@ using System.Net;
using System.Threading;
using BizHawk.Client.Common;
using BizHawk.Common;
using Newtonsoft.Json.Linq;

View File

@ -7,6 +7,7 @@ using System.Threading;
using BizHawk.Client.Common;
using BizHawk.Client.Common.cheats;
using BizHawk.Common;
using BizHawk.Emulation.Common;
using NLua;

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Common;
using BizHawk.Common.CollectionExtensions;
namespace BizHawk.Client.EmuHawk

View File

@ -7,6 +7,7 @@ using System.Threading;
using NLua;
using BizHawk.Common;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;

View File

@ -6,6 +6,7 @@ using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk.ToolExtensions;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk

View File

@ -6,6 +6,7 @@ using System.Reflection;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Reflection;
using System.Windows.Forms;
using BizHawk.Common;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;

View File

@ -12,8 +12,6 @@
<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" />
<Compile Include="$(ProjectDir)../BizHawk.Version/svnrev.cs" />
<Compile Include="$(ProjectDir)../BizHawk.Version/VersionInfo.cs" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Version/BizHawk.Version.csproj" /><!-- generates SubWCRev.cs -->
</ItemGroup>
</Project>

View File

@ -0,0 +1,49 @@
using System.IO;
using System.Reflection;
namespace BizHawk.Common
{
public static 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
public const string ReleaseDate = "January 18, 2020";
public const string HomePage = "http://tasvideos.org/BizHawk.html";
public static readonly bool DeveloperBuild = true;
public static readonly string? CustomBuildString;
public static string GetEmuVersion()
{
return DeveloperBuild
? "GIT " + SubWCRev.GIT_BRANCH + "#" + SubWCRev.GIT_SHORTHASH
: "Version " + MainVersion;
}
static VersionInfo()
{
string path = Path.Combine(GetExeDirectoryAbsolute(), "dll");
path = Path.Combine(path, "custombuild.txt");
if (File.Exists(path))
{
var lines = File.ReadAllLines(path);
if (lines.Length > 0)
{
CustomBuildString = lines[0];
}
}
}
// code copied to avoid depending on code in other projects
private static string GetExeDirectoryAbsolute()
{
var path = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ?? "";
if (path.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
path = path.Remove(path.Length - 1, 1);
}
return path;
}
}
}

View File

@ -8,7 +8,5 @@
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Common/BizHawk.Common.csproj" />
<ProjectReference Include="$(ProjectDir)../BizHawk.BizInvoke/BizHawk.BizInvoke.csproj" />
<Compile Include="$(ProjectDir)../BizHawk.Version/svnrev.cs" />
<Compile Include="$(ProjectDir)../BizHawk.Version/VersionInfo.cs" />
</ItemGroup>
</Project>

View File

@ -13,8 +13,6 @@
<ProjectReference Include="$(ProjectDir)../BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Emulation.DiscSystem/BizHawk.Emulation.DiscSystem.csproj" />
<ProjectReference Include="..\BizHawk.Common\BizHawk.Common.csproj" />
<Compile Include="$(ProjectDir)../BizHawk.Version/svnrev.cs" />
<Compile Include="$(ProjectDir)../BizHawk.Version/VersionInfo.cs" />
<EmbeddedResource Include="Resources/**/*" />
</ItemGroup>
<ItemGroup>

View File

@ -6,7 +6,5 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(ProjectDir)../BizHawk.Common/BizHawk.Common.csproj" />
<Compile Include="$(ProjectDir)../BizHawk.Version/svnrev.cs" />
<Compile Include="$(ProjectDir)../BizHawk.Version/VersionInfo.cs" />
</ItemGroup>
</Project>

View File

@ -1,24 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../MainSlnCommon.props" />
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<DefineConstants>TRACE</DefineConstants>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<ErrorReport>prompt</ErrorReport>
<Optimize>true</Optimize>
<OutputPath>./bin</OutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<NoWarn>CS2008</NoWarn>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<!-- svnrev.cs / VersionInfo.cs are only used in other projects -->
<Compile Include="dummy.cs" /><!-- there was a bug in 1.x when no source files were included, including an empty file fixed it -->
</ItemGroup>
<Target Name="Build">
<!-- when is this called? it has never run and failed on Linux -->
<Exec Command="&quot;$(MSBuildProjectDirectory)\subwcrev.bat&quot; $(MSBuildProjectDirectory)" Condition=" '$(OS)' == 'Windows_NT' " WorkingDirectory="$(MSBuildProjectDirectory)" />
</Target>
<Target Name="PreBuild" AfterTargets="PreBuildEvent">
<Exec Command='"$(ProjectDir)..\..\Build\BizHawk.Build.Tool.exe" GIT_REV --wc "$(ProjectDir).." --template "$(ProjectDir)svnrev_template" --out "$(ProjectDir)svnrev.cs"' Condition=" '$(OS)' == 'Windows_NT' " />
<Exec Command='"$(ProjectDir)../../Build/standin.sh"' Condition=" '$(OS)' != 'Windows_NT' " />
<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"' />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Delete Files="$(OutputPath)BizHawk.Version.csproj" /><!-- no source files, generated svnrev.cs is included in BizHawk.Common -->
</Target>
</Project>

View File

@ -1,48 +0,0 @@
#nullable enable
using System.IO;
using System.Reflection;
internal static 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
public const string ReleaseDate = "January 18, 2020";
public const string HomePage = "http://tasvideos.org/BizHawk.html";
public static readonly bool DeveloperBuild = true;
public static readonly string? CustomBuildString;
public static string GetEmuVersion()
{
return DeveloperBuild
? "GIT " + SubWCRev.GIT_BRANCH + "#" + SubWCRev.GIT_SHORTHASH
: "Version " + MainVersion;
}
static VersionInfo()
{
string path = Path.Combine(GetExeDirectoryAbsolute(), "dll");
path = Path.Combine(path, "custombuild.txt");
if (File.Exists(path))
{
var lines = File.ReadAllLines(path);
if (lines.Length > 0)
{
CustomBuildString = lines[0];
}
}
}
// code copied to avoid depending on code in other projects
private static string GetExeDirectoryAbsolute()
{
var path = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ?? "";
if (path.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
path = path.Remove(path.Length - 1, 1);
}
return path;
}
}

View File

@ -7,7 +7,5 @@
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="all" />
<Reference Include="System.Windows.Forms" />
<Compile Include="$(ProjectDir)../BizHawk.Version/svnrev.cs" />
<Compile Include="$(ProjectDir)../BizHawk.Version/VersionInfo.cs" />
</ItemGroup>
</Project>