diff options
author | Simon Pasquier <spasquie@redhat.com> | 2019-03-25 12:47:57 +0100 |
---|---|---|
committer | Johannes 'fish' Ziemke <github@freigeist.org> | 2019-03-25 12:47:57 +0100 |
commit | dbe7badc7c37da1ddaaa33db4860e51a73c4c44a (patch) | |
tree | 9fad12c85f6537992e4f7051a90d2c3ffa44732d /Makefile.common | |
parent | 2f87b7cba6d6eb729a78724335fd59e746fcdff4 (diff) | |
download | prometheus_node_collector-dbe7badc7c37da1ddaaa33db4860e51a73c4c44a.tar.bz2 prometheus_node_collector-dbe7badc7c37da1ddaaa33db4860e51a73c4c44a.tar.xz prometheus_node_collector-dbe7badc7c37da1ddaaa33db4860e51a73c4c44a.zip |
Update Makefile.common (#1288)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Diffstat (limited to 'Makefile.common')
-rw-r--r-- | Makefile.common | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/Makefile.common b/Makefile.common index 79001dd..ed29aa8 100644 --- a/Makefile.common +++ b/Makefile.common | |||
@@ -60,7 +60,6 @@ $(warning Some recipes may not work as expected as the current Go runtime is '$( | |||
60 | endif | 60 | endif |
61 | endif | 61 | endif |
62 | PROMU := $(FIRST_GOPATH)/bin/promu | 62 | PROMU := $(FIRST_GOPATH)/bin/promu |
63 | STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck | ||
64 | pkgs = ./... | 63 | pkgs = ./... |
65 | 64 | ||
66 | ifeq (arm, $(GOHOSTARCH)) | 65 | ifeq (arm, $(GOHOSTARCH)) |
@@ -72,8 +71,17 @@ endif | |||
72 | 71 | ||
73 | PROMU_VERSION ?= 0.3.0 | 72 | PROMU_VERSION ?= 0.3.0 |
74 | PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz | 73 | PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz |
75 | STATICCHECK_VERSION ?= 2019.1 | 74 | |
76 | STATICCHECK_URL := https://github.com/dominikh/go-tools/releases/download/$(STATICCHECK_VERSION)/staticcheck_$(GOHOSTOS)_$(GOHOSTARCH) | 75 | STATICCHECK := |
76 | # staticcheck only supports linux, freebsd, darwin and windows platforms on i386/amd64 | ||
77 | # windows isn't included here because of the path separator being different. | ||
78 | ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin)) | ||
79 | ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386)) | ||
80 | STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck | ||
81 | STATICCHECK_VERSION ?= 2019.1 | ||
82 | STATICCHECK_URL := https://github.com/dominikh/go-tools/releases/download/$(STATICCHECK_VERSION)/staticcheck_$(GOHOSTOS)_$(GOHOSTARCH) | ||
83 | endif | ||
84 | endif | ||
77 | 85 | ||
78 | PREFIX ?= $(shell pwd) | 86 | PREFIX ?= $(shell pwd) |
79 | BIN_DIR ?= $(shell pwd) | 87 | BIN_DIR ?= $(shell pwd) |
@@ -87,14 +95,14 @@ ifeq ($(GOHOSTARCH),amd64) | |||
87 | endif | 95 | endif |
88 | endif | 96 | endif |
89 | 97 | ||
90 | .PHONY: all | ||
91 | all: precheck style staticcheck unused build test | ||
92 | |||
93 | # This rule is used to forward a target like "build" to "common-build". This | 98 | # This rule is used to forward a target like "build" to "common-build". This |
94 | # allows a new "build" target to be defined in a Makefile which includes this | 99 | # allows a new "build" target to be defined in a Makefile which includes this |
95 | # one and override "common-build" without override warnings. | 100 | # one and override "common-build" without override warnings. |
96 | %: common-% ; | 101 | %: common-% ; |
97 | 102 | ||
103 | .PHONY: common-all | ||
104 | common-all: precheck style check_license staticcheck unused build test | ||
105 | |||
98 | .PHONY: common-style | 106 | .PHONY: common-style |
99 | common-style: | 107 | common-style: |
100 | @echo ">> checking code style" | 108 | @echo ">> checking code style" |
@@ -116,6 +124,15 @@ common-check_license: | |||
116 | exit 1; \ | 124 | exit 1; \ |
117 | fi | 125 | fi |
118 | 126 | ||
127 | .PHONY: common-deps | ||
128 | common-deps: | ||
129 | @echo ">> getting dependencies" | ||
130 | ifdef GO111MODULE | ||
131 | GO111MODULE=$(GO111MODULE) $(GO) mod download | ||
132 | else | ||
133 | $(GO) get $(GOOPTS) -t ./... | ||
134 | endif | ||
135 | |||
119 | .PHONY: common-test-short | 136 | .PHONY: common-test-short |
120 | common-test-short: | 137 | common-test-short: |
121 | @echo ">> running short tests" | 138 | @echo ">> running short tests" |
@@ -138,6 +155,7 @@ common-vet: | |||
138 | 155 | ||
139 | .PHONY: common-staticcheck | 156 | .PHONY: common-staticcheck |
140 | common-staticcheck: $(STATICCHECK) | 157 | common-staticcheck: $(STATICCHECK) |
158 | ifdef STATICCHECK | ||
141 | @echo ">> running staticcheck" | 159 | @echo ">> running staticcheck" |
142 | chmod +x $(STATICCHECK) | 160 | chmod +x $(STATICCHECK) |
143 | ifdef GO111MODULE | 161 | ifdef GO111MODULE |
@@ -148,6 +166,7 @@ ifdef GO111MODULE | |||
148 | else | 166 | else |
149 | $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) | 167 | $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) |
150 | endif | 168 | endif |
169 | endif | ||
151 | 170 | ||
152 | .PHONY: common-unused | 171 | .PHONY: common-unused |
153 | common-unused: $(GOVENDOR) | 172 | common-unused: $(GOVENDOR) |
@@ -205,9 +224,11 @@ proto: | |||
205 | @echo ">> generating code from proto files" | 224 | @echo ">> generating code from proto files" |
206 | @./scripts/genproto.sh | 225 | @./scripts/genproto.sh |
207 | 226 | ||
227 | ifdef STATICCHECK | ||
208 | $(STATICCHECK): | 228 | $(STATICCHECK): |
209 | mkdir -p $(FIRST_GOPATH)/bin | 229 | mkdir -p $(FIRST_GOPATH)/bin |
210 | curl -s -L $(STATICCHECK_URL) > $(STATICCHECK) | 230 | curl -s -L $(STATICCHECK_URL) > $(STATICCHECK) |
231 | endif | ||
211 | 232 | ||
212 | ifdef GOVENDOR | 233 | ifdef GOVENDOR |
213 | .PHONY: $(GOVENDOR) | 234 | .PHONY: $(GOVENDOR) |
@@ -221,7 +242,6 @@ precheck:: | |||
221 | define PRECHECK_COMMAND_template = | 242 | define PRECHECK_COMMAND_template = |
222 | precheck:: $(1)_precheck | 243 | precheck:: $(1)_precheck |
223 | 244 | ||
224 | |||
225 | PRECHECK_COMMAND_$(1) ?= $(1) $$(strip $$(PRECHECK_OPTIONS_$(1))) | 245 | PRECHECK_COMMAND_$(1) ?= $(1) $$(strip $$(PRECHECK_OPTIONS_$(1))) |
226 | .PHONY: $(1)_precheck | 246 | .PHONY: $(1)_precheck |
227 | $(1)_precheck: | 247 | $(1)_precheck: |