JSBind.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. String JSBind::PLATFORM;
  18. void JSBind::Initialize()
  19. {
  20. context_ = new Context();
  21. fileSystem_ = new FileSystem(context_);
  22. engine_ = new Engine(context_);
  23. }
  24. #include <stdio.h>
  25. void Run(const Vector<String>& arguments)
  26. {
  27. JSBind::Initialize();
  28. if (arguments.Size() < 2)
  29. {
  30. ErrorExit("Usage: JSBind absolute_path_to_atomic_runtime_source_tree platform");
  31. }
  32. JSBind::ROOT_FOLDER = arguments[0];
  33. JSBind::PLATFORM = arguments[1];
  34. if (!JSBind::fileSystem_->DirExists(JSBind::ROOT_FOLDER + "/Source/AtomicJS/JSBind"))
  35. {
  36. ErrorExit("The given Atomic Runtime source tree is invalid");
  37. }
  38. VariantMap engineParameters;
  39. engineParameters["Headless"] = true;
  40. engineParameters["WorkerThreads"] = false;
  41. engineParameters["LogName"] = String::EMPTY;
  42. JSBind::engine_->Initialize(engineParameters);
  43. ResourceCache* cache = JSBind::context_->GetSubsystem<ResourceCache>();
  44. cache->AddResourceDir(JSBind::ROOT_FOLDER + "/Source/AtomicJS/JSBind");
  45. JSBindings* bindings = new JSBindings();
  46. bindings->Initialize();
  47. bindings->ParseHeaders();
  48. }
  49. int main(int argc, char** argv)
  50. {
  51. Vector<String> arguments;
  52. arguments = ParseArguments(argc, argv);
  53. Run(arguments);
  54. return 0;
  55. }