version.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include "version.h"
  2. #include <furi.h>
  3. /* This header is autogenerated by build system */
  4. #include "version.inc.h"
  5. #define VERSION_MAGIC (0xBE40u)
  6. #define VERSION_MAJOR (0x1u)
  7. #define VERSION_MINOR (0x0u)
  8. struct Version {
  9. // Header
  10. const uint16_t magic;
  11. const uint8_t major;
  12. const uint8_t minor;
  13. // Payload
  14. const char* git_hash;
  15. const char* git_branch;
  16. const char* build_date;
  17. const char* version;
  18. // Payload bits and pieces
  19. const uint8_t target;
  20. const bool build_is_dirty;
  21. };
  22. /* version of current running firmware (bootloader/flipper) */
  23. static const Version version = {
  24. .magic = VERSION_MAGIC,
  25. .major = VERSION_MAJOR,
  26. .minor = VERSION_MINOR,
  27. .git_hash = GIT_COMMIT,
  28. .git_branch = GIT_BRANCH,
  29. .build_date = BUILD_DATE,
  30. .version = VERSION
  31. #ifdef FURI_RAM_EXEC
  32. " (RAM)"
  33. #endif
  34. ,
  35. .target = TARGET,
  36. .build_is_dirty = BUILD_DIRTY,
  37. };
  38. const Version* version_get(void) {
  39. return &version;
  40. }
  41. const char* version_get_githash(const Version* v) {
  42. return v ? v->git_hash : version.git_hash;
  43. }
  44. const char* version_get_gitbranch(const Version* v) {
  45. return v ? v->git_branch : version.git_branch;
  46. }
  47. const char* version_get_gitbranchnum(const Version* v) {
  48. UNUSED(v);
  49. return "0";
  50. }
  51. const char* version_get_builddate(const Version* v) {
  52. return v ? v->build_date : version.build_date;
  53. }
  54. const char* version_get_version(const Version* v) {
  55. return v ? v->version : version.version;
  56. }
  57. uint8_t version_get_target(const Version* v) {
  58. return v ? v->target : version.target;
  59. }
  60. bool version_get_dirty_flag(const Version* v) {
  61. return v ? v->build_is_dirty : version.build_is_dirty;
  62. }