Skip to content

Commit

Permalink
added git commands
Browse files Browse the repository at this point in the history
  • Loading branch information
dyldonahue committed Nov 24, 2024
1 parent 878457d commit 5fd5009
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,25 @@
######################################
TARGET = shepherd2

######################################
# git
######################################
GIT_MAJOR_VERSION := $(shell git describe --tags --abbrev=0 | cut -c2- | cut -d'.' -f1)
GIT_MINOR_VERSION := $(shell git describe --tags --abbrev=0 | cut -c2- | cut -d'.' -f2)
GIT_PATCH_VERSION := $(shell git describe --tags --abbrev=0 | cut -c2- | cut -d'.' -f3)
GIT_IS_UPSTREAM_CLEAN := $(shell bash -c 'git merge-base --is-ancestor HEAD @{u} && echo 0 || echo 1')
GIT_IS_LOCAL_CLEAN := $(shell bash -c 'test -z "$$(git status --porcelain)" && echo 0 || echo 1')



all:
@echo "Version: $(GIT_MAJOR_VERSION).$(GIT_MINOR_VERSION).$(GIT_PATCH_VERSION)"

CFLAGS += -DGIT_MAJOR_VERSION=$(GIT_MAJOR_VERSION) \
-DGIT_MINOR_VERSION=$(GIT_MINOR_VERSION) \
-DGIT_PATCH_VERSION=$(GIT_PATCH_VERSION) \
-DGIT_IS_UPSTREAM_CLEAN=$(GIT_IS_UPSTREAM_CLEAN) \
-DGIT_IS_LOCAL_CLEAN=$(GIT_IS_LOCAL_CLEAN)
######################################
# building variables
######################################
Expand Down

0 comments on commit 5fd5009

Please sign in to comment.