Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit ddeb263

Browse files
authored
Merge pull request #598 from tango-controls/fix-cppzqm-non-stock-flag
.travis: Fix installation of non-stock cppzmq
2 parents d19e6c3 + 907aae9 commit ddeb263

File tree

7 files changed

+38
-23
lines changed

7 files changed

+38
-23
lines changed

.travis.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ language: cpp
44

55
env:
66
matrix:
7-
- OS_TYPE=gcc-latest CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF RUN_TESTS=OFF WARNINGS_AS_ERRORS=ON NON_STOCK_CPPZMQ=ON TANGO_USE_USING_NAMESPACE=OFF USE_PCH=ON
8-
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF RUN_TESTS=ON NON_STOCK_CPPZMQ=ON TANGO_USE_USING_NAMESPACE=OFF USE_PCH=ON
9-
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Release SONAR_SCANNER=OFF COVERALLS=OFF RUN_TESTS=ON NON_STOCK_CPPZMQ=ON
10-
- OS_TYPE=debian9 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF RUN_TESTS=ON NON_STOCK_CPPZMQ=ON
11-
- OS_TYPE=debian8 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=ON COVERALLS=ON RUN_TESTS=ON NON_STOCK_CPPZMQ=OFF
12-
- OS_TYPE=debian7 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF RUN_TESTS=ON NON_STOCK_CPPZMQ=ON
7+
- OS_TYPE=gcc-latest CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF RUN_TESTS=OFF WARNINGS_AS_ERRORS=ON STOCK_CPPZMQ=ON TANGO_USE_USING_NAMESPACE=OFF USE_PCH=ON
8+
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF RUN_TESTS=ON STOCK_CPPZMQ=ON TANGO_USE_USING_NAMESPACE=OFF USE_PCH=ON
9+
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Release SONAR_SCANNER=OFF COVERALLS=OFF RUN_TESTS=ON STOCK_CPPZMQ=ON
10+
- OS_TYPE=debian9 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF RUN_TESTS=ON STOCK_CPPZMQ=ON
11+
- OS_TYPE=debian8 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=ON COVERALLS=ON RUN_TESTS=ON STOCK_CPPZMQ=OFF
12+
- OS_TYPE=debian7 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF RUN_TESTS=ON STOCK_CPPZMQ=ON
1313

1414
notifications:
1515
email: false
@@ -33,7 +33,7 @@ before_install:
3333
- docker pull tangocs/mysql:9.2.2
3434
- docker pull tangocs/tango-cs:latest
3535
- git clone https://github.com/JoakimSoderberg/coveralls-cmake.git
36-
- git clone -b v4.2.2 https://${CI_USER_TOKEN}@github.com/zeromq/cppzmq.git cppzmq
36+
- (test ${STOCK_CPPZMQ} = "OFF" && git clone -b v4.2.2 https://${CI_USER_TOKEN}@github.com/zeromq/cppzmq.git cppzmq) || mkdir cppzmq
3737
- git clone -b tango-9-lts https://${CI_USER_TOKEN}@github.com/tango-controls/tango-idl.git idl
3838
- wget https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip && unzip build-wrapper-linux-x86.zip
3939

@@ -45,7 +45,7 @@ before_script:
4545
- docker build --build-arg APP_UID=$(id -u) --build-arg APP_GID=$(id -g) -t cpp_tango .travis/${OS_TYPE}
4646
- docker run --name cpp_tango -e TANGO_HOST=${TANGO_HOST} -e BINTRAY_USER_NAME=tango-ci -e BINTRAY_API_KEY=${CI_BINTRAY_API_KEY} -e COVERALLS_REPO_TOKEN=${COVERALLS_REPO_TOKEN} --link tango_cs:tango_cs -v `pwd`:/home/tango/src -v `pwd`/idl:/home/tango/idl -v `pwd`/cppzmq:/home/tango/cppzmq -v `pwd`/coveralls-cmake:/home/tango/coveralls-cmake -v `pwd`/build-wrapper-linux-x86:/home/tango/build-wrapper-linux-x86 -dit cpp_tango
4747
- .travis/install_tango_idl.sh
48-
- (test ${NON_STOCK_CPPZMQ} = "ON" && .travis/install_cppzmq.sh) || true
48+
- (test ${STOCK_CPPZMQ} = "OFF" && .travis/install_cppzmq.sh) || true
4949
#work around gcov ignored by sonar
5050
- sudo mkdir /home/tango && sudo mkdir /home/tango/src && sudo mount --bind `pwd` /home/tango/src
5151

configure/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,18 @@ Please install cppzmq (https://github.com/zeromq/cppzmq) on your system and/or u
151151
<OMNI_BASE>/include and system include directories).")
152152
endif()
153153

154+
if(NOT WIN32)
155+
try_compile(TANGO_ZMQ_HAS_DISCONNECT ${CMAKE_BINARY_DIR}/test_cppzmq_disconnect
156+
SOURCES ${CMAKE_SOURCE_DIR}/configure/test_cppzmq_disconnect.cpp
157+
COMPILE_DEFINITIONS "-I ${CPPZMQ_BASE}/include -I ${ZMQ_BASE}/include"
158+
LINK_LIBRARIES "${ZMQ_PKG_LIBRARIES}")
159+
160+
message(STATUS "Check if zmq::socket has a disconnect method: ${TANGO_ZMQ_HAS_DISCONNECT}")
161+
else()
162+
set(TANGO_ZMQ_HAS_DISCONNECT TRUE)
163+
message(STATUS "Check if zmq::socket has a disconnect method: ${TANGO_ZMQ_HAS_DISCONNECT} (hardcoded)")
164+
endif(NOT WIN32)
165+
154166
message("Verifying ${OMNIIDL_PATH}omniidl")
155167
if(WIN32)
156168
execute_process(COMMAND ${OMNIIDL_PATH}omniidl.exe -V RESULT_VARIABLE FAILED)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <zmq.hpp>
2+
3+
int main(int, char**)
4+
{
5+
zmq::context_t c;
6+
zmq::socket_t s(c, ZMQ_REQ);
7+
s.disconnect("some endpoint");
8+
}

cppapi/client/eventconsumer.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@
4444

4545
#include <zmq.hpp>
4646

47-
#ifdef ZMQ_VERSION
48-
#if ZMQ_VERSION > 30201
49-
#define ZMQ_HAS_DISCONNECT
50-
#endif
51-
#endif
52-
53-
5447
namespace Tango
5548
{
5649

cppapi/client/eventkeepalive.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ bool EventConsumerKeepAliveThread::reconnect_to_zmq_channel(EvChanIte &ipos,Even
187187

188188
std::string adm_name = ipos->second.full_adm_name;
189189

190-
#ifdef ZMQ_HAS_DISCONNECT
190+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
191191
//
192192
// Forget exception which could happen during massive restart of device server process running on the same host
193193
//
@@ -405,7 +405,7 @@ void EventConsumerKeepAliveThread::re_subscribe_event(EvCbIte &epos,EvChanIte &i
405405
void EventConsumerKeepAliveThread::reconnect_to_zmq_event(EvChanIte &ipos,EventConsumer *event_consumer,DeviceData &dd)
406406
{
407407
EvCbIte epos;
408-
#ifdef ZMQ_HAS_DISCONNECT
408+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
409409
bool disconnect_called = false;
410410
#endif
411411

@@ -447,7 +447,7 @@ void EventConsumerKeepAliveThread::reconnect_to_zmq_event(EvChanIte &ipos,EventC
447447
std::string prefix = fqen.substr(0,pos + 1);
448448
d_name.insert(0,prefix);
449449

450-
#ifdef ZMQ_HAS_DISCONNECT
450+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
451451
if (disconnect_called == false)
452452
{
453453
event_consumer->disconnect_event(epos->second.fully_qualified_event_name,epos->second.endpoint);

cppapi/client/zmqeventconsumer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ bool ZmqEventConsumer::process_ctrl(zmq::message_t &received_ctrl,zmq::pollitem_
799799
//
800800

801801
const char *event_name = &(tmp_ptr[1]);
802-
#ifdef ZMQ_HAS_DISCONNECT
802+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
803803
const char *endpoint = &(tmp_ptr[1 + ::strlen(event_name) + 1]);
804804
const char *endpoint_event = &(tmp_ptr[1 + ::strlen(event_name) + ::strlen(endpoint) + 2]);
805805
#endif
@@ -821,7 +821,7 @@ bool ZmqEventConsumer::process_ctrl(zmq::message_t &received_ctrl,zmq::pollitem_
821821
multi_tango_host(heartbeat_sub_sock,UNSUBSCRIBE,base_name);
822822
}
823823

824-
#ifdef ZMQ_HAS_DISCONNECT
824+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
825825
//
826826
// Remove the endpoint in the vector of already connected heartbeat and disconnect the socket to this endpoint
827827
//
@@ -1348,7 +1348,7 @@ void ZmqEventConsumer::connect_event_channel(std::string &channel_name,TANGO_UNU
13481348
buffer[length] = ZMQ_CONNECT_HEARTBEAT;
13491349
length++;
13501350

1351-
#ifdef ZMQ_HAS_DISCONNECT
1351+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
13521352
buffer[length] = 0;
13531353
#else
13541354
if (reconnect == true)
@@ -1720,7 +1720,7 @@ void ZmqEventConsumer::connect_event_system(TANGO_UNUSED(std::string &device_nam
17201720
buffer[length] = ZMQ_CONNECT_EVENT;
17211721
length++;
17221722

1723-
#ifdef ZMQ_HAS_DISCONNECT
1723+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
17241724
buffer[length] = 0;
17251725
#else
17261726
if (filters.size() == 1 && filters[0] == "reconnect")
@@ -3545,7 +3545,7 @@ ReceivedFromAdmin ZmqEventConsumer::initialize_received_from_admin(const Tango::
35453545
return result;
35463546
}
35473547

3548-
#ifdef ZMQ_HAS_DISCONNECT
3548+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
35493549
void ZmqEventConsumer::disconnect_socket(zmq::socket_t& socket, const char* endpoint)
35503550
{
35513551
try

cppapi/server/tango_const.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ const int PUB_HWM = 1000;
145145
const int SUB_HWM = 1000;
146146
const int SUB_SEND_HWM = 10000;
147147

148+
#cmakedefine TANGO_ZMQ_HAS_DISCONNECT
149+
148150
//
149151
// Event when using a file as database stuff
150152
//

0 commit comments

Comments
 (0)