2020-04-30 15:07:27 +08:00
|
|
|
SHELL := /bin/bash
|
|
|
|
PROJECT=tinykv
|
|
|
|
GOPATH ?= $(shell go env GOPATH)
|
|
|
|
|
|
|
|
# Ensure GOPATH is set before running build process.
|
|
|
|
ifeq "$(GOPATH)" ""
|
|
|
|
$(error Please set the environment variable GOPATH before running `make`)
|
|
|
|
endif
|
|
|
|
|
|
|
|
GO := GO111MODULE=on go
|
|
|
|
GOBUILD := $(GO) build $(BUILD_FLAG) -tags codes
|
2020-04-29 21:38:49 +08:00
|
|
|
GOTEST := $(GO) test -v --count=1 --parallel=1 -p=1
|
2020-04-30 15:07:27 +08:00
|
|
|
|
|
|
|
TEST_LDFLAGS := ""
|
|
|
|
|
|
|
|
PACKAGE_LIST := go list ./...| grep -vE "cmd"
|
|
|
|
PACKAGES := $$($(PACKAGE_LIST))
|
|
|
|
|
|
|
|
# Targets
|
|
|
|
.PHONY: clean test proto kv scheduler dev
|
|
|
|
|
|
|
|
default: kv scheduler
|
|
|
|
|
|
|
|
dev: default test
|
|
|
|
|
|
|
|
test:
|
|
|
|
@echo "Running tests in native mode."
|
|
|
|
@export TZ='Asia/Shanghai'; \
|
2020-04-30 14:22:58 +08:00
|
|
|
LOG_LEVEL=fatal $(GOTEST) -cover $(PACKAGES)
|
2020-04-30 15:07:27 +08:00
|
|
|
|
|
|
|
CURDIR := $(shell pwd)
|
|
|
|
export PATH := $(CURDIR)/bin/:$(PATH)
|
|
|
|
proto:
|
|
|
|
mkdir -p $(CURDIR)/bin
|
|
|
|
(cd proto && ./generate_go.sh)
|
|
|
|
GO111MODULE=on go build ./proto/pkg/...
|
|
|
|
|
|
|
|
kv:
|
|
|
|
$(GOBUILD) -o bin/tinykv-server kv/main.go
|
|
|
|
|
|
|
|
scheduler:
|
|
|
|
$(GOBUILD) -o bin/tinyscheduler-server scheduler/main.go
|
|
|
|
|
2020-04-23 11:51:56 +08:00
|
|
|
ci: default
|
2020-04-30 15:07:27 +08:00
|
|
|
@echo "Checking formatting"
|
|
|
|
@test -z "$$(gofmt -s -l $$(find . -name '*.go' -type f -print) | tee /dev/stderr)"
|
|
|
|
@echo "Running Go vet"
|
|
|
|
@go vet ./...
|
|
|
|
|
|
|
|
format:
|
|
|
|
@gofmt -s -w `find . -name '*.go' -type f ! -path '*/_tools/*' -print`
|
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project1:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./kv/server -run 1
|
2020-04-30 15:07:27 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2: project2a project2b project2c
|
2020-04-30 15:07:27 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2a:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./raft -run 2A
|
2020-04-30 15:07:27 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2aa:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./raft -run 2AA
|
2020-04-07 15:52:39 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2ab:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./raft -run 2AB
|
2020-04-07 15:52:39 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2ac:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./raft -run 2AC
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project2b:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./kv/test_raftstore -run 2B
|
2020-04-30 15:07:27 +08:00
|
|
|
|
2020-04-23 11:37:46 +08:00
|
|
|
project2c:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./raft ./kv/test_raftstore -run 2C
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project3: project3a project3b project3c
|
|
|
|
|
|
|
|
project3a:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./raft -run 3A
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project3b:
|
2020-05-20 15:00:00 +08:00
|
|
|
$(GOTEST) ./kv/test_raftstore -run 3B
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project3c:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./scheduler/... -run 3C
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project4: project4a project4b project4c
|
|
|
|
|
|
|
|
project4a:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./kv/transaction/... -run 4A
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project4b:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./kv/transaction/... -run 4B
|
2020-04-23 11:37:46 +08:00
|
|
|
|
|
|
|
project4c:
|
2020-04-30 14:22:58 +08:00
|
|
|
$(GOTEST) ./kv/transaction/... -run 4C
|