From 241d6cd286e09316cb0da2fcb831a36ef617345f Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Thu, 9 Mar 2023 14:40:16 +0100 Subject: [PATCH] add logging to integer/linear_programming; keep absl log symbols in libortools, enable GLPK in bazel --- examples/cpp/integer_programming.cc | 1 + examples/cpp/linear_programming.cc | 1 + ortools/base/CMakeLists.txt | 3 +++ ortools/base/logging.cc | 4 ++++ ortools/linear_solver/BUILD.bazel | 8 ++++++-- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/examples/cpp/integer_programming.cc b/examples/cpp/integer_programming.cc index a70082467d..cb5f98909d 100644 --- a/examples/cpp/integer_programming.cc +++ b/examples/cpp/integer_programming.cc @@ -92,6 +92,7 @@ void RunAllExamples() { int main(int argc, char** argv) { InitGoogle(argv[0], &argc, &argv, true); + absl::SetFlag(&FLAGS_stderrthreshold, 0); operations_research::RunAllExamples(); return EXIT_SUCCESS; } diff --git a/examples/cpp/linear_programming.cc b/examples/cpp/linear_programming.cc index 7eccf4e33b..427fd7bff1 100644 --- a/examples/cpp/linear_programming.cc +++ b/examples/cpp/linear_programming.cc @@ -122,6 +122,7 @@ void RunAllExamples() { int main(int argc, char** argv) { InitGoogle(argv[0], &argc, &argv, true); + absl::SetFlag(&FLAGS_stderrthreshold, 0); operations_research::RunAllExamples(); return EXIT_SUCCESS; } diff --git a/ortools/base/CMakeLists.txt b/ortools/base/CMakeLists.txt index 676883bac9..cf2c03c010 100644 --- a/ortools/base/CMakeLists.txt +++ b/ortools/base/CMakeLists.txt @@ -34,6 +34,9 @@ target_include_directories(${NAME} PRIVATE target_link_libraries(${NAME} PRIVATE ZLIB::ZLIB absl::base + absl::log + absl::log_flags + absl::log_initialize absl::strings absl::str_format protobuf::libprotobuf diff --git a/ortools/base/logging.cc b/ortools/base/logging.cc index 2bf15a979e..a10b6bd405 100644 --- a/ortools/base/logging.cc +++ b/ortools/base/logging.cc @@ -36,4 +36,8 @@ void FixFlagsAndEnvironmentForSwig() { absl::EnableLogPrefix(false); } +void KeepAbslSymbols() { + absl::SetFlag(&FLAGS_stderrthreshold, 0); +} + } // namespace operations_research diff --git a/ortools/linear_solver/BUILD.bazel b/ortools/linear_solver/BUILD.bazel index 662c841529..85e3bdfd88 100644 --- a/ortools/linear_solver/BUILD.bazel +++ b/ortools/linear_solver/BUILD.bazel @@ -113,7 +113,10 @@ cc_library( "-DUSE_PDLP", "-DUSE_SCIP", "-DUSE_HIGHS", - ], + ] + select({ + ":with_glpk": ["-DUSE_GLPK"], + "//conditions:default": [], + }), deps = [ ":linear_solver_cc_proto", ":scip_with_glop", @@ -150,7 +153,8 @@ cc_library( "//ortools/util:fp_utils", "//ortools/util:lazy_mutable_copy", ] + select({ - ":with_glpk": ["@glpk//:glpk"], + ":with_glpk": ["@glpk//:glpk", + "//ortools/glpk:glpk_env_deleter"], "//conditions:default": [], }), )