|
1 | 1 | # This is the default Clever Golang Makefile. |
2 | 2 | # It is stored in the dev-handbook repo, github.com/Clever/dev-handbook |
3 | 3 | # Please do not alter this file directly. |
4 | | -GOLANG_MK_VERSION := 1.2.1 |
| 4 | +GOLANG_MK_VERSION := 1.3.1 |
5 | 5 |
|
6 | 6 | SHELL := /bin/bash |
7 | 7 | SYSTEM := $(shell uname -a | cut -d" " -f1 | tr '[:upper:]' '[:lower:]') |
@@ -48,7 +48,7 @@ golang-ensure-curl-installed: |
48 | 48 | # We pin its version because an update could add a new lint check which would make |
49 | 49 | # previously passing tests start failing without changing our code. |
50 | 50 | # this package is deprecated and frozen |
51 | | -# Infra recomendation is to eventaully move to https://github.com/golangci/golangci-lint so don't fail on linting error for now |
| 51 | +# Infra recommendation is to eventually move to https://github.com/golangci/golangci-lint so don't fail on linting error for now |
52 | 52 | GOLINT := $(GOPATH)/bin/golint |
53 | 53 | $(GOLINT): |
54 | 54 | go install -mod=readonly golang.org/x/lint/golint@738671d3881b9731cc63024d5d88cf28db875626 |
@@ -159,17 +159,28 @@ $(call golang-vet,$(1)) |
159 | 159 | $(call golang-test-strict-cover,$(1)) |
160 | 160 | endef |
161 | 161 |
|
162 | | -# golang-build: builds a golang binary. ensures CGO build is done during CI. This is needed to make a binary that works with a Docker alpine image. |
| 162 | +# golang-build: builds a golang binary |
163 | 163 | # arg1: pkg path |
164 | 164 | # arg2: executable name |
165 | 165 | define golang-build |
166 | 166 | @echo "BUILDING $(2)..." |
167 | | -@if [ -z "$$CI" ]; then \ |
168 | | - go build -o bin/$(2) $(1); \ |
169 | | -else \ |
170 | | - echo "-> Building CGO binary"; \ |
171 | | - CGO_ENABLED=0 go build -installsuffix cgo -o bin/$(2) $(1); \ |
172 | | -fi; |
| 167 | +@CGO_ENABLED=0 go build -o bin/$(2) $(1); |
| 168 | +endef |
| 169 | + |
| 170 | +# golang-debug-build: builds a golang binary with debugging capabilities |
| 171 | +# arg1: pkg path |
| 172 | +# arg2: executable name |
| 173 | +define golang-debug-build |
| 174 | +@echo "BUILDING $(2) FOR DEBUG..." |
| 175 | +@CGO_ENABLED=0 go build -gcflags="all=-N -l" -o bin/$(2) $(1); |
| 176 | +endef |
| 177 | + |
| 178 | +# golang-cgo-build: builds a golang binary with CGO |
| 179 | +# arg1: pkg path |
| 180 | +# arg2: executable name |
| 181 | +define golang-cgo-build |
| 182 | +@echo "BUILDING $(2) WITH CGO ..." |
| 183 | +@CGO_ENABLED=1 go build -installsuffix cgo -o bin/$(2) $(1); |
173 | 184 | endef |
174 | 185 |
|
175 | 186 | # golang-setup-coverage: set up the coverage file |
|
0 commit comments