-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (55 loc) · 2.07 KB
/
Makefile
File metadata and controls
70 lines (55 loc) · 2.07 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
.PHONY: build clean ui
VERSION=2.0.0
BIN=answer
DIR_SRC=./cmd/answer
DOCKER_CMD=docker
GO_ENV=CGO_ENABLED=0 GO111MODULE=on
Revision=$(shell git rev-parse --short HEAD 2>/dev/null || echo "")
GO_FLAGS=-ldflags="-X github.com/apache/answer/cmd.Version=$(VERSION) -X 'github.com/apache/answer/cmd.Revision=$(Revision)' -X 'github.com/apache/answer/cmd.Time=`date +%s`' -extldflags -static"
GO=$(GO_ENV) "$(shell which go)"
GOLANGCI_VERSION ?= v2.6.2
TOOLS_BIN := $(shell mkdir -p build/tools && realpath build/tools)
GOLANGCI = $(TOOLS_BIN)/golangci-lint-$(GOLANGCI_VERSION)
$(GOLANGCI):
rm -f $(TOOLS_BIN)/golangci-lint*
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/$(GOLANGCI_VERSION)/install.sh | sh -s -- -b $(TOOLS_BIN) $(GOLANGCI_VERSION)
mv $(TOOLS_BIN)/golangci-lint $(TOOLS_BIN)/golangci-lint-$(GOLANGCI_VERSION)
build: generate
@$(GO) build $(GO_FLAGS) -o $(BIN) $(DIR_SRC)
# https://dev.to/thewraven/universal-macos-binaries-with-go-1-16-3mm3
universal: generate
@GOOS=darwin GOARCH=amd64 $(GO_ENV) $(GO) build $(GO_FLAGS) -o ${BIN}_amd64 $(DIR_SRC)
@GOOS=darwin GOARCH=arm64 $(GO_ENV) $(GO) build $(GO_FLAGS) -o ${BIN}_arm64 $(DIR_SRC)
@lipo -create -output ${BIN} ${BIN}_amd64 ${BIN}_arm64
@rm -f ${BIN}_amd64 ${BIN}_arm64
generate:
@$(GO) get github.com/swaggo/swag/cmd/[email protected]
@$(GO) get github.com/google/wire/cmd/[email protected]
@$(GO) get go.uber.org/mock/[email protected]
@$(GO) install github.com/swaggo/swag/cmd/[email protected]
@$(GO) install github.com/google/wire/cmd/[email protected]
@$(GO) install go.uber.org/mock/[email protected]
@$(GO) generate ./...
@$(GO) mod tidy
check:
@mockgen -version
@swag -v
@wire flags
test:
@$(GO) test ./internal/repo/repo_test
# clean all build result
clean:
@$(GO) clean ./...
@rm -f $(BIN)
install-ui-packages:
@corepack enable
@corepack prepare [email protected] --activate
ui:
@cd ui && pnpm pre-install && pnpm build && cd -
lint: generate $(GOLANGCI)
@bash ./script/check-asf-header.sh
$(GOLANGCI) run
lint-fix: generate $(GOLANGCI)
@bash ./script/check-asf-header.sh
$(GOLANGCI) run --fix
all: clean build