-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
38 lines (26 loc) · 1.02 KB
/
Makefile
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
DISTDIR:= dist
PROGROOT=redicrypt
.PHONY: all
all: clean ${DISTDIR}/${PROGROOT}.so
deps/redismodule.h:
@mkdir deps
@wget -q -O $@ https://raw.githubusercontent.com/redis/redis/unstable/src/redismodule.h
${DISTDIR}/${PROGROOT}_go.a: c_bridge.go
go mod download
go build -buildmode=c-archive -o $@ $?
${DISTDIR}/${PROGROOT}_go.h: c_bridge.go
go build -buildmode=c-shared -o ${DISTDIR}/${PROGROOT}_go.so $? src/redicrypt
${DISTDIR}/${PROGROOT}.o: ${PROGROOT}.c ${DISTDIR}/${PROGROOT}_go.h deps/redismodule.h
gcc -w -fPIC -std=gnu99 -c -static -o $@ $<
${DISTDIR}/${PROGROOT}.so: ${DISTDIR}/${PROGROOT}_go.a ${DISTDIR}/${PROGROOT}.o
gcc -w -shared -Bsymbolic -lc -lffi -nostdlib -o $@ -Wl,--whole-archive $?
clean:
rm -rf ${DISTDIR}
docker::
docker build -t ${PROGROOT}:latest .
test::
cd src/redicrypt && go test
run:: ${DISTDIR}/${PROGROOT}.so
REDICRYPT_KEY=12345678901234567890123456789012 redis-server --loadmodule ${DISTDIR}/${PROGROOT}.so
test_docker:: docker
docker run --rm --name ${PROGROOT} ${PROGROOT}:latest