2020-10-30 16:25:06 +08:00
|
|
|
# Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
GO ?= go
|
|
|
|
PWD := $(shell pwd)
|
|
|
|
GOPATH := $(shell $(GO) env GOPATH)
|
|
|
|
|
|
|
|
INSTALL_PATH := $(PWD)/bin
|
|
|
|
LIBRARY_PATH := $(PWD)/lib
|
|
|
|
|
2020-11-09 18:47:37 +08:00
|
|
|
all: build-cpp build-go
|
2020-10-30 16:25:06 +08:00
|
|
|
|
|
|
|
get-build-deps:
|
|
|
|
@(env bash $(PWD)/scripts/install_deps.sh)
|
|
|
|
|
2020-12-09 20:07:27 +08:00
|
|
|
getdeps:
|
|
|
|
@mkdir -p ${GOPATH}/bin
|
|
|
|
@which golangci-lint 1>/dev/null || (echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.27.0)
|
2021-01-13 13:36:27 +08:00
|
|
|
@which ruleguard 1>/dev/null || (echo "Installing ruleguard" && go get github.com/quasilyte/go-ruleguard/cmd/ruleguard@v0.2.1)
|
2020-12-09 20:07:27 +08:00
|
|
|
|
2020-12-31 17:25:45 +08:00
|
|
|
tools/bin/revive: tools/check/go.mod
|
|
|
|
cd tools/check; \
|
|
|
|
$(GO) build -o ../bin/revive github.com/mgechev/revive
|
|
|
|
|
2020-11-23 19:57:05 +08:00
|
|
|
cppcheck:
|
|
|
|
@(env bash ${PWD}/scripts/core_build.sh -l)
|
2020-11-18 10:07:05 +08:00
|
|
|
|
|
|
|
generated-proto-go:export protoc:=${PWD}/cmake_build/thirdparty/protobuf/protobuf-build/protoc
|
|
|
|
generated-proto-go: build-cpp
|
2020-12-09 20:07:27 +08:00
|
|
|
@mkdir -p ${GOPATH}/bin
|
|
|
|
@which protoc-gen-go 1>/dev/null || (echo "Installing protoc-gen-go" && go get github.com/golang/protobuf/protoc-gen-go@v1.3.2)
|
2020-11-18 10:07:05 +08:00
|
|
|
@(env bash $(PWD)/scripts/proto_gen_go.sh)
|
|
|
|
|
|
|
|
check-proto-product: generated-proto-go
|
|
|
|
@(env bash $(PWD)/scripts/check_proto_product.sh)
|
|
|
|
|
2020-10-30 16:25:06 +08:00
|
|
|
fmt:
|
2020-12-29 17:19:44 +08:00
|
|
|
ifdef GO_DIFF_FILES
|
|
|
|
@echo "Running $@ check"
|
|
|
|
@GO111MODULE=on env bash $(PWD)/scripts/gofmt.sh $(GO_DIFF_FILES)
|
|
|
|
else
|
2020-10-30 16:25:06 +08:00
|
|
|
@echo "Running $@ check"
|
2020-11-18 10:07:05 +08:00
|
|
|
@GO111MODULE=on env bash $(PWD)/scripts/gofmt.sh cmd/
|
|
|
|
@GO111MODULE=on env bash $(PWD)/scripts/gofmt.sh internal/
|
2020-12-03 19:00:11 +08:00
|
|
|
@GO111MODULE=on env bash $(PWD)/scripts/gofmt.sh tests/go/
|
2020-12-29 17:19:44 +08:00
|
|
|
endif
|
2020-10-30 16:25:06 +08:00
|
|
|
|
2020-12-31 17:25:45 +08:00
|
|
|
lint:tools/bin/revive
|
|
|
|
@echo "Running $@ check"
|
|
|
|
@tools/bin/revive -formatter friendly -config tools/check/revive.toml ./...
|
|
|
|
|
2020-10-30 16:25:06 +08:00
|
|
|
#TODO: Check code specifications by golangci-lint
|
2021-01-14 15:12:08 +08:00
|
|
|
static-check:
|
2020-10-30 16:25:06 +08:00
|
|
|
@echo "Running $@ check"
|
|
|
|
@GO111MODULE=on ${GOPATH}/bin/golangci-lint cache clean
|
2020-12-08 14:41:04 +08:00
|
|
|
@GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=30m --config ./.golangci.yml ./internal/...
|
|
|
|
@GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=30m --config ./.golangci.yml ./cmd/...
|
|
|
|
@GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=30m --config ./.golangci.yml ./tests/go/...
|
2020-10-30 16:25:06 +08:00
|
|
|
|
2020-11-03 11:25:47 +08:00
|
|
|
ruleguard:
|
2020-12-29 17:19:44 +08:00
|
|
|
ifdef GO_DIFF_FILES
|
|
|
|
@echo "Running $@ check"
|
|
|
|
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go $(GO_DIFF_FILES)
|
|
|
|
else
|
2020-11-03 11:25:47 +08:00
|
|
|
@echo "Running $@ check"
|
2020-11-13 10:00:32 +08:00
|
|
|
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go ./internal/...
|
|
|
|
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go ./cmd/...
|
2020-12-03 19:00:11 +08:00
|
|
|
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go ./tests/go/...
|
2020-12-29 17:19:44 +08:00
|
|
|
endif
|
2020-11-03 11:25:47 +08:00
|
|
|
|
2021-01-13 13:36:27 +08:00
|
|
|
verifiers: getdeps cppcheck fmt static-check ruleguard
|
2020-10-30 16:25:06 +08:00
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
# Builds various components locally.
|
2021-04-09 14:07:03 +08:00
|
|
|
binlog:
|
|
|
|
@echo "Building binlog ..."
|
|
|
|
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/binlog $(PWD)/cmd/binlog/main.go 1>/dev/null
|
2021-02-20 10:15:37 +08:00
|
|
|
|
2021-04-09 14:07:03 +08:00
|
|
|
master:
|
|
|
|
@echo "Building master service ..."
|
2021-02-20 10:15:37 +08:00
|
|
|
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/masterservice $(PWD)/cmd/masterservice/main.go 1>/dev/null
|
|
|
|
|
2021-04-09 14:07:03 +08:00
|
|
|
proxyservice:
|
|
|
|
@echo "Building proxy service ..."
|
|
|
|
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/proxyservice $(PWD)/cmd/proxy/service/proxy_service.go 1>/dev/null
|
|
|
|
|
|
|
|
proxynode:
|
2021-01-26 19:24:09 +08:00
|
|
|
@echo "Building proxy node ..."
|
2021-04-09 14:07:03 +08:00
|
|
|
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/proxynode $(PWD)/cmd/proxy/node/proxy_node.go 1>/dev/null
|
2021-01-18 19:32:08 +08:00
|
|
|
|
2021-04-09 14:07:03 +08:00
|
|
|
queryservice:
|
|
|
|
@echo "Building query service ..."
|
|
|
|
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/queryservice $(PWD)/cmd/queryservice/queryservice.go 1>/dev/null
|
|
|
|
|
|
|
|
querynode:
|
2021-01-18 19:32:08 +08:00
|
|
|
@echo "Building query node ..."
|
2021-01-27 09:50:52 +08:00
|
|
|
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/querynode $(PWD)/cmd/querynode/querynode.go 1>/dev/null
|
2021-01-18 19:32:08 +08:00
|
|
|
|
2021-04-09 14:07:03 +08:00
|
|
|
dataservice:
|
|
|
|
@echo "Building data service ..."
|
|
|
|
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/dataservice $(PWD)/cmd/dataservice/main.go 1>/dev/null
|
|
|
|
|
|
|
|
datanode:
|
2021-01-26 14:46:54 +08:00
|
|
|
@echo "Building data node ..."
|
|
|
|
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/datanode $(PWD)/cmd/datanode/main.go 1>/dev/null
|
|
|
|
|
2021-01-26 19:24:09 +08:00
|
|
|
indexservice: build-cpp
|
2021-04-09 14:07:03 +08:00
|
|
|
@echo "Building index service ..."
|
2021-01-29 17:08:31 +08:00
|
|
|
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/indexservice $(PWD)/cmd/indexservice/main.go 1>/dev/null
|
2021-01-18 19:32:08 +08:00
|
|
|
|
2021-04-09 14:07:03 +08:00
|
|
|
indexnode: build-cpp
|
|
|
|
@echo "Building index node ..."
|
|
|
|
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/indexnode $(PWD)/cmd/indexnode/main.go 1>/dev/null
|
2021-03-16 17:55:42 +08:00
|
|
|
|
2021-04-09 14:07:03 +08:00
|
|
|
singlenode: build-cpp
|
|
|
|
@echo "Building single node ..."
|
2021-01-14 09:52:03 +08:00
|
|
|
@mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build -o $(INSTALL_PATH)/singlenode $(PWD)/cmd/singlenode/main.go 1>/dev/null
|
2020-10-30 16:25:06 +08:00
|
|
|
|
2021-04-12 14:11:06 +08:00
|
|
|
build-go: binlog master proxyservice proxynode queryservice querynode indexservice indexnode dataservice datanode singlenode
|
2021-01-25 15:58:04 +08:00
|
|
|
|
2020-10-30 16:25:06 +08:00
|
|
|
build-cpp:
|
2020-12-08 19:53:22 +08:00
|
|
|
@(env bash $(PWD)/scripts/core_build.sh -f "$(CUSTOM_THIRDPARTY_PATH)")
|
|
|
|
@(env bash $(PWD)/scripts/cwrapper_build.sh -t Release -f "$(CUSTOM_THIRDPARTY_PATH)")
|
2021-01-14 15:12:08 +08:00
|
|
|
@go env -w CGO_CFLAGS="-I$(PWD)/internal/kv/rocksdb/cwrapper/output/include"
|
|
|
|
@go env -w CGO_LDFLAGS="-L$(PWD)/internal/kv/rocksdb/cwrapper/output/lib -l:librocksdb.a -lstdc++ -lm -lz"
|
|
|
|
@(env bash $(PWD)/scripts/cwrapper_rocksdb_build.sh -t Release -f "$(CUSTOM_THIRDPARTY_PATH)")
|
|
|
|
@go get github.com/tecbot/gorocksdb
|
2020-10-30 16:25:06 +08:00
|
|
|
|
|
|
|
build-cpp-with-unittest:
|
2020-12-08 19:53:22 +08:00
|
|
|
@(env bash $(PWD)/scripts/core_build.sh -u -f "$(CUSTOM_THIRDPARTY_PATH)")
|
|
|
|
@(env bash $(PWD)/scripts/cwrapper_build.sh -t Release -f "$(CUSTOM_THIRDPARTY_PATH)")
|
2020-10-30 16:25:06 +08:00
|
|
|
|
|
|
|
# Runs the tests.
|
2020-10-31 16:30:20 +08:00
|
|
|
unittest: test-cpp test-go
|
2020-10-30 16:25:06 +08:00
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
#TODO: proxynode master query node writer's unittest
|
2021-01-14 15:12:08 +08:00
|
|
|
test-go:build-cpp
|
2020-10-30 16:25:06 +08:00
|
|
|
@echo "Running go unittests..."
|
2021-01-26 13:41:41 +08:00
|
|
|
@echo "disable go unittest for now, enable it later"
|
2021-01-29 09:27:26 +08:00
|
|
|
@(env bash $(PWD)/scripts/run_go_unittest.sh)
|
2020-10-30 16:25:06 +08:00
|
|
|
|
|
|
|
test-cpp: build-cpp-with-unittest
|
2020-11-03 11:25:47 +08:00
|
|
|
@echo "Running cpp unittests..."
|
2020-10-30 16:25:06 +08:00
|
|
|
@(env bash $(PWD)/scripts/run_cpp_unittest.sh)
|
|
|
|
|
|
|
|
#TODO: build each component to docker
|
|
|
|
docker: verifiers
|
|
|
|
|
|
|
|
# Builds each component and installs it to $GOPATH/bin.
|
|
|
|
install: all
|
|
|
|
@echo "Installing binary to './bin'"
|
2021-02-20 10:15:37 +08:00
|
|
|
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/bin/masterservice $(GOPATH)/bin/masterservice
|
2021-01-27 09:50:52 +08:00
|
|
|
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/bin/queryservice $(GOPATH)/bin/queryservice
|
2020-11-26 16:01:31 +08:00
|
|
|
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/bin/querynode $(GOPATH)/bin/querynode
|
2021-01-22 09:36:18 +08:00
|
|
|
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/bin/proxynode $(GOPATH)/bin/proxynode
|
2021-01-22 12:57:23 +08:00
|
|
|
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/bin/proxyservice $(GOPATH)/bin/proxyservice
|
2021-01-14 09:52:03 +08:00
|
|
|
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/bin/singlenode $(GOPATH)/bin/singlenode
|
2021-01-26 14:31:31 +08:00
|
|
|
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/bin/indexservice $(GOPATH)/bin/indexservice
|
|
|
|
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/bin/indexnode $(GOPATH)/bin/indexnode
|
2021-02-20 10:15:37 +08:00
|
|
|
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/bin/dataservice $(GOPATH)/bin/dataservice
|
|
|
|
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/bin/datanode $(GOPATH)/bin/datanode
|
2020-10-30 16:25:06 +08:00
|
|
|
@mkdir -p $(LIBRARY_PATH) && cp -f $(PWD)/internal/core/output/lib/* $(LIBRARY_PATH)
|
|
|
|
@echo "Installation successful."
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@echo "Cleaning up all the generated files"
|
|
|
|
@find . -name '*.test' | xargs rm -fv
|
|
|
|
@find . -name '*~' | xargs rm -fv
|
2021-01-11 18:35:54 +08:00
|
|
|
@rm -rf bin/
|
|
|
|
@rm -rf lib/
|
2021-02-20 10:15:37 +08:00
|
|
|
@rm -rf $(GOPATH)/bin/masterservice
|
2021-01-22 09:36:18 +08:00
|
|
|
@rm -rf $(GOPATH)/bin/proxynode
|
2021-01-22 12:57:23 +08:00
|
|
|
@rm -rf $(GOPATH)/bin/proxyservice
|
2021-01-27 09:50:52 +08:00
|
|
|
@rm -rf $(GOPATH)/bin/queryservice
|
2021-01-11 18:35:54 +08:00
|
|
|
@rm -rf $(GOPATH)/bin/querynode
|
2021-01-14 09:52:03 +08:00
|
|
|
@rm -rf $(GOPATH)/bin/singlenode
|
2021-01-26 14:31:31 +08:00
|
|
|
@rm -rf $(GOPATH)/bin/indexservice
|
|
|
|
@rm -rf $(GOPATH)/bin/indexnode
|
2021-02-20 10:15:37 +08:00
|
|
|
@rm -rf $(GOPATH)/bin/dataservice
|
|
|
|
@rm -rf $(GOPATH)/bin/datanode
|