Skip to content

Commit

Permalink
Problem: Zyre out of sync with zproject
Browse files Browse the repository at this point in the history
Solution: Re-generate it!
  • Loading branch information
Kevin Sapper committed May 24, 2019
1 parent c655a28 commit 191fe27
Show file tree
Hide file tree
Showing 16 changed files with 462 additions and 130 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Expand Up @@ -72,15 +72,17 @@ if (NOT HAVE_NET_IF_H)
CHECK_INCLUDE_FILE("net/if.h" HAVE_NET_IF_H) CHECK_INCLUDE_FILE("net/if.h" HAVE_NET_IF_H)
endif() endif()


file(WRITE "${SOURCE_DIR}/src/platform.h.in" " file(REMOVE "${SOURCE_DIR}/src/platform.h")

file(WRITE "${CMAKE_BINARY_DIR}/platform.h.in" "
#cmakedefine HAVE_LINUX_WIRELESS_H #cmakedefine HAVE_LINUX_WIRELESS_H
#cmakedefine HAVE_NET_IF_H #cmakedefine HAVE_NET_IF_H
#cmakedefine HAVE_NET_IF_MEDIA_H #cmakedefine HAVE_NET_IF_MEDIA_H
#cmakedefine HAVE_GETIFADDRS #cmakedefine HAVE_GETIFADDRS
#cmakedefine HAVE_FREEIFADDRS #cmakedefine HAVE_FREEIFADDRS
") ")


configure_file("${SOURCE_DIR}/src/platform.h.in" "${SOURCE_DIR}/src/platform.h") configure_file("${CMAKE_BINARY_DIR}/platform.h.in" "${CMAKE_BINARY_DIR}/platform.h")


#The MSVC C compiler is too out of date, #The MSVC C compiler is too out of date,
#so the sources have to be compiled as c++ #so the sources have to be compiled as c++
Expand Down Expand Up @@ -181,7 +183,7 @@ install(FILES ${zyre_headers} DESTINATION include)
######################################################################## ########################################################################




include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include") include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include" "${CMAKE_BINARY_DIR}")
set (zyre_sources set (zyre_sources
src/zyre.c src/zyre.c
src/zyre_event.c src/zyre_event.c
Expand Down Expand Up @@ -556,7 +558,7 @@ set(cmake_generated ${CMAKE_BINARY_DIR}/CMakeCache.txt
${CMAKE_BINARY_DIR}/DartConfiguration.tcl ${CMAKE_BINARY_DIR}/DartConfiguration.tcl
${CMAKE_BINARY_DIR}/Testing ${CMAKE_BINARY_DIR}/Testing
${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_BINARY_DIR}/src/platform.h ${CMAKE_BINARY_DIR}/platform.h
${CMAKE_BINARY_DIR}/src/libzyre.pc ${CMAKE_BINARY_DIR}/src/libzyre.pc
${CMAKE_BINARY_DIR}/src/libzyre.so ${CMAKE_BINARY_DIR}/src/libzyre.so
${CMAKE_BINARY_DIR}/src/zyre_selftest ${CMAKE_BINARY_DIR}/src/zyre_selftest
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -29,7 +29,7 @@ RUN sudo make install
RUN sudo ldconfig RUN sudo ldconfig


WORKDIR /home/zmq WORKDIR /home/zmq
RUN git clone --quiet git://github.com/zeromq/zyre.git zyre RUN git clone --quiet https://github.com/zeromq/zyre zyre
WORKDIR /home/zmq/zyre WORKDIR /home/zmq/zyre
RUN ./autogen.sh 2> /dev/null RUN ./autogen.sh 2> /dev/null
RUN ./configure --quiet --without-docs RUN ./configure --quiet --without-docs
Expand Down
70 changes: 65 additions & 5 deletions Findlibzmq.cmake
Expand Up @@ -23,11 +23,71 @@ find_path (
HINTS ${PC_LIBZMQ_INCLUDE_HINTS} HINTS ${PC_LIBZMQ_INCLUDE_HINTS}
) )


find_library ( if (MSVC)
LIBZMQ_LIBRARIES # libzmq dll/lib built with MSVC is named using the Boost convention.
NAMES zmq # https://github.com/zeromq/czmq/issues/577
HINTS ${PC_LIBZMQ_LIBRARY_HINTS} # https://github.com/zeromq/czmq/issues/1972
) if (MSVC_IDE)
set(MSVC_TOOLSET "-${CMAKE_VS_PLATFORM_TOOLSET}")
else ()
set(MSVC_TOOLSET "")
endif ()

# Retrieve ZeroMQ version number from zmq.h
file(STRINGS "${LIBZMQ_INCLUDE_DIRS}/zmq.h" zmq_version_defines
REGEX "#define ZMQ_VERSION_(MAJOR|MINOR|PATCH)")
foreach(ver ${zmq_version_defines})
if(ver MATCHES "#define ZMQ_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$")
set(ZMQ_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "")
endif()
endforeach()

set(_zmq_version ${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH})

set(_zmq_debug_names)
set(_zmq_release_names)

set(_zmq_debug_names
"libzmq${MSVC_TOOLSET}-mt-gd-${_zmq_version}" # Debug, BUILD_SHARED
"libzmq${MSVC_TOOLSET}-mt-sgd-${_zmq_version}" # Debug, BUILD_STATIC
"libzmq-mt-gd-${_zmq_version}" # Debug, BUILD_SHARED
"libzmq-mt-sgd-${_zmq_version}" # Debug, BUILD_STATIC
)

set(_zmq_release_names
"libzmq${MSVC_TOOLSET}-mt-${_zmq_version}" # Release|RelWithDebInfo|MinSizeRel, BUILD_SHARED
"libzmq${MSVC_TOOLSET}-mt-s-${_zmq_version}" # Release|RelWithDebInfo|MinSizeRel, BUILD_STATIC
"libzmq-mt-${_zmq_version}" # Release|RelWithDebInfo|MinSizeRel, BUILD_SHARED
"libzmq-mt-s-${_zmq_version}" # Release|RelWithDebInfo|MinSizeRel, BUILD_STATIC
)

find_library (ZeroMQ_LIBRARY_DEBUG
NAMES ${_zmq_debug_names}
)

find_library (ZeroMQ_LIBRARY_RELEASE
NAMES ${_zmq_release_names}
)

if (ZeroMQ_LIBRARY_RELEASE AND ZeroMQ_LIBRARY_DEBUG)
set(LIBZMQ_LIBRARIES
debug ${ZeroMQ_LIBRARY_DEBUG}
optimized ${ZeroMQ_LIBRARY_RELEASE}
)
elseif (ZeroMQ_LIBRARY_RELEASE)
set(LIBZMQ_LIBRARIES ${ZeroMQ_LIBRARY_RELEASE})
elseif (ZeroMQ_LIBRARY_DEBUG)
set(LIBZMQ_LIBRARIES ${ZeroMQ_LIBRARY_DEBUG})
endif ()
endif ()

if (NOT LIBZMQ_LIBRARIES)
find_library (
LIBZMQ_LIBRARIES
NAMES zmq libzmq
HINTS ${PC_LIBZMQ_LIBRARY_HINTS}
)
endif ()


include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)


Expand Down
114 changes: 59 additions & 55 deletions bindings/delphi/libzyre.pas

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions bindings/jni/build.gradle
Expand Up @@ -31,7 +31,7 @@ dependencies {
testCompile 'org.hamcrest:hamcrest-all:1.3' testCompile 'org.hamcrest:hamcrest-all:1.3'
} }


wrapper.gradleVersion = '5.0' wrapper.gradleVersion = '5.4.1'


// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Build section // Build section
Expand All @@ -55,7 +55,16 @@ task initCMake(type: Exec, dependsOn: 'generateJniHeaders') {
task buildNative(type: Exec, dependsOn: 'initCMake') { task buildNative(type: Exec, dependsOn: 'initCMake') {
commandLine "make" commandLine "make"
} }

task copyLibs(type: Copy) {
from "/usr/lib/libzyre.so", "/usr/local/lib/libzyre.so", "/tmp/lib/libzyre.so",
"/usr/lib/libzmq.so", "/usr/local/lib/libzmq.so", "/tmp/lib/libzmq.so",
"/usr/lib/libczmq.so", "/usr/local/lib/libczmq.so", "/tmp/lib/libczmq.so"
into "."
}

jar.dependsOn buildNative jar.dependsOn buildNative
jar.dependsOn copyLibs
test.dependsOn buildNative test.dependsOn buildNative


jar { jar {
Expand Down Expand Up @@ -133,5 +142,5 @@ bintray {


clean.doFirst { clean.doFirst {
delete "${rootDir}/CMakeCache.txt" delete "${rootDir}/CMakeCache.txt"
delete "${rootDir}/libczmqjni.so" delete fileTree("${rootDir}") { include "*.so" }
} }
13 changes: 13 additions & 0 deletions bindings/jni/src/main/java/org/zeromq/zyre/Zyre.java
Expand Up @@ -6,6 +6,7 @@
*/ */
package org.zeromq.zyre; package org.zeromq.zyre;


import java.util.stream.Stream;
import org.scijava.nativelib.NativeLoader; import org.scijava.nativelib.NativeLoader;
import org.zeromq.czmq.*; import org.zeromq.czmq.*;


Expand All @@ -14,6 +15,18 @@ public class Zyre implements AutoCloseable{
if (System.getProperty("java.vm.vendor").contains("Android")) { if (System.getProperty("java.vm.vendor").contains("Android")) {
System.loadLibrary("zyrejni"); System.loadLibrary("zyrejni");
} else { } else {
Stream.of(
"zmq",
"czmq",
"zyre"
)
.forEach(lib -> {
try {
NativeLoader.loadLibrary(lib);
} catch (Exception e) {
System.err.println("[WARN] " + e.getMessage() +" from jar. Assuming it is installed on the system.");
}
});
try { try {
NativeLoader.loadLibrary("zyrejni"); NativeLoader.loadLibrary("zyrejni");
} catch (Exception e) { } catch (Exception e) {
Expand Down
13 changes: 13 additions & 0 deletions bindings/jni/src/main/java/org/zeromq/zyre/ZyreEvent.java
Expand Up @@ -6,6 +6,7 @@
*/ */
package org.zeromq.zyre; package org.zeromq.zyre;


import java.util.stream.Stream;
import org.scijava.nativelib.NativeLoader; import org.scijava.nativelib.NativeLoader;
import org.zeromq.czmq.*; import org.zeromq.czmq.*;


Expand All @@ -14,6 +15,18 @@ public class ZyreEvent implements AutoCloseable{
if (System.getProperty("java.vm.vendor").contains("Android")) { if (System.getProperty("java.vm.vendor").contains("Android")) {
System.loadLibrary("zyrejni"); System.loadLibrary("zyrejni");
} else { } else {
Stream.of(
"zmq",
"czmq",
"zyre"
)
.forEach(lib -> {
try {
NativeLoader.loadLibrary(lib);
} catch (Exception e) {
System.err.println("[WARN] " + e.getMessage() +" from jar. Assuming it is installed on the system.");
}
});
try { try {
NativeLoader.loadLibrary("zyrejni"); NativeLoader.loadLibrary("zyrejni");
} catch (Exception e) { } catch (Exception e) {
Expand Down
17 changes: 17 additions & 0 deletions bindings/python/_project.py
@@ -0,0 +1,17 @@
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
NAME = "zyre"
VERSION = "2.0.1"
LICENSE = "mplv2"
DESCRIPTION = """Python bindings of: an open-source framework for proximity-based p2p apps"""
URL = "https://github.com/zeromq/zyre"
PACKAGES = ["zyre"]
REQUIRES = [
"czmq",
]
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
34 changes: 18 additions & 16 deletions bindings/python_cffi/zyre_cffi/Zyre.py
Expand Up @@ -47,12 +47,12 @@ def set_name(self, name):
""" """
utils.lib.zyre_set_name(self._p, utils.to_bytes(name)) utils.lib.zyre_set_name(self._p, utils.to_bytes(name))


def set_header(self, name, format, ): def set_header(self, name, format, *format_args):
""" """
Set node header; these are provided to other nodes during discovery Set node header; these are provided to other nodes during discovery
and come in each ENTER message. and come in each ENTER message.
""" """
utils.lib.zyre_set_header(self._p, utils.to_bytes(name), format, ) utils.lib.zyre_set_header(self._p, utils.to_bytes(name), format, *format_args)


def set_verbose(self): def set_verbose(self):
""" """
Expand Down Expand Up @@ -111,7 +111,7 @@ def set_interface(self, value):
""" """
utils.lib.zyre_set_interface(self._p, utils.to_bytes(value)) utils.lib.zyre_set_interface(self._p, utils.to_bytes(value))


def set_endpoint(self, format, ): def set_endpoint(self, format, *format_args):
""" """
By default, Zyre binds to an ephemeral TCP port and broadcasts the local By default, Zyre binds to an ephemeral TCP port and broadcasts the local
host name using UDP beaconing. When you call this method, Zyre will use host name using UDP beaconing. When you call this method, Zyre will use
Expand All @@ -122,7 +122,7 @@ def set_endpoint(self, format, ):
that is meaningful to remote as well as local nodes). Returns 0 if that is meaningful to remote as well as local nodes). Returns 0 if
the bind was successful, else -1. the bind was successful, else -1.
""" """
return utils.lib.zyre_set_endpoint(self._p, format, ) return utils.lib.zyre_set_endpoint(self._p, format, *format_args)


def set_contest_in_group(self, group): def set_contest_in_group(self, group):
""" """
Expand Down Expand Up @@ -153,28 +153,28 @@ def set_zap_domain(self, domain):
""" """
utils.lib.zyre_set_zap_domain(self._p, utils.to_bytes(domain)) utils.lib.zyre_set_zap_domain(self._p, utils.to_bytes(domain))


def gossip_bind(self, format, ): def gossip_bind(self, format, *format_args):
""" """
Set-up gossip discovery of other nodes. At least one node in the cluster Set-up gossip discovery of other nodes. At least one node in the cluster
must bind to a well-known gossip endpoint, so other nodes can connect to must bind to a well-known gossip endpoint, so other nodes can connect to
it. Note that gossip endpoints are completely distinct from Zyre node it. Note that gossip endpoints are completely distinct from Zyre node
endpoints, and should not overlap (they can use the same transport). endpoints, and should not overlap (they can use the same transport).
""" """
utils.lib.zyre_gossip_bind(self._p, format, ) utils.lib.zyre_gossip_bind(self._p, format, *format_args)


def gossip_connect(self, format, ): def gossip_connect(self, format, *format_args):
""" """
Set-up gossip discovery of other nodes. A node may connect to multiple Set-up gossip discovery of other nodes. A node may connect to multiple
other nodes, for redundancy paths. For details of the gossip network other nodes, for redundancy paths. For details of the gossip network
design, see the CZMQ zgossip class. design, see the CZMQ zgossip class.
""" """
utils.lib.zyre_gossip_connect(self._p, format, ) utils.lib.zyre_gossip_connect(self._p, format, *format_args)


def gossip_connect_curve(self, public_key, format, ): def gossip_connect_curve(self, public_key, format, *format_args):
""" """
Set-up gossip discovery with CURVE enabled. Set-up gossip discovery with CURVE enabled.
""" """
utils.lib.zyre_gossip_connect_curve(self._p, utils.to_bytes(public_key), format, ) utils.lib.zyre_gossip_connect_curve(self._p, utils.to_bytes(public_key), format, *format_args)


def gossip_unpublish(self, node): def gossip_unpublish(self, node):
""" """
Expand Down Expand Up @@ -224,26 +224,26 @@ def whisper(self, peer, msg_p):
Send message to single peer, specified as a UUID string Send message to single peer, specified as a UUID string
Destroys message after sending Destroys message after sending
""" """
return utils.lib.zyre_whisper(self._p, utils.to_bytes(peer), msg_p._p) return utils.lib.zyre_whisper(self._p, utils.to_bytes(peer), utils.ffi.new("zmsg_t **", msg_p._p))


def shout(self, group, msg_p): def shout(self, group, msg_p):
""" """
Send message to a named group Send message to a named group
Destroys message after sending Destroys message after sending
""" """
return utils.lib.zyre_shout(self._p, utils.to_bytes(group), msg_p._p) return utils.lib.zyre_shout(self._p, utils.to_bytes(group), utils.ffi.new("zmsg_t **", msg_p._p))


def whispers(self, peer, format, ): def whispers(self, peer, format, *format_args):
""" """
Send formatted string to a single peer specified as UUID string Send formatted string to a single peer specified as UUID string
""" """
return utils.lib.zyre_whispers(self._p, utils.to_bytes(peer), format, ) return utils.lib.zyre_whispers(self._p, utils.to_bytes(peer), format, *format_args)


def shouts(self, group, format, ): def shouts(self, group, format, *format_args):
""" """
Send formatted string to a named group Send formatted string to a named group
""" """
return utils.lib.zyre_shouts(self._p, utils.to_bytes(group), format, ) return utils.lib.zyre_shouts(self._p, utils.to_bytes(group), format, *format_args)


def peers(self): def peers(self):
""" """
Expand Down Expand Up @@ -301,13 +301,15 @@ def print_py(self):
""" """
utils.lib.zyre_print(self._p) utils.lib.zyre_print(self._p)


@staticmethod
def version(): def version():
""" """
Return the Zyre version for run-time API detection; returns Return the Zyre version for run-time API detection; returns
major * 10000 + minor * 100 + patch, as a single integer. major * 10000 + minor * 100 + patch, as a single integer.
""" """
return utils.lib.zyre_version() return utils.lib.zyre_version()


@staticmethod
def test(verbose): def test(verbose):
""" """
Self test of this class. Self test of this class.
Expand Down
1 change: 1 addition & 0 deletions bindings/python_cffi/zyre_cffi/ZyreEvent.py
Expand Up @@ -92,6 +92,7 @@ def print_py(self):
""" """
utils.lib.zyre_event_print(self._p) utils.lib.zyre_event_print(self._p)


@staticmethod
def test(verbose): def test(verbose):
""" """
Self test of this class. Self test of this class.
Expand Down

0 comments on commit 191fe27

Please sign in to comment.