helper_get_openmpt_version.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #define LIBOPENMPT_BUILD
  2. #include "common/BuildSettings.h"
  3. #include <iostream>
  4. #include <string>
  5. #include <vector>
  6. #include "common/versionNumber.h"
  7. #include "libopenmpt/libopenmpt_version.h"
  8. #define VER_HELPER_STRINGIZE(x) #x
  9. #define VER_STRINGIZE(x) VER_HELPER_STRINGIZE(x)
  10. int main( int argc, char * argv [] ) {
  11. std::vector<std::string> args = std::vector<std::string>( argv, argv + argc );
  12. for ( std::vector<std::string>::const_iterator i = args.begin(); i != args.end(); ++i ) {
  13. if ( i == args.begin() ) {
  14. // skip program name
  15. continue;
  16. }
  17. std::string arg = *i;
  18. if ( arg == "" ) {
  19. std::cout << "unknown" << std::endl;
  20. } else if ( arg == "openmpt" ) {
  21. std::cout << VER_STRINGIZE(VER_MAJORMAJOR) << "." << VER_STRINGIZE(VER_MAJOR) << "." << VER_STRINGIZE(VER_MINOR) << "." << VER_STRINGIZE(VER_MINORMINOR) << std::endl;
  22. } else if ( arg == "openmpt-version-majormajor" ) {
  23. std::cout << VER_STRINGIZE(VER_MAJORMAJOR) << std::endl;
  24. } else if ( arg == "openmpt-version-major" ) {
  25. std::cout << VER_STRINGIZE(VER_MAJOR) << std::endl;
  26. } else if ( arg == "openmpt-version-minor" ) {
  27. std::cout << VER_STRINGIZE(VER_MINOR) << std::endl;
  28. } else if ( arg == "openmpt-version-minorminor" ) {
  29. std::cout << VER_STRINGIZE(VER_MINORMINOR) << std::endl;
  30. #ifdef OPENMPT_API_VERSION_MAJOR
  31. } else if ( arg == "libopenmpt-version-major" ) {
  32. std::cout << OPENMPT_API_VERSION_MAJOR << std::endl;
  33. #endif
  34. #ifdef OPENMPT_API_VERSION_MINOR
  35. } else if ( arg == "libopenmpt-version-minor" ) {
  36. std::cout << OPENMPT_API_VERSION_MINOR << std::endl;
  37. #endif
  38. #ifdef OPENMPT_API_VERSION_PATCH
  39. } else if ( arg == "libopenmpt-version-patch" ) {
  40. std::cout << OPENMPT_API_VERSION_PATCH << std::endl;
  41. #endif
  42. #ifdef OPENMPT_API_VERSION_PREREL
  43. } else if ( arg == "libopenmpt-version-prerel" ) {
  44. std::cout << OPENMPT_API_VERSION_PREREL << std::endl;
  45. #endif
  46. #ifdef OPENMPT_API_VERSION_STRING
  47. } else if ( arg == "libopenmpt-version-string" ) {
  48. std::cout << OPENMPT_API_VERSION_STRING << std::endl;
  49. #endif
  50. } else {
  51. std::cout << "unknown" << std::endl;
  52. }
  53. }
  54. return 0;
  55. }