Skip to content

Commit 8aa9ffd

Browse files
authored
Merge pull request #33 from tarantool/static-build
Builtin mosquitto library
2 parents bc4e385 + 66c097f commit 8aa9ffd

File tree

11 files changed

+127
-65
lines changed

11 files changed

+127
-65
lines changed

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[submodule "third_party/mosquitto"]
22
path = third_party/mosquitto
33
url = https://github.com/eclipse/mosquitto
4+
tag = v1.6.2

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ env:
1515
- OS=fedora DIST=26
1616
- OS=fedora DIST=27
1717
- OS=ubuntu DIST=xenial
18-
- OS=ubuntu DIST=artful
1918
- OS=ubuntu DIST=bionic
2019
- OS=ubuntu DIST=cosmic
2120
- OS=debian DIST=jessie

CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
88
find_package(Tarantool REQUIRED)
99
include_directories(${TARANTOOL_INCLUDE_DIRS})
1010

11-
find_package(Mosquitto REQUIRED)
12-
include_directories(${MOSQUITTO_INCLUDE_DIRS})
11+
if (NOT DEFINED STATIC_BUILD)
12+
find_package(Mosquitto REQUIRED)
13+
include_directories(${MOSQUITTO_INCLUDE_DIRS})
14+
message(STATUS "libmosquitto: ${MOSQUITTO_INCLUDE_DIRS} ${MOSQUITTO_LIBRARIES}")
15+
endif()
1316

1417
message(STATUS "tarantool: ${TARANTOOL_INCLUDE_DIRS}")
15-
message(STATUS "libmosquitto: ${MOSQUITTO_INCLUDE_DIRS} ${MOSQUITTO_LIBRARIES}")
1618

1719
# Set CFLAGS
1820
set(MY_C_FLAGS "-Wall -Wextra -Werror -std=gnu11 -fno-strict-aliasing")
1921
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_C_FLAGS}")
2022
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MY_C_FLAGS}")
2123

22-
include_directories(${TARANTOOL_INCLUDE_DIRS}
23-
${MOSQUITTO_INCLUDE_DIRS})
24+
include_directories(${TARANTOOL_INCLUDE_DIRS})
2425

2526
# Build module
2627
add_subdirectory(mqtt)

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,19 @@ Key features:
3939
## Prerequisites
4040
-------------------------------
4141

42-
Before reading any further, make sure you have an MQTT broker installed.
42+
Before reading any further, make sure you have an MQTT broker installed or use static build by passing **STATIC_BUILD** flags to cmake.
4343

4444
### Building from source
4545

46-
Clone the repository with submodules, bootstrap, and build the client:
46+
Clone the repository with submodules and build the client:
4747

4848
```bash
4949
$ git clone https://github.com/tarantool/mqtt.git
5050
$ cd mqtt
5151
$ git submodule update --init --recursive
52-
$ ./bootstrap.sh
53-
$ make -C build
52+
$ mkdir build && cd build
53+
$ cmake ..
54+
$ make -j
5455
```
5556

5657
[Back to content](#content)

bootstrap.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

mqtt/CMakeLists.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
# driver
22

3-
add_library(driver SHARED driver.c)
3+
# we don't need to build documentation for mosquitto
4+
option(DOCUMENTATION "Build documentation?" OFF)
5+
6+
option(WITH_STATIC_LIBRARIES "Build static versions of the libmosquitto/pp libraries?" OFF)
7+
8+
if( STATIC_BUILD )
9+
set(WITH_STATIC_LIBRARIES ON)
10+
set(OPENSSL_USE_STATIC_LIBS ON)
11+
endif()
412

513
set(LDFLAGS_EX "")
614
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
715
set(LDFLAGS_EX ${LDFLAGS_EX} "-undefined dynamic_lookup")
816
endif()
917

10-
message(STATUS ${MOSQUITTO_LIBRARIES})
18+
add_library(driver SHARED driver.c)
1119

12-
target_link_libraries(driver ${MOSQUITTO_LIBRARIES} ${LDFLAGS_EX} -rdynamic)
13-
set_target_properties(driver PROPERTIES PREFIX "" OUTPUT_NAME "driver")
20+
if( DEFINED STATIC_BUILD )
21+
unset(CMAKE_C_FLAGS)
22+
add_subdirectory(../third_party/mosquitto ../third_party/mosquitto/build)
23+
if( STATIC_BUILD )
24+
target_link_libraries(driver libmosquitto_static ${LDFLAGS_EX})
25+
else()
26+
target_link_libraries(driver libmosquitto ${LDFLAGS_EX} -rdynamic)
27+
endif()
28+
else()
29+
target_link_libraries(driver ${MOSQUITTO_LIBRARIES} ${LDFLAGS_EX})
30+
endif()
31+
set_target_properties(driver PROPERTIES PREFIX "" OUTPUT_NAME driver)
1432

15-
install(TARGETS driver LIBRARY DESTINATION ${TARANTOOL_INSTALL_LIBDIR}/mqtt)
33+
install(TARGETS driver DESTINATION ${TARANTOOL_INSTALL_LIBDIR}/mqtt)
1634
install(FILES init.lua DESTINATION ${TARANTOOL_INSTALL_LUADIR}/mqtt)

rockspecs/mqtt-1.2.1-2.rockspec

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package = "mqtt"
2+
version = "1.2.1-2"
3+
source = {
4+
url = "git://github.com/tarantool/mqtt.git",
5+
tag = "1.2.1"
6+
}
7+
description = {
8+
summary = "Mqtt connector for Tarantool",
9+
homepage = "https://github.com/tarantool/mqtt",
10+
license = "BSD"
11+
}
12+
dependencies = {
13+
"lua >= 5.1"
14+
}
15+
build = {
16+
type = "cmake";
17+
variables = {
18+
CMAKE_BUILD_TYPE="RelWithDebInfo";
19+
TARANTOOL_INSTALL_LIBDIR="$(LIBDIR)";
20+
TARANTOOL_INSTALL_LUADIR="$(LUADIR)";
21+
STATIC_BUILD="$(STATIC_BUILD)";
22+
};
23+
platforms = {
24+
macosx = {
25+
variables = {
26+
OPENSSL_ROOT_DIR="/usr/local/opt/openssl";
27+
};
28+
};
29+
};
30+
}

rockspecs/mqtt-1.4.0-2.rockspec

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package = "mqtt"
2+
version = "1.4.0-2"
3+
source = {
4+
url = "git://github.com/tarantool/mqtt.git",
5+
tag = "1.4.0"
6+
}
7+
description = {
8+
summary = "Mqtt connector for Tarantool",
9+
homepage = "https://github.com/tarantool/mqtt",
10+
license = "BSD"
11+
}
12+
dependencies = {
13+
"lua >= 5.1"
14+
}
15+
build = {
16+
type = "cmake";
17+
variables = {
18+
CMAKE_BUILD_TYPE="RelWithDebInfo";
19+
TARANTOOL_INSTALL_LIBDIR="$(LIBDIR)";
20+
TARANTOOL_INSTALL_LUADIR="$(LUADIR)";
21+
STATIC_BUILD="$(STATIC_BUILD)";
22+
OPENSSL_ROOT_DIR="/usr/local/opt/openssl";
23+
};
24+
platforms = {
25+
macosx = {
26+
variables = {
27+
OPENSSL_ROOT_DIR="/usr/local/opt/openssl";
28+
};
29+
};
30+
};
31+
}

rockspecs/mqtt-scm-2.rockspec

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package = "mqtt"
2+
version = "scm-2"
3+
source = {
4+
url = "git://github.com/tarantool/mqtt.git",
5+
tag = "master"
6+
}
7+
description = {
8+
summary = "Mqtt connector for Tarantool",
9+
homepage = "https://github.com/tarantool/mqtt",
10+
license = "BSD"
11+
}
12+
dependencies = {
13+
"lua >= 5.1"
14+
}
15+
build = {
16+
type = "cmake";
17+
variables = {
18+
CMAKE_BUILD_TYPE="RelWithDebInfo";
19+
TARANTOOL_INSTALL_LIBDIR="$(LIBDIR)";
20+
TARANTOOL_INSTALL_LUADIR="$(LUADIR)";
21+
STATIC_BUILD="$(STATIC_BUILD)";
22+
};
23+
platforms = {
24+
macosx = {
25+
variables = {
26+
OPENSSL_ROOT_DIR="/usr/local/opt/openssl";
27+
};
28+
};
29+
};
30+
}

third_party/bootstrap.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)