Skip to content
Snippets Groups Projects
Commit ebec2c71 authored by Ramin Yaghoubzadeh's avatar Ramin Yaghoubzadeh
Browse files

Changes to CMake build of CPP lib and tests complete.

** returned to 'soashared' build system for the time being **
Example 'component' source file added.
parent 29e7bdcf
No related branches found
No related tags found
No related merge requests found
<project name="ipaaca-all" default="build" basedir="."> <project name="ipaaca-all" default="build" basedir=".">
<target name="resolve"> <import file="../soashared/ant/build-recurse.xml" />
<subant target="resolve" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="build" depends="-pre-compilation">
<subant target="build" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="clean">
<subant target="clean" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="-pre-compilation">
<subant target="-pre-compilation" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="compile" depends="-pre-compilation">
<subant target="compile" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="dist">
<subant target="dist" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="jar">
<subant target="jar" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
</project> </project>
<project name="ipaacalib" default="build" basedir="."> <project name="ipaacalib" default="build" basedir=".">
<target name="resolve"> <import file="../../soashared/ant/build-recurse.xml" />
<subant target="resolve" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="build" depends="-pre-compilation">
<subant target="build" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="clean">
<subant target="clean" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="-pre-compilation">
<subant target="-pre-compilation" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="compile" depends="-pre-compilation">
<subant target="compile" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="dist">
<subant target="dist" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
<target name="jar">
<subant target="jar" genericantfile="build.xml">
<fileset dir="." includes="*/build.xml"/>
</subant>
</target>
</project> </project>
cmake_minimum_required (VERSION 2.6) cmake_minimum_required (VERSION 2.6)
# project name # project name
project (ipaaca) project (ipaaca_cpp)
## use the following line to enable console debug messages in ipaaca ## use the following line to enable console debug messages in ipaaca
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_DEBUG_MESSAGES") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_DEBUG_MESSAGES")
...@@ -9,11 +9,21 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_DEBUG_MESSAGES") ...@@ -9,11 +9,21 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_DEBUG_MESSAGES")
# find cmake modules locally too # find cmake modules locally too
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
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(Boost COMPONENTS system filesystem thread regex REQUIRED)
set(PROTOLIBS protobuf) 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(Protobuf REQUIRED)
link_directories(${PROTOBUF_LIBRARY_DIRS})
include_directories(${PROTOBUF_INCLUDE_DIRS})
#set(PROTOLIBS protobuf)
set(RSBLIBS rsc rsbcore) set(RSBLIBS rsc rsbcore)
set(LIBS ${LIBS} ${BOOSTLIBS} ${PROTOLIBS} ${RSBLIBS}) #set(LIBS ${LIBS} ${BOOSTLIBS} ${PROTOLIBS} ${RSBLIBS})
#set(LIBS ${LIBS} ${PROTOLIBS} ${RSBLIBS})
set(LIBS ${LIBS} ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${RSBLIBS})
# enhance the default search paths (headers, libs ...) # enhance the default search paths (headers, libs ...)
set(CMAKE_PREFIX_PATH ${PROJECT_SOURCE_DIR}:/opt/local:${CMAKE_PREFIX_PATH}) set(CMAKE_PREFIX_PATH ${PROJECT_SOURCE_DIR}:/opt/local:${CMAKE_PREFIX_PATH})
...@@ -70,5 +80,9 @@ install( ...@@ -70,5 +80,9 @@ install(
DESTINATION / DESTINATION /
FILES_MATCHING PATTERN "*.h" PATTERN "*.hh" PATTERN "*.hpp" PATTERN "*.inl" FILES_MATCHING PATTERN "*.h" PATTERN "*.hh" PATTERN "*.hpp" PATTERN "*.inl"
) )
install(
FILES build/ipaaca.pb.h
DESTINATION /include
)
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project name="IpaacaCpp" default="dist"> <project name="IpaacaCpp" default="dist">
<import file="../../../soashared/ant/build.xml" /> <import file="../../../soashared/ant/build.xml" />
<target name="-pre-compilation"> <target name="check-proto-files">
<echo message="Compiling protobuf file" /> <echo message="Checking whether compiled protobuf files are already present..." />
<exec executable="protoc"> <available file="build/ipaaca.pb.h" property="pb.present"/>
<arg value="--proto_path=../proto" />
<arg value="../proto/ipaaca.proto" />
<arg value="--cpp_out=build/" />
</exec>
</target> </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" />
<exec executable="protoc">
<arg value="--proto_path=../proto" />
<arg value="../proto/ipaaca.proto" />
<arg value="--cpp_out=build/" />
</exec>
</target>
<target name="-pre-compilation" depends="-proto-yes,-proto-no" />
</project> </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 )
link_directories( ${PROJECT_SOURCE_DIR}/../../../dist/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
)
//
// Ipaaca 2 (ipaaca-rsb)
//
// *****************************
// *** ***
// *** C++ usage example ***
// *** ***
// *****************************
//
// Example class highlighting the use of the C++ interface
// to ipaaca2. This class uses a setup similar to an ipaaca1
// 'Component' (the concept does not exist anymore in ipaaca2).
//
#include <ipaaca.h>
#include <typeinfo>
using namespace ipaaca;
/// Test component for ipaaca2
/// The interface is much more flexible than in ipaaca1.
/// This example class provides an interface similar to ipaaca1.
class LegacyComponent {
protected:
/// Make a buffer pair, as in ipaaca1.
/// NOTE1: This is no longer a restriction. You can have
/// multiple buffers, no input buffer, etc.
/// NOTE2: Most objects are referred to using smart pointers
/// using the type name <className>::ptr - don't use '*'
OutputBuffer::ptr _out_buf;
InputBuffer::ptr _in_buf;
public:
/// Constructor to set up the component
LegacyComponent();
/// IU event handler function. Can be a member function,
/// a static function, anything. Use boost::bind on registration.
/// NOTE1: you can register any number of handlers on any Buffer.
/// NOTE2: this example function has the appropriate signature.
void handle_iu_event(IUInterface::ptr iu, IUEventType event_type, bool local);
/// example publishing function to produce a 'grounded' IU
void publish_reply_iu(const std::string& text, const std::string& received_iu_uid);
void publish_hello_world();
};
LegacyComponent::LegacyComponent() {
/// First create the buffer pair
/// Create an output buffer
_out_buf = OutputBuffer::create("MyOutputBuffer");
/// Create an input buffer with category interest
/// NOTE: You can pass up to four categories as strings
// to the constructor, or use an std::vector<std::string>
_in_buf = InputBuffer::create("MyInputBuffer", "myCategoryInterest");
/// Now register the IU handler on both buffers.
/// NOTE1: we could register separate handlers instead.
/// NOTE2: boost::bind enables use of simple closures:
/// You could specify constants for the handler function, as long as the
/// remaining open arguments form the correct signature for IU handlers.
/// ** If you simply want to use a class member function, use it as below **
/// NOTE3: the Buffers are 'live' immediately on creation. As soon as
/// you connect a handler, it can be triggered (no backend connect etc.).
/// If this is not what you want, you should set a flag when you are
/// ready to actually start, and have the handlers honor that flag.
_out_buf->register_handler(boost::bind(&LegacyComponent::handle_iu_event, this, _1, _2, _3));
_in_buf->register_handler(boost::bind(&LegacyComponent::handle_iu_event, this, _1, _2, _3));
}
void LegacyComponent::handle_iu_event(IUInterface::ptr iu, IUEventType event_type, bool local)
{
if (local) {
std::cout << "[Received update of self-owned IU]" << std::endl;
// could do processing here to cope with remote change of own IU
} else {
// event on a remote IU
if (event_type == IU_ADDED) {
std::cout << "[Received new IU!]" << std::endl;
/// new Payload class enables dynamic typing to some degree (numeric default 0)
std::string description = iu->payload()["description"];
double fraction = iu->payload()["fraction"];
/// let's also get the grounded-in links
std::set<std::string> grin_links = iu->get_links("GRIN");
std::cout << "[ Current description: " << description << "]" << std::endl;
/// let's also react by emitting an IU ourselves (function below)
publish_reply_iu("important-result", iu->uid());
} else if (event_type == IU_UPDATED) {
std::cout << "[Received IU payload update for IU " << iu->uid() << "]" << std::endl;
std::string description = iu->payload()["description"];
std::cout << "[ Current description: " << description << "]" << std::endl;
} else if (event_type == IU_LINKSUPDATED) {
std::cout << "[IU links updated.]" << std::endl;
} else if (event_type == IU_COMMITTED) {
std::cout << "[IU " << iu->uid() << " has been committed to.]" << std::endl;
} else if (event_type == IU_RETRACTED) {
std::cout << "[IU " << iu->uid() << " has been retracted.]" << std::endl;
} else if (event_type == IU_DELETED) {
std::cout << "[IU " << iu->uid() << " has been deleted.]" << std::endl;
} else {
// Possible to stringify the type:
std::cout << "[(IU event " << iu_event_type_to_str(event_type) << " " << iu->uid() << ")]" << std::endl;
}
}
}
void LegacyComponent::publish_reply_iu(const std::string& text, const std::string& received_iu_uid) {
/// create a new IU
IU::ptr iu = IU::create( "myResultCategory" );
/// Add something to the payload
iu->payload()["description"] = "SomeResult";
/// Now add a grounded-in link pointing to the IU received before
/// There are no limitations to the link group names.
/// "GRIN" is a convention for the "grounded-in" function of the GAM.
iu->add_link("GRIN", received_iu_uid);
/// add to output buffer ( = "publish")
_out_buf->add(iu);
}
void LegacyComponent::publish_hello_world() {
IU::ptr iu = IU::create( "myCategoryInterest"); //helloWorld" );
iu->payload()["description"] = "Hello world";
_out_buf->add(iu);
}
int main() {
std::cout << "Creating buffers..." << std::endl;
LegacyComponent compo;
sleep(1);
std::cout << "Publishing an initial IU..." << std::endl;
compo.publish_hello_world();
std::cout << "*** Running main loop, press Ctrl-C to cancel... ***" << std::endl;
/// NOTE: custom main loop no longer required.
while (true) sleep(1);
}
cmake_minimum_required (VERSION 2.6)
# project name
project (ipaaca_cpp_test)
## 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 )
link_directories( ${PROJECT_SOURCE_DIR}/../../../dist/lib )
# specify source files for ipaaca (auto-generated ones are in build/ )
set (SOURCE
src/testipaaca.cc
)
# compile all files to "ipaaca" shared library
add_executable(testipaaca ${SOURCE})
# and link all the required external libs (found above using find_package etc.)
target_link_libraries(testipaaca ${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 testipaaca
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
CONFIG = -DIPAACA_DEBUG_MESSAGES CONFIG = -DIPAACA_DEBUG_MESSAGES
IPAACASOURCES = ../../src/ipaaca.cc ipaaca.pb.cc #IPAACASOURCES = ../../src/ipaaca.cc ipaaca.pb.cc
TEXTSOURCES = ${IPAACASOURCES} textsender.cc #TEXTSOURCES = ${IPAACASOURCES} testipaaca.cc
CCFLAGS=-I. -I../../src -I/usr/local/include -I/opt/local/include ${CONFIG} TEXTSOURCES = testipaaca.cc
CCFLAGS=-I../../../../dist/include -I. -I../../src -I/usr/local/include -I/opt/local/include ${CONFIG}
BOOSTLIBS = -L/opt/local/lib -lboost_regex-mt -lboost_date_time-mt -lboost_program_options-mt -lboost_thread-mt -lboost_filesystem-mt -lboost_signals-mt -lboost_system-mt BOOSTLIBS = -L/opt/local/lib -lboost_regex-mt -lboost_date_time-mt -lboost_program_options-mt -lboost_thread-mt -lboost_filesystem-mt -lboost_signals-mt -lboost_system-mt
PROTOLIBS = -L/opt/local/lib -lprotobuf PROTOLIBS = -L/opt/local/lib -lprotobuf
LIBS = ${BOOSTLIBS} ${PROTOLIBS} -L/usr/local/lib -lrsc -lrsbcore #LIBS = ${BOOSTLIBS} ${PROTOLIBS} -L/usr/local/lib -lrsc -lrsbcore
LIBS = -L../../../../dist/lib -lipaaca
COMPILER = gfilt COMPILER = gfilt
all: protoc textsender all: testipaaca
textsender: testipaaca:
${COMPILER} ${CCFLAGS} -o textsender ${TEXTSOURCES} ${LIBS} ${COMPILER} ${CCFLAGS} -o testipaaca ${TEXTSOURCES} ${LIBS}
protoc: protoc:
protoc --proto_path=../../../proto ../../../proto/ipaaca.proto --cpp_out=. protoc --proto_path=../../../proto ../../../proto/ipaaca.proto --cpp_out=.
clean: clean:
rm -f textsender ipaaca.pb.h ipaaca.pb.cc rm -f testipaaca ipaaca.pb.h ipaaca.pb.cc
...@@ -106,7 +106,7 @@ void TextSender::publish_text_to_print(const std::string& text, const std::strin ...@@ -106,7 +106,7 @@ void TextSender::publish_text_to_print(const std::string& text, const std::strin
} }
} }
int main() { int old_main() {
TextSender sender; TextSender sender;
sleep(1); sleep(1);
sender.publish_text_to_print("(INIT)"); sender.publish_text_to_print("(INIT)");
...@@ -114,4 +114,8 @@ int main() { ...@@ -114,4 +114,8 @@ int main() {
while (true) sleep(1); while (true) sleep(1);
} }
int main() {
std::cerr << "TODO: implement Ipaaca C++ test cases." << std::endl;
return 0;
}
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
<import file="../../../soashared/ant/build.xml" /> <import file="../../../soashared/ant/build.xml" />
<!-- import file="../../../HmiBuild/build.xml" / --> <!-- import file="../../../HmiBuild/build.xml" / -->
<target name="dist">
<echo>FIXME - Ramin's hack: JAVA - DOING NOTHING ON DIST</echo>
</target>
<target name="-pre-compilation"> <target name="-pre-compilation">
<echo message="Compiling protobuf file" /> <echo message="Compiling protobuf file" />
<mkdir dir="generatedsrc"/> <mkdir dir="generatedsrc"/>
......
...@@ -6,5 +6,5 @@ Specification-Title: IpaacaJava ...@@ -6,5 +6,5 @@ Specification-Title: IpaacaJava
Specification-Version: 0.1 Specification-Version: 0.1
Specification-Vendor: ipaaca Specification-Vendor: ipaaca
Implementation-Title: IpaacaJava Implementation-Title: IpaacaJava
Implementation-Version: July 24 2012 02:58 PM Implementation-Version: July 27 2012 02:19 PM
Implementation-Vendor: ipaaca Implementation-Vendor: ipaaca
\ No newline at end of file
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
<project name="IpaacaPython" default="run"> <project name="IpaacaPython" default="run">
<import file="../../../soashared/ant/build.xml" /> <import file="../../../soashared/ant/build.xml" />
<!--import file="../../../HmiBuild/build.xml" / --> <!--import file="../../../HmiBuild/build.xml" / -->
<target name="dist">
<echo>FIXME - Ramin's hack: PYTHON - DOING NOTHING ON DIST</echo>
</target>
<target name="-pre-compilation"> <target name="-pre-compilation">
<echo message="Compiling protobuf file" /> <echo message="Compiling protobuf file" />
<exec executable="protoc"> <exec executable="protoc">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment