-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
42 lines (32 loc) · 1.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
.PHONY: test build
BUILD_TIME := $(shell date "+%F %T")
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR := $(dir $(MKFILE_PATH))
TARGET = ${MKFILE_DIR}build/bin/gofbot
RELEASE?=$(shell git describe --tags)
GIT_REPO_INFO=$(shell git config --get remote.origin.url)
ifndef COMMIT
COMMIT := git-$(shell git rev-parse --short HEAD)
endif
default: build
mod:
@echo "-------------- download the modules ---------------"
@go mod download
build:
@echo "-------------- building the program ---------------"
cd ${MKFILE_DIR} && go build -v -ldflags "-s -w \
-X github.com/bonaysoft/gofbot/cmd.repo=${GIT_REPO_INFO} \
-X github.com/bonaysoft/gofbot/cmd.commit=${COMMIT} \
-X github.com/bonaysoft/gofbot/cmd.release=${RELEASE} \
" -o ${TARGET}
@echo "-------------- version detail ---------------"
@${TARGET} -v
test:
go test -coverprofile=.coverprofile -covermode=atomic ./...
go tool cover --func=.coverprofile
covhtml:
go tool cover -html=.coverprofile
run: build
${TARGET}
clean:
rm -rf ${MKFILE_DIR}build