-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (31 loc) · 1.02 KB
/
Makefile
File metadata and controls
40 lines (31 loc) · 1.02 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
GO ?= go
BIN ?= bin/cloudcanal
PKG ?= ./...
TEST_PKG ?= ./test/...
COVER_PROFILE ?= coverage.out
DIST_DIR ?= dist
VERSION ?= dev
COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo unknown)
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
GO_BUILD_FLAGS ?=
EXTRA_LDFLAGS ?=
BUILDINFO_PKG := github.com/ClouGence/cloudcanal-openapi-cli/internal/buildinfo
LDFLAGS ?= -X $(BUILDINFO_PKG).Version=$(VERSION) -X $(BUILDINFO_PKG).Commit=$(COMMIT) -X $(BUILDINFO_PKG).BuildTime=$(BUILD_TIME) $(EXTRA_LDFLAGS)
.PHONY: build test vet test-race cover ci release-assets clean
build:
mkdir -p $(dir $(BIN))
$(GO) build $(GO_BUILD_FLAGS) -ldflags "$(LDFLAGS)" -o $(BIN) ./cmd/cloudcanal
test:
$(GO) test $(PKG)
vet:
$(GO) vet $(PKG)
test-race:
$(GO) test -race $(TEST_PKG)
cover:
$(GO) test -coverpkg=$(PKG) -coverprofile=$(COVER_PROFILE) $(TEST_PKG)
$(GO) tool cover -func=$(COVER_PROFILE)
ci: test vet test-race cover build
release-assets:
./scripts/build_release_assets.sh
clean:
rm -rf $(dir $(BIN)) $(DIST_DIR) $(COVER_PROFILE)