-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
56 lines (40 loc) · 1.5 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
PERCEIVERS = $(shell ls cmd)
ifndef REGISTRY
REGISTRY=gcr.io/saas-hub-stg
endif
ifdef IMAGE_PREFIX
PREFIX="$(IMAGE_PREFIX)-"
endif
ifneq (, $(findstring gcr.io,$(REGISTRY)))
PREFIX_CMD="gcloud"
DOCKER_OPTS="--"
endif
OUTDIR=_output
LOCAL_TARGET=local
CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
.PHONY: all clean test push test ${PERCEIVERS} container local
all: build
build: ${OUTDIR} $(PERCEIVERS)
${LOCAL_TARGET}: ${OUTDIR} $(PERCEIVERS)
$(PERCEIVERS):
ifeq ($(MAKECMDGOALS),${LOCAL_TARGET})
cd cmd/$@; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@
else
docker run --rm -e CGO_ENABLED=0 -e GOOS=linux -e GOARCH=amd64 -e GO111MODULE=off -v "${CURRENT_DIR}":/go/src/github.com/blackducksoftware/perceivers -w /go/src/github.com/blackducksoftware/perceivers/cmd/$@ golang:1.13 go build -o $@
endif
cp cmd/$@/$@ ${OUTDIR}
container: $(PERCEIVERS)
$(foreach p,${PERCEIVERS},cd ${CURRENT_DIR}/cmd/$p; docker build -t $(REGISTRY)/$(PREFIX)${p} .;)
push: container
$(foreach p,${PERCEIVERS},$(PREFIX_CMD) docker $(DOCKER_OPTS) push $(REGISTRY)/$(PREFIX)${p}:latest;)
test:
docker run --rm -e CGO_ENABLED=0 -e GOOS=linux -e GOARCH=amd64 -e GO111MODULE=off -v "${CURRENT_DIR}":/go/src/github.com/blackducksoftware/perceivers -w /go/src/github.com/blackducksoftware/perceivers golang:1.13 go test ./pkg/...
clean:
rm -rf ${OUTDIR}
$(foreach p,${PERCEIVERS},rm -f cmd/$p/$p;)
${OUTDIR}:
mkdir -p ${OUTDIR}
lint:
./hack/verify-gofmt.sh
./hack/verify-golint.sh
./hack/verify-govet.sh