ReleaseInformations.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Ryujinx.Common.Configuration;
  2. using System;
  3. using System.Reflection;
  4. namespace Ryujinx.Common
  5. {
  6. // DO NOT EDIT, filled by CI
  7. public static class ReleaseInformations
  8. {
  9. private const string FlatHubChannelOwner = "flathub";
  10. public static string BuildVersion = "%%RYUJINX_BUILD_VERSION%%";
  11. public static string BuildGitHash = "%%RYUJINX_BUILD_GIT_HASH%%";
  12. public static string ReleaseChannelName = "%%RYUJINX_TARGET_RELEASE_CHANNEL_NAME%%";
  13. public static string ReleaseChannelOwner = "%%RYUJINX_TARGET_RELEASE_CHANNEL_OWNER%%";
  14. public static string ReleaseChannelRepo = "%%RYUJINX_TARGET_RELEASE_CHANNEL_REPO%%";
  15. public static bool IsValid()
  16. {
  17. return !BuildGitHash.StartsWith("%%") &&
  18. !ReleaseChannelName.StartsWith("%%") &&
  19. !ReleaseChannelOwner.StartsWith("%%") &&
  20. !ReleaseChannelRepo.StartsWith("%%");
  21. }
  22. public static bool IsFlatHubBuild()
  23. {
  24. return IsValid() && ReleaseChannelOwner.Equals(FlatHubChannelOwner);
  25. }
  26. public static string GetVersion()
  27. {
  28. if (IsValid())
  29. {
  30. return BuildVersion;
  31. }
  32. else
  33. {
  34. return Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
  35. }
  36. }
  37. public static string GetBaseApplicationDirectory()
  38. {
  39. if (IsFlatHubBuild())
  40. {
  41. return AppDataManager.BaseDirPath;
  42. }
  43. return AppDomain.CurrentDomain.BaseDirectory;
  44. }
  45. }
  46. }