2
0

version.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  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
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell 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
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "platform/platform.h"
  23. #include "app/version.h"
  24. #include "console/console.h"
  25. #include "console/engineAPI.h"
  26. static const U32 csgVersionNumber = TORQUE_GAME_ENGINE;
  27. static const U32 appVersionNumber = TORQUE_APP_VERSION;
  28. U32 getVersionNumber()
  29. {
  30. return csgVersionNumber;
  31. }
  32. U32 getAppVersionNumber()
  33. {
  34. return appVersionNumber;
  35. }
  36. const char* getVersionString()
  37. {
  38. return TORQUE_GAME_ENGINE_VERSION_STRING;
  39. }
  40. const char* getAppVersionString()
  41. {
  42. return TORQUE_APP_VERSION_STRING;
  43. }
  44. /// TGE 0001
  45. /// TGEA 0002
  46. /// TGB 0003
  47. /// TGEA 360 0004
  48. /// TGE WII 0005
  49. /// Torque 3D 0006
  50. /// Torque 3D MIT 0007
  51. const char* getEngineProductString()
  52. {
  53. #ifndef TORQUE_ENGINE_PRODUCT
  54. return "Torque Engine";
  55. #else
  56. switch (TORQUE_ENGINE_PRODUCT)
  57. {
  58. case 0001:
  59. return "Torque Game Engine";
  60. case 0002:
  61. return "Torque Game Engine Advanced";
  62. case 0003:
  63. return "Torque 2D";
  64. case 0004:
  65. return "Torque 360";
  66. case 0005:
  67. return "Torque for Wii";
  68. case 0006:
  69. return "Torque 3D";
  70. case 0007:
  71. return "Torque 3D MIT";
  72. default:
  73. return "Torque Engine";
  74. };
  75. #endif
  76. }
  77. const char* getCompileTimeString()
  78. {
  79. return __DATE__ " at " __TIME__;
  80. }
  81. //----------------------------------------------------------------
  82. ConsoleFunctionGroupBegin( CompileInformation, "Functions to get version information about the current executable." );
  83. DefineEngineFunction( getVersionNumber, S32, (), , "Get the version of the engine build, as a string.\n\n"
  84. "@ingroup Debugging")
  85. {
  86. return getVersionNumber();
  87. }
  88. DefineEngineFunction( getAppVersionNumber, S32, (), , "Get the version of the application build, as a string.\n\n"
  89. "@ingroup Debugging")
  90. {
  91. return getAppVersionNumber();
  92. }
  93. DefineEngineFunction( getVersionString, const char*, (), , "Get the version of the engine build, as a human readable string.\n\n"
  94. "@ingroup Debugging")
  95. {
  96. return getVersionString();
  97. }
  98. DefineEngineFunction( getAppVersionString, const char*, (), , "Get the version of the aplication build, as a human readable string.\n\n"
  99. "@ingroup Debugging")
  100. {
  101. return getAppVersionString();
  102. }
  103. DefineEngineFunction( getEngineName, const char*, (), , "Get the name of the engine product that this is running from, as a string.\n\n"
  104. "@ingroup Debugging")
  105. {
  106. return getEngineProductString();
  107. }
  108. DefineEngineFunction( getCompileTimeString, const char*, (), , "Get the time of compilation.\n\n"
  109. "@ingroup Debugging")
  110. {
  111. return getCompileTimeString();
  112. }
  113. DefineEngineFunction( getBuildString, const char*, (), , "Get the type of build, \"Debug\" or \"Release\".\n\n"
  114. "@ingroup Debugging")
  115. {
  116. #ifdef TORQUE_DEBUG
  117. return "Debug";
  118. #else
  119. return "Release";
  120. #endif
  121. }
  122. ConsoleFunctionGroupEnd( CompileInformation );