Unverified Commit f0f029c5 authored by Luca Boccassi's avatar Luca Boccassi Committed by GitHub

Merge pull request #3132 from sigiesec/add-vs2008-vs2010-ci

Add CI for VS2008 and VS2010 and fix their builds
parents 653c2073 7b686900
...@@ -11,6 +11,20 @@ environment: ...@@ -11,6 +11,20 @@ environment:
MSVCVERSION: "v120" MSVCVERSION: "v120"
MSVCYEAR: "vs2013" MSVCYEAR: "vs2013"
matrix: matrix:
- platform: Win32
configuration: Release
WITH_LIBSODIUM: OFF # unavailable build files for VS2008
ENABLE_CURVE: ON
CMAKE_GENERATOR: "Visual Studio 9 2008"
MSVCVERSION: "v90"
MSVCYEAR: "vs2008"
- platform: Win32
configuration: Release
WITH_LIBSODIUM: ON
ENABLE_CURVE: ON
CMAKE_GENERATOR: "Visual Studio 10 2010"
MSVCVERSION: "v100"
MSVCYEAR: "vs2010"
- platform: Win32 - platform: Win32
configuration: Release configuration: Release
WITH_LIBSODIUM: ON WITH_LIBSODIUM: ON
...@@ -107,10 +121,11 @@ before_build: ...@@ -107,10 +121,11 @@ before_build:
- cmd: cmake -D CMAKE_INCLUDE_PATH="%SODIUM_INCLUDE_DIR%" -D CMAKE_LIBRARY_PATH="%SODIUM_LIBRARY_DIR%" -D WITH_LIBSODIUM="%WITH_LIBSODIUM%" -D ENABLE_DRAFTS="ON" -D ENABLE_ANALYSIS="%ENABLE_ANALYSIS%" -D ENABLE_CURVE="%ENABLE_CURVE%" -D API_POLLER="%API_POLLER%" -D POLLER="%POLLER%" -D CMAKE_C_FLAGS_RELEASE="/MT" -D CMAKE_C_FLAGS_DEBUG="/MTd" -D WITH_LIBSODIUM="%WITH_LIBSODIUM%" -G "%CMAKE_GENERATOR%" "%APPVEYOR_BUILD_FOLDER%" - cmd: cmake -D CMAKE_INCLUDE_PATH="%SODIUM_INCLUDE_DIR%" -D CMAKE_LIBRARY_PATH="%SODIUM_LIBRARY_DIR%" -D WITH_LIBSODIUM="%WITH_LIBSODIUM%" -D ENABLE_DRAFTS="ON" -D ENABLE_ANALYSIS="%ENABLE_ANALYSIS%" -D ENABLE_CURVE="%ENABLE_CURVE%" -D API_POLLER="%API_POLLER%" -D POLLER="%POLLER%" -D CMAKE_C_FLAGS_RELEASE="/MT" -D CMAKE_C_FLAGS_DEBUG="/MTd" -D WITH_LIBSODIUM="%WITH_LIBSODIUM%" -G "%CMAKE_GENERATOR%" "%APPVEYOR_BUILD_FOLDER%"
- cmd: cd "%LIBZMQ_SRCDIR%" - cmd: cd "%LIBZMQ_SRCDIR%"
build: build_script:
parallel: true - cmd: set verbosity=Minimal
project: C:\projects\build_libzmq\ZeroMQ.sln - cmd: if "%MSVCYEAR%"=="vs2008" set verbosity=Normal
verbosity: minimal - cmd: if "%MSVCYEAR%"=="vs2008" set path=C:\Windows\Microsoft.NET\Framework\v3.5;%path%
- cmd: msbuild C:\projects\build_libzmq\ZeroMQ.sln /verbosity:%verbosity% /maxcpucount /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
# TODO this does not work with sonarcloud.io, as it misses the sonar-cxx plugin # TODO this does not work with sonarcloud.io, as it misses the sonar-cxx plugin
# build_script: # build_script:
......
...@@ -57,23 +57,23 @@ template <typename T, typename A = c_single_allocator> ...@@ -57,23 +57,23 @@ template <typename T, typename A = c_single_allocator>
class decoder_base_t : public i_decoder class decoder_base_t : public i_decoder
{ {
public: public:
explicit decoder_base_t (A *allocator_) : explicit decoder_base_t (const size_t buf_size_) :
next (NULL), next (NULL),
read_pos (NULL), read_pos (NULL),
to_read (0), to_read (0),
allocator (allocator_) allocator (buf_size_)
{ {
buf = allocator->allocate (); buf = allocator.allocate ();
} }
// The destructor doesn't have to be virtual. It is made virtual // The destructor doesn't have to be virtual. It is made virtual
// just to keep ICC and code checking tools from complaining. // just to keep ICC and code checking tools from complaining.
virtual ~decoder_base_t () { allocator->deallocate (); } virtual ~decoder_base_t () { allocator.deallocate (); }
// Returns a buffer to be filled with binary data. // Returns a buffer to be filled with binary data.
void get_buffer (unsigned char **data_, std::size_t *size_) void get_buffer (unsigned char **data_, std::size_t *size_)
{ {
buf = allocator->allocate (); buf = allocator.allocate ();
// If we are expected to read large message, we'll opt for zero- // If we are expected to read large message, we'll opt for zero-
// copy, i.e. we'll ask caller to fill the data directly to the // copy, i.e. we'll ask caller to fill the data directly to the
...@@ -83,14 +83,14 @@ class decoder_base_t : public i_decoder ...@@ -83,14 +83,14 @@ class decoder_base_t : public i_decoder
// As a consequence, large messages being received won't block // As a consequence, large messages being received won't block
// other engines running in the same I/O thread for excessive // other engines running in the same I/O thread for excessive
// amounts of time. // amounts of time.
if (to_read >= allocator->size ()) { if (to_read >= allocator.size ()) {
*data_ = read_pos; *data_ = read_pos;
*size_ = to_read; *size_ = to_read;
return; return;
} }
*data_ = buf; *data_ = buf;
*size_ = allocator->size (); *size_ = allocator.size ();
} }
// Processes the data in the buffer previously allocated using // Processes the data in the buffer previously allocated using
...@@ -151,7 +151,7 @@ class decoder_base_t : public i_decoder ...@@ -151,7 +151,7 @@ class decoder_base_t : public i_decoder
virtual void resize_buffer (std::size_t new_size) virtual void resize_buffer (std::size_t new_size)
{ {
allocator->resize (new_size); allocator.resize (new_size);
} }
protected: protected:
...@@ -168,6 +168,8 @@ class decoder_base_t : public i_decoder ...@@ -168,6 +168,8 @@ class decoder_base_t : public i_decoder
next = next_; next = next_;
} }
A &get_allocator () { return allocator; }
private: private:
// Next step. If set to NULL, it means that associated data stream // Next step. If set to NULL, it means that associated data stream
// is dead. Note that there can be still data in the process in such // is dead. Note that there can be still data in the process in such
...@@ -181,7 +183,7 @@ class decoder_base_t : public i_decoder ...@@ -181,7 +183,7 @@ class decoder_base_t : public i_decoder
std::size_t to_read; std::size_t to_read;
// The duffer for data to decode. // The duffer for data to decode.
A *allocator; A allocator;
unsigned char *buf; unsigned char *buf;
decoder_base_t (const decoder_base_t &); decoder_base_t (const decoder_base_t &);
......
...@@ -39,8 +39,7 @@ ...@@ -39,8 +39,7 @@
#include "err.hpp" #include "err.hpp"
zmq::v1_decoder_t::v1_decoder_t (size_t bufsize_, int64_t maxmsgsize_) : zmq::v1_decoder_t::v1_decoder_t (size_t bufsize_, int64_t maxmsgsize_) :
c_single_allocator (bufsize_), decoder_base_t<v1_decoder_t> (bufsize_),
decoder_base_t<v1_decoder_t> (this),
maxmsgsize (maxmsgsize_) maxmsgsize (maxmsgsize_)
{ {
int rc = in_progress.init (); int rc = in_progress.init ();
......
...@@ -36,8 +36,7 @@ namespace zmq ...@@ -36,8 +36,7 @@ namespace zmq
{ {
// Decoder for ZMTP/1.0 protocol. Converts data batches into messages. // Decoder for ZMTP/1.0 protocol. Converts data batches into messages.
class v1_decoder_t : public zmq::c_single_allocator, class v1_decoder_t : public decoder_base_t<v1_decoder_t>
public decoder_base_t<v1_decoder_t>
{ {
public: public:
v1_decoder_t (size_t bufsize_, int64_t maxmsgsize_); v1_decoder_t (size_t bufsize_, int64_t maxmsgsize_);
......
...@@ -41,8 +41,7 @@ ...@@ -41,8 +41,7 @@
zmq::v2_decoder_t::v2_decoder_t (size_t bufsize_, zmq::v2_decoder_t::v2_decoder_t (size_t bufsize_,
int64_t maxmsgsize_, int64_t maxmsgsize_,
bool zero_copy_) : bool zero_copy_) :
shared_message_memory_allocator (bufsize_), decoder_base_t<v2_decoder_t, shared_message_memory_allocator> (bufsize_),
decoder_base_t<v2_decoder_t, shared_message_memory_allocator> (this),
msg_flags (0), msg_flags (0),
zero_copy (zero_copy_), zero_copy (zero_copy_),
maxmsgsize (maxmsgsize_) maxmsgsize (maxmsgsize_)
...@@ -114,9 +113,10 @@ int zmq::v2_decoder_t::size_ready (uint64_t msg_size, ...@@ -114,9 +113,10 @@ int zmq::v2_decoder_t::size_ready (uint64_t msg_size,
// the current message can exceed the current buffer. We have to copy the buffer // the current message can exceed the current buffer. We have to copy the buffer
// data into a new message and complete it in the next receive. // data into a new message and complete it in the next receive.
if (unlikely ( shared_message_memory_allocator &allocator = get_allocator ();
!zero_copy if (unlikely (!zero_copy
|| ((unsigned char *) read_pos + msg_size > (data () + size ())))) { || ((unsigned char *) read_pos + msg_size
> (allocator.data () + allocator.size ())))) {
// a new message has started, but the size would exceed the pre-allocated arena // a new message has started, but the size would exceed the pre-allocated arena
// this happens every time when a message does not fit completely into the buffer // this happens every time when a message does not fit completely into the buffer
rc = in_progress.init_size (static_cast<size_t> (msg_size)); rc = in_progress.init_size (static_cast<size_t> (msg_size));
...@@ -124,15 +124,16 @@ int zmq::v2_decoder_t::size_ready (uint64_t msg_size, ...@@ -124,15 +124,16 @@ int zmq::v2_decoder_t::size_ready (uint64_t msg_size,
// construct message using n bytes from the buffer as storage // construct message using n bytes from the buffer as storage
// increase buffer ref count // increase buffer ref count
// if the message will be a large message, pass a valid refcnt memory location as well // if the message will be a large message, pass a valid refcnt memory location as well
rc = in_progress.init (const_cast<unsigned char *> (read_pos), rc =
static_cast<size_t> (msg_size), in_progress.init (const_cast<unsigned char *> (read_pos),
shared_message_memory_allocator::call_dec_ref, static_cast<size_t> (msg_size),
buffer (), provide_content ()); shared_message_memory_allocator::call_dec_ref,
allocator.buffer (), allocator.provide_content ());
// For small messages, data has been copied and refcount does not have to be increased // For small messages, data has been copied and refcount does not have to be increased
if (in_progress.is_zcmsg ()) { if (in_progress.is_zcmsg ()) {
advance_content (); allocator.advance_content ();
inc_ref (); allocator.inc_ref ();
} }
} }
......
...@@ -38,10 +38,8 @@ namespace zmq ...@@ -38,10 +38,8 @@ namespace zmq
// Decoder for ZMTP/2.x framing protocol. Converts data stream into messages. // Decoder for ZMTP/2.x framing protocol. Converts data stream into messages.
// The class has to inherit from shared_message_memory_allocator because // The class has to inherit from shared_message_memory_allocator because
// the base class calls allocate in its constructor. // the base class calls allocate in its constructor.
class v2_decoder_t : class v2_decoder_t
// inherit first from allocator to ensure that it is constructed before decoder_base_t : public decoder_base_t<v2_decoder_t, shared_message_memory_allocator>
public shared_message_memory_allocator,
public decoder_base_t<v2_decoder_t, shared_message_memory_allocator>
{ {
public: public:
v2_decoder_t (size_t bufsize_, int64_t maxmsgsize_, bool zero_copy_); v2_decoder_t (size_t bufsize_, int64_t maxmsgsize_, bool zero_copy_);
......
...@@ -152,15 +152,18 @@ add_library (unity ...@@ -152,15 +152,18 @@ add_library (unity
"${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.h" "${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.h"
"${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity_internals.h") "${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity_internals.h")
set_target_properties (unity PROPERTIES set_target_properties (unity PROPERTIES
PUBLIC_HEADER "${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.h") PUBLIC_HEADER "${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.h")
target_compile_definitions (unity PUBLIC "UNITY_USE_COMMAND_LINE_ARGS" "UNITY_EXCLUDE_FLOAT") target_compile_definitions (unity PUBLIC "UNITY_USE_COMMAND_LINE_ARGS" "UNITY_EXCLUDE_FLOAT")
target_include_directories (unity target_include_directories (unity PUBLIC "${CMAKE_CURRENT_LIST_DIR}/../external/unity")
PUBLIC "${CMAKE_CURRENT_LIST_DIR}/../external/unity")
IF (MSVC_VERSION LESS 1700) IF (MSVC_VERSION LESS 1700)
SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.c" PROPERTIES LANGUAGE CXX) SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.c" PROPERTIES LANGUAGE CXX)
ENDIF() ENDIF()
IF (MSVC_VERSION LESS 1600)
target_compile_definitions (unity PUBLIC "UNITY_EXCLUDE_STDINT_H")
ENDIF()
# add library and include dirs for all targets # add library and include dirs for all targets
if (BUILD_SHARED) if (BUILD_SHARED)
link_libraries(libzmq ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} unity) link_libraries(libzmq ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} unity)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment