BuildCmd.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include <Atomic/Core/StringUtils.h>
  2. #include <Atomic/IO/Log.h>
  3. #include <Atomic/IO/File.h>
  4. #include "../ToolSystem.h"
  5. #include "../Build/BuildSystem.h"
  6. #include "BuildCmd.h"
  7. #include <Poco/File.h>
  8. namespace ToolCore
  9. {
  10. BuildCmd::BuildCmd(Context* context) : Command(context)
  11. {
  12. }
  13. BuildCmd::~BuildCmd()
  14. {
  15. }
  16. bool BuildCmd::Parse(const Vector<String>& arguments, unsigned startIndex, String& errorMsg)
  17. {
  18. String argument = arguments[startIndex].ToLower();
  19. String value = startIndex + 1 < arguments.Size() ? arguments[startIndex + 1] : String::EMPTY;
  20. if (argument != "build")
  21. {
  22. errorMsg = "Unable to parse build command";
  23. return false;
  24. }
  25. if (!value.Length())
  26. {
  27. errorMsg = "Unable to parse build platform";
  28. return false;
  29. }
  30. buildPlatform_ = value.ToLower();
  31. return true;
  32. }
  33. void BuildCmd::Run()
  34. {
  35. LOGINFOF("Building project for: %s", buildPlatform_.CString());
  36. ToolSystem* tsystem = GetSubsystem<ToolSystem>();
  37. Project* project = tsystem->GetProject();
  38. Platform* platform = NULL;
  39. if (buildPlatform_ == "mac")
  40. platform = tsystem->GetPlatformByID(PLATFORMID_MAC);
  41. if (!platform)
  42. {
  43. Error(ToString("Unknown build platform: %s", buildPlatform_.CString()));
  44. return;
  45. }
  46. // create the build
  47. BuildBase* buildBase = platform->NewBuild(project);
  48. // add it to the build system
  49. BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
  50. buildSystem->QueueBuild(buildBase);
  51. // clear the current platform
  52. tsystem->SetCurrentPlatform(PLATFORMID_UNDEFINED);
  53. Finished();
  54. }
  55. }