Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "librdkafka"]
path = librdkafka
url = https://github.com/edenhill/librdkafka.git
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ if(${tntver} VERSION_LESS 1.7.4.291)
message(FATAL_ERROR "Tarantool >= 1.7.4-291 is required")
endif()

set(RDKAFKA_FIND_REQUIRED ON)
find_package(RdKafka)
if(STATIC_BUILD)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want a single option that will be the same for all rocks and mean roughly "link all your stuff statically, and don't use anything external". Hence STATIC_BUILD

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocks us with that. We still can add separate options and the helper one. This is the right way, because packaging for distros usually requires linking with system libraries, but sometimes there are problems with some specific system libraries: e.g. lack of them in certain distros.

Hipster way packaging should not break existing agreements. Otherwise it would be the systemd way: a half of the world will hate us.

Copy link

@knazarov knazarov May 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not saying we should remove BUNDLED*, I'm just saying there should be a universal option that you can use to link all dependencies statically. It could be an alias of BUNDLED_* in case if there is only one dependency. But if there is more than one (which is true in case of kafka), it should statically link everything.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for systemd, there is only a small and vocal hater community, which doesn't even have strong arguments, except the fact that systemd is monolithic.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against. Thanks for the clarification.

include(buildRdKafka)
buildrdkafka()
else()
set(RDKAFKA_FIND_REQUIRED ON)
find_package(RdKafka)
endif()

include_directories(${TARANTOOL_INCLUDE_DIRS})

Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ non critical errors as strings which allows you to decide how to handle it.

# Installation
```bash
tarantoolctl rocks install https://raw.githubusercontent.com/tarantool/tnt-kafka/master/rockspecs/kafka-scm-1.rockspec
tarantoolctl rocks install https://raw.githubusercontent.com/tarantool/kafka/master/rockspecs/kafka-scm-1.rockspec
```

## Build module with statically linked librdkafka

To install kafka module with builtin librdkafka dependency, use option `STATIC_BUILD`:

```bash
tarantoolctl rocks STATIC_BUILD=ON install https://raw.githubusercontent.com/tarantool/kafka/master/rockspecs/kafka-scm-1.rockspec
```

# Examples
Expand Down
6 changes: 6 additions & 0 deletions cmake/FindRdKafka.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ find_path(RDKAFKA_INCLUDE_DIR
NAMES librdkafka/rdkafka.h
HINTS ${RDKAFKA_ROOT_DIR}/include
)

find_library(RDKAFKA_LIBRARY
NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}rdkafka${CMAKE_SHARED_LIBRARY_SUFFIX} rdkafka
HINTS ${RDKAFKA_ROOT_DIR}/lib
)

find_library(RDKAFKA_STATIC
NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}rdkafka${CMAKE_STATIC_LIBRARY_SUFFIX} rdkafka
HINTS ${RDKAFKA_ROOT_DIR}/lib
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(RDKAFKA DEFAULT_MSG
RDKAFKA_LIBRARY
Expand Down
10 changes: 10 additions & 0 deletions cmake/buildRdKafka.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
macro(buildrdkafka)
add_custom_target(
rdkafka
COMMAND ./configure
COMMAND make
COMMAND make install
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/librdkafka
VERBATIM
)
endmacro()
10 changes: 9 additions & 1 deletion kafka/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ if (APPLE)
-undefined suppress -flat_namespace")
endif(APPLE)

target_link_libraries(tntkafka ${RDKAFKA_LIBRARY} pthread)
target_link_libraries(tntkafka pthread)

if (STATIC_BUILD)
add_dependencies(tntkafka rdkafka)
target_link_libraries(tntkafka ${CMAKE_SOURCE_DIR}/librdkafka/src/librdkafka.a)
else()
target_link_libraries(tntkafka ${RDKAFKA_LIBRARY})
endif()

set_target_properties(tntkafka PROPERTIES PREFIX "" OUTPUT_NAME "tntkafka")

install(TARGETS tntkafka LIBRARY DESTINATION ${TARANTOOL_INSTALL_LIBDIR}/kafka)
install(FILES init.lua DESTINATION ${TARANTOOL_INSTALL_LUADIR}/kafka)
1 change: 1 addition & 0 deletions librdkafka
Submodule librdkafka added at 8695b9
6 changes: 2 additions & 4 deletions rockspecs/kafka-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ dependencies = {
external_dependencies = {
TARANTOOL = {
header = 'tarantool/module.h'
},
RDKAFKA = {
header = 'librdkafka/rdkafka.h'
}
}
build = {
Expand All @@ -26,6 +23,7 @@ build = {
CMAKE_BUILD_TYPE="RelWithDebInfo",
TARANTOOL_DIR="$(TARANTOOL_DIR)",
TARANTOOL_INSTALL_LIBDIR="$(LIBDIR)",
TARANTOOL_INSTALL_LUADIR="$(LUADIR)"
TARANTOOL_INSTALL_LUADIR="$(LUADIR)",
STATIC_BUILD="$(STATIC_BUILD)"
}
}