Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(INFRANG-6623): Update golang.mk #332

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions golang.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This is the default Clever Golang Makefile.
# It is stored in the dev-handbook repo, github.com/Clever/dev-handbook
# Please do not alter this file directly.
GOLANG_MK_VERSION := 1.2.1
GOLANG_MK_VERSION := 1.3.0

SHELL := /bin/bash
SYSTEM := $(shell uname -a | cut -d" " -f1 | tr '[:upper:]' '[:lower:]')
Expand Down Expand Up @@ -159,17 +159,28 @@ $(call golang-vet,$(1))
$(call golang-test-strict-cover,$(1))
endef

# 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.
# golang-build: builds a golang binary
# arg1: pkg path
# arg2: executable name
define golang-build
@echo "BUILDING $(2)..."
@if [ -z "$$CI" ]; then \
go build -o bin/$(2) $(1); \
else \
echo "-> Building CGO binary"; \
CGO_ENABLED=0 go build -installsuffix cgo -o bin/$(2) $(1); \
fi;
@CGO_ENABLED=0 go build -o bin/$(2) $(1);
endef

# golang-debug-build: builds a golang binary with debugging capabilities
# arg1: pkg path
# arg2: executable name
define golang-debug-build
@echo "BUILDING $(2) FOR DEBUG..."
@CGO_ENABLED=0 go build -gcflags="all=-N -l" -o bin/$(2) $(1);
endef

# golang-cgo-build: builds a golang binary with CGO
# arg1: pkg path
# arg2: executable name
define golang-cgo-build
@echo "BUILDING $(2) WITH CGO ..."
@CGO_ENABLED=1 go build -installsuffix cgo -o bin/$(2) $(1);
endef

# golang-setup-coverage: set up the coverage file
Expand Down