BsBuildManager.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsBuildManager.h"
  4. #include "BsBuildDataRTTI.h"
  5. #include "BsFileSerializer.h"
  6. #include "BsFileSystem.h"
  7. #include "BsEditorApplication.h"
  8. namespace BansheeEngine
  9. {
  10. BuildData::BuildData()
  11. :activePlatform(PlatformType::Windows)
  12. {
  13. platformData.resize((UINT32)PlatformType::Count);
  14. platformData[0] = bs_shared_ptr_new<WinPlatformInfo>();
  15. }
  16. RTTITypeBase* BuildData::getRTTIStatic()
  17. {
  18. return BuildDataRTTI::instance();
  19. }
  20. RTTITypeBase* BuildData::getRTTI() const
  21. {
  22. return BuildData::getRTTIStatic();
  23. }
  24. const WString BuildManager::BUILD_FOLDER_NAME = L"Builds\\";
  25. BuildManager::BuildManager()
  26. {
  27. mBuildData = bs_shared_ptr_new<BuildData>();
  28. }
  29. const Vector<PlatformType>& BuildManager::getAvailablePlatforms() const
  30. {
  31. static const Vector<PlatformType> PLATFORMS = { PlatformType::Windows };
  32. return PLATFORMS;
  33. }
  34. PlatformType BuildManager::getActivePlatform() const
  35. {
  36. return mBuildData->activePlatform;
  37. }
  38. void BuildManager::setActivePlatform(PlatformType type)
  39. {
  40. if ((UINT32)type < (UINT32)PlatformType::Count)
  41. mBuildData->activePlatform = type;
  42. }
  43. SPtr<PlatformInfo> BuildManager::getActivePlatformInfo() const
  44. {
  45. return mBuildData->platformData[(UINT32)mBuildData->activePlatform];
  46. }
  47. SPtr<PlatformInfo> BuildManager::getPlatformInfo(PlatformType type) const
  48. {
  49. if ((UINT32)type < (UINT32)mBuildData->platformData.size())
  50. return mBuildData->platformData[(UINT32)type];
  51. return nullptr;
  52. }
  53. Vector<WString> BuildManager::getFrameworkAssemblies(PlatformType type) const
  54. {
  55. switch (type)
  56. {
  57. case PlatformType::Windows:
  58. default:
  59. return { L"mscorlib", L"System", L"System.Core" };
  60. }
  61. }
  62. Vector<Path> BuildManager::getNativeBinaries(PlatformType type) const
  63. {
  64. Vector<Path> libs = { L"BansheeEngine", L"BansheeCore", L"BansheeUtility",
  65. L"BansheeD3D11RenderAPI", L"BansheeGLRenderAPI", L"BansheeMono", L"BansheeOISInput",
  66. L"RenderBeast", L"SBansheeEngine", L"BansheeOIS", L"mono-2.0", L"nvtt" };
  67. switch (type)
  68. {
  69. case PlatformType::Windows:
  70. {
  71. for (auto& lib : libs)
  72. lib.setExtension(lib.getExtension() + ".dll");
  73. }
  74. }
  75. return libs;
  76. }
  77. Path BuildManager::getBuildFolder(BuildFolder folder, PlatformType platform) const
  78. {
  79. // Use Data folder as an anchor to find where the root is
  80. Path sourceRoot = Paths::getRuntimeDataPath();
  81. sourceRoot.makeAbsolute(FileSystem::getWorkingDirectoryPath());
  82. UINT32 numDataDirs = Paths::RUNTIME_DATA_PATH.getNumDirectories();
  83. if (Paths::RUNTIME_DATA_PATH.isFile())
  84. numDataDirs++;
  85. for (UINT32 i = 0; i < numDataDirs; i++)
  86. sourceRoot.makeParent();
  87. switch (folder)
  88. {
  89. case BuildFolder::SourceRoot:
  90. return sourceRoot;
  91. case BuildFolder::DestinationRoot:
  92. {
  93. switch (platform)
  94. {
  95. case PlatformType::Windows:
  96. return gEditorApplication().getProjectPath() + BUILD_FOLDER_NAME + L"Windows";
  97. }
  98. return gEditorApplication().getProjectPath() + BUILD_FOLDER_NAME;
  99. }
  100. case BuildFolder::NativeBinaries:
  101. {
  102. Path binariesPath = FileSystem::getWorkingDirectoryPath();
  103. return binariesPath.makeRelative(sourceRoot);
  104. }
  105. case BuildFolder::BansheeDebugAssemblies:
  106. return Paths::DEBUG_ASSEMBLY_PATH;
  107. case BuildFolder::BansheeReleaseAssemblies:
  108. return Paths::RELEASE_ASSEMBLY_PATH;
  109. case BuildFolder::Data:
  110. return Paths::ENGINE_DATA_PATH;
  111. }
  112. return Path::BLANK;
  113. }
  114. Path BuildManager::getMainExecutable(PlatformType type) const
  115. {
  116. switch (type)
  117. {
  118. case PlatformType::Windows:
  119. {
  120. Path output = Paths::getRuntimeDataPath() + "Binaries\\Win64\\Game.exe";
  121. output.makeAbsolute(FileSystem::getWorkingDirectoryPath());
  122. return output;
  123. }
  124. }
  125. return Path::BLANK;
  126. }
  127. WString BuildManager::getDefines(PlatformType type) const
  128. {
  129. return getPlatformInfo(type)->defines;
  130. }
  131. void BuildManager::clear()
  132. {
  133. mBuildData = nullptr;
  134. }
  135. void BuildManager::save(const Path& outFile)
  136. {
  137. FileEncoder fe(outFile);
  138. fe.encode(mBuildData.get());
  139. }
  140. void BuildManager::load(const Path& inFile)
  141. {
  142. if (FileSystem::exists(inFile))
  143. {
  144. FileDecoder fd(inFile);
  145. mBuildData = std::static_pointer_cast<BuildData>(fd.decode());
  146. }
  147. if (mBuildData == nullptr)
  148. mBuildData = bs_shared_ptr_new<BuildData>();
  149. }
  150. }