BindCmd.cpp 1.9 KB

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