Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (65 loc) · 1.57 KB
/
Copy pathMakefile
File metadata and controls
84 lines (65 loc) · 1.57 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
APP := screenlens
CMD := ./cmd/screenlens
BIN_DIR := bin
CONFIG ?= config.yaml
GO ?= go
GOFLAGS ?=
LDFLAGS ?=
GUI_TAGS ?= gui
ifeq ($(OS),Windows_NT)
GUI_LDFLAGS ?= -H=windowsgui
else
GUI_LDFLAGS ?=
endif
TEST_RUNNER ?=
ifneq ($(OS),Windows_NT)
ifeq ($(shell uname -s 2>/dev/null),Linux)
ifeq ($(DISPLAY),)
TEST_RUNNER := xvfb-run -a
endif
endif
endif
ifeq ($(OS),Windows_NT)
GUI_BINARY := $(BIN_DIR)/$(APP).exe
CONSOLE_BINARY := $(BIN_DIR)/$(APP)-console.exe
else
GUI_BINARY := $(BIN_DIR)/$(APP)
CONSOLE_BINARY := $(BIN_DIR)/$(APP)-console
endif
.PHONY: all build build-gui build-console fmt tidy test race vet check run run-gui install install-gui clean
ifeq ($(OS),Windows_NT)
build: build-gui
else
build: build-console
endif
all: check build
build-gui:
@$(GO) build $(GOFLAGS) -tags "$(GUI_TAGS)" -ldflags "$(GUI_LDFLAGS) $(LDFLAGS)" -o "$(GUI_BINARY)" $(CMD)
build-console:
@$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o "$(CONSOLE_BINARY)" $(CMD)
fmt:
@gofmt -w cmd internal
tidy:
@$(GO) mod tidy
test:
@$(TEST_RUNNER) $(GO) test ./...
race:
@$(TEST_RUNNER) $(GO) test -race ./...
vet:
@$(GO) vet ./...
check: fmt tidy test vet
run:
@$(GO) run $(CMD) -config "$(CONFIG)"
run-gui:
@$(GO) run -tags "$(GUI_TAGS)" -ldflags "$(GUI_LDFLAGS)" $(CMD) -config "$(CONFIG)"
install:
@$(GO) install $(CMD)
install-gui:
@$(GO) install -tags "$(GUI_TAGS)" -ldflags "$(GUI_LDFLAGS)" $(CMD)
clean:
@$(GO) clean
ifeq ($(OS),Windows_NT)
@if exist "$(BIN_DIR)" rmdir /s /q "$(BIN_DIR)"
else
@rm -rf "$(BIN_DIR)"
endif