Newer
Older
project / mk / git-info-conf.mk
Nomura Kei on 27 Aug 2022 1 KB UPDATE
  1. # ==============================================================================
  2. # git 情報
  3. # ==============================================================================
  4.  
  5. # ------------------------------------------------------------------------------
  6. # git のタグなどから取得可能なバージョン情報を DEFINE に設定します。
  7. #
  8. # VERSION : git tag (v[Major].[Minor].[Release] の [Major].[Minor].[Release] 部分)
  9. # MAJOR : git tag (v[Major].[Minor].[Release] の [Major] 部分)
  10. # MINOR : git tag (v[Major].[Minor].[Release] の [Minor] 部分)
  11. # RELEASE : git tag (v[Major].[Minor].[Release] の [Release] 部分)
  12. # REVISION : git revision
  13. # DATETIME : datetime (ISO8601形式)
  14. # ------------------------------------------------------------------------------
  15. VERSION := $(shell $(GIT) tag | $(SORT) -V | $(TAIL) -1 | $(SED) -e 's/^[^0-9]\+//')
  16. REVISION := $(shell $(GIT) rev-parse --short HEAD)
  17. DATETIME := $(shell $(DATE) "+%Y%m%dT%H%M%S")
  18.  
  19. ifeq ($(strip $(VERSION)),)
  20. VERSION := v0.0.1
  21. REVISION := 0
  22. endif
  23.  
  24. MAJOR := $(shell $(ECHO) $(VERSION) | $(SED) -e 's/^[a-zA-Z]*\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)$$/\1/')
  25. MINOR := $(shell $(ECHO) $(VERSION) | $(SED) -e 's/^[a-zA-Z]*\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)$$/\2/')
  26. RELEASE := $(shell $(ECHO) $(VERSION) | $(SED) -e 's/^[a-zA-Z]*\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)$$/\3/')
  27.  
  28. DEFINE += -DVERSION='"$(VERSION)"' -DMAJOR='"$(MAJOR)"' -DMINOR='"$(MINOR)"' -DRELEASE='"$(RELEASE)"'
  29. DEFINE += -DREVISION='"$(REVISION)"'
  30. DEFINE += -DDATETIME='"$(DATETIME)"'
  31.