ReleaseInformation.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 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. #if FORCE_EXTERNAL_BASE_DIR
  38. public static string GetBaseApplicationDirectory()
  39. {
  40. return AppDataManager.BaseDirPath;
  41. }
  42. #else
  43. public static string GetBaseApplicationDirectory()
  44. {
  45. if (IsFlatHubBuild() || OperatingSystem.IsMacOS())
  46. {
  47. return AppDataManager.BaseDirPath;
  48. }
  49. return AppDomain.CurrentDomain.BaseDirectory;
  50. }
  51. #endif
  52. }
  53. }