Last active
July 17, 2023 15:04
-
-
Save maddiesch/7f5b8bb943acea75f2d0bc348d84c48e to your computer and use it in GitHub Desktop.
Golang Makefile for SAM project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GOLANG := go | |
GOLANG_TEST_FLAGS ?= -v | |
GOLANG_TEST_RUN ?= . | |
GOLANG_TEST_PATH ?= ./... | |
GO_LAMBDA_ENV ?= GOOS=linux GOARCH=arm64 | |
GO_LAMBDA_BUILD_FLAGS ?= -ldflags="-s -w" -tags "lambda.norpc" | |
GO_LAMBDA_BUILD ?= ${GO_LAMBDA_ENV} ${GOLANG} build ${GO_LAMBDA_BUILD_FLAGS} | |
GO_FILES := $(shell find . -type f -name '*.go' ! -name '*_test.go') | |
GO_TEST_FILES := $(shell find . -type f -name '*_test.go') | |
.PHONY: test | |
test: | |
${GOLANG} test ${GOLANG_TEST_FLAGS} -run ${GOLANG_TEST_RUN} ${GOLANG_TEST_PATH} | |
.PHONY: clean | |
clean: | |
rm -rf ./bin | |
${GOLANG} clean -testcache | |
bin/%/bootstrap: ${GO_FILES} ./go.mod ./go.sum | |
${GO_LAMBDA_BUILD} -o $@ ./cmd/$(patsubst bin/%/bootstrap,%,$@) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment