From f9da4640c4098107aefc6c02b12b543384cccc50 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 30 Apr 2026 09:35:03 +0300 Subject: Drop libfmt We can use std::format() and a custom print() wrapper with C++20. When moving to C++23, we can drop the wrapper. Signed-off-by: Tomi Valkeinen --- .github/workflows/c-cpp.yml | 2 +- kms++/inc/kms++/format.h | 28 ++++++++++++++++++++++++++++ kms++/meson.build | 2 +- kms++/src/videomode.cpp | 2 +- kms++util/meson.build | 2 +- kms++util/src/testpat.cpp | 1 - kmscube/meson.build | 2 +- meson.build | 2 -- utils/kmsprint.cpp | 2 +- utils/kmstest.cpp | 2 +- utils/meson.build | 2 +- 11 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 kms++/inc/kms++/format.h diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index eccafb2..c900386 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -52,7 +52,7 @@ jobs: - name: install deps run: | sudo apt install -y libdrm-dev libegl1-mesa-dev libgles2-mesa-dev libwayland-dev \ - libx11-xcb-dev libx11-dev libgbm-dev libevdev-dev libfmt-dev + libx11-xcb-dev libx11-dev libgbm-dev libevdev-dev - name: configure env: diff --git a/kms++/inc/kms++/format.h b/kms++/inc/kms++/format.h new file mode 100644 index 0000000..b48babe --- /dev/null +++ b/kms++/inc/kms++/format.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include + +// This can be removed when moving to C++23. For now, this gives us +// fmt::format() and fmt::print(). + +namespace fmt { + +using std::format; + +template +void print(std::format_string fmtstr, Args&&... args) +{ + std::string s = std::format(fmtstr, std::forward(args)...); + std::fwrite(s.data(), 1, s.size(), stdout); +} + +template +void print(std::FILE* f, std::format_string fmtstr, Args&&... args) +{ + std::string s = std::format(fmtstr, std::forward(args)...); + std::fwrite(s.data(), 1, s.size(), f); +} + +} // namespace fmt diff --git a/kms++/meson.build b/kms++/meson.build index cd7a494..4fb5fc9 100644 --- a/kms++/meson.build +++ b/kms++/meson.build @@ -68,7 +68,7 @@ else omapdrm_enabled = false endif -libkmsxx_deps = [ libdrm_dep, libfmt_dep, libdrmomap_dep ] +libkmsxx_deps = [ libdrm_dep, libdrmomap_dep ] libkmsxx = library('kms++', libkmsxx_sources, diff --git a/kms++/src/videomode.cpp b/kms++/src/videomode.cpp index 4be6de7..b7b1b28 100644 --- a/kms++/src/videomode.cpp +++ b/kms++/src/videomode.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include "helpers.h" diff --git a/kms++util/meson.build b/kms++util/meson.build index ea998f0..e2beed6 100644 --- a/kms++util/meson.build +++ b/kms++util/meson.build @@ -40,7 +40,7 @@ if thread_dep.found() libkmsxxutil_args += [ '-DHAS_PTHREAD' ] endif -libkmsxxutil_deps = [ libkmsxx_dep, libfmt_dep, thread_dep ] +libkmsxxutil_deps = [ libkmsxx_dep, thread_dep ] libkmsxxutil = library('kms++util', libkmsxxutil_sources, diff --git a/kms++util/src/testpat.cpp b/kms++util/src/testpat.cpp index fe0988e..e424103 100644 --- a/kms++util/src/testpat.cpp +++ b/kms++util/src/testpat.cpp @@ -1,6 +1,5 @@ #include -#include #include #include #include diff --git a/kmscube/meson.build b/kmscube/meson.build index fd0fb96..c26badc 100644 --- a/kmscube/meson.build +++ b/kmscube/meson.build @@ -21,7 +21,7 @@ kmscube_sources = files([ ]) kmscube_deps = [ - libdrm_dep, libkmsxx_dep, libkmsxxutil_dep, libfmt_dep, + libdrm_dep, libkmsxx_dep, libkmsxxutil_dep, dependency('x11'), dependency('xcb'), dependency('x11-xcb'), diff --git a/meson.build b/meson.build index be0b2a1..0a67bdf 100644 --- a/meson.build +++ b/meson.build @@ -36,8 +36,6 @@ endif add_project_arguments(cpp_arguments, language : 'cpp') -libfmt_dep = dependency('fmt') - libdrmomap_dep = dependency('libdrm_omap', required : get_option('omap')) if libdrmomap_dep.found() diff --git a/utils/kmsprint.cpp b/utils/kmsprint.cpp index d8b4219..849c05c 100644 --- a/utils/kmsprint.cpp +++ b/utils/kmsprint.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp index 76b64ca..40143c3 100644 --- a/utils/kmstest.cpp +++ b/utils/kmstest.cpp @@ -9,7 +9,7 @@ #include -#include +#include #include #include diff --git a/utils/meson.build b/utils/meson.build index b1d3082..54021d3 100644 --- a/utils/meson.build +++ b/utils/meson.build @@ -10,7 +10,7 @@ endif utils_enabled = true -common_deps = [ libkmsxx_dep, libkmsxxutil_dep, libfmt_dep ] +common_deps = [ libkmsxx_dep, libkmsxxutil_dep ] libevdev_dep = dependency('libevdev', required : false) -- cgit v1.2.3