-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
62 lines (51 loc) · 1.39 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
DEFAULT_TARGET: build
VERSION := 0.4.0
COMMIT := $(shell git rev-parse --short HEAD)
LDFLAGS := -X github.com/dcos/dcos-diagnostics/config.Version=$(VERSION) -X github.com/dcos/dcos-diagnostics/config.Commit=$(COMMIT)
CURRENT_DIR=$(shell pwd)
BUILD_DIR=build
PKG_DIR=/dcos-diagnostics
BINARY_NAME=dcos-diagnostics
IMAGE_NAME=dcos-diagnostics-dev
SRCS := $(shell find . -type f -name '*.go' -not -path './vendor/*')
.PHONY: docker
docker:
ifndef NO_DOCKER
docker build -t $(IMAGE_NAME) .
endif
$(BUILD_DIR)/$(BINARY_NAME): $(SRCS)
mkdir -p $(BUILD_DIR)
$(call inDocker,go build -mod=vendor -v -ldflags '$(LDFLAGS)' -o $(BUILD_DIR)/$(BINARY_NAME))
.PHONY: build
build: docker $(BUILD_DIR)/$(BINARY_NAME)
# install does not run in a docker container to build for the correct OS
.PHONY: install
install:
go install -mod=vendor -v -ldflags '$(LDFLAGS)'
.PHONY: test
test: docker
$(call inDocker,bash -x -c './scripts/test.sh')
.PHONY: integration
integration:
@echo "This project doesn't have any integration tests"
.PHONY: publish
publish:
@echo "This project doesn't have any artifacts to be published"
.PHONY: clean
clean:
rm -rf ./$(BUILD_DIR)
ifdef NO_DOCKER
define inDocker
$1
endef
else
define inDocker
docker run \
$(shell test -t 0 && echo "-t -i" || true) \
-v $(CURRENT_DIR):$(PKG_DIR) \
-w $(PKG_DIR) \
--rm \
$(IMAGE_NAME) \
$1
endef
endif