BsBuildManager.cpp 2.3 KB

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