Main.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #include <chrono>
  4. #include <iostream>
  5. #include <string>
  6. using namespace std;
  7. //#define DEVELOP
  8. // Path to Urho3D's root folder (CMAKE_SOURCE_DIR). There must be no slash at the end
  9. string _sourceDir;
  10. namespace SourceData
  11. {
  12. void LoadAllXmls(const string& dir);
  13. }
  14. namespace ASBindingGenerator
  15. {
  16. void ProcessAllEnums();
  17. void ProcessAllClasses();
  18. void ProcessAllGlobalVariables();
  19. void ProcessAllGlobalFunctions();
  20. void SaveResult();
  21. void GenerateTemplates();
  22. void GenerateBindings()
  23. {
  24. ProcessAllEnums();
  25. ProcessAllClasses();
  26. ProcessAllGlobalVariables();
  27. ProcessAllGlobalFunctions();
  28. SaveResult();
  29. GenerateTemplates();
  30. }
  31. }
  32. namespace LuaBindingGenerator
  33. {
  34. void GenerateBindings()
  35. {
  36. }
  37. }
  38. namespace JSBindingGenerator
  39. {
  40. void GenerateBindings()
  41. {
  42. }
  43. }
  44. namespace CSBindingGenerator
  45. {
  46. void GenerateBindings()
  47. {
  48. }
  49. }
  50. int main(int argc, char* argv[])
  51. {
  52. // Required for ToWide()
  53. setlocale(LC_ALL, "en_US.utf8");
  54. #ifdef DEVELOP
  55. string inputDir = R"(G:/my_games/urho3d_fork/build_vs/Source/Tools/BindingGenerator/generated/xml)";
  56. _sourceDir = R"(G:/my_games/urho3d_fork/repo)";
  57. #else
  58. if (argc != 3)
  59. return -1;
  60. string inputDir = argv[1];
  61. _sourceDir = argv[2];
  62. #endif
  63. auto start = chrono::high_resolution_clock::now();
  64. SourceData::LoadAllXmls(inputDir);
  65. auto end = chrono::high_resolution_clock::now();
  66. cout << "Loaded in " << chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms\n";
  67. start = chrono::high_resolution_clock::now();
  68. ASBindingGenerator::GenerateBindings();
  69. end = chrono::high_resolution_clock::now();
  70. cout << "Generated in " << chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms\n";
  71. LuaBindingGenerator::GenerateBindings();
  72. JSBindingGenerator::GenerateBindings();
  73. CSBindingGenerator::GenerateBindings();
  74. return 0;
  75. }