Debian Codegraph @

Makefile

raw symbols SCIP
1 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
2 current_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
3
4 MESOS_API_VERSION := v1
5 API_PKG := ./api/${MESOS_API_VERSION}/lib
6 API_VENDOR := ${current_dir}/api/${MESOS_API_VERSION}/vendor
7 CMD_PKG := ./api/${MESOS_API_VERSION}/cmd
8 CMD_VENDOR := ./api/${MESOS_API_VERSION}/cmd/vendor
9
10 PROTO_PATH := ${GOPATH}/src/:${API_VENDOR}/:.
11 PROTO_PATH := ${PROTO_PATH}:${API_VENDOR}/github.com/gogo/protobuf/protobuf
12 PROTO_PATH := ${PROTO_PATH}:${API_VENDOR}/github.com/gogo/protobuf/gogoproto
13
14 PACKAGES ?= $(shell go list ${API_PKG}/...|grep -v vendor)
15 TEST_DIRS ?= $(sort $(dir $(shell find ${API_PKG} -name '*_test.go' | grep -v vendor)))
16 BINARIES ?= $(shell go list -f "{{.Name}} {{.ImportPath}}" ${CMD_PKG}/...|grep -v -e vendor|grep -e ^main|cut -f2 -d' ')
17 TEST_FLAGS ?= -race
18 COVERAGE_TARGETS = ${TEST_DIRS:%/=%.cover}
19
20 GO_VERSION := $(shell go version|cut -f3 -d' '|dd bs=1 count=5 2>/dev/null)
21
22 .PHONY: all
23 all: test
24
25 .PHONY: install
26 install: INSTALL_FLAGS +=
27 install:
28 go install $(INSTALL_FLAGS) $(BINARIES)
29
30 .PHONY: test
31 test:
32 go $@ $(TEST_FLAGS) $(TEST_DIRS)
33
34 .PHONY: test-verbose
35 test-verbose: TEST_FLAGS += -v
36 test-verbose: test
37
38 .PHONY: coverage $(COVERAGE_TARGETS)
39 coverage: REPORT=_output/coverage.out
40 coverage: COVER_PACKAGE = $(shell go list ${API_PKG}/...|egrep -v 'vendor|cmd'|tr '\n' ','|sed -e 's/,$$//')
41 coverage: TEST_FLAGS = -v -cover -coverpkg=$(COVER_PACKAGE)
42 coverage: $(COVERAGE_TARGETS)
43 echo "mode: set" >$(REPORT) && cat _output/*.cover | grep -v mode: | sort -r | \
44 awk '{if($$1 != last) {print $$0;last=$$1}}' >> $(REPORT)
45 $(COVERAGE_TARGETS): %.cover :
46 mkdir -p _output && go test ./$* $(TEST_FLAGS) -coverprofile=_output/$(subst /,___,$@)
47
48 .PHONY: vet
49 vet:
50 go $@ $(PACKAGES) $(BINARIES)
51
52 .PHONY: codecs
53 codecs: protobufs ffjson
54
55 .PHONY: protobufs-requirements
56 protobufs-requirements: REQUIRED_PROTOC_BINARIES = protoc-gen-gogo
57 protobufs-requirements:
58 @for i in ${REQUIRED_PROTOC_BINARIES}; do which $$i >/dev/null || { echo "failed to locate binary: $$i"; exit 1; }; done
59
60 .PHONY: protobufs
61 protobufs: protobufs-requirements clean-protobufs
62 (cd ${API_PKG}; protoc --proto_path="${PROTO_PATH}" --gogo_out=. *.proto)
63 (cd ${API_PKG}; protoc --proto_path="${PROTO_PATH}" --gogo_out=. ./scheduler/*.proto)
64 (cd ${API_PKG}; protoc --proto_path="${PROTO_PATH}" --gogo_out=. ./executor/*.proto)
65 (cd ${API_PKG}; protoc --proto_path="${PROTO_PATH}" --gogo_out=. ./agent/*.proto)
66 (cd ${API_PKG}; protoc --proto_path="${PROTO_PATH}" --gogo_out=. ./quota/*.proto)
67 (cd ${API_PKG}; protoc --proto_path="${PROTO_PATH}" --gogo_out=. ./allocator/*.proto)
68 (cd ${API_PKG}; protoc --proto_path="${PROTO_PATH}" --gogo_out=. ./maintenance/*.proto)
69 (cd ${API_PKG}; protoc --proto_path="${PROTO_PATH}" --gogo_out=. ./master/*.proto)
70
71 .PHONY: clean-protobufs
72 clean-protobufs:
73 (cd ${API_PKG}; rm -f *.pb.go */*.pb.go)
74
75 .PHONY: ffjson
76 ffjson: clean-ffjson
77 (cd ${API_PKG}; ffjson *.pb.go)
78 (cd ${API_PKG}; ffjson scheduler/*.pb.go)
79 (cd ${API_PKG}; ffjson executor/*.pb.go)
80 (cd ${API_PKG}; ffjson agent/*.pb.go)
81 (cd ${API_PKG}; ffjson quota/*.pb.go)
82 (cd ${API_PKG}; ffjson allocator/*.pb.go)
83 (cd ${API_PKG}; ffjson maintenance/*.pb.go)
84 (cd ${API_PKG}; ffjson master/*.pb.go)
85
86 .PHONY: clean-ffjson
87 clean-ffjson:
88 (cd ${API_PKG}; rm -f *ffjson.go */*ffjson.go)
89
90 .PHONY: sync
91 sync:
92 @which govendor >/dev/null || { echo "govendor not found in $$PATH"; exit 1; }
93 (cd ${API_VENDOR}; govendor sync)
94 (cd ${CMD_VENDOR}; govendor sync)
95
96 .PHONY: generate
97 generate: GENERATE_PACKAGES = ./api/v1/lib/extras/executor/eventrules ./api/v1/lib/extras/executor/callrules ./api/v1/lib/extras/scheduler/eventrules ./api/v1/lib/extras/scheduler/callrules ./api/v1/lib/executor/events ./api/v1/lib/executor/calls ./api/v1/lib/scheduler/events ./api/v1/lib/scheduler/calls ./api/v1/lib/agent/calls ./api/v1/lib/master/calls ./api/v1/lib/httpcli/httpagent ./api/v1/lib/httpcli/httpmaster ./api/v1/lib/httpcli/httpexec
98 generate:
99 go generate -x ${GENERATE_PACKAGES}
100
101 GOPKG := github.com/mesos/mesos-go
102 GOPKG_DIRNAME := $(shell dirname $(GOPKG))
103 UID ?= $(shell id -u $$USER)
104 GID ?= $(shell id -g $$USER)
105
106 DOCKER_IMAGE_REPO ?= jdef
107 DOCKER_IMAGE_NAME ?= example-scheduler-httpv1
108 DOCKER_IMAGE_VERSION ?= latest
109 DOCKER_IMAGE_TAG ?= $(DOCKER_IMAGE_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)
110
111 GOLDFLAGS = -X $(GOPKG)/api/${MESOS_API_VERSION}/cmd.DockerImageTag=$(DOCKER_IMAGE_TAG)
112
113 BUILD_STEP := 'ln -s /src /go/src/$(GOPKG) && cd /go/src/$(GOPKG) && go install -ldflags "$(GOLDFLAGS)" $(BINARIES)'
114 COPY_STEP := 'cp /go/bin/* /src/_output/ && chown $(UID):$(GID) /src/_output/*'
115
116 # required for docker/Makefile
117 export DOCKER_IMAGE_TAG
118
119 .PHONY: docker
120 docker:
121 mkdir -p _output
122 test -n "$(UID)" || (echo 'ERROR: $$UID is undefined'; exit 1)
123 test -n "$(GID)" || (echo 'ERROR: $$GID is undefined'; exit 1)
124 docker run --rm -v "$$PWD":/src -w /go/src/$(GOPKG_DIRNAME) golang:1.8.1-alpine sh -c $(BUILD_STEP)' && '$(COPY_STEP)
125 make -C api/${MESOS_API_VERSION}/docker
126
127 .PHONY: coveralls
128 coveralls: IGNORE_FILES = $(shell { find api/v1/cmd -type d ; ls api/v1/lib{,/scheduler,/executor,/agent,/quota,/allocator,/maintenance,/master}/*.pb{,_ffjson}.go ; find api/v0 -type d; } | tr '\n' ,)
129 coveralls: SHELL := /bin/bash
130 coveralls:
131 test "$(TRAVIS)" = "" || rm -rf $$HOME/gopath/pkg
132 $(MAKE) coverage
133 $$HOME/gopath/bin/goveralls -service=travis-ci -coverprofile=_output/coverage.out -ignore=$(IGNORE_FILES)
134
135 # re-generate protobuf and json code, check that there are no differences w/ respect to what's been checked in
136 .PHONY: validate-protobufs
137 ifeq ($(GO_VERSION),go1.8)
138 validate-protobufs: SHELL := /bin/bash
139 validate-protobufs:
140 (cd api/v1; govendor install +vendor,program) && $(MAKE) -s protobufs ffjson && [[ `{ git status --porcelain || echo "failed"; } | tee /tmp/status | wc -l` = "0" ]] || { cat /tmp/status; git diff; false; }
141 else
142 validate-protobufs:
143 endif