JSBind.cpp 1.5 KB

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