Skip to content

Commit

Permalink
Merge branch 'kinetic' into fix/pcl-io-linking
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Ignacio Ubeira committed Dec 11, 2018
2 parents 4edb6bc + 7953fdb commit 3b33501
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ catkin config \
-DBUILD_SHARED_LIBS=0 -DCMAKE_INSTALL_PREFIX=$CMAKE_PREFIX_PATH \
-DBoost_NO_BOOST_CMAKE=ON -DBOOST_ROOT=$CMAKE_PREFIX_PATH -DANDROID=TRUE \
-DBOOST_INCLUDEDIR=$CMAKE_PREFIX_PATH/include/boost -DBOOST_LIBRARYDIR=$CMAKE_PREFIX_PATH/lib \
-DROSCONSOLE_BACKEND=print -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DCMAKE_FIND_ROOT_PATH=$prefix -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
-DBUILD_TESTING=OFF -DCATKIN_ENABLE_TESTING=OFF

Expand Down
3 changes: 3 additions & 0 deletions do_everything.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ if [[ $skip -ne 1 ]] ; then

## ROS patches

# Patch rosconsole - Add android backend
apply_patch $my_loc/patches/rosconsole.patch

# Patch catkin - Fix transitive linking of interface libraries for static builds
apply_patch $my_loc/patches/catkin.patch

Expand Down
12 changes: 5 additions & 7 deletions patches/lz4.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
--- libs/lz4-r124/cmake_unofficial/CMakeLists.txt 2014-10-31 16:38:11.346334129 -0300
+++ libs/lz4-r124/cmake_unofficial/CMakeLists.txt 2014-10-31 19:04:39.786517080 -0300
@@ -14,8 +14,8 @@
--- libs/lz4-r131/cmake_unofficial/CMakeLists.txt
+++ libs/lz4-r131/cmake_unofficial/CMakeLists.txt
@@ -14,7 +14,7 @@
MESSAGE( STATUS "64 bit architecture detected size of void * is " ${SIZEOF_VOID_P})
ENDIF()

-option(BUILD_TOOLS "Build the command line tools" ON)
-option(BUILD_LIBS "Build the libraries in addition to the tools" OFF)
+option(BUILD_TOOLS "Build the command line tools" OFF)
+option(BUILD_LIBS "Build the libraries in addition to the tools" ON)
option(BUILD_LIBS "Build the libraries in addition to the tools" ON)

if(UNIX AND BUILD_LIBS)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
IF("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
180 changes: 180 additions & 0 deletions patches/rosconsole.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
--- catkin_ws/src/ros_comm/rosconsole/CMakeLists.txt
+++ catkin_ws/src/ros_comm/rosconsole/CMakeLists.txt
@@ -10,9 +10,10 @@ find_package(catkin REQUIRED COMPONENTS cpp_common rostime rosunit)
find_package(Boost COMPONENTS regex system thread)

# select rosconsole backend
-set(ROSCONSOLE_BACKEND "" CACHE STRING "Type of rosconsole backend, one of 'log4cxx', 'glog', 'print'")
+set(ROSCONSOLE_BACKEND "" CACHE STRING "Type of rosconsole backend, one of 'android', 'log4cxx', 'glog', 'print'")
set(rosconsole_backend_INCLUDE_DIRS)
set(rosconsole_backend_LIBRARIES)
+
if(ROSCONSOLE_BACKEND STREQUAL "" OR ROSCONSOLE_BACKEND STREQUAL "log4cxx")
find_package(Log4cxx QUIET)
if(NOT LOG4CXX_LIBRARIES)
@@ -27,6 +28,12 @@ if(ROSCONSOLE_BACKEND STREQUAL "" OR ROSCONSOLE_BACKEND STREQUAL "log4cxx")
message(FATAL_ERROR "Couldn't find log4cxx library")
endif()
endif()
+if(ROSCONSOLE_BACKEND STREQUAL "" OR ROSCONSOLE_BACKEND STREQUAL "android")
+ if(ANDROID)
+ list(APPEND rosconsole_backend_LIBRARIES rosconsole_android rosconsole_backend_interface log)
+ set(ROSCONSOLE_BACKEND "android")
+ endif()
+endif()
if(ROSCONSOLE_BACKEND STREQUAL "" OR ROSCONSOLE_BACKEND STREQUAL "glog")
find_package(PkgConfig)
pkg_check_modules(GLOG QUIET libglog)
@@ -85,6 +92,9 @@ elseif(ROSCONSOLE_BACKEND STREQUAL "glog")
elseif(ROSCONSOLE_BACKEND STREQUAL "print")
add_library(rosconsole_print src/rosconsole/impl/rosconsole_print.cpp)
target_link_libraries(rosconsole_print rosconsole_backend_interface)
+elseif(ROSCONSOLE_BACKEND STREQUAL "android")
+ add_library(rosconsole_android src/rosconsole/impl/rosconsole_android.cpp)
+ target_link_libraries(rosconsole_android rosconsole_backend_interface log)
else()
message(FATAL_ERROR "Unknown rosconsole backend '${ROSCONSOLE_BACKEND}'")
endif()

--- /dev/null
+++ catkin_ws/src/ros_comm/rosconsole/src/rosconsole/impl/rosconsole_android.cpp
@@ -0,0 +1,128 @@
+#include "ros/console.h"
+
+#include <android/log.h>
+
+namespace ros
+{
+namespace console
+{
+namespace impl
+{
+
+std::vector<std::pair<std::string, levels::Level> > rosconsole_android_log_levels;
+LogAppender* rosconsole_android_appender = 0;
+
+void initialize() {}
+
+std::string getName(void* handle);
+
+void print(void* handle, ::ros::console::Level level, const char* str, const char* file, const char* function, int line)
+{
+ // pass log message to appender
+ if(rosconsole_android_appender)
+ {
+ rosconsole_android_appender->log(level, str, file, function, line);
+ }
+
+ android_LogPriority android_log_level;
+ if(level == ::ros::console::levels::Info)
+ {
+ android_log_level = ANDROID_LOG_INFO;
+ }
+ else if(level == ::ros::console::levels::Warn)
+ {
+ android_log_level = ANDROID_LOG_WARN;
+ }
+ else if(level == ::ros::console::levels::Error)
+ {
+ android_log_level = ANDROID_LOG_ERROR;
+ }
+ else if(level == ::ros::console::levels::Fatal)
+ {
+ android_log_level = ANDROID_LOG_FATAL;
+ }
+ else if (level == ::ros::console::levels::Debug)
+ {
+ android_log_level = ANDROID_LOG_DEBUG;
+ }
+ else
+ {
+ // ignore debug
+ return;
+ }
+
+ std::string name = getName(handle);
+
+ std::stringstream ss;
+ ss << name << ": in file:" << file << ":" << line;
+ __android_log_print(android_log_level, ss.str().c_str(), "%s", str);
+}
+
+bool isEnabledFor(void* handle, ::ros::console::Level level)
+{
+ size_t index = (size_t)handle;
+ if(index < rosconsole_android_log_levels.size())
+ {
+ return level >= rosconsole_android_log_levels[index].second;
+ }
+ return false;
+}
+
+void* getHandle(const std::string& name)
+{
+ size_t count = rosconsole_android_log_levels.size();
+ for(size_t index = 0; index < count; index++)
+ {
+ if(name == rosconsole_android_log_levels[index].first)
+ {
+ return (void*)index;
+ }
+ }
+ // add unknown names on demand with default level
+ rosconsole_android_log_levels.push_back(std::pair<std::string, levels::Level>(name, ::ros::console::levels::Info));
+ return (void*)(rosconsole_android_log_levels.size() - 1);
+}
+
+std::string getName(void* handle)
+{
+ size_t index = (size_t)handle;
+ if(index < rosconsole_android_log_levels.size())
+ {
+ return rosconsole_android_log_levels[index].first;
+ }
+ return "";
+}
+
+void register_appender(LogAppender* appender)
+{
+ rosconsole_android_appender = appender;
+}
+
+void shutdown()
+{}
+
+bool get_loggers(std::map<std::string, levels::Level>& loggers)
+{
+ for(std::vector<std::pair<std::string, levels::Level> >::const_iterator it = rosconsole_android_log_levels.begin(); it != rosconsole_android_log_levels.end(); it++)
+ {
+ loggers[it->first] = it->second;
+ }
+ return true;
+}
+
+bool set_logger_level(const std::string& name, levels::Level level)
+{
+ for(std::vector<std::pair<std::string, levels::Level> >::iterator it = rosconsole_android_log_levels.begin(); it != rosconsole_android_log_levels.end(); it++)
+ {
+ if(name == it->first)
+ {
+ it->second = level;
+ return true;
+ }
+ }
+ return false;
+}
+
+} // namespace impl
+} // namespace console
+} // namespace ros

--- catkin_ws/src/ros_comm/rosconsole/src/rosconsole/impl/rosconsole_glog.cpp
+++ catkin_ws/src/ros_comm/rosconsole/src/rosconsole/impl/rosconsole_glog.cpp
@@ -75,7 +75,6 @@ void* getHandle(const std::string& name)
{
return (void*)index;
}
- index++;
}
// add unknown names on demand with default level
rosconsole_glog_log_levels.push_back(std::pair<std::string, levels::Level>(name, ::ros::console::levels::Info));

0 comments on commit 3b33501

Please sign in to comment.