Skip to content

Commit

Permalink
Add support for QNX 7.1
Browse files Browse the repository at this point in the history
Signed-off-by: James Choi <[email protected]>
  • Loading branch information
chachoi committed Oct 2, 2023
1 parent 4411e49 commit 34d3173
Show file tree
Hide file tree
Showing 106 changed files with 1,550 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ test/security_tests/security_test_local_config.json
/test/event_tests/event_test_master.json
/test/event_tests/event_test_slave_tcp.json
/test/event_tests/event_test_slave_udp.json

!build_qnx/*
29 changes: 27 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ find_package(Threads REQUIRED)

# Boost
find_package( Boost 1.55 COMPONENTS system thread filesystem REQUIRED )
include_directories(SYSTEM ${Boost_INCLUDE_DIR} )
if(${CMAKE_SYSTEM_NAME} MATCHES "QNX")
include_directories(${Boost_INCLUDE_DIR} )
else()
include_directories(SYSTEM ${Boost_INCLUDE_DIR} )
endif()

if(Boost_FOUND)
if(Boost_LIBRARY_DIR)
Expand Down Expand Up @@ -245,6 +249,8 @@ if (MSVC)
set(USE_RT "")
link_directories(${Boost_LIBRARY_DIR_DEBUG})
ADD_DEFINITIONS( -DBOOST_ALL_DYN_LINK )
elseif(${CMAKE_SYSTEM_NAME} MATCHES "QNX")
set(USE_RT "")
else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OS_CXX_FLAGS} -g ${OPTIMIZE} -std=c++14 ${NO_DEPRECATED} ${EXPORTSYMBOLS}")
set(USE_RT "rt")
Expand Down Expand Up @@ -347,6 +353,9 @@ endif ()

target_link_libraries(${VSOMEIP_NAME}-e2e ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${USE_RT} ${DL_LIBRARY} ${SystemD_LIBRARIES})

if(${CMAKE_SYSTEM_NAME} MATCHES "QNX")
target_link_libraries(${VSOMEIP_NAME}-e2e socket)
endif()
################################################################################
# Compatibility library
################################################################################
Expand Down Expand Up @@ -395,7 +404,11 @@ set(EXAMPLE_CONFIG_FILES
################################################################################
# Configuration parameters
################################################################################
set (VSOMEIP_BASE_PATH "/tmp")
if(${CMAKE_SYSTEM_NAME} MATCHES "QNX")
set (VSOMEIP_BASE_PATH "/var")
else()
set (VSOMEIP_BASE_PATH "/tmp")
endif()
if (BASE_PATH)
set (VSOMEIP_BASE_PATH ${BASE_PATH})
endif ()
Expand Down Expand Up @@ -741,3 +754,15 @@ add_dependencies(build_tests build_benchmark_tests)
# add test directory

add_subdirectory( test EXCLUDE_FROM_ALL )

if (${CMAKE_SYSTEM_NAME} MATCHES "QNX")
install(DIRECTORY ${PROJECT_BINARY_DIR}/test/
DESTINATION bin/vsomeip_tests/test
PATTERN "CMakeFiles" EXCLUDE
PATTERN "*.cmake" EXCLUDE
PATTERN "Makefile" EXCLUDE
)

install(FILES ${PROJECT_BINARY_DIR}/examples/routingmanagerd/routingmanagerd
DESTINATION bin/vsomeip_tests/examples/routingmanagerd)
endif()
8 changes: 8 additions & 0 deletions build_qnx/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LIST=OS
ifndef QRECURSE
QRECURSE=recurse.mk
ifdef QCONFIG
QRDIR=$(dir $(QCONFIG))
endif
endif
include $(QRDIR)$(QRECURSE)
108 changes: 108 additions & 0 deletions build_qnx/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)

#where to install vsomeip:
#$(INSTALL_ROOT_$(OS)) is pointing to $QNX_TARGET
#by default, unless it was manually re-routed to
#a staging area by setting both INSTALL_ROOT_nto
#and USE_INSTALL_ROOT
VSOMEIP_INSTALL_ROOT ?= $(INSTALL_ROOT_$(OS))

#where to find the vsomeip external dependencies, such as Boost
VSOMEIP_EXTERNAL_DEPS_INSTALL ?= $(USE_ROOT_$(OS))

# Get version information from CMakeLists.txt
VSOMEIP_MAJOR_VERSION = $(word 3, $(shell bash -c "grep VSOMEIP_MAJOR_VERSION $(PROJECT_ROOT)/../CMakeLists.txt | head -1 | head -c-2"))
VSOMEIP_MINOR_VERSION = $(word 3, $(shell bash -c "grep VSOMEIP_MINOR_VERSION $(PROJECT_ROOT)/../CMakeLists.txt | head -1 | head -c-2"))
VSOMEIP_PATCH_VERSION = $(word 3, $(shell bash -c "grep VSOMEIP_PATCH_VERSION $(PROJECT_ROOT)/../CMakeLists.txt | head -1 | head -c-2"))

#choose Release or Debug
CMAKE_BUILD_TYPE ?= Release

#set the following to TRUE if you want to compile the vsomeip tests.
#If you do, make sure to set GTEST_ROOT to point to the google test library sources
GENERATE_TESTS ?= TRUE
TEST_IP_MASTER ?= XXX.XXX.XXX.XXX
TEST_IP_SLAVE ?= XXX.XXX.XXX.XXX

#set the following to FALSE if generating .pinfo files is causing problems
GENERATE_PINFO_FILES ?= TRUE

#override 'all' target to bypass the default QNX build system
ALL_DEPENDENCIES = vsomeip_all
.PHONY: vsomeip_all

FLAGS += -g -D_QNX_SOURCE
LDFLAGS += -Wl,--build-id=md5 -lang-c++ -lsocket

CMAKE_ARGS = -DCMAKE_TOOLCHAIN_FILE=$(PROJECT_ROOT)/qnx.nto.toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=$(VSOMEIP_INSTALL_ROOT)/$(CPUVARDIR)/usr \
-DCMAKE_CXX_STANDARD=14 \
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE \
-DVSOMEIP_EXTERNAL_DEPS_INSTALL=$(VSOMEIP_EXTERNAL_DEPS_INSTALL) \
-DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
-DCMAKE_MODULE_PATH=$(PROJECT_ROOT) \
-DEXTRA_CMAKE_C_FLAGS="$(FLAGS)" \
-DEXTRA_CMAKE_CXX_FLAGS="$(FLAGS)" \
-DEXTRA_CMAKE_LINKER_FLAGS="$(LDFLAGS)" \
-DINSTALL_INCLUDE_DIR=$(VSOMEIP_INSTALL_ROOT)/usr/include \
-DCPUVARDIR=$(CPUVARDIR) \
-DGCC_VER=${GCC_VER} \
-DVSOMEIP_INSTALL_ROUTINGMANAGERD=ON

ifeq ($(GENERATE_TESTS), TRUE)
CMAKE_ARGS += -DENABLE_SIGNAL_HANDLING=1 \
-DTEST_IP_MASTER=$(TEST_IP_MASTER) \
-DTEST_IP_SLAVE=$(TEST_IP_SLAVE)
endif

MAKE_ARGS ?= -j $(firstword $(JLEVEL) 4)

define PINFO
endef
PINFO_STATE=Experimental
USEFILE=

include $(MKFILES_ROOT)/qtargets.mk

ifneq ($(wildcard $(foreach dir,$(LIBVPATH),$(dir)/libregex.so)),)
LDFLAGS += -lregex
endif


ifndef NO_TARGET_OVERRIDE
vsomeip_all:
@mkdir -p build
@cd build && cmake $(CMAKE_ARGS) ../../../../../
@cd build && make all $(MAKE_ARGS)
@cd build && make build_tests $(MAKE_ARGS)

install: vsomeip_all
@cd build && make install $(MAKE_ARGS)
@cd build && make build_tests install $(MAKE_ARGS)

clean iclean spotless:
@rm -fr build

endif

#everything down below deals with the generation of the PINFO
#information for shared objects that is used by the QNX build
#infrastructure to embed metadata in the .so files, for example
#data and time, version number, description, etc. Metadata can
#be retrieved on the target by typing 'use -i <path to vsomeip .so file>'.
#this is optional: setting GENERATE_PINFO_FILES to FALSE will disable
#the insertion of metadata in .so files.
ifeq ($(GENERATE_PINFO_FILES), TRUE)
#the following rules are called by the cmake generated makefiles,
#in order to generate the .pinfo files for the shared libraries
%.so.$(VSOMEIP_MAJOR_VERSION).$(VSOMEIP_MINOR_VERSION).$(VSOMEIP_PATCH_VERSION):
$(ADD_PINFO)
$(ADD_USAGE)

%vsomeipd:
$(ADD_PINFO)
$(ADD_USAGE)
endif
8 changes: 8 additions & 0 deletions build_qnx/nto/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LIST=CPU
ifndef QRECURSE
QRECURSE=recurse.mk
ifdef QCONFIG
QRDIR=$(dir $(QCONFIG))
endif
endif
include $(QRDIR)$(QRECURSE)
8 changes: 8 additions & 0 deletions build_qnx/nto/aarch64/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LIST=VARIANT
ifndef QRECURSE
QRECURSE=recurse.mk
ifdef QCONFIG
QRDIR=$(dir $(QCONFIG))
endif
endif
include $(QRDIR)$(QRECURSE)
5 changes: 5 additions & 0 deletions build_qnx/nto/aarch64/le/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include ../../../common.mk

CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=aarch64
FLAGS += $(VFLAG_le) $(CCVFLAG_le)
LDFLAGS += $(VFLAG_le) $(LDVFLAG_le)
8 changes: 8 additions & 0 deletions build_qnx/nto/x86_64/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LIST=VARIANT
ifndef QRECURSE
QRECURSE=recurse.mk
ifdef QCONFIG
QRDIR=$(dir $(QCONFIG))
endif
endif
include $(QRDIR)$(QRECURSE)
3 changes: 3 additions & 0 deletions build_qnx/nto/x86_64/o/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include ../../../common.mk

CMAKE_ARGS += -DCMAKE_SYSTEM_PROCESSOR=x86_64
43 changes: 43 additions & 0 deletions build_qnx/qnx.nto.toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
if("$ENV{QNX_HOST}" STREQUAL "")
message(FATAL_ERROR "QNX_HOST environment variable not found. Please set the variable to your host's build tools")
endif()
if("$ENV{QNX_TARGET}" STREQUAL "")
message(FATAL_ERROR "QNX_TARGET environment variable not found. Please set the variable to the qnx target location")
endif()

if(CMAKE_HOST_WIN32)
set(HOST_EXECUTABLE_SUFFIX ".exe")
#convert windows paths to cmake paths
file(TO_CMAKE_PATH "$ENV{QNX_HOST}" QNX_HOST)
file(TO_CMAKE_PATH "$ENV{QNX_TARGET}" QNX_TARGET)
else()
set(QNX_HOST "$ENV{QNX_HOST}")
set(QNX_TARGET "$ENV{QNX_TARGET}")
endif()

message(STATUS "using QNX_HOST ${QNX_HOST}")
message(STATUS "using QNX_TARGET ${QNX_TARGET}")

set(CMAKE_SYSTEM_NAME QNX)
set(CMAKE_C_COMPILER ${QNX_HOST}/usr/bin/qcc)
set(CMAKE_CXX_COMPILER ${QNX_HOST}/usr/bin/qcc)
set(CMAKE_AR "${QNX_HOST}/usr/bin/nto${CMAKE_SYSTEM_PROCESSOR}-ar${HOST_EXECUTABLE_SUFFIX}" CACHE PATH "archiver")
set(CMAKE_RANLIB "${QNX_HOST}/usr/bin/nto${CMAKE_SYSTEM_PROCESSOR}-ranlib${HOST_EXECUTABLE_SUFFIX}" CACHE PATH "ranlib")

if ("${GCC_VER}" STREQUAL "")
set(GCC_VERSION "" CACHE STRING "gcc_ver")
else()
set(GCC_VERSION "${GCC_VER}," CACHE STRING "gcc_ver")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -V${GCC_VERSION}gcc_nto${CMAKE_SYSTEM_PROCESSOR} ${EXTRA_CMAKE_C_FLAGS}" CACHE STRING "c_flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -V${GCC_VERSION}gcc_nto${CMAKE_SYSTEM_PROCESSOR} ${EXTRA_CMAKE_CXX_FLAGS}" CACHE STRING "cxx_flags")

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_CMAKE_LINKER_FLAGS}" CACHE STRING "exe_linker_flags")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${EXTRA_CMAKE_LINKER_FLAGS}" CACHE STRING "so_linker_flags")

set(CMAKE_FIND_ROOT_PATH ${VSOMEIP_EXTERNAL_DEPS_INSTALL};${VSOMEIP_EXTERNAL_DEPS_INSTALL}/${CPUVARDIR};${QNX_TARGET};${QNX_TARGET}/${CPUVARDIR})

set(CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries.")
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
3 changes: 3 additions & 0 deletions examples/routingmanagerd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# Daemon
add_executable(routingmanagerd routingmanagerd.cpp)
target_link_libraries(routingmanagerd ${VSOMEIP_NAME} ${Boost_LIBRARIES} ${DL_LIBRARY} ${DLT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
if(${CMAKE_SYSTEM_NAME} MATCHES "QNX")
target_link_libraries(routingmanagerd socket)
endif()
add_dependencies(routingmanagerd ${VSOMEIP_NAME})

option(VSOMEIP_INSTALL_ROUTINGMANAGERD "Whether or not to install the routing manager daemon.")
Expand Down
2 changes: 1 addition & 1 deletion implementation/configuration/include/internal.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
#define VSOMEIP_MINIMUM_CHECK_TTL_TIMEOUT 100
#define VSOMEIP_SETSOCKOPT_TIMEOUT_US 500000 // microseconds

#if defined(__linux__) || defined(ANDROID)
#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)
#include <pthread.h>
#endif

Expand Down
6 changes: 3 additions & 3 deletions implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ bool configuration_impl::load(const std::string &_name) {
}
if (its_folder != "") {
its_input.insert(its_folder);
#if defined(__linux__) || defined(ANDROID)
#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)
// load security configuration files from UID_GID sub folder if existing
std::stringstream its_security_config_folder;
its_security_config_folder << its_folder << "/" << getuid() << "_" << getgid();
Expand Down Expand Up @@ -1101,13 +1101,13 @@ void configuration_impl::add_plugin(std::map<plugin_type_e, std::set<std::string
#endif

if (_plugin_data.type_ == "application_plugin") {
#if defined(__linux__) || defined(ANDROID)
#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)
its_library += ".";
its_library += (VSOMEIP_APPLICATION_PLUGIN_VERSION + '0');
#endif
_plugins[plugin_type_e::APPLICATION_PLUGIN].insert(its_library);
} else if (_plugin_data.type_ == "configuration_plugin") {
#if defined(__linux__) || defined(ANDROID)
#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)
its_library += ".";
its_library += (VSOMEIP_PRE_CONFIGURATION_PLUGIN_VERSION + '0');
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define VSOMEIP_V3_LOCAL_SERVER_ENDPOINT_IMPL_RECEIVE_OP_HPP_

#if VSOMEIP_BOOST_VERSION >= 106600
#if defined(__linux__) || defined(ANDROID)
#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)

#include <boost/asio/local/stream_protocol.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class local_uds_server_endpoint_impl: public local_uds_server_endpoint_base_impl
void set_bound_client_host(const std::string &_bound_client_host);
std::string get_bound_client_host() const;

#if defined(__linux__) || defined(ANDROID)
#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)
void set_bound_sec_client(const vsomeip_sec_client_t &_sec_client);
#endif

Expand All @@ -124,7 +124,7 @@ class local_uds_server_endpoint_impl: public local_uds_server_endpoint_base_impl
boost::system::error_code const &_error, std::size_t _bytes);
void receive_cbk(boost::system::error_code const &_error,
std::size_t _bytes
#if defined(__linux__) || defined(ANDROID)
#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)
, std::uint32_t const &_uid, std::uint32_t const &_gid
#endif
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define VSOMEIP_V3_UDP_SERVER_ENDPOINT_IMPL_RECEIVE_OP_HPP_

#if VSOMEIP_BOOST_VERSION >= 106600
#if defined(__linux__) || defined(ANDROID)
#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)

#include <iomanip>

Expand Down
6 changes: 3 additions & 3 deletions implementation/endpoints/src/client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ void client_endpoint_impl<Protocol>::shutdown_and_close_socket_unlocked(bool _re

local_port_ = 0;
if (socket_->is_open()) {
#if defined(__linux__) || defined(ANDROID)
#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)
if (-1 == fcntl(socket_->native_handle(), F_GETFD)) {
VSOMEIP_ERROR << "cei::shutdown_and_close_socket_unlocked: socket/handle closed already '"
<< std::string(std::strerror(errno))
Expand Down Expand Up @@ -830,7 +830,7 @@ void client_endpoint_impl<Protocol>::start_dispatch_timer(
its_offset = std::chrono::nanoseconds::zero();
}

#if defined(__linux__) || defined(ANDROID)
#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)
dispatch_timer_.expires_from_now(its_offset);
#else
dispatch_timer_.expires_from_now(
Expand All @@ -857,7 +857,7 @@ void client_endpoint_impl<Protocol>::update_last_departure() {
}

// Instantiate template
#if defined(__linux__) || defined(ANDROID)
#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)
template class client_endpoint_impl<boost::asio::local::stream_protocol>;
#endif
template class client_endpoint_impl<boost::asio::ip::tcp>;
Expand Down
7 changes: 7 additions & 0 deletions implementation/endpoints/src/endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ template class endpoint_impl<boost::asio::local::stream_protocol>;
#endif
#endif

#ifdef __QNX__
#if VSOMEIP_BOOST_VERSION < 106600
template class endpoint_impl<boost::asio::local::stream_protocol_ext>;
#endif
template class endpoint_impl<boost::asio::local::stream_protocol>;
#endif

template class endpoint_impl<boost::asio::ip::tcp>;
template class endpoint_impl<boost::asio::ip::udp>;

Expand Down
Loading

0 comments on commit 34d3173

Please sign in to comment.