-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
49 lines (38 loc) · 1.29 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# SPDX-FileCopyrightText: 2020 SAP SE
# SPDX-FileCopyrightText: 2021 SAP SE
# SPDX-FileCopyrightText: 2022 SAP SE
# SPDX-FileCopyrightText: 2023 SAP SE
#
# SPDX-License-Identifier: Apache-2.0
GO ?= go
BINS ?= $(patsubst cmd/%,%,$(wildcard cmd/*))
REUSE_ARGS = --skip-unrecognised --copyright='SAP SE' --license='Apache-2.0'
build: $(BINS)
$(BINS):
go build -o $@ ./cmd/$@/
generate:
ifeq (x$(TARGET),x)
grep -r '^// Code generated by ".*"\; DO NOT EDIT.$\' ./ | awk -F: '{ print $$1 }' | xargs --no-run-if-empty rm
$(GO) generate ./...
reuse addheader $(REUSE_ARGS) $(shell find . -type f -not -path '*/.git/*')
else
grep '^// Code generated by ".*"\; DO NOT EDIT.$\' ./$(TARGET)/* | awk -F: '{ print $$1 }' | xargs --no-run-if-empty rm
$(GO) generate ./$(TARGET)
reuse addheader $(REUSE_ARGS) $(shell find ./$(TARGET) -type f -not -path '*/.git/*')
endif
lint:
golangci-lint run ./...
integration:
$(GO) test -race -cover ./... --tags=integration
.PHONY: report
report:
$(GO) clean -testcache
$(GO) test -race -cover -coverprofile=/tmp/cov.out ./... --tags=integration
$(GO) tool cover -html=/tmp/cov.out -o ./report.html
rm /tmp/cov.out
EXAMPLES := $(dir $(wildcard examples/*/main.go))
examples: $(EXAMPLES)
.PHONY: $(EXAMPLES)
$(EXAMPLES):
@echo Running example: $@
$(GO) run ./$@/main.go