-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
54 lines (40 loc) · 1.72 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
OS=$(shell uname -s)
ifeq ($(OS), Darwin)
SHLIB_EXT=dylib
else
SHLIB_EXT=so
endif
OPENRESTY_PREFIX=/usr/local/openresty
#LUA_VERSION := 5.1
PREFIX ?= /usr/local
LUA_INCLUDE_DIR ?= $(PREFIX)/include
LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
INSTALL ?= install
RELEASE_FOLDER = target/$(CARGO_BUILD_TARGET)/release
DEBUG_RELEASE_FOLDER = target/$(CARGO_BUILD_TARGET)/debug
.PHONY: all test install build clean
all: ;
build: $(RELEASE_FOLDER)/libatc_router.$(SHLIB_EXT) $(RELEASE_FOLDER)/libatc_router.a
$(RELEASE_FOLDER)/libatc_router.%: src/*.rs
cargo build --release
$(DEBUG_RELEASE_FOLDER)/libatc_router.%: src/*.rs
cargo build
install-lualib:
$(INSTALL) -d $(DESTDIR)$(LUA_LIB_DIR)/resty/router/
$(INSTALL) -m 664 lib/resty/router/*.lua $(DESTDIR)$(LUA_LIB_DIR)/resty/router/
install: build install-lualib
$(INSTALL) -m 775 $(RELEASE_FOLDER)/libatc_router.$(SHLIB_EXT) $(DESTDIR)$(LUA_LIB_DIR)/libatc_router.$(SHLIB_EXT)
install-debug: $(DEBUG_RELEASE_FOLDER)/libatc_router.% install-lualib
$(INSTALL) -m 775 $(DEBUG_RELEASE_FOLDER)/libatc_router.$(SHLIB_EXT) $(DESTDIR)$(LUA_LIB_DIR)/libatc_router.$(SHLIB_EXT)
test: $(DEBUG_RELEASE_FOLDER)/libatc_router.%
PATH="$(OPENRESTY_PREFIX)/nginx/sbin:$$PATH" \
LUA_PATH="$(realpath lib)/?.lua;$(realpath lib)/?/init.lua;$$LUA_PATH" \
LUA_CPATH="$(realpath $(DEBUG_RELEASE_FOLDER))/?.so;$$LUA_CPATH" \
prove -r t/
valgrind: $(DEBUG_RELEASE_FOLDER)/libatc_router.%
(PATH="$(OPENRESTY_PREFIX)/nginx/sbin:$$PATH" \
LUA_PATH="$(realpath lib)/?.lua;$(realpath lib)/?/init.lua;$$LUA_PATH" \
LUA_CPATH="$(realpath $(DEBUG_RELEASE_FOLDER))/?.so;$$LUA_CPATH" \
prove -r t/) 2>&1 | tee /dev/stderr | grep -q "match-leak-kinds: definite" && exit 1 || exit 0
clean:
rm -rf target