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

@ -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;
}; };
@ -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,7 +232,9 @@ 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) {
@ -245,13 +242,14 @@ class MYNTEYE_API MessageLogger {
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());
} }
} }
@ -315,9 +313,11 @@ class MYNTEYE_API LoggerVoidify {
// 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))
@ -370,11 +370,13 @@ class MYNTEYE_API LoggerVoidify {
#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) {
@ -384,24 +386,26 @@ 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) \
LOG_IF_FALSE(FATAL, (val1 op val2)) \
<< "Check failed: " #val1 " " #op " " #val2 " " << "Check failed: " #val1 " " #op " " #val2 " "
// Check_op macro definitions // Check_op macro definitions
@ -422,12 +426,24 @@ void LogMessageFatal(const char *file, int line, const T &message) {
#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 ---------------------------
@ -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(
{ {