-
Notifications
You must be signed in to change notification settings - Fork 117
/
Makefile
75 lines (53 loc) · 2.08 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
PROJDIR=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
# change to project dir so we can express all as relative paths
$(shell cd $(PROJDIR))
REPO_PATH=agola.io/agola
VERSION ?= $(shell scripts/git-version.sh)
LD_FLAGS="-w -X $(REPO_PATH)/cmd.Version=$(VERSION)"
$(shell mkdir -p bin )
$(shell mkdir -p tools/bin )
AGOLA_TAGS = sqlite_unlock_notify
AGOLA_WEBBUNDLE_DEPS = webbundle/bindata.go
AGOLA_WEBBUNDLE_TAGS = webbundle
ifdef WEBBUNDLE
ifndef WEBDISTPATH
$(error WEBDISTPATH must be provided when building the webbundle)
endif
AGOLA_DEPS = $(AGOLA_WEBBUNDLE_DEPS)
AGOLA_TAGS += $(AGOLA_WEBBUNDLE_TAGS)
endif
TOOLBOX_OSES=linux
TOOLBOX_ARCHS=amd64 arm64
.PHONY: all
all: build
.PHONY: build
build: agola agola-toolbox
# don't use existing file names and track go sources, let's do this to the go tool
.PHONY: agola
agola: $(AGOLA_DEPS)
GO111MODULE=on go build $(if $(AGOLA_TAGS),-tags "$(AGOLA_TAGS)") -ldflags $(LD_FLAGS) -o $(PROJDIR)/bin/agola $(REPO_PATH)/cmd/agola
# toolbox MUST be statically compiled so it can be used in any image for that arch
.PHONY: agola-toolbox
agola-toolbox:
$(foreach GOOS, $(TOOLBOX_OSES),\
$(foreach GOARCH, $(TOOLBOX_ARCHS), $(shell GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 GO111MODULE=on go build $(if $(AGOLA_TAGS),-tags "$(AGOLA_TAGS)") -ldflags $(LD_FLAGS) -o $(PROJDIR)/bin/agola-toolbox-$(GOOS)-$(GOARCH) $(REPO_PATH)/cmd/toolbox)))
.PHONY: go-bindata
go-bindata:
GOBIN=$(PROJDIR)/tools/bin go install github.com/go-bindata/go-bindata/go-bindata
.PHONY: gocovmerge
gocovmerge:
GOBIN=$(PROJDIR)/tools/bin go install github.com/wadey/gocovmerge
webbundle/bindata.go: go-bindata $(WEBDISTPATH)
./tools/bin/go-bindata -o webbundle/bindata.go -tags webbundle -pkg webbundle -prefix "$(WEBDISTPATH)" -nocompress=true "$(WEBDISTPATH)/..."
.PHONY: generate
generate: generators
go generate $(PROJDIR)/...
.PHONY: generators
generators:
go build -o $(PROJDIR)/tools/bin/dbgenerator ./internal/generators/db
.PHONY: docker-agola
docker-agola:
docker build --target agola . -t agola
.PHONY: docker-agolademo
docker-agolademo:
docker build . -t agolademo