Skip to content

Commit

Permalink
OJI-1392: Code changes to support cross-compilation for QNX 6.5. Add …
Browse files Browse the repository at this point in the history
…installation instructions.
  • Loading branch information
Denis Kimcherenko committed Oct 6, 2016
1 parent 14369b4 commit e61106c
Show file tree
Hide file tree
Showing 8 changed files with 340 additions and 11 deletions.
17 changes: 12 additions & 5 deletions client/client-multi/client-cpp/CMakeLists.txt
Expand Up @@ -219,9 +219,13 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
endif()

if(CMAKE_COMPILER_IS_GNUCXX)
list(APPEND KAA_COMPILE_OPTIONS
-Wall
-std=c++11)
list(APPEND KAA_COMPILE_OPTIONS -Wall)

if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
list(APPEND KAA_COMPILE_OPTIONS -std=gnu++11)
else()
list(APPEND KAA_COMPILE_OPTIONS -std=c++11)
endif()
endif()

#
Expand Down Expand Up @@ -430,6 +434,9 @@ set(KAA_THIRDPARTY_LIBRARIES
${BOTAN_LIBRARY}
${AVRO_LIBRARIES}
${Boost_LIBRARIES}
# The CMAKE_THREAD_LIBS_INIT variable is the replacement of a platform-dependent thread library.
# It is initialized on calling find_package(Boost).
${CMAKE_THREAD_LIBS_INIT}
)

if(KAA_WITH_SQLITE_LOG_STORAGE)
Expand All @@ -448,10 +455,10 @@ if(WIN32 AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
dbghelp)
endif()

if(NOT WIN32)
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(KAA_THIRDPARTY_LIBRARIES
${KAA_THIRDPARTY_LIBRARIES}
pthread)
socket)
endif()

set(KAA_SOURCE_FILES
Expand Down
4 changes: 0 additions & 4 deletions client/client-multi/client-cpp/Modules/FindBotan.cmake
Expand Up @@ -67,10 +67,6 @@ find_package_handle_standard_args(Botan
BOTAN_INCLUDE_DIR
)

if(NOT WIN32 AND NOT APPLE)
list(APPEND BOTAN_LIBRARY "-lrt")
endif(NOT WIN32 AND NOT APPLE)

mark_as_advanced(BOTAN_FOUND
BOTAN_LIBRARY
BOTAN_INCLUDE_DIR)
Expand Down
138 changes: 138 additions & 0 deletions client/client-multi/client-cpp/docs/qnx/INSTALL
@@ -0,0 +1,138 @@
#
# Copyright 2014-2016 CyberVision, Inc.
#
# 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.
#

============================== SYSTEM REQUIREMENTS =====================

Host: Ubuntu 14.04 x64
Target: QNX 6.5

============================== TOOLS ===================================

### QNX SDP
1. Download and install QNX SDP 6.5.0 + SP1 (from official site)

2. Upgrade GCC to 4.8.3 and binutils to 2.24
http://stackoverflow.com/questions/34168433/am-i-able-to-use-c11-in-qnx/34975932#34975932

3. Copy <KAA_SDK_HOME>/tools/qnx/include/* to <QNX_SDP_HOME>/target/qnx6/usr/include/c++/4.8.3/

### QNX SDP

- CMake (minimum 2.8.12)
- Python 2.7

============================== ENV VARS ================================

export KAA_THIRDPARTY_HOME=<YOUR_CUSTOM_DIRECTORY>

============================== Boost 1.61 ==============================

### For host

sudo apt-get install libboost-all-dev

### For target

./bootstrap.sh

./b2 \
toolset=qcc \
target-os=qnxnto \
variant=release \
link=static \
threading=multi \
cxxflags="-V4.8.3,gcc_ntox86 -Y_gpp -Wc,-std=gnu++11" \
linkflags="-V4.8.3,gcc_ntox86 -Y_gpp -lang-c++" \
--prefix=$KAA_THIRDPARTY_HOME/usr \
--with-system \
--with-thread \
--with-log \
--with-filesystem \
--with-iostreams \
--with-program_options \
-q \
install

============================== Avro 1.7.5 ==============================

### For host

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make install

### For target

Patch by <KAA_SDK_HOME>/tools/avro-cpp-disable-tests.patch

mkdir build && cd build

cmake \
-DQNX_HOST=$QNX_HOST \
-DQNX_TARGET=$QNX_TARGET \
-DCMAKE_TOOLCHAIN_FILE=<KAA_SDK_HOME>/toolchains/qnx-x86.cmake \
-DCMAKE_INSTALL_PREFIX=$KAA_THIRDPARTY_HOME/usr \
-DCMAKE_FIND_ROOT_PATH=$KAA_THIRDPARTY_HOME \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
..

nmake install

============================== Botan 1.11 ==============================

find . -type f \( -name "*.h" -or -name "*.hpp" -or -name "*.cpp" \) -print0 | xargs -0 sed -i '/include <string>/a #include <custom\/string.h>'

./configure.py \
--os=qnx \
--cpu=x86_32 \
--cc=gcc \
--cc-bin=i486-pc-nto-qnx6.5.0-g++ \
--cc-abi-flags="-D_HAS_C9X -mstackrealign" \
--disable-shared \
--link-method=copy \
--prefix=$KAA_THIRDPARTY_HOME/usr

make install

ln -s $KAA_THIRDPARTY_HOME/include/botan-1.11/botan $KAA_THIRDPARTY_HOME/include/botan

============================== Sqlite (autoconf) ==============================

CC=i486-pc-nto-qnx6.5.0-gcc \
./configure \
--host=i486-pc-nto-qnx6.5.0 \
--enable-shared=no \
--enable-static=yes \
--prefix=$KAA_THIRDPARTY_HOME/usr

make install

============================== Kaa C++ SDK ==============================

cmake \
-DQNX_HOST=$QNX_HOST \
-DQNX_TARGET=$QNX_TARGET \
-DCMAKE_TOOLCHAIN_FILE=../toolchains/qnx-x86.cmake \
-DCMAKE_INSTALL_PREFIX=$KAA_THIRDPARTY_HOME/usr \
-DCMAKE_FIND_ROOT_PATH=$KAA_THIRDPARTY_HOME \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DKAA_WITH_SQLITE_LOG_STORAGE=1 \
-DAvro_USE_STATIC_LIBS=ON \
-DBoost_USE_STATIC_LIBS=ON \
-DBotan_USE_STATIC_LIBS=ON \
..
4 changes: 4 additions & 0 deletions client/client-multi/client-cpp/impl/logging/LoggingUtils.cpp
Expand Up @@ -20,6 +20,10 @@
#include <sstream>
#include <iterator>

#ifdef QNX_650_CPP11_TO_STRING_PATCH
#include <custom/string.h>
#endif

#include <boost/format.hpp>

namespace kaa {
Expand Down
4 changes: 4 additions & 0 deletions client/client-multi/client-cpp/kaa/http/HttpUtils.hpp
Expand Up @@ -20,6 +20,10 @@
#include <cstdint>
#include <string>

#ifdef QNX_650_CPP11_TO_STRING_PATCH
#include <custom/string.h>
#endif

#include <boost/asio.hpp>

namespace kaa {
Expand Down
5 changes: 3 additions & 2 deletions client/client-multi/client-cpp/pom.xml
Expand Up @@ -72,18 +72,19 @@
<exclude>gcovr.log</exclude>
<exclude>gcovr-report.xml</exclude>
<exclude>test/resources/test_kaa_status.file</exclude>
<exclude>build/**</exclude>
<exclude>**/build/**</exclude>
<exclude>gcovr</exclude>
<exclude>test/resources/*.json</exclude>
<exclude>Modules/FindSqlite3.cmake</exclude>
<exclude>tools/avro-cpp-disable-tests.patch</exclude>
<exclude>toolchains/*.cmake</exclude>
<exclude>tools/qnx/include/**</exclude>
<exclude>avro/configuration.avsc</exclude>
<exclude>avro/endpoint.avsc</exclude>
<exclude>avro/log.avsc</exclude>
<exclude>avro/notification.avsc</exclude>
<exclude>avro/profile.avsc</exclude>
</excludes>
</excludes>
</configuration>
</plugin>
</plugins>
Expand Down
35 changes: 35 additions & 0 deletions client/client-multi/client-cpp/toolchains/qnx-x86.cmake
@@ -0,0 +1,35 @@
#
# Copyright 2014-2016 CyberVision, Inc.
#
# 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.
#

set(CMAKE_SYSTEM_NAME QNX)
set(CMAKE_SYSTEM_VERSION 6.5.0)

set(CMAKE_C_COMPILER ${QNX_HOST}/usr/bin/i486-pc-nto-qnx${CMAKE_SYSTEM_VERSION}-gcc)
set(CMAKE_CXX_COMPILER ${QNX_HOST}/usr/bin/i486-pc-nto-qnx${CMAKE_SYSTEM_VERSION}-g++)

set(CMAKE_LIBRARY_ARCHITECTURE x86)

set(CMAKE_FIND_ROOT_PATH
${CMAKE_FIND_ROOT_PATH}
${QNX_TARGET}
${QNX_TARGET}/${CMAKE_LIBRARY_ARCHITECTURE})

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

add_definitions(-DQNX_650_CPP11_TO_STRING_PATCH)

0 comments on commit e61106c

Please sign in to comment.