1
1
# Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
2
2
3
3
SHELL: =/bin/bash
4
+ GO_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
5
+ ROOT_FOLDER := $(abspath $(GO_DIR ) /..)
6
+ GLIDE_CORE_FOLDER := $(ROOT_FOLDER ) /glide-core
7
+ GLIDE_FFI_FOLDER := $(ROOT_FOLDER ) /ffi
4
8
5
9
install-build-tools :
6
10
go install google.golang.org/protobuf/cmd/
[email protected]
@@ -42,51 +46,58 @@ clean:
42
46
rm -rf target
43
47
rm -rf reports
44
48
45
- build-glide-client :
46
- cargo build --release
47
- cbindgen --config cbindgen.toml --crate glide-rs --output lib.h --lang c
49
+ build-glide-ffi :
50
+ cd $(GLIDE_FFI_FOLDER ) && cargo build $(BUILD_FLAGS )
51
+ $(MAKE ) gen-c-bindings
52
+
53
+ # Release build
54
+ build-glide-client : BUILD_FLAGS=--release
55
+ build-glide-client : build-glide-ffi
56
+
57
+ # Debug build (no --release flag)
58
+ build-glide-client-debug : BUILD_FLAGS=
59
+ build-glide-client-debug : build-glide-ffi
60
+
61
+ gen-c-bindings :
62
+ cd $(GLIDE_FFI_FOLDER ) && \
63
+ cbindgen --config cbindgen.toml --crate glide-ffi --output $(GO_DIR ) /lib.h --lang c
48
64
@if [ " $$ (uname)" = " Darwin" ]; then \
49
- strip -x target/release/libglide_rs .a; \
65
+ strip -x $( GLIDE_FFI_FOLDER ) / target/release/libglide_ffi .a; \
50
66
if [ " $$ (uname -m)" = " arm64" ]; then \
51
67
echo " Platform: aarch64-apple-darwin" ; \
52
68
mkdir -p rustbin/aarch64-apple-darwin; \
53
- cp target/release/libglide_rs .a rustbin/aarch64-apple-darwin/; \
69
+ cp $( GLIDE_FFI_FOLDER ) / target/release/libglide_ffi .a rustbin/aarch64-apple-darwin/; \
54
70
elif [ " $$ (uname -m)" = " x86_64" ]; then \
55
71
echo " Platform: x86_64-apple-darwin" ; \
56
72
mkdir -p rustbin/x86_64-apple-darwin; \
57
- cp target/release/libglide_rs .a rustbin/x86_64-apple-darwin/; \
73
+ cp $( GLIDE_FFI_FOLDER ) / target/release/libglide_ffi .a rustbin/x86_64-apple-darwin/; \
58
74
fi ; \
59
75
elif [ " $$ (uname)" = " Linux" ]; then \
60
- strip --strip-unneeded target/release/libglide_rs .a; \
76
+ strip --strip-unneeded $( GLIDE_FFI_FOLDER ) / target/release/libglide_ffi .a; \
61
77
if [ " $$ (uname -m)" = " arm64" ] || [ " $$ (uname -m)" = " aarch64" ]; then \
62
78
echo " Platform: aarch64-unknown-linux-gnu" ; \
63
79
mkdir -p rustbin/aarch64-unknown-linux-gnu; \
64
- cp target/release/libglide_rs .a rustbin/aarch64-unknown-linux-gnu/; \
80
+ cp $( GLIDE_FFI_FOLDER ) / target/release/libglide_ffi .a rustbin/aarch64-unknown-linux-gnu/; \
65
81
elif [ " $$ (uname -m)" = " x86_64" ]; then \
66
82
echo " Platform: x86_64-unknown-linux-gnu" ; \
67
83
mkdir -p rustbin/x86_64-unknown-linux-gnu; \
68
- cp target/release/libglide_rs .a rustbin/x86_64-unknown-linux-gnu/; \
84
+ cp $( GLIDE_FFI_FOLDER ) / target/release/libglide_ffi .a rustbin/x86_64-unknown-linux-gnu/; \
69
85
fi ; \
70
86
else \
71
87
echo " Unsupported platform: $( shell uname) , $( shell uname -m) " ; \
72
88
exit 1; \
73
89
fi
74
90
75
-
76
- build-glide-client-debug :
77
- cargo build
78
- cbindgen --config cbindgen.toml --crate glide-rs --output lib.h --lang c
79
-
80
91
generate-protobuf :
81
92
rm -rf protobuf
82
93
mkdir -p protobuf
83
- protoc --proto_path=../glide-core /src/protobuf \
94
+ protoc --proto_path=$( GLIDE_CORE_FOLDER ) /src/protobuf \
84
95
--go_opt=Mconnection_request.proto=github.com/valkey-io/valkey-glide/go/protobuf \
85
96
--go_opt=Mcommand_request.proto=github.com/valkey-io/valkey-glide/go/protobuf \
86
97
--go_opt=Mresponse.proto=github.com/valkey-io/valkey-glide/go/protobuf \
87
98
--go_out=./protobuf \
88
99
--go_opt=paths=source_relative \
89
- ../glide-core /src/protobuf/* .proto
100
+ $( GLIDE_CORE_FOLDER ) /src/protobuf/* .proto
90
101
91
102
lint :
92
103
go vet ./...
@@ -116,7 +127,7 @@ format:
116
127
unit-test :
117
128
mkdir -p reports
118
129
set -o pipefail; \
119
- LD_LIBRARY_PATH=$(shell find . -name libglide_rs .a|grep -w release|tail -1|xargs dirname|xargs readlink -f) :${LD_LIBRARY_PATH} \
130
+ LD_LIBRARY_PATH=$(shell find . -name libglide_ffi .a|grep -w release|tail -1|xargs dirname|xargs readlink -f) :${LD_LIBRARY_PATH} \
120
131
go test -v ./... -skip ' Example|TestGlideTestSuite' -run Test $(if $(test-filter ) , -run $(test-filter ) ) \
121
132
| tee >( go tool test2json -t -p github.com/valkey-io/valkey-glide/go/utils | go-test-report -o reports/unit-tests.html -t unit-test > /dev/null)
122
133
@@ -131,7 +142,7 @@ example-test:
131
142
CLUSTER_OUTPUT=$$(python3 ../utils/cluster_manager.py start --cluster-mode); \
132
143
GLIDE_CLUSTER_NODES=$$(echo "$$CLUSTER_OUTPUT" | grep 'CLUSTER_NODES=' | cut -d'=' -f2); \
133
144
echo "GLIDE_CLUSTER_NODES=$$GLIDE_CLUSTER_NODES"; \
134
- LD_LIBRARY_PATH=$(shell find . -name libglide_rs .a|grep -w release|tail -1|xargs dirname|xargs readlink -f):${LD_LIBRARY_PATH} \
145
+ LD_LIBRARY_PATH=$(shell find . -name libglide_ffi .a|grep -w release|tail -1|xargs dirname|xargs readlink -f):${LD_LIBRARY_PATH} \
135
146
go test -v ./api -skip Test $(if $(test-filter), -run $(test-filter)) -clusternodes $$GLIDE_CLUSTER_NODES -standalonenode $$GLIDE_NODE \
136
147
| tee >(go tool test2json -t -p github.com/valkey-io/valkey-glide/go/api \
137
148
| go-test-report -o reports/example-tests.html -t example-test > /dev/null)
@@ -147,7 +158,7 @@ modules-test: __it
147
158
__it :
148
159
mkdir -p reports
149
160
set -o pipefail; \
150
- LD_LIBRARY_PATH=$(shell find . -name libglide_rs .a|grep -w release|tail -1|xargs dirname|xargs readlink -f) :${LD_LIBRARY_PATH} \
161
+ LD_LIBRARY_PATH=$(shell find . -name libglide_ffi .a|grep -w release|tail -1|xargs dirname|xargs readlink -f) :${LD_LIBRARY_PATH} \
151
162
go test -v ./integTest/... \
152
163
$(TEST_FILTER ) \
153
164
$(if $(filter true, $(tls ) ) , --tls,) \
0 commit comments