BindCmd.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include <Atomic/Core/Context.h>
  2. #include <Atomic/Core/StringUtils.h>
  3. #include <Atomic/IO/Log.h>
  4. #include <Atomic/IO/File.h>
  5. #include "../ToolSystem.h"
  6. #include "../ToolEnvironment.h"
  7. #include "../JSBind/JSBind.h"
  8. #include "BindCmd.h"
  9. namespace ToolCore
  10. {
  11. BindCmd::BindCmd(Context* context) : Command(context)
  12. {
  13. }
  14. BindCmd::~BindCmd()
  15. {
  16. }
  17. bool BindCmd::Parse(const Vector<String>& arguments, unsigned startIndex, String& errorMsg)
  18. {
  19. String argument = arguments[startIndex].ToLower();
  20. sourceRootFolder_ = startIndex + 1 < arguments.Size() ? arguments[startIndex + 1] : String::EMPTY;
  21. packageFolder_ = startIndex + 2 < arguments.Size() ? arguments[startIndex + 2] : String::EMPTY;
  22. bindPlatform_ = startIndex + 3 < arguments.Size() ? arguments[startIndex + 3] : String::EMPTY;
  23. if (argument != "bind")
  24. {
  25. errorMsg = "Unable to parse bind command";
  26. return false;
  27. }
  28. if (!sourceRootFolder_.Length())
  29. {
  30. errorMsg = "Unable to parse bind command";
  31. return false;
  32. }
  33. if (!packageFolder_.Length())
  34. {
  35. errorMsg = "Unable to parse bind command";
  36. return false;
  37. }
  38. if (!bindPlatform_.Length())
  39. {
  40. errorMsg = "Unable to parse bind command";
  41. return false;
  42. }
  43. return true;
  44. }
  45. void BindCmd::Run()
  46. {
  47. ToolEnvironment* env = GetSubsystem<ToolEnvironment>();
  48. //bindPlatform_ = "MACOSX";
  49. sourceRootFolder_ = env->GetRootSourceDir();
  50. //packageFolder_ = "Source/AtomicJS/Packages/Atomic/";
  51. SharedPtr<JSBind> jsbind(new JSBind(context_));
  52. context_->RegisterSubsystem(jsbind);
  53. LOGINFOF("Generating JS Bindings");
  54. jsbind->GenerateBindings(sourceRootFolder_, packageFolder_, bindPlatform_);
  55. Finished();
  56. }
  57. }