This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
/
Makefile
131 lines (108 loc) · 3.6 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Copyright 2017 The Kubernetes Authors.
# Copyright 2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
IMPORT_PATH=github.com/intel/oim
REGISTRY_NAME=localhost:5000
IMAGE_VERSION_oim-csi-driver=canary
IMAGE_TAG=$(REGISTRY_NAME)/$*:$(IMAGE_VERSION_$*)
REV=$(shell git describe --long --tags --match='v*' --dirty)
OIM_CMDS=oim-controller oim-csi-driver oim-registry oimctl
# Need bash for coproc in test/test.make.
SHELL=bash
# Ensures that (among others) _work/clear-kvm.img gets deleted when configuring it fails.
.DELETE_ON_ERROR:
include doc/doc.make
include test/test.make
# Build main set of components.
.PHONY: all
all: $(OIM_CMDS)
# Build all binaries, including tests.
# Must use the workaround from https://github.com/golang/go/issues/15513
build: $(OIM_CMDS)
go test -run none $(TEST_ALL)
# Run operations only developers should need after making code changes.
update:
.PHONY: update
.PHONY: $(OIM_CMDS)
$(OIM_CMDS):
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o _output/$@ ./cmd/$@
# _output is used as the build context. All files inside it are sent
# to the Docker daemon when building images.
%-container: %
cp cmd/$*/Dockerfile _output/Dockerfile.$*
cd _output && \
docker build \
--build-arg HTTP_PROXY \
--build-arg HTTPS_PROXY \
--build-arg NO_PROXY \
-t $(IMAGE_TAG) -f Dockerfile.$* .
push-%: %-container
docker push $(IMAGE_TAG)
.PHONY: clean
clean:
go clean -r -x
-rm -rf _output _work
SPDK_SOURCE = vendor/github.com/spdk/spdk
_work/vhost:
mkdir -p _work
cd $(SPDK_SOURCE) && ./configure --with-rbd && make -j
cp -a $(SPDK_SOURCE)/app/vhost/vhost $@
# protobuf API handling
OIM_SPEC := spec.md
OIM_PROTO := pkg/spec/oim.proto
# This is the target for building the temporary OIM protobuf file.
#
# The temporary file is not versioned, and thus will always be
# built on Travis-CI.
$(OIM_PROTO).tmp: $(OIM_SPEC) Makefile
echo "// Code generated by make; DO NOT EDIT." > "$@"
cat $< | sed -n -e '/```protobuf$$/,/^```$$/ p' | sed '/^```/d' >> "$@"
# This is the target for building the OIM protobuf file.
#
# This target depends on its temp file, which is not versioned.
# Therefore when built on Travis-CI the temp file will always
# be built and trigger this target. On Travis-CI the temp file
# is compared with the real file, and if they differ the build
# will fail.
#
# Locally the temp file is simply copied over the real file.
$(OIM_PROTO): $(OIM_PROTO).tmp
ifeq (true,$(TRAVIS))
diff "$@" "$?"
else
diff "$@" "$?" > /dev/null 2>&1 || cp -f "$?" "$@"
endif
# If this is not running on Travis-CI then for sake of convenience
# go ahead and update the language bindings as well.
ifneq (true,$(TRAVIS))
#build:
# $(MAKE) -C lib/go
# $(MAKE) -C lib/cxx
endif
.PHONY: update_spec
update: update_spec
update_spec: $(OIM_PROTO)
$(MAKE) -C pkg/spec
.PHONY: update_yaml
update: update_yaml
update_yaml:
./hack/update-images.sh
./hack/update-rbac.sh
# check generated files for violation of standards
test: test_proto
test_proto: $(OIM_PROTO)
awk '{ if (length > 72) print NR, $$0 }' $? | diff - /dev/null
update: update_dep
update_dep:
dep ensure -v