lib/fmt: require libfmt 9

Version 9 added the "debug format" which I'd like to use.
This commit is contained in:
Max Kellermann 2024-04-16 11:31:07 +02:00
parent 08810991c2
commit 39c9e92f42
12 changed files with 7 additions and 103 deletions

View File

@ -98,7 +98,7 @@ jobs:
with: with:
action: build action: build
directory: output/full directory: output/full
setup-options: -Ddocumentation=disabled -Dtest=true -Dsystemd=enabled -Dpcre=enabled setup-options: -Ddocumentation=disabled -Dtest=true -Dsystemd=enabled -Dpcre=enabled --force-fallback-for=fmt
options: --verbose options: --verbose
meson-version: 0.56.0 meson-version: 0.56.0
@ -107,7 +107,7 @@ jobs:
with: with:
action: test action: test
directory: output/full directory: output/full
setup-options: -Ddocumentation=disabled -Dtest=true -Dsystemd=enabled -Dpcre=enabled setup-options: -Ddocumentation=disabled -Dtest=true -Dsystemd=enabled -Dpcre=enabled --force-fallback-for=fmt
options: --verbose options: --verbose
meson-version: 0.56.0 meson-version: 0.56.0
@ -116,7 +116,7 @@ jobs:
with: with:
action: build action: build
directory: output/mini directory: output/mini
setup-options: -Dbuildtype=minsize -Dauto_features=disabled -Dtest=true -Ddaemon=false -Dinotify=false -Depoll=false -Deventfd=false -Dsignalfd=false -Dtcp=false -Ddsd=false -Ddatabase=false -Dneighbor=false -Dcue=false -Dfifo=false -Dhttpd=false -Dpipe=false -Drecorder=false -Dsnapcast=false setup-options: -Dbuildtype=minsize -Dauto_features=disabled -Dtest=true -Ddaemon=false -Dinotify=false -Depoll=false -Deventfd=false -Dsignalfd=false -Dtcp=false -Ddsd=false -Ddatabase=false -Dneighbor=false -Dcue=false -Dfifo=false -Dhttpd=false -Dpipe=false -Drecorder=false -Dsnapcast=false --force-fallback-for=fmt
options: --verbose options: --verbose
meson-version: 0.56.0 meson-version: 0.56.0

2
NEWS
View File

@ -55,7 +55,7 @@ ver 0.24 (not yet released)
- remove JACK DLL support - remove JACK DLL support
* remove Haiku support * remove Haiku support
* remove Boost dependency * remove Boost dependency
* require libfmt 7 or later * require libfmt 9 or later
* documentation: switch to sphinx-rtd-theme * documentation: switch to sphinx-rtd-theme
ver 0.23.15 (2023/12/20) ver 0.23.15 (2023/12/20)

View File

@ -14,11 +14,7 @@ LogVFmt(LogLevel level, const Domain &domain,
fmt::string_view format_str, fmt::format_args args) noexcept fmt::string_view format_str, fmt::format_args args) noexcept
{ {
fmt::memory_buffer buffer; fmt::memory_buffer buffer;
#if FMT_VERSION >= 80000
fmt::vformat_to(std::back_inserter(buffer), format_str, args); fmt::vformat_to(std::back_inserter(buffer), format_str, args);
#else
fmt::vformat_to(buffer, format_str, args);
#endif
Log(level, domain, {buffer.data(), buffer.size()}); Log(level, domain, {buffer.data(), buffer.size()});
} }

View File

@ -1,15 +1,11 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project // Copyright The Music Player Daemon Project
#ifndef MPD_LOG_HXX #pragma once
#define MPD_LOG_HXX
#include "LogLevel.hxx" #include "LogLevel.hxx"
#include <fmt/core.h> #include <fmt/core.h>
#if FMT_VERSION >= 80000 && FMT_VERSION < 90000
#include <fmt/format.h>
#endif
#include <exception> #include <exception>
#include <string_view> #include <string_view>
@ -29,14 +25,8 @@ void
LogFmt(LogLevel level, const Domain &domain, LogFmt(LogLevel level, const Domain &domain,
const S &format_str, Args&&... args) noexcept const S &format_str, Args&&... args) noexcept
{ {
#if FMT_VERSION >= 90000
return LogVFmt(level, domain, format_str, return LogVFmt(level, domain, format_str,
fmt::make_format_args(args...)); fmt::make_format_args(args...));
#else
return LogVFmt(level, domain, fmt::to_string_view(format_str),
fmt::make_args_checked<Args...>(format_str,
args...));
#endif
} }
template<typename S, typename... Args> template<typename S, typename... Args>
@ -126,5 +116,3 @@ LogError(const std::exception_ptr &ep, const char *msg) noexcept
{ {
Log(LogLevel::ERROR, ep, msg); Log(LogLevel::ERROR, ep, msg);
} }
#endif /* LOG_H */

View File

@ -28,11 +28,7 @@ bool
Response::VFmt(fmt::string_view format_str, fmt::format_args args) noexcept Response::VFmt(fmt::string_view format_str, fmt::format_args args) noexcept
{ {
fmt::memory_buffer buffer; fmt::memory_buffer buffer;
#if FMT_VERSION >= 80000
fmt::vformat_to(std::back_inserter(buffer), format_str, args); fmt::vformat_to(std::back_inserter(buffer), format_str, args);
#else
fmt::vformat_to(buffer, format_str, args);
#endif
return Write(buffer.data(), buffer.size()); return Write(buffer.data(), buffer.size());
} }

View File

@ -1,15 +1,11 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project // Copyright The Music Player Daemon Project
#ifndef MPD_RESPONSE_HXX #pragma once
#define MPD_RESPONSE_HXX
#include "protocol/Ack.hxx" #include "protocol/Ack.hxx"
#include <fmt/core.h> #include <fmt/core.h>
#if FMT_VERSION >= 80000 && FMT_VERSION < 90000
#include <fmt/format.h>
#endif
#include <cstddef> #include <cstddef>
#include <span> #include <span>
@ -66,14 +62,8 @@ public:
template<typename S, typename... Args> template<typename S, typename... Args>
bool Fmt(const S &format_str, Args&&... args) noexcept { bool Fmt(const S &format_str, Args&&... args) noexcept {
#if FMT_VERSION >= 90000
return VFmt(format_str, return VFmt(format_str,
fmt::make_format_args(args...)); fmt::make_format_args(args...));
#else
return VFmt(fmt::to_string_view(format_str),
fmt::make_args_checked<Args...>(format_str,
args...));
#endif
} }
/** /**
@ -92,15 +82,7 @@ public:
template<typename S, typename... Args> template<typename S, typename... Args>
void FmtError(enum ack code, void FmtError(enum ack code,
const S &format_str, Args&&... args) noexcept { const S &format_str, Args&&... args) noexcept {
#if FMT_VERSION >= 90000
return VFmtError(code, format_str, return VFmtError(code, format_str,
fmt::make_format_args(args...)); fmt::make_format_args(args...));
#else
return VFmtError(code, fmt::to_string_view(format_str),
fmt::make_args_checked<Args...>(format_str,
args...));
#endif
} }
}; };
#endif

View File

@ -52,11 +52,7 @@ BufferedOutputStream::VFmt(fmt::string_view format_str, fmt::format_args args)
/* TODO format into this object's buffer instead of allocating /* TODO format into this object's buffer instead of allocating
a new one */ a new one */
fmt::memory_buffer b; fmt::memory_buffer b;
#if FMT_VERSION >= 80000
fmt::vformat_to(std::back_inserter(b), format_str, args); fmt::vformat_to(std::back_inserter(b), format_str, args);
#else
fmt::vformat_to(b, format_str, args);
#endif
return Write(std::as_bytes(std::span{b.data(), b.size()})); return Write(std::as_bytes(std::span{b.data(), b.size()}));
} }

View File

@ -7,9 +7,6 @@
#include "util/SpanCast.hxx" #include "util/SpanCast.hxx"
#include <fmt/core.h> #include <fmt/core.h>
#if FMT_VERSION >= 80000 && FMT_VERSION < 90000
#include <fmt/format.h>
#endif
#include <cstddef> #include <cstddef>
#include <string_view> #include <string_view>
@ -71,14 +68,8 @@ public:
template<typename S, typename... Args> template<typename S, typename... Args>
void Fmt(const S &format_str, Args&&... args) { void Fmt(const S &format_str, Args&&... args) {
#if FMT_VERSION >= 90000
VFmt(format_str, VFmt(format_str,
fmt::make_format_args(args...)); fmt::make_format_args(args...));
#else
VFmt(fmt::to_string_view(format_str),
fmt::make_args_checked<Args...>(format_str,
args...));
#endif
} }
#ifdef _UNICODE #ifdef _UNICODE

View File

@ -4,9 +4,6 @@
#pragma once #pragma once
#include <fmt/core.h> #include <fmt/core.h>
#if FMT_VERSION >= 80000 && FMT_VERSION < 90000
#include <fmt/format.h>
#endif
#include <stdexcept> // IWYU pragma: export #include <stdexcept> // IWYU pragma: export
@ -19,14 +16,8 @@ template<typename S, typename... Args>
auto auto
FmtRuntimeError(const S &format_str, Args&&... args) noexcept FmtRuntimeError(const S &format_str, Args&&... args) noexcept
{ {
#if FMT_VERSION >= 90000
return VFmtRuntimeError(format_str, return VFmtRuntimeError(format_str,
fmt::make_format_args(args...)); fmt::make_format_args(args...));
#else
return VFmtRuntimeError(fmt::to_string_view(format_str),
fmt::make_args_checked<Args...>(format_str,
args...));
#endif
} }
[[nodiscard]] [[gnu::pure]] [[nodiscard]] [[gnu::pure]]
@ -38,12 +29,6 @@ template<typename S, typename... Args>
auto auto
FmtInvalidArgument(const S &format_str, Args&&... args) noexcept FmtInvalidArgument(const S &format_str, Args&&... args) noexcept
{ {
#if FMT_VERSION >= 90000
return VFmtInvalidArgument(format_str, return VFmtInvalidArgument(format_str,
fmt::make_format_args(args...)); fmt::make_format_args(args...));
#else
return VFmtInvalidArgument(fmt::to_string_view(format_str),
fmt::make_args_checked<Args...>(format_str,
args...));
#endif
} }

View File

@ -6,9 +6,6 @@
#include "system/Error.hxx" // IWYU pragma: export #include "system/Error.hxx" // IWYU pragma: export
#include <fmt/core.h> #include <fmt/core.h>
#if FMT_VERSION >= 80000 && FMT_VERSION < 90000
#include <fmt/format.h>
#endif
#include <type_traits> #include <type_traits>
@ -23,14 +20,8 @@ std::system_error
FmtSystemError(std::error_code code, FmtSystemError(std::error_code code,
const S &format_str, Args&&... args) noexcept const S &format_str, Args&&... args) noexcept
{ {
#if FMT_VERSION >= 90000
return VFmtSystemError(code, format_str, return VFmtSystemError(code, format_str,
fmt::make_format_args(args...)); fmt::make_format_args(args...));
#else
return VFmtSystemError(code, fmt::to_string_view(format_str),
fmt::make_args_checked<Args...>(format_str,
args...));
#endif
} }
#ifdef _WIN32 #ifdef _WIN32
@ -46,14 +37,8 @@ std::system_error
FmtLastError(DWORD code, FmtLastError(DWORD code,
const S &format_str, Args&&... args) noexcept const S &format_str, Args&&... args) noexcept
{ {
#if FMT_VERSION >= 90000
return VFmtLastError(code, format_str, return VFmtLastError(code, format_str,
fmt::make_format_args(args...)); fmt::make_format_args(args...));
#else
return VFmtLastError(code, fmt::to_string_view(format_str),
fmt::make_args_checked<Args...>(format_str,
args...));
#endif
} }
template<typename S, typename... Args> template<typename S, typename... Args>

View File

@ -6,9 +6,6 @@
#include "util/StringBuffer.hxx" #include "util/StringBuffer.hxx"
#include <fmt/core.h> #include <fmt/core.h>
#if FMT_VERSION < 90000
#include <fmt/format.h> // for the fmt::buffer::flush() implementation
#endif
template<std::size_t size> template<std::size_t size>
StringBuffer<size> & StringBuffer<size> &
@ -35,14 +32,8 @@ StringBuffer<size> &
FmtToBuffer(StringBuffer<size> &buffer, FmtToBuffer(StringBuffer<size> &buffer,
const S &format_str, Args&&... args) noexcept const S &format_str, Args&&... args) noexcept
{ {
#if FMT_VERSION >= 90000
return VFmtToBuffer(buffer, format_str, return VFmtToBuffer(buffer, format_str,
fmt::make_format_args(args...)); fmt::make_format_args(args...));
#else
return VFmtToBuffer(buffer, fmt::to_string_view(format_str),
fmt::make_args_checked<Args...>(format_str,
args...));
#endif
} }
template<std::size_t size, typename S, typename... Args> template<std::size_t size, typename S, typename... Args>
@ -50,12 +41,6 @@ template<std::size_t size, typename S, typename... Args>
auto auto
FmtBuffer(const S &format_str, Args&&... args) noexcept FmtBuffer(const S &format_str, Args&&... args) noexcept
{ {
#if FMT_VERSION >= 90000
return VFmtBuffer<size>(format_str, return VFmtBuffer<size>(format_str,
fmt::make_format_args(args...)); fmt::make_format_args(args...));
#else
return VFmtBuffer<size>(fmt::to_string_view(format_str),
fmt::make_args_checked<Args...>(format_str,
args...));
#endif
} }

View File

@ -1,4 +1,4 @@
libfmt = dependency('fmt', version: '>= 7', fallback: ['fmt', 'fmt_dep']) libfmt = dependency('fmt', version: '>= 9', fallback: ['fmt', 'fmt_dep'])
if compiler.get_id() == 'clang' and compiler.version().version_compare('<15') if compiler.get_id() == 'clang' and compiler.version().version_compare('<15')
libfmt = declare_dependency( libfmt = declare_dependency(