Remove submodule glog

This commit is contained in:
Kalman 2018-11-16 17:52:58 +08:00
parent 2096f93a92
commit 4021c565d2
9 changed files with 112 additions and 103 deletions

3
.gitmodules vendored
View File

@ -1,9 +1,6 @@
[submodule "test/gtest"] [submodule "test/gtest"]
path = test/gtest path = test/gtest
url = https://github.com/google/googletest.git url = https://github.com/google/googletest.git
[submodule "third_party/glog"]
path = third_party/glog
url = https://github.com/google/glog.git
[submodule "tools/linter"] [submodule "tools/linter"]
path = tools/linter path = tools/linter
url = https://github.com/slightech/linter.git url = https://github.com/slightech/linter.git

View File

@ -24,7 +24,6 @@ help:
@echo " make apidoc make api doc" @echo " make apidoc make api doc"
@echo " make opendoc open api doc (html)" @echo " make opendoc open api doc (html)"
@echo " make init init project" @echo " make init init project"
@echo " make 3rdparty build 3rdparty: glog"
@echo " make build build project" @echo " make build build project"
@echo " make install install project" @echo " make install install project"
@echo " make test build test and run" @echo " make test build test and run"
@ -61,15 +60,7 @@ opendoc: apidoc
submodules: submodules:
@git submodule update --init @git submodule update --init
.PHONY: submodules
third_party: submodules
@$(call echo,Make $@)
@$(call echo,Make glog,33)
@$(call cmake_build,./third_party/glog/_build)
3rdparty: third_party
.PHONY: submodules third_party 3rdparty
# init # init

View File

@ -17,4 +17,6 @@ option(WITH_API "Build with API layer, need OpenCV" ON)
message(STATUS "Options:") message(STATUS "Options:")
message(STATUS " WITH_API: ${WITH_API}") message(STATUS " WITH_API: ${WITH_API}")
# How to install glog?
# Ubuntu: `sudo apt-get install libgoogle-glog-dev`
option(WITH_GLOG "Include glog support" OFF) option(WITH_GLOG "Include glog support" OFF)

View File

@ -103,25 +103,25 @@
#include "mynteye/mynteye.h" #include "mynteye/mynteye.h"
#ifdef MYNTEYE_OS_ANDROID #ifdef MYNTEYE_OS_ANDROID
# include <android/log.h> #include <android/log.h>
#endif // ANDROID #endif // ANDROID
// Log severity level constants. // Log severity level constants.
#ifdef MYNTEYE_OS_WIN #ifdef MYNTEYE_OS_WIN
const int FATAL = -1; const int FATAL = -1;
#ifndef ERROR // NOT windows.h #ifndef ERROR // NOT windows.h
const int ERROR = 0; const int ERROR = 0;
#endif #endif
const int WARNING = 1; const int WARNING = 1;
const int INFO = 2; const int INFO = 2;
#else #else
const int FATAL = -3; const int FATAL = -3;
const int ERROR = -2; const int ERROR = -2;
const int WARNING = -1; const int WARNING = -1;
const int INFO = 0; const int INFO = 0;
#endif #endif
@ -130,12 +130,12 @@ const int INFO = 0;
namespace google { namespace google {
typedef int LogSeverity; typedef int LogSeverity;
const int FATAL = ::FATAL; const int FATAL = ::FATAL;
#ifndef ERROR // NOT windows.h #ifndef ERROR // NOT windows.h
const int ERROR = ::ERROR; const int ERROR = ::ERROR;
#endif #endif
const int WARNING = ::WARNING; const int WARNING = ::WARNING;
const int INFO = ::INFO; const int INFO = ::INFO;
// Sink class used for integration with mock and test functions. If sinks are // Sink class used for integration with mock and test functions. If sinks are
// added, all log output is also sent to each sink through the send function. // added, all log output is also sent to each sink through the send function.
@ -144,13 +144,10 @@ const int INFO = ::INFO;
class MYNTEYE_API LogSink { class MYNTEYE_API LogSink {
public: public:
virtual ~LogSink() {} virtual ~LogSink() {}
virtual void send(LogSeverity severity, virtual void send(
const char* full_filename, LogSeverity severity, const char *full_filename,
const char* base_filename, const char *base_filename, int line, const struct tm *tm_time,
int line, const char *message, size_t message_len) = 0;
const struct tm* tm_time,
const char* message,
size_t message_len) = 0;
virtual void WaitTillSent() = 0; virtual void WaitTillSent() = 0;
}; };
@ -160,7 +157,7 @@ MYNTEYE_API extern std::set<LogSink *> log_sinks_global;
// Added by chachi - a runtime global maximum log level. Defined in logging.cc // Added by chachi - a runtime global maximum log level. Defined in logging.cc
MYNTEYE_API extern int log_severity_global; MYNTEYE_API extern int log_severity_global;
inline void InitGoogleLogging(char */*argv*/) { inline void InitGoogleLogging(char * /*argv*/) {
// Do nothing; this is ignored. // Do nothing; this is ignored.
} }
@ -186,7 +183,7 @@ inline void RemoveLogSink(LogSink *sink) {
class MYNTEYE_API MessageLogger { class MYNTEYE_API MessageLogger {
public: public:
MessageLogger(const char *file, int line, const char *tag, int severity) MessageLogger(const char *file, int line, const char *tag, int severity)
: file_(file), line_(line), tag_(tag), severity_(severity) { : file_(file), line_(line), tag_(tag), severity_(severity) {
// Pre-pend the stream with the file and line number. // Pre-pend the stream with the file and line number.
StripBasename(std::string(file), &filename_only_); StripBasename(std::string(file), &filename_only_);
stream_ << SeverityLabel() << "/" << filename_only_ << ":" << line << " "; stream_ << SeverityLabel() << "/" << filename_only_ << ":" << line << " ";
@ -208,8 +205,8 @@ class MYNTEYE_API MessageLogger {
// Bound the logging level. // Bound the logging level.
const int kMaxVerboseLevel = 2; const int kMaxVerboseLevel = 2;
int android_level_index = std::min(std::max(FATAL, severity_), int android_level_index =
kMaxVerboseLevel) - FATAL; std::min(std::max(FATAL, severity_), kMaxVerboseLevel) - FATAL;
int android_log_level = android_log_levels[android_level_index]; int android_log_level = android_log_levels[android_level_index];
// Output the log string the Android log at the appropriate level. // Output the log string the Android log at the appropriate level.
@ -217,9 +214,7 @@ class MYNTEYE_API MessageLogger {
// Indicate termination if needed. // Indicate termination if needed.
if (severity_ == FATAL) { if (severity_ == FATAL) {
__android_log_write(ANDROID_LOG_FATAL, __android_log_write(ANDROID_LOG_FATAL, tag_.c_str(), "terminating.\n");
tag_.c_str(),
"terminating.\n");
} }
#else #else
// If not building on Android, log all output to std::cerr. // If not building on Android, log all output to std::cerr.
@ -237,21 +232,24 @@ class MYNTEYE_API MessageLogger {
} }
// Return the stream associated with the logger object. // Return the stream associated with the logger object.
std::stringstream &stream() { return stream_; } std::stringstream &stream() {
return stream_;
}
private: private:
void LogToSinks(int severity) { void LogToSinks(int severity) {
time_t rawtime; time_t rawtime;
struct tm* timeinfo; struct tm *timeinfo;
time (&rawtime); time(&rawtime);
timeinfo = localtime(&rawtime); timeinfo = localtime_r(&rawtime);
std::set<google::LogSink*>::iterator iter; std::set<google::LogSink *>::iterator iter;
// Send the log message to all sinks. // Send the log message to all sinks.
for (iter = google::log_sinks_global.begin(); for (iter = google::log_sinks_global.begin();
iter != google::log_sinks_global.end(); ++iter) { iter != google::log_sinks_global.end(); ++iter) {
(*iter)->send(severity, file_.c_str(), filename_only_.c_str(), line_, (*iter)->send(
timeinfo, stream_.str().c_str(), stream_.str().size()); severity, file_.c_str(), filename_only_.c_str(), line_, timeinfo,
stream_.str().c_str(), stream_.str().size());
} }
} }
@ -307,17 +305,19 @@ class MYNTEYE_API MessageLogger {
// is not used" and "statement has no effect". // is not used" and "statement has no effect".
class MYNTEYE_API LoggerVoidify { class MYNTEYE_API LoggerVoidify {
public: public:
LoggerVoidify() { } LoggerVoidify() {}
// This has to be an operator with a precedence lower than << but // This has to be an operator with a precedence lower than << but
// higher than ?: // higher than ?:
void operator&(const std::ostream &/*s*/) { } void operator&(const std::ostream & /*s*/) {}
}; };
// Log only if condition is met. Otherwise evaluates to void. // Log only if condition is met. Otherwise evaluates to void.
#define LOG_IF(severity, condition) \ #define LOG_IF(severity, condition) \
(static_cast<int>(severity) > google::log_severity_global || !(condition)) ? \ (static_cast<int>(severity) > google::log_severity_global || !(condition)) \
(void) 0 : LoggerVoidify() & \ ? (void)0 \
MessageLogger((char *)__FILE__, __LINE__, "native", severity).stream() : LoggerVoidify() & \
MessageLogger((char *)__FILE__, __LINE__, "native", severity) \
.stream()
// Log only if condition is NOT met. Otherwise evaluates to void. // Log only if condition is NOT met. Otherwise evaluates to void.
#define LOG_IF_FALSE(severity, condition) LOG_IF(severity, !(condition)) #define LOG_IF_FALSE(severity, condition) LOG_IF(severity, !(condition))
@ -326,23 +326,23 @@ class MYNTEYE_API LoggerVoidify {
// google3 code is discouraged and the following shortcut exists for // google3 code is discouraged and the following shortcut exists for
// backward compatibility with existing code. // backward compatibility with existing code.
#ifdef MYNTEYE_MAX_LOG_LEVEL #ifdef MYNTEYE_MAX_LOG_LEVEL
# define LOG(n) LOG_IF(n, (n <= MYNTEYE_MAX_LOG_LEVEL)) #define LOG(n) LOG_IF(n, (n <= MYNTEYE_MAX_LOG_LEVEL))
# define VLOG(n) LOG_IF(n, (n <= MYNTEYE_MAX_LOG_LEVEL)) #define VLOG(n) LOG_IF(n, (n <= MYNTEYE_MAX_LOG_LEVEL))
# define LG LOG_IF(INFO, (INFO <= MYNTEYE_MAX_LOG_LEVEL)) #define LG LOG_IF(INFO, (INFO <= MYNTEYE_MAX_LOG_LEVEL))
# define VLOG_IF(n, condition) \ #define VLOG_IF(n, condition) \
LOG_IF(n, (n <= MYNTEYE_MAX_LOG_LEVEL) && condition) LOG_IF(n, (n <= MYNTEYE_MAX_LOG_LEVEL) && condition)
#else #else
# define LOG(n) LOG_IF(n, true) #define LOG(n) LOG_IF(n, true)
# define VLOG(n) LOG_IF(n, true) #define VLOG(n) LOG_IF(n, true)
# define LG LOG_IF(INFO, true) #define LG LOG_IF(INFO, true)
# define VLOG_IF(n, condition) LOG_IF(n, condition) #define VLOG_IF(n, condition) LOG_IF(n, condition)
#endif #endif
// Currently, VLOG is always on for levels below MYNTEYE_MAX_LOG_LEVEL. // Currently, VLOG is always on for levels below MYNTEYE_MAX_LOG_LEVEL.
#ifndef MYNTEYE_MAX_LOG_LEVEL #ifndef MYNTEYE_MAX_LOG_LEVEL
# define VLOG_IS_ON(x) (1) #define VLOG_IS_ON(x) (1)
#else #else
# define VLOG_IS_ON(x) (x <= MYNTEYE_MAX_LOG_LEVEL) #define VLOG_IS_ON(x) (x <= MYNTEYE_MAX_LOG_LEVEL)
#endif #endif
#ifdef MYNTEYE_OS_WIN // INFO is 2, change VLOG(2) to VLOG(4) #ifdef MYNTEYE_OS_WIN // INFO is 2, change VLOG(2) to VLOG(4)
@ -351,32 +351,34 @@ class MYNTEYE_API LoggerVoidify {
#undef VLOG_IS_ON #undef VLOG_IS_ON
#ifdef MYNTEYE_MAX_LOG_LEVEL #ifdef MYNTEYE_MAX_LOG_LEVEL
# define VLOG(n) LOG_IF(n+2, (n+2 <= MYNTEYE_MAX_LOG_LEVEL)) #define VLOG(n) LOG_IF(n + 2, (n + 2 <= MYNTEYE_MAX_LOG_LEVEL))
# define VLOG_IF(n, condition) \ #define VLOG_IF(n, condition) \
LOG_IF(n+2, (n+2 <= MYNTEYE_MAX_LOG_LEVEL) && condition) LOG_IF(n + 2, (n + 2 <= MYNTEYE_MAX_LOG_LEVEL) && condition)
#else #else
# define VLOG(n) LOG_IF(n+2, true) #define VLOG(n) LOG_IF(n + 2, true)
# define VLOG_IF(n, condition) LOG_IF(n+2, condition) #define VLOG_IF(n, condition) LOG_IF(n + 2, condition)
#endif #endif
#ifndef MYNTEYE_MAX_LOG_LEVEL #ifndef MYNTEYE_MAX_LOG_LEVEL
# define VLOG_IS_ON(x) (1+2) #define VLOG_IS_ON(x) (1 + 2)
#else #else
# define VLOG_IS_ON(x) (x+2 <= MYNTEYE_MAX_LOG_LEVEL) #define VLOG_IS_ON(x) (x + 2 <= MYNTEYE_MAX_LOG_LEVEL)
#endif #endif
#endif #endif
#ifndef NDEBUG #ifndef NDEBUG
# define DLOG LOG #define DLOG LOG
#else #else
# define DLOG(severity) true ? (void) 0 : LoggerVoidify() & \ #define DLOG(severity) \
MessageLogger((char *)__FILE__, __LINE__, "native", severity).stream() true ? (void)0 \
: LoggerVoidify() & \
MessageLogger((char *)__FILE__, __LINE__, "native", severity) \
.stream()
#endif #endif
// Log a message and terminate. // Log a message and terminate.
template<class T> template <class T>
void LogMessageFatal(const char *file, int line, const T &message) { void LogMessageFatal(const char *file, int line, const T &message) {
MessageLogger(file, line, "native", FATAL).stream() << message; MessageLogger(file, line, "native", FATAL).stream() << message;
} }
@ -384,25 +386,27 @@ void LogMessageFatal(const char *file, int line, const T &message) {
// ---------------------------- CHECK macros --------------------------------- // ---------------------------- CHECK macros ---------------------------------
// Check for a given boolean condition. // Check for a given boolean condition.
#define CHECK(condition) LOG_IF_FALSE(FATAL, condition) \ #define CHECK(condition) \
<< "Check failed: " #condition " " LOG_IF_FALSE(FATAL, condition) << "Check failed: " #condition " "
#ifndef NDEBUG #ifndef NDEBUG
// Debug only version of CHECK // Debug only version of CHECK
# define DCHECK(condition) LOG_IF_FALSE(FATAL, condition) \ #define DCHECK(condition) \
<< "Check failed: " #condition " " LOG_IF_FALSE(FATAL, condition) << "Check failed: " #condition " "
#else #else
// Optimized version - generates no code. // Optimized version - generates no code.
# define DCHECK(condition) if (false) LOG_IF_FALSE(FATAL, condition) \ #define DCHECK(condition) \
<< "Check failed: " #condition " " if (false) \
LOG_IF_FALSE(FATAL, condition) << "Check failed: " #condition " "
#endif // NDEBUG #endif // NDEBUG
// ------------------------- CHECK_OP macros --------------------------------- // ------------------------- CHECK_OP macros ---------------------------------
// Generic binary operator check macro. This should not be directly invoked, // Generic binary operator check macro. This should not be directly invoked,
// instead use the binary comparison macros defined below. // instead use the binary comparison macros defined below.
#define CHECK_OP(val1, val2, op) LOG_IF_FALSE(FATAL, (val1 op val2)) \ #define CHECK_OP(val1, val2, op) \
<< "Check failed: " #val1 " " #op " " #val2 " " LOG_IF_FALSE(FATAL, (val1 op val2)) \
<< "Check failed: " #val1 " " #op " " #val2 " "
// Check_op macro definitions // Check_op macro definitions
#define CHECK_EQ(val1, val2) CHECK_OP(val1, val2, ==) #define CHECK_EQ(val1, val2) CHECK_OP(val1, val2, ==)
@ -414,20 +418,32 @@ void LogMessageFatal(const char *file, int line, const T &message) {
#ifndef NDEBUG #ifndef NDEBUG
// Debug only versions of CHECK_OP macros. // Debug only versions of CHECK_OP macros.
# define DCHECK_EQ(val1, val2) CHECK_OP(val1, val2, ==) #define DCHECK_EQ(val1, val2) CHECK_OP(val1, val2, ==)
# define DCHECK_NE(val1, val2) CHECK_OP(val1, val2, !=) #define DCHECK_NE(val1, val2) CHECK_OP(val1, val2, !=)
# define DCHECK_LE(val1, val2) CHECK_OP(val1, val2, <=) #define DCHECK_LE(val1, val2) CHECK_OP(val1, val2, <=)
# define DCHECK_LT(val1, val2) CHECK_OP(val1, val2, <) #define DCHECK_LT(val1, val2) CHECK_OP(val1, val2, <)
# define DCHECK_GE(val1, val2) CHECK_OP(val1, val2, >=) #define DCHECK_GE(val1, val2) CHECK_OP(val1, val2, >=)
# define DCHECK_GT(val1, val2) CHECK_OP(val1, val2, >) #define DCHECK_GT(val1, val2) CHECK_OP(val1, val2, >)
#else #else
// These versions generate no code in optimized mode. // These versions generate no code in optimized mode.
# define DCHECK_EQ(val1, val2) if (false) CHECK_OP(val1, val2, ==) #define DCHECK_EQ(val1, val2) \
# define DCHECK_NE(val1, val2) if (false) CHECK_OP(val1, val2, !=) if (false) \
# define DCHECK_LE(val1, val2) if (false) CHECK_OP(val1, val2, <=) CHECK_OP(val1, val2, ==)
# define DCHECK_LT(val1, val2) if (false) CHECK_OP(val1, val2, <) #define DCHECK_NE(val1, val2) \
# define DCHECK_GE(val1, val2) if (false) CHECK_OP(val1, val2, >=) if (false) \
# define DCHECK_GT(val1, val2) if (false) CHECK_OP(val1, val2, >) CHECK_OP(val1, val2, !=)
#define DCHECK_LE(val1, val2) \
if (false) \
CHECK_OP(val1, val2, <=)
#define DCHECK_LT(val1, val2) \
if (false) \
CHECK_OP(val1, val2, <)
#define DCHECK_GE(val1, val2) \
if (false) \
CHECK_OP(val1, val2, >=)
#define DCHECK_GT(val1, val2) \
if (false) \
CHECK_OP(val1, val2, >)
#endif // NDEBUG #endif // NDEBUG
// ---------------------------CHECK_NOTNULL macros --------------------------- // ---------------------------CHECK_NOTNULL macros ---------------------------
@ -435,7 +451,7 @@ void LogMessageFatal(const char *file, int line, const T &message) {
// Helpers for CHECK_NOTNULL(). Two are necessary to support both raw pointers // Helpers for CHECK_NOTNULL(). Two are necessary to support both raw pointers
// and smart pointers. // and smart pointers.
template <typename T> template <typename T>
T& CheckNotNullCommon(const char *file, int line, const char *names, T& t) { T &CheckNotNullCommon(const char *file, int line, const char *names, T &t) {
if (t == NULL) { if (t == NULL) {
LogMessageFatal(file, line, std::string(names)); LogMessageFatal(file, line, std::string(names));
} }
@ -443,12 +459,12 @@ T& CheckNotNullCommon(const char *file, int line, const char *names, T& t) {
} }
template <typename T> template <typename T>
T* CheckNotNull(const char *file, int line, const char *names, T* t) { T *CheckNotNull(const char *file, int line, const char *names, T *t) {
return CheckNotNullCommon(file, line, names, t); return CheckNotNullCommon(file, line, names, t);
} }
template <typename T> template <typename T>
T& CheckNotNull(const char *file, int line, const char *names, T& t) { T &CheckNotNull(const char *file, int line, const char *names, T &t) {
return CheckNotNullCommon(file, line, names, t); return CheckNotNullCommon(file, line, names, t);
} }
@ -462,7 +478,8 @@ T& CheckNotNull(const char *file, int line, const char *names, T& t) {
CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val)) CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val))
#else #else
// Optimized version - generates no code. // Optimized version - generates no code.
#define DCHECK_NOTNULL(val) if (false)\ #define DCHECK_NOTNULL(val) \
if (false) \
CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val)) CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val))
#endif // NDEBUG #endif // NDEBUG

View File

@ -13,8 +13,8 @@
// limitations under the License. // limitations under the License.
#include <opencv2/highgui/highgui.hpp> #include <opencv2/highgui/highgui.hpp>
#include "mynteye/logger.h"
#include "mynteye/api.h" #include "mynteye/api.h"
#include "mynteye/logger.h"
#include "mynteye/times.h" #include "mynteye/times.h"
MYNTEYE_USE_NAMESPACE MYNTEYE_USE_NAMESPACE

View File

@ -90,7 +90,9 @@ bool dir_exists(const std::string &p) {
std::vector<std::string> get_plugin_paths() { std::vector<std::string> get_plugin_paths() {
std::string info_path(MYNTEYE_SDK_INSTALL_DIR); std::string info_path(MYNTEYE_SDK_INSTALL_DIR);
info_path.append(MYNTEYE_OS_SEP "share" MYNTEYE_OS_SEP "mynteye" MYNTEYE_OS_SEP "build.info"); info_path.append(
MYNTEYE_OS_SEP "share" MYNTEYE_OS_SEP "mynteye" MYNTEYE_OS_SEP
"build.info");
cv::FileStorage fs(info_path, cv::FileStorage::READ); cv::FileStorage fs(info_path, cv::FileStorage::READ);
if (!fs.isOpened()) { if (!fs.isOpened()) {

View File

@ -21,8 +21,8 @@
#include <gflags/gflags.h> #include <gflags/gflags.h>
#endif #endif
#include "mynteye/mynteye.h"
#include "mynteye/logger.h" #include "mynteye/logger.h"
#include "mynteye/mynteye.h"
int main(int /*argc*/, char *argv[]) { int main(int /*argc*/, char *argv[]) {
// Set whether log messages go to stderr instead of logfiles // Set whether log messages go to stderr instead of logfiles

1
third_party/glog vendored

@ -1 +0,0 @@
Subproject commit 8d7a107d68c127f3f494bb7807b796c8c5a97a82

View File

@ -20,8 +20,8 @@
#include "mynteye/device.h" #include "mynteye/device.h"
#include "mynteye/files.h" #include "mynteye/files.h"
#include "mynteye/types.h"
#include "mynteye/logger.h" #include "mynteye/logger.h"
#include "mynteye/types.h"
#include "internal/types.h" #include "internal/types.h"
@ -231,7 +231,8 @@ void DeviceWriter::SaveAllInfos(const std::string &dir) {
} }
SaveDeviceInfo(*device_->GetInfo(), dir + MYNTEYE_OS_SEP "device.info"); SaveDeviceInfo(*device_->GetInfo(), dir + MYNTEYE_OS_SEP "device.info");
SaveImgParams( SaveImgParams(
*device_->GetInfo(), device_->GetImgParams(), dir + MYNTEYE_OS_SEP "img.params"); *device_->GetInfo(), device_->GetImgParams(),
dir + MYNTEYE_OS_SEP "img.params");
auto &&m_in = device_->GetMotionIntrinsics(); auto &&m_in = device_->GetMotionIntrinsics();
SaveImuParams( SaveImuParams(
{ {