Skip to content

Commit

Permalink
Merge pull request #185 from eProsima/v1.5.0
Browse files Browse the repository at this point in the history
v1.5.0 release
  • Loading branch information
pablogs9 authored Sep 22, 2020
2 parents 4eb6930 + 66f5888 commit 35fa39a
Show file tree
Hide file tree
Showing 16 changed files with 1,651 additions and 128 deletions.
78 changes: 44 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
option(UAGENT_SUPERBUILD "Enable superbuild compilation." ON)
option(UAGENT_BUILD_TESTS "Build tests." OFF)
option(UAGENT_INSTALLER "Build Windows installer." OFF)
option(UAGENT_ISOLATED_INSTALL "Install the project and dependencies into saparated folders with version control." OFF)
option(UAGENT_ISOLATED_INSTALL "Install the project and dependencies into separated folders with version control." OFF)
option(UAGENT_USE_INTERNAL_GTEST "Enable internal GTest libraries." OFF)
option(BUILD_SHARED_LIBS "Control shared/static building." ON)

Expand All @@ -33,6 +33,8 @@ option(UAGENT_DISCOVERY_PROFILE "Build Discovery profile." ON)
option(UAGENT_P2P_PROFILE "Build P2P discovery profile." ON)
option(UAGENT_LOGGER_PROFILE "Build logger profile." ON)
option(UAGENT_SECURITY_PROFILE "Build security profile." OFF)
option(UAGENT_CLI_PROFILE "Build CLI profile." ON)
option(UAGENT_BUILD_EXECUTABLE "Build MicroXRCE-DDS Agent provided executable." ON)

option(UAGENT_BUILD_CI_TESTS "Build CI test cases.")
if(UAGENT_BUILD_CI_TESTS)
Expand Down Expand Up @@ -65,9 +67,11 @@ set(_fastcdr_version 1.0.13)
set(_fastcdr_tag v1.0.13)
list(APPEND _deps "fastcdr\;${_fastcdr_version}")

set(_cli11_version 1.7.1)
set(_cli11_tag v1.7.1)
list(APPEND _deps "CLI11\;${_cli11_version}")
if(UAGENT_CLI_PROFILE)
set(_cli11_version 1.7.1)
set(_cli11_tag v1.7.1)
list(APPEND _deps "CLI11\;${_cli11_version}")
endif()

if(UAGENT_P2P_PROFILE)
set(_microxrcedds_client_version 1.2.3)
Expand All @@ -79,7 +83,7 @@ if(UAGENT_FAST_PROFILE)
set(_fastdds_version 2.0)
set(_fastdds_tag 2.0.x)
list(APPEND _deps "fastrtps\;${_fastdds_version}")
set(_foonathan_memory_tag master)
set(_foonathan_memory_tag c619113) # This tag should be updated every time it gets updated in foonathan_memory_vendor eProsima's package
endif()

if(UAGENT_LOGGER_PROFILE)
Expand Down Expand Up @@ -166,6 +170,7 @@ endif()
# Set source files
set(SRCS
src/cpp/Agent.cpp
src/cpp/AgentInstance.cpp
src/cpp/Root.cpp
src/cpp/processor/Processor.cpp
src/cpp/client/ProxyClient.cpp
Expand All @@ -183,6 +188,7 @@ set(SRCS
src/cpp/types/SubMessageHeader.cpp
src/cpp/message/InputMessage.cpp
src/cpp/message/OutputMessage.cpp
$<$<NOT:$<BOOL:${UAGENT_CLI_PROFILE}>>:src/cpp/utils/ArgumentParser.cpp>
src/cpp/transport/Server.cpp
src/cpp/transport/serial/SerialProtocol.cpp
${TRANSPORT_SRCS}
Expand Down Expand Up @@ -278,7 +284,7 @@ target_link_libraries(${PROJECT_NAME}
$<$<PLATFORM_ID:Windows>:ws2_32>
$<$<PLATFORM_ID:Windows>:iphlpapi>
$<$<BOOL:${UAGENT_LOGGER_PROFILE}>:spdlog::spdlog>
CLI11::CLI11
$<$<BOOL:${UAGENT_CLI_PROFILE}>:CLI11::CLI11>
PRIVATE
$<$<BOOL:${UAGENT_FAST_PROFILE}>:fastrtps>
$<$<BOOL:${UAGENT_P2P_PROFILE}>:microxrcedds_client>
Expand All @@ -301,20 +307,22 @@ target_include_directories(${PROJECT_NAME} BEFORE
)

# Executable
add_executable(MicroXRCEAgent microxrce_agent.cpp)
target_link_libraries(MicroXRCEAgent
PRIVATE
${PROJECT_NAME}
$<$<BOOL:$<PLATFORM_ID:Linux>>:rt>
$<$<BOOL:$<PLATFORM_ID:Linux>>:dl>
)
if(UAGENT_BUILD_EXECUTABLE)
add_executable(MicroXRCEAgent microxrce_agent.cpp)
target_link_libraries(MicroXRCEAgent
PRIVATE
${PROJECT_NAME}
$<$<BOOL:$<PLATFORM_ID:Linux>>:rt>
$<$<BOOL:$<PLATFORM_ID:Linux>>:dl>
)

set_target_properties(MicroXRCEAgent PROPERTIES
CXX_STANDARD
11
CXX_STANDARD_REQUIRED
YES
)
set_target_properties(MicroXRCEAgent PROPERTIES
CXX_STANDARD
11
CXX_STANDARD_REQUIRED
YES
)
endif()

# XML default profile used to launch exec in the building folder
file(COPY ${PROJECT_SOURCE_DIR}/agent.refs
Expand Down Expand Up @@ -399,20 +407,22 @@ install(
)

# Install agent exec
install(
TARGETS
MicroXRCEAgent
EXPORT
MicroXRCEAgentTargets
RUNTIME
DESTINATION ${BIN_INSTALL_DIR}
LIBRARY
DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE
DESTINATION ${LIB_INSTALL_DIR}
COMPONENT
executables
)
if(UAGENT_BUILD_EXECUTABLE)
install(
TARGETS
MicroXRCEAgent
EXPORT
MicroXRCEAgentTargets
RUNTIME
DESTINATION ${BIN_INSTALL_DIR}
LIBRARY
DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE
DESTINATION ${LIB_INSTALL_DIR}
COMPONENT
executables
)
endif()

# Create config.hpp
configure_file(${PROJECT_SOURCE_DIR}/include/uxr/agent/config.hpp.in
Expand Down Expand Up @@ -495,7 +505,7 @@ if(EXISTS ${CMAKE_BINARY_DIR}/temp_install/)
endif()

# Generate Windows Installer.
if(WIN32 AND UAGENT_INSTALLER)
if(WIN32 AND UAGENT_INSTALLER AND UAGENT_BUILD_EXECUTABLE)
# Set product name.
set(PRODUCT_NAME_SHORT "MicroXRCEAgent")
set(PRODUCT_NAME_LONG "Micro XRCE-DDS Agent")
Expand Down
53 changes: 28 additions & 25 deletions cmake/SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ if(UAGENT_FAST_PROFILE)
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DTHIRDPARTY:BOOL=ON
-DCOMPILE_TOOLS:BOOL=OFF
-DSECURITY:BOOL=${UAGENT_SECURITY_PROFILE}
DEPENDS
fastcdr
Expand All @@ -139,30 +140,32 @@ if(UAGENT_FAST_PROFILE)
endif()

# CLI11.
unset(CLI11_DIR CACHE)
find_package(CLI11 ${_cli11_version} EXACT QUIET)
if(NOT CLI11_FOUND)
ExternalProject_Add(cli11
GIT_REPOSITORY
https://github.com/CLIUtils/CLI11.git
GIT_TAG
${_cli11_tag}
PREFIX
${PROJECT_BINARY_DIR}/CLI11
INSTALL_DIR
${PROJECT_BINARY_DIR}/temp_install/cli11-${_cli11_version}
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH};${CMAKE_INSTALL_PREFIX}
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCLI11_TESTING:BOOL=OFF
-DCLI11_EXAMPLES:BOOL=OFF
)
list(APPEND _deps cli11)
if(UAGENT_CLI_PROFILE)
unset(CLI11_DIR CACHE)
find_package(CLI11 ${_cli11_version} EXACT QUIET)
if(NOT CLI11_FOUND)
ExternalProject_Add(cli11
GIT_REPOSITORY
https://github.com/CLIUtils/CLI11.git
GIT_TAG
${_cli11_tag}
PREFIX
${PROJECT_BINARY_DIR}/CLI11
INSTALL_DIR
${PROJECT_BINARY_DIR}/temp_install/cli11-${_cli11_version}
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH};${CMAKE_INSTALL_PREFIX}
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCLI11_TESTING:BOOL=OFF
-DCLI11_EXAMPLES:BOOL=OFF
)
list(APPEND _deps cli11)
endif()
endif()

if(UAGENT_LOGGER_PROFILE)
Expand Down Expand Up @@ -266,4 +269,4 @@ ExternalProject_Add(uagent
""
DEPENDS
${_deps}
)
)
3 changes: 2 additions & 1 deletion colcon.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"fastrtps"
],
"cmake-args":[
"-DUAGENT_ISOLATED_INSTALL=OFF"
"-DUAGENT_ISOLATED_INSTALL=OFF",
"-DUAGENT_CLI_PROFILE=OFF"
]
}
102 changes: 102 additions & 0 deletions include/uxr/agent/AgentInstance.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright 2020 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// 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
//
// http://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 UXR_AGENT_AGENT_INSTANCE_HPP_
#define UXR_AGENT_AGENT_INSTANCE_HPP_

#include <uxr/agent/config.hpp>

#ifdef UAGENT_CLI_PROFILE
#include <uxr/agent/utils/CLI.hpp>
#else
#include <uxr/agent/utils/ArgumentParser.hpp>
#endif // UAGENT_CLI_PROFILE

#include <csignal>

namespace eprosima {
namespace uxr {

/**
* @brief Singleton class to manage the launch process of a MicroXRCE-DDS Agent.
*/
class AgentInstance
{
public:
/**
* @brief Default constructor.
*/
UXR_AGENT_EXPORT AgentInstance();
/**
* @brief AgentInstance class shall not be copy constructible.
*/
UXR_AGENT_EXPORT AgentInstance(
const AgentInstance &) = delete;

UXR_AGENT_EXPORT AgentInstance(
AgentInstance &&) = delete;

/**
* @brief AgentInstance class shall not be copy assignable.
*/
UXR_AGENT_EXPORT AgentInstance& operator =(
const AgentInstance &) = delete;

UXR_AGENT_EXPORT AgentInstance& operator =(
AgentInstance &&) = delete;

/**
* @brief Get instance associated to this class.
* @return Static reference to the singleton AgentInstance object.
*/
UXR_AGENT_EXPORT static AgentInstance& getInstance();

/**
* @brief Create an Agent instance, based on provided input parameters from user.
* @param[in] argc Number of available parameters introduced by the user.
* @param[in] argv List of parameters to be parsed to instantiate an Agent.
* @return Boolean value indicating if a Micro XRCE-DDS Agent was instantiated successfully.
*/
UXR_AGENT_EXPORT bool create(
int argc,
char** argv);

/**
* @brief Run the created agent until finished via user interrupt or process error.
*/
UXR_AGENT_EXPORT void run();

private:
#ifdef UAGENT_CLI_PROFILE
CLI::App app_;
cli::UDPv4Subcommand udpv4_subcmd_;
cli::UDPv6Subcommand udpv6_subcmd_;
cli::TCPv4Subcommand tcpv4_subcmd_;
cli::TCPv6Subcommand tcpv6_subcmd_;
#ifndef _WIN32
cli::TermiosSubcommand termios_subcmd_;
cli::PseudoTerminalSubcommand pseudo_serial_subcmd_;
#endif // _WIN32
cli::ExitSubcommand exit_subcmd_;
#else
std::thread agent_thread_;
#endif // UAGENT_CLI_PROFILE
#ifndef _WIN32
sigset_t signals_;
#endif // _WIN32
};
} // uxr
} // eprosima

#endif // UXR_AGENT_AGENT_INSTANCE_HPP_
1 change: 1 addition & 0 deletions include/uxr/agent/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace uxr {
#cmakedefine UAGENT_P2P_PROFILE
#endif
#cmakedefine UAGENT_LOGGER_PROFILE
#cmakedefine UAGENT_CLI_PROFILE

const uint16_t DISCOVERY_PORT = 7400;
const char* const DISCOVERY_IP = "239.255.0.2";
Expand Down
Loading

0 comments on commit 35fa39a

Please sign in to comment.