-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
32 lines (25 loc) · 939 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
.PHONY: build dist test bench clean
COMMIT := $(shell git log --pretty=format:"%h" -n 1)
VERSION := $(shell git tag -l --sort=-version:refname "v*" | head -n1)
LD_FLAGS := "-s -w -X 'github.com/evilmartians/caddy_rails/version.Version=$(VERSION)' -X 'github.com/evilmartians/caddy_rails/version.Commit=$(COMMIT)'"
PLATFORMS = linux darwin freebsd
ARCHITECTURES = amd64 arm64 arm
build:
go build -ldflags $(LD_FLAGS) -o bin/ ./cmd/...
build-all: clean
@for platform in $(PLATFORMS); do \
for arch in $(ARCHITECTURES); do \
if [ "$$platform" = "darwin" ] && [ "$$arch" = "arm" ]; then \
continue; \
fi; \
output="dist/caddy-rails-$$platform-$$arch"; \
echo "Building for $$platform/$$arch..."; \
env GOOS=$$platform GOARCH=$$arch go build -ldflags $(LD_FLAGS) -o $$output ./cmd/caddy_rails/main.go; \
done; \
done
test:
go test ./...
bench:
go test -bench=. -benchmem -run=^# ./...
clean:
rm -rf bin dist