Apply LTS transformations for 20260526 LTS branch (#2063)
* Apply LTS transformations for 20260526 LTS branch
* [Cherry-pick] Fix logging when absl::SourceLocation is an alias of std::source_location
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3583e3d..2b6bbfe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,8 +23,8 @@
cmake_policy(SET CMP0141 NEW)
endif (POLICY CMP0141)
-project(absl LANGUAGES CXX)
-set(ABSL_SOVERSION 0)
+project(absl LANGUAGES CXX VERSION 20260526)
+set(ABSL_SOVERSION "2605.0.0")
include(CTest)
# Output directory is correct by default for most build setups. However, when
@@ -170,17 +170,7 @@
add_subdirectory(absl)
if(ABSL_ENABLE_INSTALL)
- # absl:lts-remove-begin(system installation is supported for LTS releases)
- # We don't support system-wide installation
- list(APPEND SYSTEM_INSTALL_DIRS "/usr/local" "/usr" "/opt/" "/opt/local" "c:/Program Files/${PROJECT_NAME}")
- if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX IN_LIST SYSTEM_INSTALL_DIRS)
- message(WARNING "\
- The default and system-level install directories are unsupported except in LTS \
- releases of Abseil. Please set CMAKE_INSTALL_PREFIX to install Abseil in your \
- source or build tree directly.\
- ")
- endif()
- # absl:lts-remove-end
+
# install as a subdirectory only
install(EXPORT ${PROJECT_NAME}Targets
diff --git a/MODULE.bazel b/MODULE.bazel
index cc60d22..7ed0b92 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -16,7 +16,7 @@
module(
name = "abseil-cpp",
- version = "head",
+ version = "20260526.0",
)
cc_configure = use_extension("@rules_cc//cc:extensions.bzl",
diff --git a/absl/base/config.h b/absl/base/config.h
index d4a7bfb..6b2c81c 100644
--- a/absl/base/config.h
+++ b/absl/base/config.h
@@ -117,8 +117,8 @@
//
// LTS releases can be obtained from
// https://github.com/abseil/abseil-cpp/releases.
-#undef ABSL_LTS_RELEASE_VERSION
-#undef ABSL_LTS_RELEASE_PATCH_LEVEL
+#define ABSL_LTS_RELEASE_VERSION 20260526
+#define ABSL_LTS_RELEASE_PATCH_LEVEL 0
// Helper macro to convert a CPP variable to a string literal.
#define ABSL_INTERNAL_DO_TOKEN_STR(x) #x
diff --git a/absl/base/options.h b/absl/base/options.h
index 033eac3..bc344e9 100644
--- a/absl/base/options.h
+++ b/absl/base/options.h
@@ -150,8 +150,8 @@
// be changed to a new, unique identifier name. In particular "head" is not
// allowed.
-#define ABSL_OPTION_USE_INLINE_NAMESPACE 0
-#define ABSL_OPTION_INLINE_NAMESPACE_NAME head
+#define ABSL_OPTION_USE_INLINE_NAMESPACE 1
+#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_20260526
// ABSL_OPTION_HARDENED
//
diff --git a/absl/log/BUILD.bazel b/absl/log/BUILD.bazel
index e6793b1..b1cff4b 100644
--- a/absl/log/BUILD.bazel
+++ b/absl/log/BUILD.bazel
@@ -502,6 +502,7 @@
"//absl/log/internal:test_matchers",
"//absl/strings",
"//absl/strings:str_format",
+ "//absl/types:source_location",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
diff --git a/absl/log/CMakeLists.txt b/absl/log/CMakeLists.txt
index b271d09..e0a307b 100644
--- a/absl/log/CMakeLists.txt
+++ b/absl/log/CMakeLists.txt
@@ -1017,6 +1017,7 @@
absl::log
absl::log_internal_test_matchers
absl::scoped_mock_log
+ absl::source_location
absl::str_format
absl::strings
GTest::gmock_main
diff --git a/absl/log/internal/log_message.h b/absl/log/internal/log_message.h
index 7e2a86a..b9b533e 100644
--- a/absl/log/internal/log_message.h
+++ b/absl/log/internal/log_message.h
@@ -179,6 +179,13 @@
LogMessage& operator<<(wchar_t* absl_nullable v);
LogMessage& operator<<(wchar_t v);
+ // Overload for absl::SourceLocation or the std::source_location alias.
+ LogMessage& operator<<(const absl::SourceLocation& loc) {
+ OstreamView view(*data_);
+ view.stream() << loc.file_name() << ':' << loc.line();
+ return *this;
+ }
+
// Handle stream manipulators e.g. std::endl.
LogMessage& operator<<(std::ostream& (*absl_nonnull m)(std::ostream& os));
LogMessage& operator<<(std::ios_base& (*absl_nonnull m)(std::ios_base& os));
diff --git a/absl/log/log_format_test.cc b/absl/log/log_format_test.cc
index b23d90f..06ce2f5 100644
--- a/absl/log/log_format_test.cc
+++ b/absl/log/log_format_test.cc
@@ -41,6 +41,7 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
+#include "absl/types/source_location.h"
namespace {
using ::absl::log_internal::AsString;
@@ -291,6 +292,21 @@
LOG(INFO) << value.bits;
}
+TEST(SourceLocationTest, Format) {
+ absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected);
+ EXPECT_CALL(test_sink, Send).Times(0);
+
+ absl::SourceLocation loc = absl::SourceLocation::current();
+ std::string expected = absl::StrCat(__FILE__, ":", __LINE__ - 1);
+
+ EXPECT_CALL(test_sink, Send(AllOf(TextMessage(Eq(expected)),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ ValueWithStr(Eq(expected))))))));
+
+ test_sink.StartCapturingLogs();
+ LOG(INFO) << loc;
+}
+
// Ignore these test cases on GCC due to "is too small to hold all values ..."
// warning.
#if !defined(__GNUC__) || defined(__clang__)