version.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "version.h"
  2. struct Version {
  3. const char* git_hash;
  4. const char* git_branch;
  5. const char* git_branch_num;
  6. const char* build_date;
  7. const char* version;
  8. const uint8_t target;
  9. const bool build_is_dirty;
  10. };
  11. /* version of current running firmware (bootloader/flipper) */
  12. static const Version version = {
  13. .git_hash = GIT_COMMIT,
  14. .git_branch = GIT_BRANCH,
  15. .git_branch_num = GIT_BRANCH_NUM,
  16. .build_date = BUILD_DATE,
  17. .version = VERSION
  18. #ifdef FURI_RAM_EXEC
  19. " (RAM)"
  20. #endif
  21. ,
  22. .target = TARGET,
  23. .build_is_dirty = BUILD_DIRTY,
  24. };
  25. const Version* version_get(void) {
  26. return &version;
  27. }
  28. const char* version_get_githash(const Version* v) {
  29. return v ? v->git_hash : version.git_hash;
  30. }
  31. const char* version_get_gitbranch(const Version* v) {
  32. return v ? v->git_branch : version.git_branch;
  33. }
  34. const char* version_get_gitbranchnum(const Version* v) {
  35. return v ? v->git_branch_num : version.git_branch_num;
  36. }
  37. const char* version_get_builddate(const Version* v) {
  38. return v ? v->build_date : version.build_date;
  39. }
  40. const char* version_get_version(const Version* v) {
  41. return v ? v->version : version.version;
  42. }
  43. uint8_t version_get_target(const Version* v) {
  44. return v ? v->target : version.target;
  45. }
  46. bool version_get_dirty_flag(const Version* v) {
  47. return v ? v->build_is_dirty : version.build_is_dirty;
  48. }