From d309b58f63cfc382e0003cff85ab057fd06d3d23 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Fri, 8 Mar 2024 01:50:37 +0700 Subject: Makefile: reorder default tasks and add flags for reproducible build The lint and build should be the first tasks, so in case we have warnings or errors the tests are not running. The flags for reproducible build are taken from Arch Linux wiki [1]. [1]: https://wiki.archlinux.org/title/Go_package_guidelines#Flags_and_build_options --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c9b3f94c..41527d6c 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ VERSION := $(shell git describe --tags) .PHONY: all install build docs docs-serve clean distclean .PHONY: lint test test.prof -all: test lint build +all: lint build test install: go install ./cmd/... @@ -21,7 +21,12 @@ install: build: BUILD_FLAGS=-ldflags "-s -w -X 'git.sr.ht/~shulhan/pakakeh.go.Version=$(VERSION)'" build: mkdir -p _bin/ - go build $(BUILD_FLAGS) -o _bin/ ./cmd/... + go build \ + -trimpath \ + -buildmode=pie \ + -mod=readonly \ + -modcacherw \ + $(BUILD_FLAGS) -o _bin/ ./cmd/... test: CGO_ENABLED=1 go test -failfast -timeout=1m -race -coverprofile=$(COVER_OUT) ./... -- cgit v1.3