Main.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // Copyright (c) 2008-2020 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include <chrono>
  23. #include <iostream>
  24. #include <string>
  25. using namespace std;
  26. //#define DEVELOP
  27. // Path to Urho3D's root folder (CMAKE_SOURCE_DIR). There must be no slash at the end
  28. string _sourceDir;
  29. namespace SourceData
  30. {
  31. void LoadAllXmls(const string& dir);
  32. }
  33. namespace ASBindingGenerator
  34. {
  35. void ProcessAllEnums();
  36. void ProcessAllClasses();
  37. void ProcessAllClassesNew();
  38. void ProcessAllGlobalVariables();
  39. void ProcessAllGlobalFunctions();
  40. void SaveResult();
  41. void GenerateTemplates();
  42. void GenerateBindings()
  43. {
  44. ProcessAllEnums();
  45. ProcessAllClasses();
  46. ProcessAllClassesNew();
  47. ProcessAllGlobalVariables();
  48. ProcessAllGlobalFunctions();
  49. SaveResult();
  50. GenerateTemplates();
  51. }
  52. }
  53. namespace LuaBindingGenerator
  54. {
  55. void GenerateBindings()
  56. {
  57. }
  58. }
  59. namespace JSBindingGenerator
  60. {
  61. void GenerateBindings()
  62. {
  63. }
  64. }
  65. namespace CSBindingGenerator
  66. {
  67. void GenerateBindings()
  68. {
  69. }
  70. }
  71. int main(int argc, char* argv[])
  72. {
  73. #ifdef DEVELOP
  74. string inputDir = R"(G:/MyGames/Urho3DFork/Build/Source/Tools/BindingGenerator/generated/xml)";
  75. _sourceDir = R"(G:/MyGames/Urho3DFork/Urho3D)";
  76. #else
  77. if (argc != 3)
  78. return -1;
  79. string inputDir = argv[1];
  80. _sourceDir = argv[2];
  81. #endif
  82. auto start = chrono::high_resolution_clock::now();
  83. SourceData::LoadAllXmls(inputDir);
  84. auto end = chrono::high_resolution_clock::now();
  85. cout << "Loaded in " << chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms\n";
  86. start = chrono::high_resolution_clock::now();
  87. ASBindingGenerator::GenerateBindings();
  88. end = chrono::high_resolution_clock::now();
  89. cout << "Generated in " << chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms\n";
  90. LuaBindingGenerator::GenerateBindings();
  91. JSBindingGenerator::GenerateBindings();
  92. CSBindingGenerator::GenerateBindings();
  93. return 0;
  94. }