-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
64 lines (43 loc) · 2.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
PACKAGE=github.com/StamusNetworks/stamusctl/internal/app
LOGGER=github.com/StamusNetworks/stamusctl/internal/logging
CURRENT_DIR=$(shell pwd)
DIST_DIR=${CURRENT_DIR}/dist
CLI_NAME=stamusctl
DAEMON_NAME=stamusd
HOST_OS:=$(shell go env GOOS)
HOST_ARCH:=$(shell go env GOARCH)
TARGET_ARCH?=linux/amd64
VERSION=$(shell cat ${CURRENT_DIR}/VERSION)
BUILD_DATE:=$(if $(BUILD_DATE),$(BUILD_DATE),$(shell date -u +'%Y-%m-%dT%H:%M:%SZ'))
GIT_COMMIT:=$(if $(GIT_COMMIT),$(GIT_COMMIT),$(shell git rev-parse HEAD))
GIT_TAG:=$(if $(GIT_TAG),$(GIT_TAG),$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi))
GOPATH?=$(shell if test -x `which go`; then go env GOPATH; else echo "$(HOME)/go"; fi)
GOCACHE?=$(HOME)/.cache/go-build
STATIC_BUILD?=true
DEV_IMAGE?=false
override LDFLAGS += \
-X ${PACKAGE}.Arch=${TARGET_ARCH} \
-X ${PACKAGE}.Commit=${GIT_COMMIT} \
-X ${PACKAGE}.Version=${VERSION} \
-X ${LOGGER}.envType=prd
all: cli daemon
cli:
CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -ldflags="-extldflags=-static" -o ${DIST_DIR}/${CLI_NAME} ./cmd
test-cli:
CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" BUILD_MODE=test STAMUS_APP_NAME=stamusctl go build -v -ldflags '${LDFLAGS}' -ldflags="-extldflags=-static" -o ${DIST_DIR}/${CLI_NAME} ./cmd
test:
go test ./internal/models
daemon:
CGO_ENABLED=0 GODEBUG="tarinsecurepath=0,zipinsecurepath=0" go build -v -ldflags '${LDFLAGS}' -ldflags="-extldflags=-static" -o ${DIST_DIR}/${DAEMON_NAME} ./cmd
daemon-dev:
air run
daemon-test: init-embeds
EMBED_MODE=true go test ./.test/unit
build-swaggo-image:
docker build . -t swag-daemon -f docker/Dockerfile.swag
update-swagger: build-swaggo-image
docker run --rm -it -v .:/code swag-daemon:latest
# This step is needed in tests to have embeds loaded in some xdg paths
init-embeds:
STAMUS_APP_NAME=stamusctl EMBED_MODE=true go run ./cmd compose init -h
.PHONY: all cli test-cli test daemon daemon-dev daemon-test build-swaggo-image update-swagger init-embeds