-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
106 lines (92 loc) · 2.4 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
NAME := cq-source-openstack
DESCRIPTION := CloudQuery OpenStack source plugin
KIND := source
COPYRIGHT := 2024 © Andrea Funtò
LICENSE := MIT
LICENSE_URL := https://opensource.org/license/mit/
VERSION_MAJOR := 0
VERSION_MINOR := 1
VERSION_PATCH := 0
VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
LICENSE="MIT"
RELEASE=1
PRODUCER_URL=https://github.com/dihedron/
DOWNLOAD_URL=$(PRODUCER_URL)cq-source-openstack
SHELL := /bin/bash
platforms="$$(go tool dist list)"
module := $$(grep "module .*" go.mod | sed 's/module //gi')
package := $(module)/version
now := $$(date --rfc-3339=seconds)
# comment this to disable compression; to improve compression
# consider replacing upx -9 with upx --brute (slow!)
strip := -w -s
#
# Linux x86-64 build settings
#
linux/amd64: GOAMD64 = v3
#
# Windows x86-64 build settings
#
windows/amd64: GOAMD64 = v3
.PHONY: default
default: linux/amd64;
%:
@go mod tidy
ifeq (, $(shell which govulncheck))
@go install golang.org/x/vuln/cmd/govulncheck@latest
endif
@govulncheck ./...
@for platform in "$(platforms)"; do \
if test "$(@)" = "$$platform"; then \
echo "Building target $(@)..."; \
mkdir -p dist/$(@); \
GOOS=$(shell echo $(@) | cut -d "/" -f 1) \
GOARCH=$(shell echo $(@) | cut -d "/" -f 2) \
GOAMD64=$(GOAMD64) \
CGO_ENABLED=0 \
go build -v \
-ldflags="\
$(strip) \
-X '$(package).Name=$(NAME)' \
-X '$(package).Description=$(DESCRIPTION)' \
-X '$(package).Kind=$(KIND)' \
-X '$(package).Copyright=$(COPYRIGHT)' \
-X '$(package).License=$(LICENSE)' \
-X '$(package).LicenseURL=$(LICENSE_URL)' \
-X '$(package).BuildTime=$(now)' \
-X '$(package).VersionMajor=$(VERSION_MAJOR)' \
-X '$(package).VersionMinor=$(VERSION_MINOR)' \
-X '$(package).VersionPatch=$(VERSION_PATCH)'" \
-o dist/$(@)/ .;\
echo ...done!; \
fi; \
done
.PHONY: optimise
optimise:
ifeq (, $(shell which upx))
@sudo apt install upx
endif
@for binary in `find dist/ -name 'cq-source-openstack*'`; do \
upx --brute $$binary; \
done;
.PHONY: clean
clean:
@rm -rf dist
# .PHONY: local
# local:
# goreleaser build --single-target --snapshot --clean
.PHONY: test
test:
go test -timeout 3m ./...
.PHONY: lint
lint:
@golangci-lint run --timeout 10m
.PHONY: gen-docs
gen-docs:
rm -rf ./docs/tables/*
go run main.go doc ./docs/tables
# All gen targets
.PHONY: gen
gen: gen-docs