JSBind.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  2. // Please see LICENSE.md in repository root for license information
  3. // https://github.com/AtomicGameEngine/AtomicGameEngine
  4. #include <Atomic/Atomic.h>
  5. #include <Atomic/Core/ProcessUtils.h>
  6. #include <Atomic/Resource/ResourceCache.h>
  7. #include "JSBind.h"
  8. #include "JSBindings.h"
  9. #ifdef WIN32
  10. #include <Windows.h>
  11. #endif
  12. using namespace Atomic;
  13. SharedPtr<Context> JSBind::context_;
  14. SharedPtr<FileSystem> JSBind::fileSystem_;
  15. SharedPtr<Engine> JSBind::engine_;
  16. String JSBind::ROOT_FOLDER;
  17. void JSBind::Initialize()
  18. {
  19. context_ = new Context();
  20. fileSystem_ = new FileSystem(context_);
  21. engine_ = new Engine(context_);
  22. }
  23. #include <stdio.h>
  24. void Run(const Vector<String>& arguments)
  25. {
  26. JSBind::Initialize();
  27. if (arguments.Size() < 1)
  28. {
  29. ErrorExit("Usage: JSBind absolute_path_to_atomic_runtime_source_tree");
  30. }
  31. JSBind::ROOT_FOLDER = arguments[0];
  32. if (!JSBind::fileSystem_->DirExists(JSBind::ROOT_FOLDER + "/Source/Tools/JSBind"))
  33. {
  34. ErrorExit("The given Atomic Runtime source tree is invalid");
  35. }
  36. VariantMap engineParameters;
  37. engineParameters["Headless"] = true;
  38. engineParameters["WorkerThreads"] = false;
  39. engineParameters["LogName"] = String::EMPTY;
  40. JSBind::engine_->Initialize(engineParameters);
  41. ResourceCache* cache = JSBind::context_->GetSubsystem<ResourceCache>();
  42. cache->AddResourceDir(JSBind::ROOT_FOLDER + "/Source/Tools/JSBind");
  43. JSBindings* bindings = new JSBindings();
  44. bindings->Initialize();
  45. bindings->ParseHeaders();
  46. }
  47. int main(int argc, char** argv)
  48. {
  49. Vector<String> arguments;
  50. arguments = ParseArguments(argc, argv);
  51. Run(arguments);
  52. return 0;
  53. }