Skip to content

Commit b29e7f9

Browse files
authored
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
1 parent 147d631 commit b29e7f9

8 files changed

Lines changed: 33 additions & 18 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ if (POLICY CMP0141)
2323
cmake_policy(SET CMP0141 NEW)
2424
endif (POLICY CMP0141)
2525

26-
project(absl LANGUAGES CXX)
27-
set(ABSL_SOVERSION 0)
26+
project(absl LANGUAGES CXX VERSION 20260526)
27+
set(ABSL_SOVERSION "2605.0.0")
2828
include(CTest)
2929

3030
# Output directory is correct by default for most build setups. However, when
@@ -170,17 +170,7 @@ endif()
170170
add_subdirectory(absl)
171171

172172
if(ABSL_ENABLE_INSTALL)
173-
# absl:lts-remove-begin(system installation is supported for LTS releases)
174-
# We don't support system-wide installation
175-
list(APPEND SYSTEM_INSTALL_DIRS "/usr/local" "/usr" "/opt/" "/opt/local" "c:/Program Files/${PROJECT_NAME}")
176-
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX IN_LIST SYSTEM_INSTALL_DIRS)
177-
message(WARNING "\
178-
The default and system-level install directories are unsupported except in LTS \
179-
releases of Abseil. Please set CMAKE_INSTALL_PREFIX to install Abseil in your \
180-
source or build tree directly.\
181-
")
182-
endif()
183-
# absl:lts-remove-end
173+
184174

185175
# install as a subdirectory only
186176
install(EXPORT ${PROJECT_NAME}Targets

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
module(
1818
name = "abseil-cpp",
19-
version = "head",
19+
version = "20260526.0",
2020
)
2121

2222
cc_configure = use_extension("@rules_cc//cc:extensions.bzl",

absl/base/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@
117117
//
118118
// LTS releases can be obtained from
119119
// https://github.com/abseil/abseil-cpp/releases.
120-
#undef ABSL_LTS_RELEASE_VERSION
121-
#undef ABSL_LTS_RELEASE_PATCH_LEVEL
120+
#define ABSL_LTS_RELEASE_VERSION 20260526
121+
#define ABSL_LTS_RELEASE_PATCH_LEVEL 0
122122

123123
// Helper macro to convert a CPP variable to a string literal.
124124
#define ABSL_INTERNAL_DO_TOKEN_STR(x) #x

absl/base/options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@
150150
// be changed to a new, unique identifier name. In particular "head" is not
151151
// allowed.
152152

153-
#define ABSL_OPTION_USE_INLINE_NAMESPACE 0
154-
#define ABSL_OPTION_INLINE_NAMESPACE_NAME head
153+
#define ABSL_OPTION_USE_INLINE_NAMESPACE 1
154+
#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_20260526
155155

156156
// ABSL_OPTION_HARDENED
157157
//

absl/log/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ cc_test(
502502
"//absl/log/internal:test_matchers",
503503
"//absl/strings",
504504
"//absl/strings:str_format",
505+
"//absl/types:source_location",
505506
"@googletest//:gtest",
506507
"@googletest//:gtest_main",
507508
],

absl/log/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ absl_cc_test(
10171017
absl::log
10181018
absl::log_internal_test_matchers
10191019
absl::scoped_mock_log
1020+
absl::source_location
10201021
absl::str_format
10211022
absl::strings
10221023
GTest::gmock_main

absl/log/internal/log_message.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ class LogMessage {
179179
LogMessage& operator<<(wchar_t* absl_nullable v);
180180
LogMessage& operator<<(wchar_t v);
181181

182+
// Overload for absl::SourceLocation or the std::source_location alias.
183+
LogMessage& operator<<(const absl::SourceLocation& loc) {
184+
OstreamView view(*data_);
185+
view.stream() << loc.file_name() << ':' << loc.line();
186+
return *this;
187+
}
188+
182189
// Handle stream manipulators e.g. std::endl.
183190
LogMessage& operator<<(std::ostream& (*absl_nonnull m)(std::ostream& os));
184191
LogMessage& operator<<(std::ios_base& (*absl_nonnull m)(std::ios_base& os));

absl/log/log_format_test.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "absl/strings/str_cat.h"
4242
#include "absl/strings/str_format.h"
4343
#include "absl/strings/string_view.h"
44+
#include "absl/types/source_location.h"
4445

4546
namespace {
4647
using ::absl::log_internal::AsString;
@@ -291,6 +292,21 @@ TYPED_TEST(SignedIntLogFormatTest, BitfieldNegative) {
291292
LOG(INFO) << value.bits;
292293
}
293294

295+
TEST(SourceLocationTest, Format) {
296+
absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected);
297+
EXPECT_CALL(test_sink, Send).Times(0);
298+
299+
absl::SourceLocation loc = absl::SourceLocation::current();
300+
std::string expected = absl::StrCat(__FILE__, ":", __LINE__ - 1);
301+
302+
EXPECT_CALL(test_sink, Send(AllOf(TextMessage(Eq(expected)),
303+
ENCODED_MESSAGE(HasValues(ElementsAre(
304+
ValueWithStr(Eq(expected))))))));
305+
306+
test_sink.StartCapturingLogs();
307+
LOG(INFO) << loc;
308+
}
309+
294310
// Ignore these test cases on GCC due to "is too small to hold all values ..."
295311
// warning.
296312
#if !defined(__GNUC__) || defined(__clang__)

0 commit comments

Comments
 (0)