Skip to content

Commit cce38b0

Browse files
committed
fixes 3
1 parent ca001a5 commit cce38b0

File tree

7 files changed

+74
-22
lines changed

7 files changed

+74
-22
lines changed

CMakeLists.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,31 @@ IF(NOT CMAKE_BUILD_TYPE)
1616
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
1717
ENDIF()
1818

19-
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
20-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
19+
#----------------------------------------------------------------------------------------------
20+
21+
SET(CMAKE_CC_COMMON_FLAGS "-fPIC")
22+
23+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CC_COMMON_FLAGS}")
24+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CC_COMMON_FLAGS}")
2125

2226
# For adding specific Release flags
2327
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
2428
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
2529

2630
# Add -fno-omit-frame-pointer to avoid seeing incomplete stack traces
27-
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -ggdb -fno-omit-frame-pointer")
28-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -ggdb -fno-omit-frame-pointer")
31+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -ggdb -fno-omit-frame-pointer -DVALGRIND")
32+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -ggdb -fno-omit-frame-pointer -DVALGRIND")
33+
34+
#----------------------------------------------------------------------------------------------
35+
36+
IF (USE_COVERAGE)
37+
IF (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
38+
MESSAGE(FATAL_ERROR "Build type must be DEBUG for coverage")
39+
ENDIF()
40+
SET(CMAKE_CC_COMMON_FLAGS "${CMAKE_CC_COMMON_FLAGS} -coverage")
41+
ENDIF()
42+
43+
#----------------------------------------------------------------------------------------------
2944

3045
option(BUILD_TF "Build the TensorFlow backend" ON)
3146
option(BUILD_TFLITE "Build the TensorFlow Lite backend" ON)

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ COPY --from=redis /usr/local/ /usr/local/
2121
COPY ./opt/ opt/
2222
COPY ./test/test_requirements.txt test/
2323

24-
RUN ./opt/readies/bin/getpy
24+
RUN ./opt/readies/bin/getpy3
2525
RUN ./opt/system-setup.py
2626

2727
ARG DEPS_ARGS=""

Dockerfile.arm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ WORKDIR /build
1919
COPY ./opt/ opt/
2020
COPY ./test/test_requirements.txt test/
2121

22-
RUN ./opt/readies/bin/getpy
22+
RUN ./opt/readies/bin/getpy3
2323
RUN ./opt/system-setup.py
2424

2525
ARG DEPS_ARGS=""

Dockerfile.gpu-test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ COPY --from=redis /usr/local/ /usr/local/
2121
COPY ./opt/ opt/
2222
COPY ./test/test_requirements.txt test/
2323

24-
RUN ./opt/readies/bin/getpy
24+
RUN ./opt/readies/bin/getpy3
2525
RUN ./opt/system-setup.py
2626

2727
ARG DEPS_ARGS=""

opt/Makefile

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ MK_CUSTOM_CLEAN:=1
1212
define HELP
1313
make setup # install prerequisited (CAUTION: THIS WILL MODIFY YOUR SYSTEM)
1414
make fetch # download and prepare dependant modules
15+
1516
make build # compile and link
17+
DEBUG=1 # build for debugging
18+
WHY=1 # explain CMake decisions (into /tmp/cmake.why)
1619
make clean # remove build artifacts
1720
ALL=1 # remove entire artifacts directory
1821

1922
make test # run tests
2023
TEST=test # run only test `test` with Redis output
2124
TEST_ARGS=args # add extra RLTest `args`
2225
VERBOSE=1 # verbose tests output
23-
COVERAGE=1 # perform coverage analysis
26+
COV=1 # perform coverage analysis
2427

2528
make pack # create installation packages
2629
PACK_DEPS=0 # do not pack dependencies
@@ -68,19 +71,23 @@ TARGET=$(BINDIR)/redisai.so
6871

6972
BACKENDS_PATH ?= $(INSTALL_DIR)/backends
7073

74+
#----------------------------------------------------------------------------------------------
75+
7176
CMAKE_FILES += \
7277
$(SRCDIR)/CMakeLists.txt \
7378
$(SRCDIR)/src/CMakeLists.txt \
7479
$(SRCDIR)/libtorch_c/CMakeLists.txt
7580

76-
ifeq ($(COVERAGE),1)
77-
WITH_COVERAGE=on
81+
ifeq ($(COV),1)
82+
USE_COVERAGE=on
83+
else
84+
USE_COVERAGE=off
7885
endif
7986

8087
CMAKE_FLAGS += \
8188
-DDEPS_PATH=$(abspath $(DEPS_DIR)) \
8289
-DINSTALL_PATH=$(abspath $(INSTALL_DIR)) \
83-
-DENABLE_CODECOVERAGE=$(WITH_COVERAGE) \
90+
-DUSE_COVERAGE=$(USE_COVERAGE) \
8491
-DDEVICE=$(DEVICE)
8592

8693
ifeq ($(WITH_TF),0)
@@ -149,6 +156,13 @@ endif
149156

150157
#----------------------------------------------------------------------------------------------
151158

159+
define CHECK_REDIS_SERVER
160+
$(SHOW)if ! command -v redis-server > /dev/null; then \
161+
echo "Cannot find redis-server. Aborting." ;\
162+
exit 1 ;\
163+
fi
164+
endef
165+
152166
TEST_REPORT_DIR ?= $(PWD)
153167
ifeq ($(VERBOSE),1)
154168
TEST_ARGS += -v
@@ -166,30 +180,52 @@ SLAVES ?= 1
166180
AOF ?= 1
167181

168182
TEST_PREFIX=set -e; cd $(ROOT)/test
183+
184+
define TEST_CMD
185+
DEVICE=$(DEVICE) PYDEBUG=$(PYDEBUG) python3 -m RLTest $(TEST_ARGS) --module $(INSTALL_DIR)/redisai.so
186+
endef
187+
169188
# TODO: --errors-for-leak-kinds=definite
170-
VALGRIND_OPTIONS="--leak-check=full -q --show-reachable=no --show-possibly-lost=no"
171-
TEST_CMD= DEVICE=$(DEVICE) PYDEBUG=$(PYDEBUG) python3 -m RLTest $(TEST_ARGS) --module $(INSTALL_DIR)/redisai.so
172-
VALGRIND_TEST_CMD= DEVICE=$(DEVICE) PYDEBUG=$(PYDEBUG) python3 -m RLTest $(TEST_ARGS) --module $(INSTALL_DIR)/redisai.so --no-output-catch --use-valgrind --vg-no-fail-on-errors --vg-verbose --vg-options $(VALGRIND_OPTIONS) --vg-suppressions $(realpath $(REDIS_VALGRIND_SUPRESS))
189+
VALGRIND_OPTIONS=\
190+
-q \
191+
--leak-check=full \
192+
--show-reachable=no \
193+
--show-possibly-lost=no
194+
195+
define VALGRIND_TEST_CMD
196+
$(TEST_CMD) \
197+
--no-output-catch \
198+
--use-valgrind \
199+
--vg-no-fail-on-errors \
200+
--vg-verbose
201+
--vg-options "$(VALGRIND_OPTIONS)" \
202+
--vg-suppressions $(realpath $(REDIS_VALGRIND_SUPRESS))
203+
endef
173204

174205
test:
206+
$(CHECK_REDIS_SERVER)
175207
ifneq ($(NO_LFS),1)
176208
$(SHOW)if [ "$(git lfs env > /dev/null 2>&1 ; echo $?)" != "0" ]; then cd $(ROOT); git lfs install; fi
177209
$(SHOW)cd $(ROOT); git lfs pull
178210
endif
211+
ifeq ($(COV),1)
212+
$(COVERAGE_RESET)
213+
endif
179214
ifeq ($(GEN),1)
180215
$(SHOW)$(TEST_PREFIX); $(TEST_CMD)
181216
endif
182217
ifeq ($(AOF),1)
183-
$(SHOW)$(TEST_PREFIX); printf "\nTests with --use-aof:\n\n" ;\
184-
$(TEST_CMD) --use-aof
218+
$(SHOW)$(TEST_PREFIX); printf "\nTests with --use-aof:\n\n" ; $(TEST_CMD) --use-aof
185219
endif
186220
ifeq ($(SLAVES),1)
187-
$(SHOW)$(TEST_PREFIX); printf "\nTests with --use-slaves:\n\n" ;\
188-
$(TEST_CMD) --use-slaves
221+
$(SHOW)$(TEST_PREFIX); printf "\nTests with --use-slaves:\n\n" ; $(TEST_CMD) --use-slaves
189222
endif
190-
ifeq ($(VALGRIND),1)
191-
$(SHOW)$(TEST_PREFIX); printf "\nTests with valgrind:\n\n" ;\
192-
$(VALGRIND_TEST_CMD)
223+
# ifeq ($(VALGRIND),1)
224+
# $(SHOW)$(TEST_PREFIX); printf "\nTests with valgrind:\n\n" ;\
225+
# $(VALGRIND_TEST_CMD)
226+
# endif
227+
ifeq ($(COV),1)
228+
$(COVERAGE_COLLECT_REPORT)
193229
endif
194230

195231
#----------------------------------------------------------------------------------------------

opt/readies/mk/cmake.defs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ endif
99

1010
ifeq ($(WHY),1)
1111
CMAKE_WHY=--trace-expand
12+
CMAKE_SINK=>/tmp/cmake.log
1213
endif
1314

1415
endif # MK.cmake

opt/readies/mk/cmake.rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ MK_CMAKE_FILES ?= $(SRCDIR)/CMakeLists.txt
55

66
$(BINDIR)/Makefile : bindirs $(MK_CMAKE_FILES)
77
$(SHOW)if [ ! -d $(BINDIR) ]; then echo "CMake: $(BINDIR) does not exist."; exit 1; fi
8-
$(SHOW)cd $(BINDIR); cmake $(CMAKE_WHY) $(CMAKE_FLAGS) $(abspath $(SRCDIR))
8+
$(SHOW)cd $(BINDIR); cmake $(CMAKE_WHY) $(CMAKE_FLAGS) $(abspath $(SRCDIR)) $(CMAKE_SINK)
99

1010
# $(SHOW)cd $(BINDIR); \
1111
# CMAKE_REL_ROOT=`python -c "import os; print os.path.relpath('$(SRCDIR)', '$$PWD')"` \

0 commit comments

Comments
 (0)