8000 [C] Add client shared library by kdoherty2 · Pull Request #836 · aeron-io/aeron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[C] Add client shared library #836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from Feb 4, 2020
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ option(COVERAGE_BUILD "Enable code coverage" OFF)
option(AERON_TESTS "Enable tests" ${STANDALONE_BUILD})
option(AERON_SYSTEM_TESTS "Enable system tests" ${STANDALONE_BUILD})
option(AERON_BUILD_SAMPLES "Enable building the sample projects" ${STANDALONE_BUILD})
option(LINK_SAMPLES_CLIENT_SHARED "Enable shared linking for sample projects" OFF)
option(AERON_BUILD_DOCUMENTATION "Build Aeron documentation" ${STANDALONE_BUILD})
option(AERON_INSTALL_TARGETS "Enable installation step" ${STANDALONE_BUILD})
if (UNIX)
Expand Down
3 changes: 2 additions & 1 deletion aeron-client/src/main/cpp/Aeron.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "Publication.h"
#include "Subscription.h"
#include "Context.h"
#include "util/Export.h"

/// Top namespace for Aeron C++ API
namespace aeron {
Expand All @@ -53,7 +54,7 @@ using namespace aeron::concurrent::broadcast;
* <p>
* A client application requires only one Aeron object per Media Driver.
*/
class Aeron
class CLIENT_EXPORT Aeron
{
public:
/**
Expand Down
25 changes: 24 additions & 1 deletion aeron-client/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
# limitations under the License.
#

if (MSVC AND "${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
set(BUILD_SHARED_LIBS ON)
endif ()

SET(SOURCE
Publication.cpp
ExclusivePublication.cpp
Expand Down Expand Up @@ -130,11 +134,16 @@ SET(HEADERS

# static library
add_library(aeron_client STATIC ${SOURCE} ${HEADERS})
add_library(aeron_client_shared SHARED ${SOURCE} ${HEADERS})

target_include_directories(aeron_client
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)

target_include_directories(aeron_client_shared
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)

if (MSVC)
string(REPLACE "/" "\\\\" NATIVE_PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
if (${CMAKE_VERSION} VERSION_LESS "3.13.0")
Expand All @@ -150,6 +159,13 @@ target_compile_definitions(aeron_client
PUBLIC "__PROJECT_SOURCE_DIR__=\"${NATIVE_PROJECT_SOURCE_DIR}\""
)

target_compile_definitions(aeron_client_shared
PUBLIC $<$<NOT:$<CONFIG:Debug>>:DISABLE_BOUNDS_CHECKS>
# relative file paths for use in exceptions
PUBLIC "__PROJECT_SOURCE_DIR__=\"${NATIVE_PROJECT_SOURCE_DIR}\""
PUBLIC CLIENT_SHARED DLL_EXPORT
)

if (NOT WIN32)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
Expand All @@ -159,7 +175,14 @@ target_link_libraries(aeron_client
INTERFACE ${CMAKE_THREAD_LIBS_INIT}
)

target_link_libraries(aeron_client_shared
INTERFACE ${CMAKE_THREAD_LIBS_INIT}
)

if (AERON_INSTALL_TARGETS)
install(TARGETS aeron_client ARCHIVE DESTINATION lib)
install(TARGETS aeron_client_shared aeron_client
RUNTIME DESTINATION lib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(DIRECTORY . DESTINATION include FILES_MATCHING PATTERN &quo 10000 t;*.h")
endif ()
3 changes: 2 additions & 1 deletion aeron-client/src/main/cpp/ClientConductor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "DriverListenerAdapter.h"
#include "LogBuffers.h"
#include "HeartbeatTimestamp.h"
#include "util/Export.h"

namespace aeron {

Expand All @@ -47,7 +48,7 @@ typedef std::function<long long()> nano_clock_t;
static const long KEEPALIVE_TIMEOUT_MS = 500;
static const long RESOURCE_TIMEOUT_MS = 1000;

class ClientConductor
class CLIENT_EXPORT ClientConductor
{
public:

Expand Down
3 changes: 2 additions & 1 deletion aeron-client/src/main/cpp/LogBuffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@

#include <util/MemoryMappedFile.h>
#include <concurrent/logbuffer/LogBufferDescriptor.h>
#include "util/Export.h"

namespace aeron {

using namespace aeron::util;
using namespace aeron::concurrent;
using namespace aeron::concurrent::logbuffer;

class LogBuffers
class CLIENT_EXPORT LogBuffers
{
public:
explicit LogBuffers(const char *filename, bool preTouch);
Expand Down
3 changes: 2 additions & 1 deletion aeron-client/src/main/cpp/Publication.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <concurrent/status/UnsafeBufferPosition.h>
#include "concurrent/status/StatusIndicatorReader.h"
#include "LogBuffers.h"
#include "util/Export.h"

namespace aeron {

Expand Down Expand Up @@ -55,7 +56,7 @@ static const std::int64_t MAX_POSITION_EXCEEDED = -5;
* @see Aeron#addPublication
* @see Aeron#findPublication
*/
class Publication
class CLIENT_EXPORT Publication
{
public:

Expand Down
3 changes: 2 additions & 1 deletion aeron-client/src/main/cpp/Subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "concurrent/status/StatusIndicatorReader.h"
#include "concurrent/AtomicArrayUpdater.h"
#include "Image.h"
#include "util/Export.h"

namespace aeron {

Expand All @@ -48,7 +49,7 @@ class ClientConductor;
*
* @see FragmentAssembler
*/
class Subscription
class CLIENT_EXPORT Subscription
{
public:
/// @cond HIDDEN_SYMBOLS
Expand Down
3 changes: 2 additions & 1 deletion aeron-client/src/main/cpp/util/CommandOption.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
#include <map>

#include "Exceptions.h"
#include "util/Export.h"

namespace aeron { namespace util {

AERON_DECLARE_SOURCED_EXCEPTION (CommandOptionException, ExceptionCategory::EXCEPTION_CATEGORY_ERROR);

class CommandOption
class CLIENT_EXPORT CommandOption
{

private:
Expand Down
3 changes: 2 additions & 1 deletion aeron-client/src/main/cpp/util/CommandOptionParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
#include <iostream>

#include "CommandOption.h"
#include "util/Export.h"

namespace aeron { namespace util {

class CommandOptionParser
class CLIENT_EXPORT CommandOptionParser
{
private:
std::map<char, CommandOption> m_options;
Expand Down
36 changes: 36 additions & 0 deletions aeron-client/src/main/cpp/util/Export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2014-2020 Real Logic Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AERON_UTIL_EXPORT_FILE_H
#define AERON_UTIL_EXPORT_FILE_H
#include <util/Platform.h>

#ifdef AERON_COMPILER_MSVC
# if defined CLIENT_SHARED
# if defined DLL_EXPORT
# define CLIENT_EXPORT __declspec(dllexport)
# else
# define CLIENT_EXPORT __declspec(dllimport)
# endif
# else
# define CLIENT_EXPORT
# endif
#else
# define CLIENT_EXPORT
#endif



#endif // AERON_UTIL_EXPORT_FILE_H
3 changes: 2 additions & 1 deletion aeron-client/src/main/cpp/util/MemoryMappedFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <cstdint>
#include <memory>
#include "util/Export.h"

#ifdef _WIN32
#ifndef NOMINMAX
Expand All @@ -31,7 +32,7 @@

namespace aeron { namespace util {

class MemoryMappedFile
class CLIENT_EXPORT MemoryMappedFile
{
public:
typedef std::shared_ptr<MemoryMappedFile> ptr_t;
Expand Down
32 changes: 19 additions & 13 deletions aeron-samples/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
# limitations under the License.
#

set(CLIENT_LINK_LIB "aeron_client")
if(LINK_SAMPLES_CLIENT_SHARED)
set(CLIENT_LINK_LIB "aeron_client_shared")
add_definitions(-DCLIENT_SHARED)
endif()

include_directories(${AERON_CLIENT_SOURCE_PATH})

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDISABLE_BOUNDS_CHECKS")
Expand All @@ -38,49 +44,49 @@ add_executable(ExclusiveThroughput ExclusiveThroughput.cpp ${HEADERS})
add_executable(PingPong PingPong.cpp ${HEADERS})

target_link_libraries(AeronStat
aeron_client)
${CLIENT_LINK_LIB})

target_link_libraries(BasicPublisher
aeron_client)
${CLIENT_LINK_LIB})

target_link_libraries(TimeTests
${CMAKE_THREAD_LIBS_INIT})

target_link_libraries(BasicSubscriber
aeron_client)
${CLIENT_LINK_LIB})

target_link_libraries(StreamingPublisher
aeron_client)
${CLIENT_LINK_LIB})

target_link_libraries(RateSubscriber
aeron_client)
${CLIENT_LINK_LIB})

target_link_libraries(Pong
aeron_client)
${CLIENT_LINK_LIB})

target_link_libraries(Ping
aeron_client
${CLIENT_LINK_LIB}
${HDRHISTOGRAM_LIBS})

add_dependencies(Ping hdr_histogram)

target_link_libraries(Throughput
aeron_client)
${CLIENT_LINK_LIB})

target_link_libraries(ErrorStat
aeron_client)
${CLIENT_LINK_LIB})

target_link_libraries(LossStat
aeron_client)
${CLIENT_LINK_LIB})

target_link_libraries(DriverTool
aeron_client)
${CLIENT_LINK_LIB})

target_link_libraries(ExclusiveThroughput
aeron_client)
${CLIENT_LINK_LIB})

target_link_libraries(PingPong
aeron_client
${CLIENT_LINK_LIB}
${HDRHISTOGRAM_LIBS})

add_dependencies(PingPong hdr_histogram)
Expand Down
5 changes: 5 additions & 0 deletions cppbuild/cppbuild-vs.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ for %%o in (%*) do (
set EXTRA_CMAKE_ARGS=!EXTRA_CMAKE_ARGS! -DBUILD_AERON_DRIVER=ON
set PROCESSED=1
)

if "%%o"=="--link-samples-client-shared" (
set EXTRA_CMAKE_ARGS=!EXTRA_CMAKE_ARGS! -DLINK_SAMPLES_CLIENT_SHARED=ON
set PROCESSED=1
)
)

call cppbuild/vs-helper.cmd
Expand Down
0