version.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef _VERSION_H
  2. #define _VERSION_H
  3. // These variables are autogenerated and compiled
  4. // into the library by the version.cmake script
  5. extern "C"
  6. {
  7. extern const char* GIT_TAG;
  8. extern const char* GIT_REV;
  9. extern const char* GIT_BRANCH;
  10. extern const char* BUILD_TIME;
  11. }
  12. #include <string>
  13. #include <string.h>
  14. #include "Helper.h"
  15. #include <fstream>
  16. const char* build_time(void)
  17. {
  18. return BUILD_TIME;
  19. }
  20. const char* libfive_git_version(void)
  21. {
  22. return GIT_TAG;
  23. }
  24. const char* libfive_git_revision(void)
  25. {
  26. return GIT_REV;
  27. }
  28. const char* libfive_git_branch(void)
  29. {
  30. return GIT_BRANCH;
  31. }
  32. std::string getFwVersion(void) {
  33. std::string buf;
  34. if (std::string(GIT_TAG) == "") { // Tag not set, show branch
  35. buf = "Development-Branch: " + std::string(GIT_BRANCH);
  36. }
  37. else { // Tag is set, ignore branch
  38. buf = "Release: " + std::string(GIT_TAG);
  39. }
  40. buf = buf + " (Commit: " + std::string(GIT_REV) + ")";
  41. return buf;
  42. }
  43. std::string getHTMLversion(void){
  44. char buf[100]="?\0";
  45. FILE* pFile;
  46. string fn = FormatFileName("/sdcard/html/version.txt");
  47. pFile = fopen(fn.c_str(), "r");
  48. if (pFile == NULL)
  49. return std::string(buf);
  50. fgets(buf, sizeof(buf), pFile); // Line 1: Version
  51. fclose(pFile);
  52. return std::string(buf);
  53. }
  54. std::string getHTMLcommit(void){
  55. char buf[100]="?\0";
  56. FILE* pFile;
  57. string fn = FormatFileName("/sdcard/html/version.txt");
  58. pFile = fopen(fn.c_str(), "r");
  59. if (pFile == NULL)
  60. return std::string(buf);
  61. fgets(buf, sizeof(buf), pFile); // Line 1: Version -> ignored
  62. fgets(buf, sizeof(buf), pFile); // Line 2: Commit
  63. fclose(pFile);
  64. return std::string(buf);
  65. }
  66. #endif // _VERSION_H