BuildCmd.cpp 1.9 KB

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