PlatformAddCmd.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. #include <Atomic/Core/StringUtils.h>
  8. #include <Atomic/IO/Log.h>
  9. #include <Atomic/IO/File.h>
  10. #include "../ToolSystem.h"
  11. #include "../Project/Project.h"
  12. #include "PlatformAddCmd.h"
  13. #include <Poco/File.h>
  14. namespace ToolCore
  15. {
  16. PlatformAddCmd::PlatformAddCmd(Context* context) : Command(context)
  17. {
  18. }
  19. PlatformAddCmd::~PlatformAddCmd()
  20. {
  21. }
  22. bool PlatformAddCmd::Parse(const Vector<String>& arguments, unsigned startIndex, String& errorMsg)
  23. {
  24. String argument = arguments[startIndex].ToLower();
  25. String value = startIndex + 1 < arguments.Size() ? arguments[startIndex + 1] : String::EMPTY;
  26. if (argument != "platform-add")
  27. {
  28. errorMsg = "Unable to parse build command";
  29. return false;
  30. }
  31. if (!value.Length())
  32. {
  33. errorMsg = "Unable to parse platform";
  34. return false;
  35. }
  36. platformToAdd_ = value.ToLower();
  37. return true;
  38. }
  39. void PlatformAddCmd::Run()
  40. {
  41. ToolSystem* tsystem = GetSubsystem<ToolSystem>();
  42. Project* project = tsystem->GetProject();
  43. Platform* platform = tsystem->GetPlatformByName(platformToAdd_);
  44. if (!platform)
  45. {
  46. Error(ToString("Unknown platform: %s", platformToAdd_.CString()));
  47. return;
  48. }
  49. if (project->ContainsPlatform(platform->GetPlatformID()))
  50. {
  51. Error(ToString("Project already contains platform: %s", platformToAdd_.CString()));
  52. return;
  53. }
  54. LOGINFOF("Adding platform: %s", platformToAdd_.CString());
  55. project->AddPlatform(platform->GetPlatformID());
  56. Finished();
  57. }
  58. }