BuildSystem.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  2. // Please see LICENSE.md in repository root for license information
  3. // https://github.com/AtomicGameEngine/AtomicGameEngine
  4. #include "AtomicEditor.h"
  5. #include <Atomic/Core/Context.h>
  6. #include <Atomic/Core/StringUtils.h>
  7. #include <Atomic/IO/FileSystem.h>
  8. #include <Atomic/IO/Log.h>
  9. #include "BuildSystem.h"
  10. #include "BuildMac.h"
  11. #include "BuildWindows.h"
  12. #include "BuildAndroid.h"
  13. #include "BuildIOS.h"
  14. #include "BuildWeb.h"
  15. #include "UI/Modal/UIModalOps.h"
  16. #include "../AEEvents.h"
  17. #include "../AEEditor.h"
  18. namespace AtomicEditor
  19. {
  20. BuildSystem::BuildSystem(Context* context) :
  21. Object(context)
  22. {
  23. buildSettings_ = new BuildSettings(context);
  24. SubscribeToEvent(E_EDITORBUILD, HANDLER(BuildSystem, HandleEditorBuild));
  25. SubscribeToEvent(E_EDITORSHUTDOWN, HANDLER(BuildSystem, HandleEditorShutdown));
  26. }
  27. BuildSystem::~BuildSystem()
  28. {
  29. }
  30. void BuildSystem::ClearBuildCompleteUI()
  31. {
  32. if (uiBuildComplete_.Null())
  33. return;
  34. uiBuildComplete_->Hide();
  35. uiBuildComplete_ = 0;
  36. }
  37. void BuildSystem::BuildComplete(AEEditorPlatform platform, const String &buildFolder, bool success, bool fail3D)
  38. {
  39. String title;
  40. String message;
  41. if (platform == AE_PLATFORM_ANDROID)
  42. {
  43. title = "Android Deployment";
  44. message = "Android Deployment";
  45. }
  46. else if (platform == AE_PLATFORM_IOS)
  47. {
  48. title = "iOS Deployment";
  49. message = "iOS Deployment";
  50. }
  51. else if (platform == AE_PLATFORM_MAC)
  52. {
  53. title = "Mac Deployment";
  54. message = "Mac Deployment";
  55. }
  56. else if (platform == AE_PLATFORM_WINDOWS)
  57. {
  58. title = "Windows Deployment";
  59. message = "Windows Deployment";
  60. }
  61. else if (platform == AE_PLATFORM_HTML5)
  62. {
  63. title = "Web Deployment";
  64. message = "Web Deployment";
  65. }
  66. if (success)
  67. {
  68. title += " Success";
  69. message += " Success";
  70. }
  71. else
  72. {
  73. title += " Failed";
  74. message += " Failed";
  75. }
  76. // BEGIN LICENSE MANAGEMENT
  77. if (fail3D)
  78. {
  79. UIModalOps* ops = GetSubsystem<UIModalOps>();
  80. ops->ShowInfoModule3D();
  81. }
  82. else
  83. {
  84. uiBuildComplete_ = new UIBuildComplete(context_, title, message, buildFolder, success);
  85. uiBuildComplete_->Show();
  86. }
  87. // END LICENSE MANAGEMENT
  88. currentBuild_ = 0;
  89. }
  90. void BuildSystem::DoBuildMac(const String& buildPath)
  91. {
  92. currentBuild_ = SharedPtr<BuildBase>(new BuildMac(context_));
  93. currentBuild_->Build(buildPath);
  94. }
  95. void BuildSystem::DoBuildWindows(const String& buildPath)
  96. {
  97. currentBuild_ = SharedPtr<BuildBase>(new BuildWindows(context_));
  98. currentBuild_->Build(buildPath);
  99. }
  100. void BuildSystem::DoBuildAndroid(const String& buildPath)
  101. {
  102. currentBuild_ = SharedPtr<BuildBase>(new BuildAndroid(context_));
  103. currentBuild_->Build(buildPath);
  104. }
  105. void BuildSystem::DoBuildWeb(const String& buildPath)
  106. {
  107. currentBuild_ = SharedPtr<BuildBase>(new BuildWeb(context_));
  108. currentBuild_->Build(buildPath);
  109. }
  110. void BuildSystem::DoBuildIOS(const String& buildPath)
  111. {
  112. currentBuild_ = SharedPtr<BuildBase>(new BuildIOS(context_));
  113. currentBuild_->Build(buildPath);
  114. }
  115. void BuildSystem::LoadBuildSettings(rapidjson::Value::Member* jobject)
  116. {
  117. buildSettings_->Load(jobject);
  118. }
  119. void BuildSystem::SaveBuildSettings(rapidjson::PrettyWriter<rapidjson::FileStream>& writer)
  120. {
  121. buildSettings_->Save(writer);
  122. }
  123. void BuildSystem::HandleEditorBuild(StringHash eventType, VariantMap& eventData)
  124. {
  125. using namespace EditorBuild;
  126. String buildPlatform = eventData[P_PLATFORM].GetString();
  127. String buildPath = eventData[P_BUILDPATH].GetString();
  128. if (buildPlatform == "Mac")
  129. {
  130. DoBuildMac(buildPath);
  131. }
  132. else if (buildPlatform == "Windows")
  133. {
  134. DoBuildWindows(buildPath);
  135. }
  136. else if (buildPlatform == "Android")
  137. {
  138. DoBuildAndroid(buildPath);
  139. }
  140. else if (buildPlatform == "HTML5")
  141. {
  142. DoBuildWeb(buildPath);
  143. }
  144. else if (buildPlatform == "IOS")
  145. {
  146. DoBuildIOS(buildPath);
  147. }
  148. }
  149. void BuildSystem::HandleEditorShutdown(StringHash eventType, VariantMap& eventData)
  150. {
  151. context_->RemoveSubsystem(GetType());
  152. }
  153. }