forked from ekumenlabs/roscpp_android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kinetic' into fix/pcl-io-linking
- Loading branch information
Showing
4 changed files
with
189 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |