| Akron | 2ef703c | 2025-07-03 15:57:42 +0200 | [diff] [blame] | 1 | MODULE = github.com/KorAP/Koral-Mapper |
| 2 | CONFIG = github.com/KorAP/Koral-Mapper/config |
| Akron | aa62916 | 2025-06-04 11:44:52 +0200 | [diff] [blame] | 3 | DEV_DIR = $(shell pwd) |
| Akron | f22317d | 2026-02-25 11:37:59 +0100 | [diff] [blame^] | 4 | BUILDDATE = $(shell date -u '+%Y-%m-%dT%H:%M:%SZ') |
| Akron | aa62916 | 2025-06-04 11:44:52 +0200 | [diff] [blame] | 5 | BUILDVERSION = $(shell git describe --tags --abbrev=0 2>/dev/null) |
| 6 | BUILDCOMMIT = $(shell git rev-parse --short HEAD) |
| Akron | f22317d | 2026-02-25 11:37:59 +0100 | [diff] [blame^] | 7 | GO_LDFLAGS = -X $(CONFIG).Buildtime=$(BUILDDATE) \ |
| 8 | -X $(CONFIG).Buildhash=$(BUILDCOMMIT) \ |
| 9 | -X $(CONFIG).Version=$(BUILDVERSION) \ |
| 10 | -s \ |
| 11 | -w |
| Akron | aa62916 | 2025-06-04 11:44:52 +0200 | [diff] [blame] | 12 | |
| 13 | BUILDOUT = |
| 14 | ifeq ($(ACTION), build) |
| Akron | 2ef703c | 2025-07-03 15:57:42 +0200 | [diff] [blame] | 15 | BUILDOUT = -o ./koralmapper |
| Akron | aa62916 | 2025-06-04 11:44:52 +0200 | [diff] [blame] | 16 | endif |
| 17 | |
| 18 | |
| 19 | ifeq ($(strip $(BUILDVERSION)), ) |
| Akron | f22317d | 2026-02-25 11:37:59 +0100 | [diff] [blame^] | 20 | BUILDVERSION = EARLY |
| Akron | aa62916 | 2025-06-04 11:44:52 +0200 | [diff] [blame] | 21 | endif |
| 22 | |
| 23 | build: |
| 24 | go build -v \ |
| Akron | f22317d | 2026-02-25 11:37:59 +0100 | [diff] [blame^] | 25 | -ldflags "$(GO_LDFLAGS)" \ |
| Akron | aa62916 | 2025-06-04 11:44:52 +0200 | [diff] [blame] | 26 | --trimpath \ |
| 27 | $(BUILDOUT) \ |
| Akron | 2ef703c | 2025-07-03 15:57:42 +0200 | [diff] [blame] | 28 | ./cmd/koralmapper/ |
| Akron | aa62916 | 2025-06-04 11:44:52 +0200 | [diff] [blame] | 29 | |
| 30 | update: ## Update all dependencies and clean up the dependency files. |
| 31 | go get -u all && go mod tidy |
| 32 | |
| 33 | test: |
| 34 | go test ./... |
| 35 | |
| 36 | bench: ## Run all benchmarks in the code. |
| 37 | go test -bench=. -benchmem ./... -run=^# -count 5 |
| 38 | |
| 39 | vet: ## Run `go vet` on the code. |
| 40 | go vet ./... |
| 41 | |
| 42 | fuzz: |
| Akron | 428c0af | 2026-02-20 16:44:58 +0100 | [diff] [blame] | 43 | # go test -fuzz=FuzzTransformEndpoint -fuzztime=1m ./cmd/koralmapper |
| 44 | go test -fuzz=FuzzParseCfgParam -fuzztime=1m ./cmd/koralmapper |
| Akron | 50d5f83 | 2025-06-06 15:08:04 +0200 | [diff] [blame] | 45 | |
| 46 | docker: |
| Akron | f22317d | 2026-02-25 11:37:59 +0100 | [diff] [blame^] | 47 | docker build -f Dockerfile -t korap/koral-mapper:latest \ |
| 48 | --build-arg BUILDDATE="$(BUILDDATE)" \ |
| 49 | --build-arg BUILDCOMMIT="$(BUILDCOMMIT)" \ |
| 50 | --build-arg BUILDVERSION="$(BUILDVERSION)" \ |
| 51 | . |