-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
63 lines (50 loc) · 1.94 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
export CGO_ENABLED ?= 0
CGO_CPPFLAGS ?= ${CPPFLAGS}
export CGO_CPPFLAGS
CGO_CFLAGS ?= ${CFLAGS}
export CGO_CFLAGS
CGO_LDFLAGS ?= $(filter -g -L% -l% -O%,${LDFLAGS})
export CGO_LDFLAGS
DATE_FMT = +%Y-%m-%d
ifdef SOURCE_DATE_EPOCH
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
else
BUILD_DATE ?= $(shell date "$(DATE_FMT)")
endif
GO_LDFLAGS := -X github.com/profclems/compozify/internal/version.BuildDate=$(BUILD_DATE) $(GO_LDFLAGS)
ifdef COMPOZIFY_VERSION
GO_LDFLAGS := $(GO_LDFLAGS) -X github.com/profclems/compozify/internal/version.Version=$(COMPOZIFY_VERSION)
endif
EXE =
ifeq ($(shell go env GOOS),windows)
EXE = .exe
endif
install:
go install -v -trimpath -ldflags "$(GO_LDFLAGS)" ./cmd/compozify
.PHONY: build
build:
go build -trimpath -ldflags "$(GO_LDFLAGS)" -o ./bin/compozify ./cmd/compozify
.PHONY: test
test:
go test -race ./...
.PHONY: fix
fix: ## Fix lint violations
golangci-lint run --fix
gofmt -s -w .
goimports -local "github.com/profclems/compozify" -w $$(find . -type f -name '*.go' -not -path "*/vendor/*")
.PHONY: completions
completions: build
mkdir -p ./share/bash-completion/completions ./share/fish/vendor_completions.d ./share/zsh/site-functions
bin/compozify$(EXE) completion bash > ./share/bash-completion/completions/compozify
bin/compozify$(EXE) completion fish > ./share/fish/vendor_completions.d/compozify.fish
bin/compozify$(EXE) completion zsh > ./share/zsh/site-functions/_compozify
.PHONY: manpages
manpages: ## Generate manual pages
go run -trimpath -ldflags "$(GO_LDFLAGS)" ./cmd/gen-docs/main.go --manpage --path ./share/man/man1
.PHONY: docs
docs: ## Generate web docs
go run ./cmd/gen-docs/main.go --path ./docs
web: ## Build web app
cd web && pnpm install && pnpm run build
bin/compozify-web: web
go build -trimpath -ldflags "$(GO_LDFLAGS)" -o ./bin/compozify-web ./cmd/compozify-web