update base library

This commit is contained in:
Laurent Perron
2022-09-09 16:42:22 +02:00
parent 06f3057ebc
commit 79aaf280bd
16 changed files with 1706 additions and 1501 deletions

View File

@@ -31,52 +31,36 @@ config_setting(
cc_library(
name = "base",
srcs = [
"commandlineflags.cc",
"logging.cc",
"logging_utilities.cc",
"raw_logging.cc",
"version.cc",
"vlog_is_on.cc",
],
hdrs = [
"basictypes.h",
"commandlineflags.h",
"init_google.h",
"integral_types.h",
"log_severity.h",
"logging.h",
"logging_export.h",
"logging_flags.h",
"logging_utilities.h",
"macros.h",
"raw_logging.h",
"stl_logging.h",
"version.h",
"vlog_is_on.h",
],
copts = [
"-DOR_TOOLS_MAJOR=9999",
"-DOR_TOOLS_MINOR=0",
"-DOR_TOOLS_PATCH=0",
],
defines = select({
"on_linux": [],
"on_macos": [],
"on_windows": ["OR_TOOLS_EXPORTS"], # For logging_export.h
"//conditions:default": [],
}),
deps = [
":basictypes",
":check",
":commandlineflags",
":integral_types",
":log",
":logging",
":logging_extensions",
":macros",
":sysinfo",
":vlog",
"@com_google_absl//absl/base",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/container:node_hash_map",
"@com_google_absl//absl/container:node_hash_set",
"@com_google_absl//absl/debugging:failure_signal_handler",
"@com_google_absl//absl/debugging:stacktrace",
"@com_google_absl//absl/debugging:symbolize",
"@com_google_absl//absl/flags:commandlineflag",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
],
)
@@ -84,7 +68,6 @@ cc_library(
cc_library(
name = "accurate_sum",
hdrs = ["accurate_sum.h"],
deps = [":base"],
)
cc_library(
@@ -96,6 +79,15 @@ cc_library(
deps = [":base"],
)
cc_library(
name = "basictypes",
hdrs = ["basictypes.h"],
deps = [
":integral_types",
":logging",
],
)
cc_library(
name = "bitmap",
srcs = ["bitmap.cc"],
@@ -110,12 +102,37 @@ cc_library(
deps = [":base"],
)
cc_library(
name = "check",
hdrs = ["check.h"],
deps = [
":log",
":log_severity",
":logging_export",
],
)
cc_library(
name = "cleanup",
hdrs = ["cleanup.h"],
deps = [":base"],
)
cc_library(
name = "commandlineflags",
srcs = [
"commandlineflags.cc",
],
hdrs = ["commandlineflags.h"],
deps = [
":logging",
":logging_extensions",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/flags:usage",
],
)
cc_library(
name = "container_logging",
hdrs = ["container_logging.h"],
@@ -140,6 +157,14 @@ cc_library(
deps = [":base"],
)
cc_library(
name = "flags",
hdrs = ["flags.h"],
deps = [
"@com_google_absl//absl/flags:flag",
],
)
cc_library(
name = "file",
srcs = ["file.cc"],
@@ -184,6 +209,11 @@ cc_library(
deps = [":base"],
)
cc_library(
name = "integral_types",
hdrs = ["integral_types.h"],
)
cc_library(
name = "intops",
hdrs = ["strong_int.h"],
@@ -206,10 +236,79 @@ cc_library(
],
)
cc_library(
name = "log",
srcs = [
"log.cc",
"logging_utilities.cc",
"logging_utilities.h",
"raw_logging.cc",
"raw_logging.h",
"vlog_is_on.cc",
],
hdrs = [
"check.h",
"die_if_null.h",
"log.h",
],
deps = [
":flags",
":integral_types",
":log_severity",
":logging_export",
":logging_extensions",
":macros",
":vlog",
"@com_google_absl//absl/debugging:failure_signal_handler",
"@com_google_absl//absl/debugging:stacktrace",
"@com_google_absl//absl/debugging:symbolize",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/time",
],
)
cc_library(
name = "log_severity",
hdrs = ["log_severity.h"],
deps = [
":logging_export",
],
)
cc_library(
name = "logging",
hdrs = ["logging.h"],
deps = [
":check",
":log",
":log_severity",
":logging_extensions",
":vlog",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
],
)
cc_library(
name = "logging_export",
hdrs = ["logging_export.h"],
defines = select({
"on_linux": [],
"on_macos": [],
"on_windows": ["OR_TOOLS_EXPORTS"], # For logging_export.h
"//conditions:default": [],
}),
)
cc_library(
name = "logging_extensions",
hdrs = ["logging_extensions.h"],
deps = [":base"],
)
cc_library(
name = "macros",
hdrs = ["macros.h"],
)
cc_library(
@@ -342,7 +441,7 @@ cc_library(
srcs = ["sysinfo.cc"],
hdrs = ["sysinfo.h"],
deps = [
":base",
":basictypes",
"@com_google_absl//absl/strings",
],
)
@@ -362,7 +461,9 @@ cc_library(
srcs = ["timer.cc"],
hdrs = ["timer.h"],
deps = [
":base",
":basictypes",
":check",
":macros",
"@com_google_absl//absl/time",
],
)
@@ -371,3 +472,12 @@ cc_library(
name = "typeid",
hdrs = ["typeid.h"],
)
cc_library(
name = "vlog",
hdrs = ["vlog_is_on.h"],
deps = [
":integral_types",
":log_severity",
],
)

View File

@@ -14,7 +14,8 @@
#ifndef OR_TOOLS_BASE_BITMAP_H_
#define OR_TOOLS_BASE_BITMAP_H_
#include <string.h>
#include <cassert>
#include <cstring>
#include "ortools/base/basictypes.h"

19
ortools/base/check.h Normal file
View File

@@ -0,0 +1,19 @@
// Copyright 2010-2022 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OR_TOOLS_BASE_CHECK_H_
#define OR_TOOLS_BASE_CHECK_H_
#include "ortools/base/log.h"
#endif // OR_TOOLS_BASE_CHECK_H_

View File

@@ -0,0 +1,19 @@
// Copyright 2010-2022 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OR_TOOLS_BASE_DIE_IF_NULL_H_
#define OR_TOOLS_BASE_DIE_IF_NULL_H_
#include "ortools/base/log.h"
#endif // OR_TOOLS_BASE_DIE_IF_NULL_H_

77
ortools/base/flags.h Normal file
View File

@@ -0,0 +1,77 @@
// Copyright 2010-2022 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OR_TOOLS_BASE_FLAGS_H_
#define OR_TOOLS_BASE_FLAGS_H_
#include <string>
#include "absl/flags/declare.h"
#include "absl/flags/flag.h"
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// These flags should not be used in C++ code to access logging library
// configuration knobs. Use interfaces defined in ortools/base/globals.h
// instead. It is still ok to use these flags on a command line.
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Set whether log messages go to stderr *instead* of logfiles.
ABSL_DECLARE_FLAG(bool, logtostderr);
// Set whether log messages go to stderr in addition to logfiles.
ABSL_DECLARE_FLAG(bool, alsologtostderr);
// Log messages at a level >= this flag are automatically sent to
// stderr in addition to log files.
ABSL_DECLARE_FLAG(int, stderrthreshold);
// Log suppression level: messages logged at a lower level than this
// are suppressed.
ABSL_DECLARE_FLAG(int, minloglevel);
// Log messages at a level <= this flag are buffered.
// Log messages at a higher level are flushed immediately.
ABSL_DECLARE_FLAG(int, logbuflevel);
// Set whether the log prefix should be prepended to each line of output.
ABSL_DECLARE_FLAG(bool, log_prefix);
// Global lob verbosity level. Default in vlog_is_on.cc
ABSL_DECLARE_FLAG(int, v);
// Not in ABSL log/inernal/flags.h
// Set color messages logged to stderr (if supported by terminal).
ABSL_DECLARE_FLAG(bool, colorlogtostderr);
// Sets the maximum number of seconds which logs may be buffered for.
ABSL_DECLARE_FLAG(int, logbufsecs);
// If specified, logfiles are written into this directory instead of the
// default logging directory.
ABSL_DECLARE_FLAG(std::string, log_dir);
// Set the log file mode.
ABSL_DECLARE_FLAG(int, logfile_mode);
// Sets the path of the directory into which to put additional links
// to the log files.
ABSL_DECLARE_FLAG(std::string, log_link);
// Sets the maximum log file size (in MB).
ABSL_DECLARE_FLAG(int, max_log_size);
// Sets whether to avoid logging to the disk if the disk is full.
ABSL_DECLARE_FLAG(bool, stop_logging_if_full_disk);
#endif // OR_TOOLS_BASE_FLAGS_H_

View File

@@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "ortools/base/logging.h"
#include "ortools/base/log.h"
#define _GNU_SOURCE 1 // needed for O_NOFOLLOW and pread()/pwrite()
@@ -47,7 +47,6 @@
#include "absl/debugging/stacktrace.h"
#include "absl/time/time.h"
#include "ortools/base/commandlineflags.h"
#include "ortools/base/logging_utilities.h"
#include "ortools/base/raw_logging.h"

1432
ortools/base/log.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -142,7 +142,7 @@ static pthread_t g_main_thread_id;
#include "absl/debugging/stacktrace.h"
#include "absl/debugging/symbolize.h"
#include "absl/time/time.h"
#include "ortools/base/commandlineflags.h"
#include "ortools/base/check.h"
ABSL_FLAG(bool, symbolize_stacktrace, true,
"Symbolize the stack trace in the tombstone");

View File

@@ -19,7 +19,6 @@
#include "absl/base/internal/sysinfo.h" // for GetTID().
#include "absl/base/macros.h"
#include "absl/synchronization/mutex.h"
#include "ortools/base/logging.h"
namespace google {
namespace logging_internal {

View File

@@ -21,8 +21,9 @@
#include "absl/base/macros.h"
#include "absl/debugging/stacktrace.h"
#include "ortools/base/commandlineflags.h"
#include "ortools/base/logging.h"
#include "ortools/base/flags.h"
#include "ortools/base/log.h"
#include "ortools/base/log_severity.h"
#include "ortools/base/logging_utilities.h"
#if !defined(_MSC_VER)

View File

@@ -15,6 +15,7 @@
#define OR_TOOLS_BASE_RAW_LOGGING_H_
#include "ortools/base/log_severity.h"
#include "ortools/base/logging_export.h"
#include "ortools/base/vlog_is_on.h"
namespace google {

View File

@@ -13,7 +13,7 @@
#include "ortools/base/threadpool.h"
#include "ortools/base/logging.h"
#include "ortools/base/check.h"
namespace operations_research {
void RunWorker(void* data) {

View File

@@ -13,6 +13,8 @@
#include "ortools/base/timer.h"
#include "ortools/base/check.h"
ScopedWallTime::ScopedWallTime(double* aggregate_time)
: aggregate_time_(aggregate_time), timer_() {
DCHECK(aggregate_time != nullptr);

View File

@@ -17,7 +17,6 @@
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "ortools/base/basictypes.h"
#include "ortools/base/logging.h"
#include "ortools/base/macros.h"
class WallTimer {

View File

@@ -21,9 +21,8 @@
#include <string>
#include "absl/synchronization/mutex.h"
#include "ortools/base/commandlineflags.h"
#include "ortools/base/log.h"
#include "ortools/base/log_severity.h"
#include "ortools/base/logging.h"
#include "ortools/base/logging_utilities.h"
#include "ortools/base/raw_logging.h"