BsBuildManager.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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<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<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. if (winPlatformInfo->is32bit)
  66. return "Prebuilt\\Win32\\Game.exe";
  67. else
  68. return "Prebuilt\\Win64\\Game.exe";
  69. }
  70. }
  71. return Path::BLANK;
  72. }
  73. WString BuildManager::getDefines(PlatformType type) const
  74. {
  75. return getPlatformInfo(type)->defines;
  76. }
  77. void BuildManager::save(const Path& outFile)
  78. {
  79. FileEncoder fe(outFile);
  80. fe.encode(mBuildData.get());
  81. }
  82. void BuildManager::load(const Path& inFile)
  83. {
  84. if (!FileSystem::exists(inFile))
  85. return;
  86. FileDecoder fd(inFile);
  87. mBuildData = std::static_pointer_cast<BuildData>(fd.decode());
  88. }
  89. }