-
Notifications
You must be signed in to change notification settings - Fork 329
/
Makefile
133 lines (105 loc) · 4.72 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
132
133
# Copyright 2019 The OpenSDS Authors.
#
# 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
#
# https://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.
BASE_DIR := $(shell pwd)
BUILD_DIR := $(BASE_DIR)/build
DIST_DIR := $(BASE_DIR)/build/dist
VERSION ?= $(shell git describe --exact-match 2> /dev/null || \
git describe --match=$(git rev-parse --short=8 HEAD) \
--always --dirty --abbrev=8)
BUILD_TGT := soda-multicloud-$(VERSION)-linux-amd64
.PHONY: all build prebuild api aksk backend s3 dataflow block file metadata docker clean
all: build
build: api aksk backend s3 dataflow datamover block file metadata
prebuild:
mkdir -p $(BUILD_DIR)
api: prebuild
CGO_ENABLED=0 GOOS=linux go build -ldflags '-w -s -extldflags "-static"' -o $(BUILD_DIR)/api github.com/opensds/multi-cloud/api/cmd
aksk: prebuild
CGO_ENABLED=0 GOOS=linux go build -ldflags '-w -s -extldflags "-static"' -o $(BUILD_DIR)/aksk github.com/opensds/multi-cloud/aksk/cmd
backend: prebuild
CGO_ENABLED=0 GOOS=linux go build -ldflags '-w -s -extldflags "-static"' -o $(BUILD_DIR)/backend github.com/opensds/multi-cloud/backend/cmd
s3: prebuild
CGO_ENABLED=1 GOOS=linux go build -ldflags '-w -s -extldflags "-dynamic"' -o $(BUILD_DIR)/s3 github.com/opensds/multi-cloud/s3/cmd
dataflow: prebuild
CGO_ENABLED=0 GOOS=linux go build -ldflags '-w -s -extldflags "-static"' -o $(BUILD_DIR)/dataflow github.com/opensds/multi-cloud/dataflow/cmd
datamover: prebuild
CGO_ENABLED=0 GOOS=linux go build -ldflags '-w -s -extldflags "-static"' -o $(BUILD_DIR)/datamover github.com/opensds/multi-cloud/datamover/cmd
file: prebuild
CGO_ENABLED=0 GOOS=linux go build -ldflags '-w -s -extldflags "-static"' -o $(BUILD_DIR)/file github.com/opensds/multi-cloud/file/cmd
block: prebuild
CGO_ENABLED=0 GOOS=linux go build -ldflags '-w -s -extldflags "-static"' -o $(BUILD_DIR)/block github.com/opensds/multi-cloud/block/cmd
metadata: prebuild
CGO_ENABLED=0 GOOS=linux go build -ldflags '-w -s -extldflags "-static"' -o $(BUILD_DIR)/metadata github.com/opensds/multi-cloud/metadata/cmd
docker: build
cp $(BUILD_DIR)/api api
chmod 755 api/api
docker build api -t sodafoundation/multi-cloud-api:latest
cp $(BUILD_DIR)/aksk aksk
chmod 755 aksk/aksk
docker build aksk -t sodafoundation/multi-cloud-aksk:latest
cp $(BUILD_DIR)/backend backend
chmod 755 backend/backend
docker build backend -t sodafoundation/multi-cloud-backend:latest
cp $(BUILD_DIR)/file file
chmod 755 file/file
docker build file -t sodafoundation/multi-cloud-file:latest
cp $(BUILD_DIR)/block block
chmod 755 block/block
docker build block -t sodafoundation/multi-cloud-block:latest
cp $(BUILD_DIR)/metadata metadata
chmod 755 metadata/metadata
docker build metadata -t sodafoundation/multi-cloud-metadata:latest
cp $(BUILD_DIR)/s3 s3
chmod 755 s3/s3
chmod 755 s3/initdb.sh
docker build s3 -t sodafoundation/multi-cloud-s3:latest
cp $(BUILD_DIR)/dataflow dataflow
chmod 755 dataflow/dataflow
docker build dataflow -t sodafoundation/multi-cloud-dataflow:latest
cp $(BUILD_DIR)/datamover datamover
chmod 755 datamover/datamover
docker build datamover -t sodafoundation/multi-cloud-datamover:latest
.PHONY: goimports
ifeq ($(CHECK_ERROR),y)
goimports: UNFORMATTED_FILES = $(shell goimports -local $(shell go list -m) -l $(shell go list -f {{.Dir}} ./... |grep -v /vendor/ | grep -v /proto))
goimports:
@ if [ ! -z "$(UNFORMATTED_FILES)" ]; then \
echo "Formatting error in $(UNFORMATTED_FILES)"; \
exit 1; \
fi
else
goimports:
goimports -local $(shell go list -m) -w $(shell go list -f {{.Dir}} ./... |grep -v /vendor/ | grep -v /proto)
endif
clean:
rm -rf $(BUILD_DIR) api/api aksk/aksk backend/backend dataflow/dataflow datamover/datamover s3/s3 block/block file/file
version:
@echo ${VERSION}
.PHONY: dist
dist: build
rm -fr $(DIST_DIR) && mkdir -p $(DIST_DIR)/$(BUILD_TGT)/bin
cd $(DIST_DIR) && \
cp ../api $(BUILD_TGT)/bin/ && \
cp ../aksk $(BUILD_TGT)/bin/ && \
cp ../backend $(BUILD_TGT)/bin/ && \
cp ../s3 $(BUILD_TGT)/bin/ && \
cp ../dataflow $(BUILD_TGT)/bin/ && \
cp ../datamover $(BUILD_TGT)/bin/ && \
cp ../block $(BUILD_TGT)/bin/ && \
cp ../file $(BUILD_TGT)/bin/ && \
cp ../metadata $(BUILD_TGT)/bin/ && \
cp $(BASE_DIR)/LICENSE $(BUILD_TGT) && \
zip -r $(DIST_DIR)/$(BUILD_TGT).zip $(BUILD_TGT) && \
tar zcvf $(DIST_DIR)/$(BUILD_TGT).tar.gz $(BUILD_TGT)
tree $(DIST_DIR)