Main.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 ProcessAllGlobalVariables();
  38. void ProcessAllGlobalFunctions();
  39. void SaveResult();
  40. void GenerateTemplates();
  41. void GenerateBindings()
  42. {
  43. ProcessAllEnums();
  44. ProcessAllClasses();
  45. ProcessAllGlobalVariables();
  46. ProcessAllGlobalFunctions();
  47. SaveResult();
  48. GenerateTemplates();
  49. }
  50. }
  51. namespace LuaBindingGenerator
  52. {
  53. void GenerateBindings()
  54. {
  55. }
  56. }
  57. namespace JSBindingGenerator
  58. {
  59. void GenerateBindings()
  60. {
  61. }
  62. }
  63. namespace CSBindingGenerator
  64. {
  65. void GenerateBindings()
  66. {
  67. }
  68. }
  69. int main(int argc, char* argv[])
  70. {
  71. #ifdef DEVELOP
  72. string inputDir = R"(G:/MyGames/Urho3DFork/Build/Source/Tools/BindingGenerator/generated/xml)";
  73. _sourceDir = R"(G:/MyGames/Urho3DFork/Urho3D)";
  74. #else
  75. if (argc != 3)
  76. return -1;
  77. string inputDir = argv[1];
  78. _sourceDir = argv[2];
  79. #endif
  80. auto start = chrono::high_resolution_clock::now();
  81. SourceData::LoadAllXmls(inputDir);
  82. auto end = chrono::high_resolution_clock::now();
  83. cout << "Loaded in " << chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms\n";
  84. start = chrono::high_resolution_clock::now();
  85. ASBindingGenerator::GenerateBindings();
  86. end = chrono::high_resolution_clock::now();
  87. cout << "Generated in " << chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms\n";
  88. LuaBindingGenerator::GenerateBindings();
  89. JSBindingGenerator::GenerateBindings();
  90. CSBindingGenerator::GenerateBindings();
  91. return 0;
  92. }