BsBuildManager.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #include "BsBuildManager.h"
  2. #include "BsBuildDataRTTI.h"
  3. #include "BsFileSerializer.h"
  4. #include "BsFileSystem.h"
  5. namespace BansheeEngine
  6. {
  7. BuildData::BuildData()
  8. :activePlatform(PlatformType::Windows)
  9. {
  10. platformData.resize((UINT32)PlatformType::Count);
  11. }
  12. RTTITypeBase* BuildData::getRTTIStatic()
  13. {
  14. return BuildDataRTTI::instance();
  15. }
  16. RTTITypeBase* BuildData::getRTTI() const
  17. {
  18. return BuildData::getRTTIStatic();
  19. }
  20. BuildManager::BuildManager()
  21. {
  22. mBuildData = bs_shared_ptr<BuildData>();
  23. }
  24. const Vector<PlatformType>& BuildManager::getAvailablePlatforms() const
  25. {
  26. static const Vector<PlatformType> PLATFORMS = { PlatformType::Windows };
  27. return PLATFORMS;
  28. }
  29. PlatformType BuildManager::getActivePlatform() const
  30. {
  31. return mBuildData->activePlatform;
  32. }
  33. void BuildManager::setActivePlatform(PlatformType type)
  34. {
  35. if ((UINT32)type < (UINT32)PlatformType::Count)
  36. mBuildData->activePlatform = type;
  37. }
  38. SPtr<PlatformInfo> BuildManager::getActivePlatformInfo() const
  39. {
  40. return mBuildData->platformData[(UINT32)mBuildData->activePlatform];
  41. }
  42. SPtr<PlatformInfo> BuildManager::getPlatformInfo(PlatformType type) const
  43. {
  44. if ((UINT32)type < (UINT32)mBuildData->platformData.size())
  45. return mBuildData->platformData[(UINT32)type];
  46. return nullptr;
  47. }
  48. Vector<WString> BuildManager::getFrameworkAssemblies(PlatformType type) const
  49. {
  50. switch (type)
  51. {
  52. case PlatformType::Windows:
  53. default:
  54. return { L"System", L"System.Core" };
  55. }
  56. }
  57. Path BuildManager::getMainExecutable(PlatformType type) const
  58. {
  59. switch (type)
  60. {
  61. case PlatformType::Windows:
  62. {
  63. SPtr<WinPlatformInfo> winPlatformInfo = std::static_pointer_cast<WinPlatformInfo>(getPlatformInfo(type));
  64. if (winPlatformInfo->is32bit)
  65. return "Prebuilt\\Win32\\Game.exe";
  66. else
  67. return "Prebuilt\\Win64\\Game.exe";
  68. }
  69. }
  70. return Path::BLANK;
  71. }
  72. WString BuildManager::getDefines(PlatformType type) const
  73. {
  74. return getPlatformInfo(type)->defines;
  75. }
  76. void BuildManager::save(const Path& outFile)
  77. {
  78. FileEncoder fe(outFile);
  79. fe.encode(mBuildData.get());
  80. }
  81. void BuildManager::load(const Path& inFile)
  82. {
  83. if (!FileSystem::exists(inFile))
  84. return;
  85. FileDecoder fd(inFile);
  86. mBuildData = std::static_pointer_cast<BuildData>(fd.decode());
  87. }
  88. }