forked from dokku/dokku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.mk
46 lines (36 loc) · 1.2 KB
/
common.mk
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
GO_ARGS ?=
GO_PLUGIN_MAKE_TARGET ?= build
GO_REPO_ROOT := /go/src/github.com/dokku/dokku
BUILD_IMAGE := golang:1.15.6
GO_BUILD_CACHE ?= /tmp/dokku-go-build-cache
GO_MOD_CACHE ?= /tmp/dokku-go-mod-mod
.PHONY: build-in-docker build clean src-clean
build: $(BUILD)
build-in-docker: clean
mkdir -p /tmp/dokku-go-build-cache
docker run --rm \
-v $$PWD/../..:$(GO_REPO_ROOT) \
-v $(GO_BUILD_CACHE):/root/.cache \
-v $(GO_MOD_CACHE):/go/pkg/mod \
-e PLUGIN_NAME=$(PLUGIN_NAME) \
-e GO111MODULE=on \
-w $(GO_REPO_ROOT)/plugins/$(PLUGIN_NAME) \
$(BUILD_IMAGE) \
bash -c "GO_ARGS='$(GO_ARGS)' make -j4 $(GO_PLUGIN_MAKE_TARGET)" || exit $$?
clean:
rm -rf $(BUILD)
find . -xtype l -delete
commands: **/**/commands.go
go build -ldflags="-s -w" $(GO_ARGS) -o commands src/commands/commands.go
subcommands:
go build -ldflags="-s -w" $(GO_ARGS) -o subcommands/subcommands src/subcommands/subcommands.go
$(MAKE) $(SUBCOMMANDS)
subcommands/%:
ln -sf subcommands $@
src-clean:
rm -rf .gitignore src vendor Makefile *.go glide.* go.sum go.mod
triggers:
go build -ldflags="-s -w" $(GO_ARGS) -o triggers src/triggers/triggers.go
$(MAKE) $(TRIGGERS)
triggers/%:
ln -sf triggers $(shell echo $@ | cut -d '/' -f2)