-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathMakefile
More file actions
150 lines (125 loc) · 4.99 KB
/
Makefile
File metadata and controls
150 lines (125 loc) · 4.99 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Copyright 2023-2025 The Oxia 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
#
# 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.
.PHONY: build
build:
go build -tags disable_trap -ldflags "-X main.version=$(shell git describe --tags --always | cut -c2-)" -v -o bin/oxia ./cmd
# Build target: iterate through PLATFORMS and perform cross-compilation for each combination.
PLATFORMS := \
linux/amd64 \
windows/amd64 \
darwin/amd64
.PHONY: distribution
distribution:
@echo "Starting Go multi-platform executable build..."
@for platform in $(PLATFORMS); do \
GOOS=$$(echo $$platform | cut -d'/' -f1); \
GOARCH=$$(echo $$platform | cut -d'/' -f2); \
OUTPUT_NAME=bin/oxia_$${GOOS}_$${GOARCH}; \
if [ "$$GOOS" = "windows" ]; then OUTPUT_NAME=$${OUTPUT_NAME}.exe; fi; \
echo "Building $$GOOS/$${GOARCH} to $${OUTPUT_NAME}"; \
GOOS=$${GOOS} GOARCH=$${GOARCH} go build \
-ldflags "-X main.version=$$(git describe --tags --always | cut -c2-)" \
-tags disable_trap \
-v \
-o $${OUTPUT_NAME} ./cmd; \
done
@echo "All platforms built successfully! Executables are located in the bin/ directory."
# Build for release with custom output path
# Usage: make release-build OUTPUT_DIR=dist/oxia OUTPUT_NAME=oxia GOOS=linux GOARCH=amd64
.PHONY: release-build
release-build:
@test -n "$(OUTPUT_DIR)" || (echo "ERROR: OUTPUT_DIR is required" && exit 1)
@test -n "$(OUTPUT_NAME)" || (echo "ERROR: OUTPUT_NAME is required" && exit 1)
@test -n "$(GOOS)" || (echo "ERROR: GOOS is required" && exit 1)
@test -n "$(GOARCH)" || (echo "ERROR: GOARCH is required" && exit 1)
@mkdir -p $(OUTPUT_DIR)/bin $(OUTPUT_DIR)/conf
GOOS=$(GOOS) GOARCH=$(GOARCH) go build \
-tags disable_trap \
-ldflags "-X main.version=$$(git describe --tags --always | cut -c2-)" \
-v \
-o $(OUTPUT_DIR)/bin/$(OUTPUT_NAME) ./cmd
@cp conf/dataserver.yaml $(OUTPUT_DIR)/conf/
@cp conf/coordinator.yaml $(OUTPUT_DIR)/conf/
.PHONY: maelstrom
maelstrom:
go build -tags disable_trap -v -o bin/oxia-maelstrom ./oxiad/maelstrom
test: build
go test -cover -race\
./cmd/... \
./common/... \
./oxia/... \
./oxiad/... \
./tests/...
lint:
#brew install golangci-lint
go work edit -json | jq -r '.Use[].DiskPath' | xargs -I{} golangci-lint run {}/...
clean:
rm -f bin/oxia bin/oxia-maelstrom
rm -rf pkg/generated/*
find . -type f -name '*.deepcopy.go' | xargs rm
docker:
docker build -t oxia:latest .
docker_multi_arch:
docker buildx build --platform linux/x86_64,linux/arm64 -t oxia:latest .
.PHONY: proto
proto:
# go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@latest
cd common/proto && \
protoc \
--go_out=. \
--go_opt paths=source_relative \
--plugin protoc-gen-go="${GOPATH}/bin/protoc-gen-go" \
--go-grpc_out=. \
--go-grpc_opt paths=source_relative \
--plugin protoc-gen-go-grpc="${GOPATH}/bin/protoc-gen-go-grpc" \
--go-vtproto_out=. \
--go-vtproto_opt paths=source_relative \
--plugin protoc-gen-go-vtproto="${GOPATH}/bin/protoc-gen-go-vtproto" \
--go-vtproto_opt=features=marshal+unmarshal+unmarshal_unsafe+size+pool+equal+clone \
*.proto compat/*.proto
proto_clean:
rm -f */*.pb.go
proto_format:
#brew install clang-format
clang-format -i --style=Google proto/*.proto
proto_lint:
#go install github.com/yoheimuta/protolint/cmd/protoc-gen-protolint
protoc --proto_path ./proto \
--protolint_out . \
--protolint_opt config_dir_path=. \
--protolint_opt proto_root=./proto \
proto/*.proto
proto_doc:
#go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
protoc --doc_out=docs/proto --doc_opt=markdown,proto.md proto/*.proto
proto_quality: proto_format proto_lint
fetch-tla-tools:
mkdir -p tlaplus/.tools
cd tlaplus/.tools && \
wget https://github.com/tlaplus/tlaplus/releases/download/v1.8.0/tla2tools.jar && \
wget https://github.com/tlaplus/CommunityModules/releases/download/202211012231/CommunityModules-deps.jar
tla:
cd tlaplus && \
java -XX:+UseParallelGC -DTLA-Library=.tools/CommunityModules-deps.jar -jar .tools/tla2tools.jar \
-deadlock -workers auto\
OxiaReplication.tla
license-check:
@command -v go-license > /dev/null || go install github.com/palantir/go-license@latest
find . -type f -name '*.go' | grep -v '.pb.go' | xargs go-license --config=.github/license.yml --verify
license-format:
@command -v go-license > /dev/null || go install github.com/palantir/go-license@latest
find . -type f -name '*.go' | grep -v '.pb.go' | xargs go-license --config=.github/license.yml
.PHONY: generate-conf-schema
generate-conf-schema: build
bin/oxia config create-schema -o conf/schema