forked from bougou/go-ipmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (40 loc) · 1.96 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
APP_VERSION ?= $(shell git describe --abbrev=5 --dirty --tags --always)
GIT_COMMIT := $(shell git rev-parse --short=8 HEAD)
BUILD_TIME := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
BINDIR := $(PWD)/bin
OUTPUT_DIR := $(PWD)/_output
GOOS ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
GOARCH ?= amd64
LDFLAGS := $(LDFLAGS) -X github.com/bougou/go-ipmi/goipmi/commands.Version=$(APP_VERSION)
LDFLAGS := $(LDFLAGS) -X github.com/bougou/go-ipmi/goipmi/commands.Commit=$(GIT_COMMIT)
LDFLAGS := $(LDFLAGS) -X github.com/bougou/go-ipmi/goipmi/commands.BuildAt=$(BUILD_TIME)
PATH := $(BINDIR):$(PATH)
SHELL := env PATH='$(PATH)' /bin/sh
all: build
# Run tests
test: fmt vet
@# Disable --race until https://github.com/kubernetes-sigs/controller-runtime/issues/1171 is fixed.
ginkgo --randomizeAllSpecs --randomizeSuites --failOnPending --flakeAttempts=2 \
--cover --coverprofile cover.out --trace --progress $(TEST_ARGS)\
./pkg/... ./cmd/...
# Build goipmi binary
build: fmt vet
go build -ldflags "$(LDFLAGS)" -o $(OUTPUT_DIR)/goipmi ./goipmi
# Cross compiler
build-all: fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -a -o $(OUTPUT_DIR)/goipmi-$(APP_VERSION)-linux-amd64 ./goipmi
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -a -o $(OUTPUT_DIR)/goipmi-$(APP_VERSION)-linux-arm64 ./goipmi
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -a -o $(OUTPUT_DIR)/goipmi-$(APP_VERSION)-darwin-amd64 ./goipmi
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -a -o $(OUTPUT_DIR)/goipmi-$(APP_VERSION)-darwin-arm64 ./goipmi
# Run go fmt against code
fmt:
go fmt ./...
# Run go vet against code
vet:
go vet ./...
lint:
$(BINDIR)/golangci-lint run --timeout 2m0s ./...
dependencies:
test -d $(BINDIR) || mkdir $(BINDIR)
GOBIN=$(BINDIR) go install github.com/onsi/ginkgo/[email protected]
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $(BINDIR) latest