1
0

BuildVariants.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * BuildVariants.cpp
  3. * -----------------
  4. * Purpose: Handling of various OpenMPT build variants.
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #include "stdafx.h"
  10. #include "BuildVariants.h"
  11. #include "../common/version.h"
  12. #include "../misc/mptOS.h"
  13. #include "../misc/mptCPU.h"
  14. #include "Mptrack.h"
  15. OPENMPT_NAMESPACE_BEGIN
  16. bool BuildVariants::IsKnownSystem()
  17. {
  18. return false
  19. || mpt::OS::Windows::IsOriginal()
  20. || (mpt::OS::Windows::IsWine() && theApp.GetWineVersion()->Version().IsValid())
  21. ;
  22. }
  23. BuildVariants::Variants BuildVariants::GetBuildVariant()
  24. {
  25. #if defined(MPT_BUILD_RETRO)
  26. return Retro;
  27. #else
  28. #if defined(_WIN32_WINNT)
  29. #if (_WIN32_WINNT >= 0x0A00) // Windows 10
  30. return Standard;
  31. #else
  32. return Legacy;
  33. #endif
  34. #else
  35. return Unknown;
  36. #endif
  37. #endif
  38. }
  39. mpt::ustring BuildVariants::GetBuildVariantName(BuildVariants::Variants variant)
  40. {
  41. mpt::ustring result;
  42. switch(variant)
  43. {
  44. case Standard:
  45. result = U_("Standard");
  46. break;
  47. case Legacy:
  48. result = U_("Legacy");
  49. break;
  50. case Retro:
  51. result = U_("Retro");
  52. break;
  53. case Unknown:
  54. result = U_("Unknown");
  55. break;
  56. }
  57. return result;
  58. }
  59. mpt::ustring BuildVariants::GetBuildVariantDescription(BuildVariants::Variants variant)
  60. {
  61. mpt::ustring result;
  62. switch(variant)
  63. {
  64. case Standard:
  65. result = U_("");
  66. break;
  67. case Legacy:
  68. result = U_("");
  69. break;
  70. case Retro:
  71. result = U_(" RETRO");
  72. break;
  73. case Unknown:
  74. result = U_("");
  75. break;
  76. }
  77. return result;
  78. }
  79. mpt::ustring BuildVariants::GuessCurrentBuildName()
  80. {
  81. if(GetBuildVariant() == Unknown)
  82. {
  83. return mpt::ustring();
  84. }
  85. if(mpt::arch_bits == 64)
  86. {
  87. if(GetBuildVariant() == Standard)
  88. {
  89. return U_("win64");
  90. } else
  91. {
  92. return U_("win64old");
  93. }
  94. } else if(mpt::arch_bits == 32)
  95. {
  96. if(GetBuildVariant() == Standard)
  97. {
  98. return U_("win32");
  99. } else
  100. {
  101. return U_("win32old");
  102. }
  103. } else
  104. {
  105. return mpt::ustring();
  106. }
  107. }
  108. bool BuildVariants::ProcessorCanRunCurrentBuild()
  109. {
  110. #ifdef MPT_ENABLE_ARCH_INTRINSICS
  111. if((CPU::Info::Get().AvailableFeatures & CPU::GetMinimumFeatures()) != CPU::GetMinimumFeatures())
  112. {
  113. return false;
  114. }
  115. #endif // MPT_ENABLE_ARCH_INTRINSICS
  116. return true;
  117. }
  118. bool BuildVariants::SystemCanRunCurrentBuild()
  119. {
  120. if(mpt::OS::Windows::HostCanRun(mpt::OS::Windows::GetHostArchitecture(), mpt::OS::Windows::GetProcessArchitecture()) == mpt::OS::Windows::EmulationLevel::NA)
  121. {
  122. return false;
  123. }
  124. #ifdef MPT_ENABLE_ARCH_INTRINSICS
  125. if((CPU::Info::Get().AvailableFeatures & CPU::GetMinimumFeatures()) != CPU::GetMinimumFeatures())
  126. {
  127. return false;
  128. }
  129. #endif // MPT_ENABLE_ARCH_INTRINSICS
  130. if(IsKnownSystem())
  131. {
  132. if(mpt::OS::Windows::IsOriginal())
  133. {
  134. if(mpt::OS::Windows::Version::Current().IsBefore(mpt::OS::Windows::Version::GetMinimumKernelLevel()))
  135. {
  136. return false;
  137. }
  138. if(mpt::OS::Windows::Version::Current().IsBefore(mpt::OS::Windows::Version::GetMinimumAPILevel()))
  139. {
  140. return false;
  141. }
  142. } else if(mpt::OS::Windows::IsWine())
  143. {
  144. if(theApp.GetWineVersion()->Version().IsBefore(mpt::OS::Wine::GetMinimumWineVersion()))
  145. {
  146. return false;
  147. }
  148. }
  149. }
  150. return true;
  151. }
  152. OPENMPT_NAMESPACE_END