-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (63 loc) · 2.32 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
NAME = serviceplugin
PROVIDER ?= ocm.software
GITHUBORG ?= open-component-model
COMPONENT = $(PROVIDER)/plugins/$(NAME)
OCMREPO ?= ghcr.io/$(GITHUBORG)/ocm
PLATFORMS = linux/amd64 linux/arm64 darwin/arm64 darwin/amd64 windows/amd64
PLUGINTARGET = $${HOME}/.ocm/plugins
REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
VERSION = $(shell go run ./api/version/generate/release_generate.go print-rc-version $(CANDIDATE))
COMMIT = $(shell git rev-parse HEAD)
EFFECTIVE_VERSION = $(VERSION)+$(COMMIT)
GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty)
CMDSRCS=$(shell find $(REPO_ROOT)/plugins/$(NAME) -type f) Makefile
OCMSRCS=$(shell find $(REPO_ROOT)/api -type f) $(REPO_ROOT)/go.*
EXAMPLESRCS=$(shell find $(REPO_ROOT)/examples -type f) $(REPO_ROOT)/go.*
CREDS ?=
OCM = ocm $(CREDS)
GEN = $(REPO_ROOT)/gen
NOW := $(shell date -u +%FT%T%z)
BUILD_FLAGS := "-s -w \
-X github.com/open-component-model/service-model/api/version.gitVersion=$(EFFECTIVE_VERSION) \
-X github.com/open-component-model/service-model/api/version.gitTreeState=$(GIT_TREE_STATE) \
-X github.com/open-component-model/service-model/api/version.gitCommit=$(COMMIT) \
-X github.com/open-component-model/service-model/api/version.buildDate=$(NOW)"
.PHONY: build
build:
go build ./...
.PHONY: plugin
plugin: $(GEN)/.exists $(GEN)/$(NAME)/$(NAME)
gen/serviceplugin/serviceplugin:
echo doit
$(GEN)/$(NAME)/$(NAME): $(CMDSRCS) $(OCMSRCS)
CGO_ENABLED=0 go build -ldflags $(BUILD_FLAGS) -o $(GEN)/$(NAME)/$(NAME) ./plugins/$(NAME)
.PHONY: test
test:
go test -count=1 ./...
.PHONY: install
install: $(PLUGINTARGET)/$(NAME)
$(PLUGINTARGET)/$(NAME): $(GEN)/$(NAME)/$(NAME)
cp $(GEN)/$(NAME)/$(NAME) "$(PLUGINTARGET)"
.PHONY: ctf
ctf:
cd components/serviceplugin; make ctf
.PHONY: version
version:
@echo $(VERSION)
.PHONY: push
push:
cd components/serviceplugin; make push
.PHONY: examples
examples:
cd components/examples; make ctf
$(GEN)/.exists:
@mkdir -p $(GEN)
@touch $@
.PHONY: info
info:
@echo "ROOT: $(REPO_ROOT)"
@echo "VERSION: $(VERSION)"
@echo "COMMIT; $(COMMIT)"
.PHONY: clean
clean:
rm -rf $(GEN)