-
Notifications
You must be signed in to change notification settings - Fork 181
Expand file tree
/
Copy pathMakefile.common
More file actions
75 lines (59 loc) · 2.32 KB
/
Copy pathMakefile.common
File metadata and controls
75 lines (59 loc) · 2.32 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
SHELL=/bin/bash
.SHELLFLAGS = -o pipefail -c
SHELL_CASE_EXP = case "$$(uname -s)" in CYGWIN*|MINGW*|MSYS*) echo "true";; esac;
UNIX_SHELL_ON_WINDOWS := $(shell $(SHELL_CASE_EXP))
ifeq ($(UNIX_SHELL_ON_WINDOWS),true)
NUM_CORES := ${NUMBER_OF_PROCESSORS}
else
NUM_CORES := $(shell getconf _NPROCESSORS_ONLN)
endif
# SRC_ROOT is the top of the source tree.
SRC_ROOT := $(shell git rev-parse --show-toplevel)
ALL_SRC_AND_DOC_CMD := find . -type f \( \( -name "*.md" -o -name "*.go" -o -name "*.yaml" \) \) | sort
GOCMD?= go
GOOS=$(shell $(GOCMD) env GOOS)
GOARCH=$(shell $(GOCMD) env GOARCH)
TOOLS_MOD_DIR := $(SRC_ROOT)/tools
TOOLS_MOD_REGEX := "\s+_\s+\".*\""
TOOLS_PKG_NAMES := $(shell grep -E $(TOOLS_MOD_REGEX) < $(TOOLS_MOD_DIR)/tools.go | tr -d " _\"")
TOOLS_BIN_DIR := $(SRC_ROOT)/.tools
TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(TOOLS_PKG_NAMES)))
GCI := $(TOOLS_BIN_DIR)/gci
GOFUMPT := $(TOOLS_BIN_DIR)/gofumpt
GOIMPORTS := $(TOOLS_BIN_DIR)/goimports
GOVULNCHECK := $(TOOLS_BIN_DIR)/govulncheck
LINT := $(TOOLS_BIN_DIR)/golangci-lint
MISSPELL := $(TOOLS_BIN_DIR)/misspell -error
MISSPELL_CORRECTION := $(TOOLS_BIN_DIR)/misspell -w
.PHONY: goinstall-tools
goinstall-tools: $(TOOLS_BIN_NAMES)
$(TOOLS_BIN_DIR):
mkdir -p $@
$(TOOLS_BIN_NAMES): $(TOOLS_BIN_DIR) $(TOOLS_MOD_DIR)/go.mod
cd $(TOOLS_MOD_DIR) && GOOS="" GOARCH="" $(GOCMD) build -o $@ -trimpath $(filter %/$(notdir $@),$(TOOLS_PKG_NAMES))
.PHONY: moddownload
moddownload:
$(GOCMD) mod download
.PHONY: misspell
misspell: $(TOOLS_BIN_DIR)/misspell
@echo "running $(MISSPELL)"
@$(MISSPELL) $$($(ALL_SRC_AND_DOC_CMD))
.PHONY: misspell-correction
misspell-correction: $(TOOLS_BIN_DIR)/misspell
@$(MISSPELL_CORRECTION) $$($(ALL_SRC_AND_DOC_CMD))
.PHONY: gofmt
gofmt: $(GOFUMPT) $(GOIMPORTS) misspell-correction
gofmt -w -s .
$(GOFUMPT) -l -w .
$(MAKE) gogci
$(GOIMPORTS) -w -local github.com/signalfx/splunk-otel-collector-chart ./
.PHONY: golint
golint: $(LINT) misspell
$(LINT) run --allow-parallel-runners -j$(NUM_CORES)
.PHONY: govulncheck
govulncheck: $(GOVULNCHECK)
$(GOVULNCHECK) ./...
.PHONY: gogci
gogci: $(TOOLS_BIN_DIR)/gci
@echo "running $(GCI)"
@$(GCI) write -s standard -s default -s "prefix(github.com/signalfx/splunk-otel-collector-chart)" $$($(ALL_SRC_AND_DOC_CMD))