Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • scs/ipaaca
  • ramin.yaghoubzadeh/ipaaca
2 results
Show changes
Showing
with 983 additions and 0 deletions
File added
File moved
--- client.py.sav 2018-12-14 18:30:04.836523913 +0100
+++ client.py 2018-12-14 19:23:13.759468147 +0100
@@ -983,7 +983,7 @@
# sockpairR is used to break out of select() before the timeout, on a
# call to publish() etc.
- rlist = [self._sock, self._sockpairR]
+ rlist = [self._sock, self._sockpairR] if self._sock else [self._sockpairR]
try:
socklist = select.select(rlist, wlist, [], timeout)
except TypeError:
<project name="ipaacalib" default="build" basedir=".">
<import file="../../hmibuild/build-recurse.xml" />
</project>
cmake_minimum_required (VERSION 2.6)
# project name
project (ipaaca_cpp)
#set (CMAKE_CXX_STANDARD 11)
## use C++11 (starting with proto v2 / ipaaca-c++ release 12)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
## use the following line to enable console debug messages in ipaaca
## (this entails a slight slowdown since dynamic log level checks made at the very least)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_DEBUG_MESSAGES")
# expose the full RSB api in the headers (set only in ipaaca itself)
# !! NOTE: at the moment required in any ipaaca cpp project in Windows !!
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_EXPOSE_FULL_RSB_API")
## use the following line to enable building mock IUs (FakeIU)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_BUILD_MOCK_OBJECTS")
# find cmake modules locally too
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
if(WIN32) # Check if we are on Windows
if(MSVC) # Check if we are using the Visual Studio compiler
#set_target_properties(TestProject PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
#
# Setup section for Windows build (using precompiled rsb + deps)
#
# You need the rsx precompiled archive, even if you build rsb yourself,
# for the dependencies. Make sure to grab the right version (bitness
# and Visual Studio version). Tested with the rsx-0.10 branch.
# Please unpack the rsx archive into the repo dir (where ipaaca also is).
# Then set these environment variables before building rsb or ipaaca:
#
# set BOOST_ROOT=%SOA_REPO_DIR%\rsx\boost
# set PROTOBUF_ROOT=%SOA_REPO_DIR%\rsx\protobuf
# set SPREAD_ROOT=%SOA_REPO_DIR%\rsx\spread
#
#
set(LIBS ${LIBS} rpcrt4)
#set(Boost_USE_STATIC_LIBS ON)
#set(Boost_USE_MULTITHREADED ON)
#find_package(Boost COMPONENTS date_time program_options system filesystem thread signals regex REQUIRED)
#link_directories(${Boost_LIBRARY_DIRS})
#include_directories(${Boost_INCLUDE_DIRS})
## Windows linkage hack: overriding the determined libs to remove boost_thread (causes multiple-definition issues)
#set(CORRECT_BOOST_LIBS "")
#foreach(BLIB ${Boost_LIBRARIES})
# list(APPEND CORRECT_BOOST_LIBS ${BLIB})
#endforeach(BLIB ${Boost_LIBRARIES})
#set(Boost_LIBRARIES ${CORRECT_BOOST_LIBS})
# Using custom Protobuf script (from rsc) because it honors PROTOBUF_ROOT
#find_package(ProtocolBuffers REQUIRED PATHS "\\Libs\\protobuf")
#link_directories(${PROTOBUF_LIBRARY_DIRS})
#include_directories(${PROTOBUF_INCLUDE_DIRS})
#message(STATUS "############################")
#message(STATUS ${PROTOBUF_INCLUDE_DIRS})
set(PROTOBUF_LIBRARY optimized "C:\\libs\\protobuf\\x64\\lib\\libprotobuf.lib" debug "C:\\libs\\protobuf\\x64\\lib\\libprotobufd.lib")
link_directories( "C:\\libs\\protobuf\\x64\\lib" )
include_directories( "C:\\libs\\protobuf\\x64\\include" )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
else()
message(SEND_ERROR "Unsupported compiler! Please build with MSVC++ 19.x (Visual Studio 2017).")
endif()
else()
#
#
# Setup section for Linux or OS X (using 'rsb' soa project)
#
#
find_package(Boost COMPONENTS system filesystem thread regex REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
#set(BOOSTLIBS boost_regex-mt boost_date_time-mt boost_program_options-mt boost_thread-mt boost_filesystem-mt boost_signals-mt boost_system-mt)
find_package(ProtocolBuffers REQUIRED)
link_directories(${PROTOBUF_LIBRARY_DIRS})
include_directories(${PROTOBUF_INCLUDE_DIRS})
set(PROTOBUF_INPUT_DIRECTORY "${PROJECT_SOURCE_DIR}")
set(PROTOBUF_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build/ipaaca")
file(MAKE_DIRECTORY ${PROTOBUF_OUTPUT_DIRECTORY})
set(PROTOBUF_ARGUMENTS "--cpp_out=${PROTOBUF_OUTPUT_DIRECTORY}")
execute_process(COMMAND protoc ${PROTOBUF_ARGUMENTS} ipaaca.proto
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../proto/
RESULT_VARIABLE PROTOBUF_RESULT
OUTPUT_VARIABLE PROTOBUF_OUTPUT_VARIABLE)
# change for each new rsb version
if (DEFINED APPLE)
#set(RSBLIBS rsc0.14 rsb0.14)
#set(RSBLIBS rsc0.10 rsb.0.10)
else(DEFINED APPLE)
#set(RSBLIBS ${PROJECT_SOURCE_DIR}/../../deps/lib/librsc0.14.so ${PROJECT_SOURCE_DIR}/../../deps/lib/librsb0.14.so )
set(LIBS ${LIBS} uuid)
endif(DEFINED APPLE)
# enhance the default search paths (headers, libs ...)
set(CMAKE_PREFIX_PATH ${PROJECT_SOURCE_DIR}:/opt/local:${CMAKE_PREFIX_PATH})
# MacPorts compatibility
if (DEFINED APPLE)
message(STATUS "Adding extra options for building on Mac OS X")
set(CXX_DEFINES "${CXX_DEFINES} -D__MACOSX__")
link_directories( /opt/local/lib )
include_directories( /opt/local/include )
endif(DEFINED APPLE)
endif(WIN32)
set(LIBS ${LIBS} ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES})
if(NOT DEFINED WIN32)
if (DEFINED APPLE)
message(STATUS "No extra pthread flags needed on Mac")
else()
message(STATUS "Adding extra pthread flags for Linux")
# needs -lpthread AND -pthread
set(LIBS ${LIBS} pthread)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
endif(NOT DEFINED WIN32)
# Hide the rsb-induced boost-signals warning (FOR NOW)
#set(IPAACA_CXX_DEFINES "${IPAACA_CXX_DEFINES} -DBOOST_SIGNALS_NO_DEPRECATION_WARNING")
## Compiler defines copied from the old build system
#set(IPAACA_CXX_DEFINES "${IPAACA_CXX_DEFINES} -D_DEFAULT_SOURCE -DUSE_AV -DMGC_USE_DOUBLE -DLEDA_PREFIX -D__NO_CAST_TO_LOCAL_TYPE__ -DDBGLVL=0")
# Combine the extra compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_OLD_CODE_CONVENIENCE_FLAGS} ${IPAACA_CXX_DEFINES}")
# add include dir for auto-generated headers placed in build/
include_directories( ${PROJECT_SOURCE_DIR}/build )
# add local include directory
include_directories( ${PROJECT_SOURCE_DIR}/include )
# add lib and include directory from pulled dependencies
include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include )
link_directories( ${PROJECT_SOURCE_DIR}/../../deps/lib )
###
### Back-ends (will include any and all that are compileable)
###
#
if(WIN32)
if(MSVC)
# fixed configuration for Windows
set(LIBS ${LIBS} "C:\\libs\\mosquitto\\x64\\mosquitto.lib" "C:\\libs\\mosquitto\\x64\\mosquittopp.lib")
link_directories( "C:\\libs\\mosquitto\\x64" )
include_directories( "C:\\libs\\mosquitto\\x64\\include" )
set(BACKEND_SOURCES ${BACKEND_SOURCES} src/ipaaca-backend-mqtt.cc)
endif(MSVC)
else()
# dynamic checks under Unix
# 1: MQTT
find_library(MOSQUITTO_LIB mosquittopp)
if(MOSQUITTO_LIB)
message(STATUS "=== MQTT backend === enabled")
set(LIBS ${LIBS} mosquittopp)
set(BACKEND_SOURCES ${BACKEND_SOURCES} src/ipaaca-backend-mqtt.cc)
else()
message(STATUS "=== MQTT backend === DISABLED (mosquittopp not found)")
endif()
# 2: ROS
set (ROSBASE $ENV{ROS_ROOT}/../..)
find_library(ROSCPP_LIB roscpp PATHS ${ROSBASE})
if(ROSCPP_LIB)
message(STATUS "=== ROS backend === enabled")
include_directories($ENV{ROS_ROOT}/../../include)
link_directories($ENV{ROS_ROOT}/../../lib)
set(LIBS ${LIBS} roscpp roscpp_serialization rosconsole)
set(BACKEND_SOURCES ${BACKEND_SOURCES} src/ipaaca-backend-ros.cc)
else()
message(STATUS "=== ROS backend === DISABLED (roscpp not found)")
endif()
#
# Now make sure that at least one of those backends is available
#
if(NOT BACKEND_SOURCES)
message(SEND_ERROR "\nWill not build IPAACA without any backends!\n")
endif()
endif() # of Unix block
# specify source files for ipaaca (auto-generated ones are in build/ )
set (SOURCE
src/ipaaca.cc
src/ipaaca-config.cc
src/ipaaca-converters.cc
src/ipaaca-backend.cc
src/ipaaca-buffers.cc
src/ipaaca-initializer.cc
src/ipaaca-iuinterface.cc
src/ipaaca-ius.cc
src/ipaaca-links.cc
src/ipaaca-locking.cc
src/ipaaca-payload.cc
src/ipaaca-cmdline-parser.cc
src/ipaaca-string-utils.cc
src/util/notifier.cc
src/b64/b64.cc
build/ipaaca/ipaaca.pb.cc
)
set (SOURCE ${SOURCE} ${BACKEND_SOURCES})
#set (JSON_TEST_SOURCE
# src/ipaaca.cc
# src/ipaaca-buffers.cc
# src/ipaaca-fake.cc
# src/ipaaca-internal.cc
# src/ipaaca-iuinterface.cc
# src/ipaaca-json.cc # main
# src/ipaaca-locking.cc
# src/ipaaca-links.cc
# src/ipaaca-payload.cc
# src/ipaaca-cmdline-parser.cc
# src/ipaaca-string-utils.cc
# # more stuff going beyond the fake test case
# src/ipaaca-ius.cc
# build/ipaaca/ipaaca.pb.cc
# )
#
set (TESTER_SOURCE
src/ipaaca-tester.cc # main
src/ipaaca.cc
src/ipaaca-config.cc
src/ipaaca-converters.cc
src/ipaaca-backend.cc
src/ipaaca-buffers.cc
src/ipaaca-initializer.cc
src/ipaaca-iuinterface.cc
src/ipaaca-ius.cc
src/ipaaca-links.cc
src/ipaaca-locking.cc
src/ipaaca-payload.cc
src/ipaaca-cmdline-parser.cc
src/ipaaca-string-utils.cc
src/util/notifier.cc
src/b64/b64.cc
build/ipaaca/ipaaca.pb.cc
)
set (TESTER_SOURCE ${TESTER_SOURCE} ${BACKEND_SOURCES})
if(WIN32)
if(MSVC)
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "C:/Libs/ipaaca/x64")
endif()
endif()
else()
# this is for building with cmake/soa
set(CMAKE_INSTALL_PREFIX "")
endif()
# compile all files to "ipaaca" shared library
add_library(ipaaca SHARED ${SOURCE})
# and link all the required external libs (found above using find_package etc.)
target_link_libraries(ipaaca ${LIBS})
#add_executable (ipaaca-test-json ${JSON_TEST_SOURCE})
#target_link_libraries (ipaaca-test-json ${LIBS})
add_executable (ipaaca-tester-cpp ${TESTER_SOURCE})
target_compile_options (ipaaca-tester-cpp PRIVATE "-DIPAACA_STATIC_BINARY")
target_link_libraries (ipaaca-tester-cpp ${LIBS})
set(DEFAULT_BIN_SUBDIR bin)
set(DEFAULT_LIB_SUBDIR lib)
set(DEFAULT_DATA_SUBDIR share/data)
set(DEFAULT_INCLUDE_SUBDIR include)
install (
TARGETS ipaaca ipaaca-tester-cpp
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(
DIRECTORY include
DESTINATION .
FILES_MATCHING PATTERN "*.h" PATTERN "*.hh" PATTERN "*.hpp" PATTERN "*.inl"
)
install(
FILES build/ipaaca/ipaaca.pb.h
DESTINATION include/ipaaca/
)
This diff is collapsed.
# Parse arguments passed to a function into several lists separated by
# upper-case identifiers and options that do not have an associated list e.g.:
#
# SET(arguments
# hello OPTION3 world
# LIST3 foo bar
# OPTION2
# LIST1 fuz baz
# )
# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments})
#
# results in 7 distinct variables:
# * ARG_DEFAULT_ARGS: hello;world
# * ARG_LIST1: fuz;baz
# * ARG_LIST2:
# * ARG_LIST3: foo;bar
# * ARG_OPTION1: FALSE
# * ARG_OPTION2: TRUE
# * ARG_OPTION3: TRUE
#
# taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
SET(larg_names ${arg_names})
LIST(FIND larg_names "${arg}" is_arg_name)
IF (is_arg_name GREATER -1)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name GREATER -1)
SET(loption_names ${option_names})
LIST(FIND loption_names "${arg}" is_option)
IF (is_option GREATER -1)
SET(${prefix}_${arg} TRUE)
ELSE (is_option GREATER -1)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option GREATER -1)
ENDIF (is_arg_name GREATER -1)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO(PARSE_ARGUMENTS)
@echo off
md build
cd build
md ipaaca
\Users\ryaghoub\Documents\Develop\repo\protobuf\bin\protoc.exe --proto_path=../../proto ../../proto/ipaaca.proto --cpp_out=build/ipaaca/
cmake .. -DBoost_DEBUG:bool=True -DBOOST_LIBRARYDIR:string=C:\Users\ryaghoub\Downloads\boost_1_57_0__built__boost_subdir_moved_to_stage_include\stage\lib -DBoost_USE_STATIC_LIBS=ON -DBoost_USE_MULTITHREADED=ON -DPROTOBUF_ROOT:string=C:\Users\ryaghoub\Documents\Develop\repo\protobuf
msbuild INSTALL.vcxproj
language=cpp
resolve.status=beta
resource.path=${shared.resources}/;
rebuild.list=
publish.resolver=asap.sftp.publish
dist.dir=../../dist
deps.dir=../../deps
test.binary=testipaaca
<?xml version="1.0" encoding="UTF-8"?>
<project name="IpaacaCpp" default="dist">
<import file="../../../hmibuild/build.xml" />
<target name="check-proto-files">
<echo message="Checking whether compiled protobuf files are already present..." />
<available file="build/ipaaca/ipaaca.pb.h" property="pb.present"/>
</target>
<target name="-proto-yes" depends="check-proto-files" if="pb.present">
<echo message="Built protobuf files found, skipping compilation" />
</target>
<target name="-proto-no" depends="check-proto-files" unless="pb.present">
<echo message="Compiling protobuf files" />
<mkdir dir="${build.dir}/ipaaca" />
<exec executable="protoc">
<arg value="--proto_path=../proto" />
<arg value="../proto/ipaaca.proto" />
<arg value="--cpp_out=build/ipaaca/" />
</exec>
</target>
<target name="-pre-compilation" depends="-proto-yes,-proto-no" />
<target name="-compilation" depends="-build-setup, -pre-compilation">
<!-- echo message="Using temporary RSBProtocol_DIR=${cmake.base.dir}/rsc_tmp/share/rsbprotocol0.10" / -->
<cmake srcdir="${cmake.base.dir}"
bindir="${build.dir}"
buildtype="Debug">
<generator name="Visual Studio 14 Win64" platform="windows" buildtype="Release" buildargs="ALL_BUILD.vcxproj">
<variable name="CMAKE_INSTALL_PREFIX" type="PATH" value="../${zip.tmp.dir}" />
</generator>
<generator name="Visual Studio 10" platform="windows" buildargs="ALL_BUILD.vcxproj">
<variable name="CMAKE_INSTALL_PREFIX" type="PATH" value="../${zip.tmp.dir}" />
</generator>
<generator name="Unix Makefiles">
<variable name="CMAKE_INSTALL_PREFIX" type="PATH" value="" />
</generator>
<variable name="SPREAD_ROOT" type="FILEPATH" value="${env.SPREAD_ROOT}" />
<variable name="PROTOBUF_ROOT" type="FILEPATH" value="${env.PROTOBUF_ROOT}" />
</cmake>
</target>
</project>
cmake_minimum_required (VERSION 2.6)
# project name
project (ipaaca_cpp_example_component)
## use the following line to enable console debug messages in ipaaca
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_DEBUG_MESSAGES")
# find cmake modules locally too
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
find_package(Boost COMPONENTS system filesystem thread regex REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
find_package(Protobuf REQUIRED)
link_directories(${PROTOBUF_LIBRARY_DIRS})
include_directories(${PROTOBUF_INCLUDE_DIRS})
#set(RSBLIBS rsc rsbcore)
set(LIBS ${LIBS} ipaaca )
set(LIBS ${LIBS} ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES})
#${RSBLIBS})
# enhance the default search paths (headers, libs ...)
set(CMAKE_PREFIX_PATH ${PROJECT_SOURCE_DIR}:/opt/local:${CMAKE_PREFIX_PATH})
# Compiler defines copied from the old build system
set(CXX_DEFINES "-D_BSD_SOURCE -DUSE_AV -DMGC_USE_DOUBLE -DLEDA_PREFIX -D__NO_CAST_TO_LOCAL_TYPE__ -DDBGLVL=0")
if (DEFINED APPLE)
message(STATUS "Adding extra options for building on Mac OS X")
set(CXX_DEFINES "${CXX_DEFINES} -D__MACOSX__")
link_directories( /opt/local/lib )
include_directories( /opt/local/include )
endif(DEFINED APPLE)
# Combine the extra compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_OLD_CODE_CONVENIENCE_FLAGS} ${CXX_DEFINES}")
# add local include directory
include_directories( ${PROJECT_SOURCE_DIR}/include )
# add lib and include directory from pulled dependencies
include_directories( ${PROJECT_SOURCE_DIR}/../../../dist/include ${PROJECT_SOURCE_DIR}/../../../deps/include )
link_directories( ${PROJECT_SOURCE_DIR}/../../../dist/lib ${PROJECT_SOURCE_DIR}/../../../deps/lib )
# specify source files for ipaaca (auto-generated ones are in build/ )
set (SOURCE
src/example-component.cc
)
add_executable(example-component ${SOURCE})
target_link_libraries(example-component ${LIBS})
set(DEFAULT_BIN_SUBDIR bin)
set(DEFAULT_LIB_SUBDIR lib)
set(DEFAULT_DATA_SUBDIR share/data)
set(DEFAULT_INCLUDE_SUBDIR include)
set(CMAKE_INSTALL_PREFIX "")
install (
TARGETS example-component
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)