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 GOTEST := $(GO) test -p 8 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'; \ $(GOTEST) -cover $(PACKAGES) 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 ci: default test @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` lab1: go test -count=1 ./kv/server -run 1 lab2: lab2a lab2b lab2c lab2a: go test -count=1 ./raft -run 2A lab2b: go test -count=1 ./kv/test_raftstore -run 2B lab2c: go test -count=1 ./raft ./kv/test_raftstore -run 2C