Skip to content

Commit 529804c

Browse files
committed
Fixed: #6, #7, code stype, OSX build; added: test cases;
1 parent 47f9717 commit 529804c

File tree

13 files changed

+768
-624
lines changed

13 files changed

+768
-624
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
.DS_Store
2+
13
*.o
24
*.lib
35
*.a
46
*.so
57
*.so.*
68
*.dylib
79

8-
test/out
910
build
1011
CMakeCache.txt
1112
CMakeFiles
13+
Makefile
14+
*.snap
15+
*.xlog
16+
cmake_install.cmake

CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,21 @@ include_directories(${TARANTOOL_INCLUDE_DIRS})
1111
find_package(Mosquitto REQUIRED)
1212
include_directories(${MOSQUITTO_INCLUDE_DIRS})
1313

14+
message(STATUS "tarantool: ${TARANTOOL_INCLUDE_DIRS}")
15+
message(STATUS "libmosquitto: ${MOSQUITTO_INCLUDE_DIRS} ${MOSQUITTO_LIBRARIES}")
16+
1417
# Set CFLAGS
15-
set(MY_C_FLAGS "-Wall -Wextra -Werror -pedantic -std=gnu99")
18+
set(MY_C_FLAGS "-Wall -Wextra -Werror -std=gnu11 -fno-strict-aliasing")
1619
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_C_FLAGS}")
1720
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MY_C_FLAGS}")
1821

22+
include_directories(${TARANTOOL_INCLUDE_DIRS}
23+
${MOSQUITTO_INCLUDE_DIRS})
24+
1925
# Build module
2026
add_subdirectory(mqtt)
27+
28+
add_custom_target(test
29+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
30+
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/run.sh
31+
DEPENDS driver)

bootstrap.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
#!/bin/bash
22

3-
set -e
3+
set -e -x
44

5+
# Deps
56
cd third_party
67
./bootstrap.sh
78
cd -
89

9-
mkdir -p build
10+
# Common
11+
rm -r build && mkdir -p build && cd build
1012

11-
cd build
13+
if [[ "$OSTYPE" == "darwin"* ]]; then
14+
LIBS=$PWD/../third_party/mosquitto/build/lib/libmosquitto.dylib
15+
else
16+
LIBS=$PWD/../third_party/mosquitto/build/lib/libmosquitto.so
17+
fi
1218

1319
cmake \
1420
-DMOSQUITTO_INCLUDE_DIR=$PWD/../third_party/mosquitto/lib/mosquitto.h \
15-
-DMOSQUITTO_LIBRARY=$PWD/../third_party/mosquitto/build/lib/libmosquitto.so \
21+
-DMOSQUITTO_LIBRARY=${LIBS}\
1622
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
1723
../
1824

mqtt/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
# driver
2+
13
add_library(driver SHARED driver.c)
4+
5+
set(LDFLAGS_EX "")
6+
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
7+
set(LDFLAGS_EX ${LDFLAGS_EX} "-undefined dynamic_lookup")
8+
endif()
9+
210
message(STATUS ${MOSQUITTO_LIBRARIES})
3-
target_link_libraries(driver ${MOSQUITTO_LIBRARIES} -rdynamic)
11+
12+
target_link_libraries(driver ${MOSQUITTO_LIBRARIES} ${LDFLAGS_EX} -rdynamic)
413
set_target_properties(driver PROPERTIES PREFIX "" OUTPUT_NAME "driver")
14+
515
install(TARGETS driver LIBRARY DESTINATION ${TARANTOOL_INSTALL_LIBDIR}/mqtt)
616
install(FILES init.lua DESTINATION ${TARANTOOL_INSTALL_LUADIR}/mqtt)

0 commit comments

Comments
 (0)