ReleaseInformation.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 ReleaseInformation
  8. {
  9. private const string FlatHubChannelOwner = "flathub";
  10. public const string BuildVersion = "%%RYUJINX_BUILD_VERSION%%";
  11. public const string BuildGitHash = "%%RYUJINX_BUILD_GIT_HASH%%";
  12. public const string ReleaseChannelName = "%%RYUJINX_TARGET_RELEASE_CHANNEL_NAME%%";
  13. public const string ReleaseChannelOwner = "%%RYUJINX_TARGET_RELEASE_CHANNEL_OWNER%%";
  14. public const 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. return Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
  33. }
  34. #if FORCE_EXTERNAL_BASE_DIR
  35. public static string GetBaseApplicationDirectory()
  36. {
  37. return AppDataManager.BaseDirPath;
  38. }
  39. #else
  40. public static string GetBaseApplicationDirectory()
  41. {
  42. if (IsFlatHubBuild() || OperatingSystem.IsMacOS())
  43. {
  44. return AppDataManager.BaseDirPath;
  45. }
  46. return AppDomain.CurrentDomain.BaseDirectory;
  47. }
  48. #endif
  49. }
  50. }