-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (40 loc) · 1.41 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
.PHONY: all build_linux build_macos build_windows build_native clean install uninstall test
BUILD_VERSION := $(shell git describe --tags --always)
TAG_DATE := $(shell git log -1 --format=%cd --date=unix $(BUILD_VERSION))
INSTALL_DIR := ${HOME}/go/bin
INSTALL_TARGET := $(INSTALL_DIR)/$(NAME)
NAME := cfgrr
LINUX_NAME := $(NAME)_linux
MACOS_NAME := $(NAME)_macos
WIN_NAME := $(NAME)_windows.exe
BUILD_TAGS := '-s -w -X "main.version=$(BUILD_VERSION)" -X "main.tagdate=$(TAG_DATE)"'
all: build_linux build_macos build_windows
build_linux:
$(info Building Linux binary...)
GOOS=linux go build -ldflags $(BUILD_TAGS) -o bin/$(LINUX_NAME)
build_macos:
$(info Building MacOS binary...)
GOOS=darwin go build -ldflags $(BUILD_TAGS) -o bin/$(MACOS_NAME)
build_windows:
$(info Building windows binary...)
GOOS=windows go build -ldflags $(BUILD_TAGS) -o bin/$(WIN_NAME)
build_native:
$(info Building native binary...)
go build -ldflags $(BUILD_TAGS) -o bin/$(NAME)
clean:
$(info Cleaning up...)
rm -rf bin
install: |
$(info Installing $(INSTALL_TARGET))
mkdir -p $(INSTALL_DIR) && go install -ldflags $(BUILD_TAGS)
uninstall:
$(info Removing $(INSTALL_TARGET))
rm -rf $(INSTALL_TARGET)
test:
$(info Running tests...)
go test -v ./...
cover:
$(info Running coverage...)
mkdir -p coverage
go test -coverprofile=coverage/coverage.out -coverpkg=./... ./...
go tool cover -html=coverage/coverage.out -o coverage/coverage.html