build_info.h 961 B

12345678910111213141516171819202122
  1. // build_info.h -- firmware build provenance, surfaced in the WebUSB panel so you can confirm EXACTLY which
  2. // build is flashed on a board (the git commit it was built from, and whether that working tree was dirty).
  3. //
  4. // The values come from one of two sources, in priority order:
  5. // 1) -D defines on the compile line, e.g. build.extra_flags += -DOPK_GIT_HASH=\"abc12345\" -DOPK_GIT_DIRTY=1
  6. // 2) a generated git_version.h (written by gen_version.sh before compiling), picked up via __has_include.
  7. // If neither is present (a bare checkout compiled by hand) the values fall back to "unknown" / not-dirty, so
  8. // the build always succeeds -- the panel just shows "unknown" until you generate the header.
  9. #pragma once
  10. #if !defined(OPK_GIT_HASH) && defined(__has_include)
  11. #if __has_include("git_version.h")
  12. #include "git_version.h"
  13. #endif
  14. #endif
  15. #ifndef OPK_GIT_HASH
  16. #define OPK_GIT_HASH "unknown"
  17. #endif
  18. #ifndef OPK_GIT_DIRTY
  19. #define OPK_GIT_DIRTY 0
  20. #endif