restic-scheduler/Makefile

67 lines
1.6 KiB
Makefile
Raw Normal View History

2022-03-29 05:03:00 +00:00
APP_NAME = resticscheduler
2022-02-18 22:36:19 +00:00
VERSION ?= $(shell git describe --tags --dirty)
GOFILES = *.go
# Multi-arch targets are generated from this
TARGET_ALIAS = $(APP_NAME)-linux-amd64 $(APP_NAME)-linux-arm $(APP_NAME)-linux-arm64
2022-02-18 22:36:19 +00:00
TARGETS = $(addprefix dist/,$(TARGET_ALIAS))
2024-11-03 03:05:56 +00:00
CURRENT_GOARCH = $(shell go env GOARCH)
2022-04-15 19:10:04 +00:00
2022-02-18 22:36:19 +00:00
# Default make target will run tests
.DEFAULT_GOAL = test
# Build all static Minitor binaries
.PHONY: all
all: $(TARGETS)
# Build all static Linux Minitor binaries
.PHONY: all-linux
all-linux: $(filter dist/$(APP_NAME)-linux-%,$(TARGETS))
# Build restic-scheduler for the current machine
$(APP_NAME): $(GOFILES)
@echo Version: $(VERSION)
go build -ldflags '-X "main.version=$(VERSION)"' -o $(APP_NAME)
.PHONY: build
build: $(APP_NAME)
# Run all tests
.PHONY: test
test:
2023-04-25 20:32:37 +00:00
go test -v -coverprofile=coverage.out # -short
2022-02-18 22:36:19 +00:00
go tool cover -func=coverage.out
.PHONY: itest
itest: docker-build
./itest/run.sh
2022-02-18 22:36:19 +00:00
# Installs pre-commit hooks
.PHONY: install-hooks
install-hooks:
pre-commit install --install-hooks
# Runs pre-commit checks on files
.PHONY: check
check:
pre-commit run --all-files
.PHONY: clean
clean:
rm -f ./$(APP_NAME)
rm -f ./coverage.out
rm -fr ./dist
## Multi-arch targets
$(TARGETS): $(GOFILES)
mkdir -p ./dist
GOOS=$(word 2, $(subst -, ,$(@))) GOARCH=$(word 3, $(subst -, ,$(@))) CGO_ENABLED=0 \
go build -ldflags '-X "main.version=$(VERSION)"' -a -installsuffix nocgo \
-o $@
.PHONY: $(TARGET_ALIAS)
$(TARGET_ALIAS):
$(MAKE) $(addprefix dist/,$@)
2022-04-05 03:25:05 +00:00
2022-04-15 19:10:04 +00:00
docker-build: dist/$(APP_NAME)-linux-$(CURRENT_GOARCH)
docker build --platform=linux/$(CURRENT_GOARCH) . -t $(APP_NAME)