Skip to content

Commit

Permalink
feat: edit makefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
tx7do committed Dec 2, 2024
1 parent 7737355 commit e0507bc
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions backend/app.mk
Original file line number Diff line number Diff line change
@@ -1,22 +1,58 @@
GOPATH ?= $(shell go env GOPATH)
# GOVERSION is the current go version, e.g. go1.9.2
GOVERSION ?= $(shell go version | awk '{print $$3;}')

# Ensure GOPATH is set before running build process.
ifeq "$(GOPATH)" ""
$(error Please set the environment variable GOPATH before running `make`)
endif
FAIL_ON_STDOUT := awk '{ print } END { if (NR > 0) { exit 1 } }'

GO := GO111MODULE=on go
GO_CMD := GO111MODULE=on go
GIT_CMD := git
DOCKER_CMD := docker

ARCH := "`uname -s`"
LINUX := "Linux"
MAC := "Darwin"

DEFAULT_VERSION=0.0.1

ifeq ($(OS),Windows_NT)
IS_WINDOWS:=1
IS_WINDOWS:=TRUE
endif

ifneq (git,)
GIT_EXIST:=TRUE
endif

ifneq ("$(wildcard .git)", "")
HAS_DOTGIT:=TRUE
endif

ifeq ($(GIT_EXIST),TRUE)
ifeq ($(HAS_DOTGIT),TRUE)
# CUR_TAG is the last git tag plus the delta from the current commit to the tag
# e.g. v1.5.5-<nr of commits since>-g<current git sha>
CUR_TAG ?= $(shell git describe --tags --first-parent)

# LAST_TAG is the last git tag
# e.g. v1.5.5
LAST_TAG ?= $(shell git describe --match "v*" --abbrev=0 --tags --first-parent)

# VERSION is the last git tag without the 'v'
# e.g. 1.5.5
VERSION ?= $(shell git describe --match "v*" --abbrev=0 --tags --first-parent | cut -c 2-)
endif
endif

CUR_TAG ?= $(DEFAULT_VERSION)
LAST_TAG ?= v$(DEFAULT_VERSION)
VERSION ?= $(DEFAULT_VERSION)

# GOFLAGS is the flags for the go compiler.
GOFLAGS ?= -ldflags "-X main.version=$(VERSION)"

APP_VERSION=$(shell git describe --tags --always)
APP_RELATIVE_PATH=$(shell a=`basename $$PWD` && cd .. && b=`basename $$PWD` && echo $$b/$$a)
APP_NAME=$(shell echo $(APP_RELATIVE_PATH) | sed -En "s/\//-/p")
APP_DOCKER_IMAGE=$(shell echo $(APP_NAME) |awk -F '@' '{print "restroom-system/" $$0 ":0.1.0"}')
Expand Down

0 comments on commit e0507bc

Please sign in to comment.