-
Notifications
You must be signed in to change notification settings - Fork 130
/
Makefile.Common
67 lines (57 loc) · 2.3 KB
/
Makefile.Common
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
ALL_SRC := $(shell find . -name '*.go' -not -path '*/vendor/*' -type f)
GOTOOLS ?=
GOTOOLS += " github.com/golangci/golangci-lint/cmd/[email protected]"
GOTOOLS += " go.elastic.co/[email protected]"
GOTOOLS += " github.com/google/addlicense@04bfe4ee9ca5764577b029acc6a1957fd1997153"
ADDLICENCESE=addlicense
.PHONY: deps
deps:
@printf '\n================================================================\n'
@printf 'Target: go-get'
@printf '\n================================================================\n'
@$(GO_BIN) mod tidy
@$(GO_BIN) mod vendor
@echo '[go-get] Done.'
.PHONY: install-tools
install-tools:
@printf '\n================================================================\n'
@printf 'Target: go-install'
@printf '\n================================================================\n'
@for tool in $(GOTOOLS); do \
$(GO_BIN) install $$tool; \
done
@echo '[go-install] Done.'
.PHONY: addlicense
addlicense: install-tools
@ADDLICENCESEOUT=`$(ADDLICENCESE) -y "" -ignore "vendor/**" -s=only -c 'New Relic Corporation. All rights reserved.' $(ALL_SRC) 2>&1`; \
if [ "$$ADDLICENCESEOUT" ]; then \
echo "$(ADDLICENCESE) FAILED => addlicense errors:\n"; \
echo "$$ADDLICENCESEOUT\n"; \
exit 1; \
else \
echo "Add License ($(ADDLICENCESE)) finished successfully"; \
fi
.PHONY: checklicense
checklicense: install-tools
@ADDLICENCESEOUT=`$(ADDLICENCESE) -ignore "vendor/**" -check $(ALL_SRC) 2>&1`; \
if [ "$$ADDLICENCESEOUT" ]; then \
echo "$(ADDLICENCESE) FAILED => addlicense errors:\n"; \
echo "$$ADDLICENCESEOUT\n"; \
echo "Use 'make addlicense' to add header licenses this."; \
exit 1; \
else \
echo "Check License ($(ADDLICENCESE)) finished successfully"; \
fi
.PHONY: third-party-notices
third-party-notices: OUT ?= THIRD_PARTY_NOTICES.md
third-party-notices: install-tools
third-party-notices: deps
@go list -mod=mod -m -json all | go-licence-detector \
-rules assets/licence/rules.json \
-noticeTemplate assets/licence/THIRD_PARTY_NOTICES.md.tmpl \
-noticeOut $(OUT)
# -includeIndirect
.PHONY: third-party-notices-check
third-party-notices-check:
@OUT=THIRD_PARTY_NOTICES_GENERATED.md make third-party-notices
@diff THIRD_PARTY_NOTICES_GENERATED.md THIRD_PARTY_NOTICES.md 2>&1 > /dev/null || (echo "THIRD_PARTY_NOTICES.md should be generated"; exit 1)