Remove remaining fmt::format use
The only remaining use of the fmt::format library was for something
std::format can't yet handle, printing ranges. This was only used
twice, in the same file, so just manually build up the vectors in
question into a string and use std::format. This was already being done
in other places anyway.
Now the fmt::format subproject and dependencies can be completely
removed.
An added benefit is that those two fmt::format calls were failing to
build on my system when I was trying to build using subprojects, and
without them everything works.
Tested:
Can still see the traces, though I only have a 1 element vector to test
with:
Adding fan target lock of 11300 on fans [fan0] zone 0",
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I90055e9d1c8d0b79b151e1cfd0af2052005cef3c
diff --git a/control/json/actions/override_fan_target.cpp b/control/json/actions/override_fan_target.cpp
index c5e15ad..33fbd34 100644
--- a/control/json/actions/override_fan_target.cpp
+++ b/control/json/actions/override_fan_target.cpp
@@ -20,11 +20,10 @@
#include "action.hpp"
#include "group.hpp"
-#include <fmt/format.h>
-#include <fmt/ranges.h>
-
#include <nlohmann/json.hpp>
+#include <format>
+
namespace phosphor::fan::control::json
{
@@ -83,8 +82,17 @@
{
if (!_locked)
{
- record(fmt::format("Adding fan target lock of {} on fans {} zone {}",
- _target, _fans, zone.getName()));
+ std::string fanList;
+ if (!_fans.empty())
+ {
+ fanList = std::accumulate(std::next(_fans.begin()), _fans.end(),
+ _fans[0], [](auto list, auto fan) {
+ return std::move(list) + ", " + fan;
+ });
+ }
+
+ record(std::format("Adding fan target lock of {} on fans [{}] zone {}",
+ _target, fanList, zone.getName()));
for (auto& fan : _fans)
{
@@ -97,8 +105,16 @@
void OverrideFanTarget::unlockFans(Zone& zone)
{
- record(fmt::format("Un-locking fan target {} on fans {} zone {}", _target,
- _fans, zone.getName()));
+ std::string fanList;
+ if (!_fans.empty())
+ {
+ fanList = std::accumulate(
+ std::next(_fans.begin()), _fans.end(), _fans[0],
+ [](auto list, auto fan) { return std::move(list) + ", " + fan; });
+ }
+
+ record(std::format("Un-locking fan target {} on fans [{}] zone {}", _target,
+ fanList, zone.getName()));
// unlock all fans in this instance
for (auto& fan : _fans)
diff --git a/control/meson.build b/control/meson.build
index aa77784..6869043 100644
--- a/control/meson.build
+++ b/control/meson.build
@@ -100,7 +100,6 @@
'fanctl.cpp',
dependencies: [
cli11_dep,
- fmt_dep,
json_dep,
phosphor_logging_dep,
sdbusplus_dep,
diff --git a/meson.build b/meson.build
index daeca9b..e547e4f 100644
--- a/meson.build
+++ b/meson.build
@@ -52,8 +52,6 @@
json_dep = dependency('nlohmann_json')
endif
-fmt_dep = dependency('fmt')
-
phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
phosphor_logging_dep = dependency('phosphor-logging')
sdbusplus_dep = dependency('sdbusplus')
diff --git a/monitor/test/meson.build b/monitor/test/meson.build
index 4955691..369c4e2 100644
--- a/monitor/test/meson.build
+++ b/monitor/test/meson.build
@@ -3,7 +3,6 @@
)
test_deps=[
- fmt_dep,
gmock_dep,
gtest_dep,
json_dep,
diff --git a/subprojects/fmt.wrap b/subprojects/fmt.wrap
deleted file mode 100644
index 63869be..0000000
--- a/subprojects/fmt.wrap
+++ /dev/null
@@ -1,12 +0,0 @@
-[wrap-file]
-directory = fmt-8.1.1
-source_url = https://github.com/fmtlib/fmt/archive/8.1.1.tar.gz
-source_filename = fmt-8.1.1.tar.gz
-source_hash = 3d794d3cf67633b34b2771eb9f073bde87e846e0d395d254df7b211ef1ec7346
-patch_filename = fmt_8.1.1-1_patch.zip
-patch_url = https://wrapdb.mesonbuild.com/v2/fmt_8.1.1-1/get_patch
-patch_hash = 6035a67c7a8c90bed74c293c7265c769f47a69816125f7566bccb8e2543cee5e
-
-[provide]
-fmt = fmt_dep
-
diff --git a/test/meson.build b/test/meson.build
index 5e2d7b0..3a85b08 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -4,7 +4,6 @@
)
test_deps=[
- fmt_dep,
gmock_dep,
gtest_dep,
json_dep,