Skip to content

Commit

Permalink
[upstream_utils] Upgrade to fmtlib 11.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Jul 1, 2024
1 parent 1ccd8d1 commit e650e42
Show file tree
Hide file tree
Showing 43 changed files with 5,445 additions and 4,854 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <thread>
#include <vector>

#include <fmt/core.h>
#include <networktables/NetworkTableInstance.h>
#include <wpi/MemoryBuffer.h>
#include <wpi/StringExtras.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <cstdlib>
#include <thread>

#include <fmt/core.h>
#include <gtest/gtest.h>
#include <hal/HAL.h>
#include <wpi/print.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <string_view>

#include <fmt/core.h>
#include <hal/cpp/fpga_clock.h>
#include <wpi/Logger.h>
#include <wpi/SmallVector.h>
Expand Down
1 change: 1 addition & 0 deletions datalogtool/src/main/native/cpp/Exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <fmt/chrono.h>
#include <fmt/format.h>
#include <fmt/ranges.h>
#include <glass/Storage.h>
#include <glass/support/DataLogReaderThread.h>
#include <imgui.h>
Expand Down
1 change: 0 additions & 1 deletion hal/src/dev/native/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

#include <fmt/core.h>
#include <wpi/print.h>

#include "hal/HAL.h"
Expand Down
3 changes: 1 addition & 2 deletions hal/src/main/native/athena/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <FRC_NetworkCommunication/FRCComm.h>
#include <FRC_NetworkCommunication/LoadOut.h>
#include <FRC_NetworkCommunication/UsageReporting.h>
#include <fmt/format.h>
#include <wpi/MemoryBuffer.h>
#include <wpi/SmallString.h>
#include <wpi/StringExtras.h>
Expand Down Expand Up @@ -582,7 +581,7 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
});

if (!SetupNowRio()) {
fmt::print(stderr,
wpi::print(stderr,
"Failed to run SetupNowRio(). This is a fatal error. The "
"process is being terminated.\n");
std::fflush(stderr);
Expand Down
2 changes: 0 additions & 2 deletions hal/src/main/native/cpp/jni/LEDJNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

#include <fmt/core.h>

#include "HALUtil.h"
#include "edu_wpi_first_hal_LEDJNI.h"
#include "hal/LEDs.h"
Expand Down
1 change: 1 addition & 0 deletions ntcore/src/main/native/cpp/LocalStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <algorithm>

#include <fmt/ranges.h>
#include <wpi/DataLog.h>
#include <wpi/SmallString.h>
#include <wpi/StringExtras.h>
Expand Down
1 change: 1 addition & 0 deletions ntcore/src/main/native/cpp/net/ServerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <string>
#include <vector>

#include <fmt/ranges.h>
#include <wpi/Base64.h>
#include <wpi/MessagePack.h>
#include <wpi/SmallVector.h>
Expand Down
1 change: 0 additions & 1 deletion ntcore/src/main/native/cpp/networktables/NetworkTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include <algorithm>

#include <fmt/core.h>
#include <fmt/format.h>
#include <wpi/SmallString.h>
#include <wpi/StringExtras.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

#include "DeploySession.h"

#include <memory>
#include <mutex>
#include <string_view>
#include <unordered_map>

#include <fmt/core.h>
#include <fmt/format.h>
#include <wpi/SmallString.h>
#include <wpi/StringExtras.h>
#include <wpinet/uv/Error.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <cstdio>

#include <fmt/format.h>
#include <wpi/print.h>
#include <wpinet/raw_uv_ostream.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <cstdio>

#include <fmt/format.h>
#include <wpi/SmallString.h>
#include <wpi/print.h>
#include <wpinet/raw_uv_ostream.h>
Expand Down
3 changes: 1 addition & 2 deletions sysid/src/main/native/cpp/view/Analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

#include <algorithm>
#include <exception>
#include <filesystem>
#include <numbers>
#include <thread>

#include <fmt/core.h>
#include <fmt/format.h>
#include <glass/Context.h>
#include <glass/Storage.h>
#include <imgui.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tyler Veness <[email protected]>
Date: Tue, 16 May 2023 13:49:18 -0700
Subject: [PATCH 1/2] Suppress warnings we can't fix
Subject: [PATCH] Suppress warnings we can't fix

---
include/fmt/format.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/include/fmt/format.h b/include/fmt/format.h
index 7637c8a0d0687ae3b77a145c2e1ceadf7fe5f67d..bfc6d70d1c5de100b3e413d61f7394cbb3b644f1 100644
index 7c2a19b4084de8f8bb9376d91c9a508f396e50df..ed372239a24466d32d5f81514efbdbe2ddafdba8 100644
--- a/include/fmt/format.h
+++ b/include/fmt/format.h
@@ -1289,7 +1289,14 @@ inline auto equal2(const char* lhs, const char* rhs) -> bool {
@@ -1268,7 +1268,14 @@ inline auto equal2(const char* lhs, const char* rhs) -> bool {
template <typename Char>
FMT_CONSTEXPR20 FMT_INLINE void copy2(Char* dst, const char* src) {
if (!is_constant_evaluated() && sizeof(Char) == sizeof(char)) {
Expand Down

This file was deleted.

12 changes: 8 additions & 4 deletions upstream_utils/sleipnir_patches/0002-Use-fmtlib.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Subject: [PATCH 2/4] Use fmtlib

---
include/.styleguide | 1 +
include/sleipnir/util/Print.hpp | 27 ++++++++++++++-------------
2 files changed, 15 insertions(+), 13 deletions(-)
include/sleipnir/util/Print.hpp | 31 ++++++++++++++++++-------------
2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/include/.styleguide b/include/.styleguide
index 8fb61fdf9cc5ceff633d3126f0579eef25a1326f..6a7f8ed28f9cb037c9746a7e0ef5e110481d9825 100644
Expand All @@ -19,18 +19,22 @@ index 8fb61fdf9cc5ceff633d3126f0579eef25a1326f..6a7f8ed28f9cb037c9746a7e0ef5e110
+ ^fmt/
}
diff --git a/include/sleipnir/util/Print.hpp b/include/sleipnir/util/Print.hpp
index 339320bce6d017ca85025060ba445b2f025bb225..fcf2e69bfb5a081cd915bdded3caa80cd9c38518 100644
index 339320bce6d017ca85025060ba445b2f025bb225..a9220cdaadcb9b88862542935bc72781d8389239 100644
--- a/include/sleipnir/util/Print.hpp
+++ b/include/sleipnir/util/Print.hpp
@@ -2,52 +2,53 @@
@@ -2,52 +2,57 @@

#pragma once

-#include <print>
#include <system_error>
#include <utility>

+#if __has_include(<fmt/base.h>)
+#include <fmt/base.h>
+#else
+#include <fmt/core.h>
+#endif
+
namespace sleipnir {

Expand Down
7 changes: 2 additions & 5 deletions upstream_utils/update_fmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@


def main():
upstream_root = clone_repo("https://github.com/fmtlib/fmt", "10.2.1")
upstream_root = clone_repo("https://github.com/fmtlib/fmt", "11.0.0")
wpilib_root = get_repo_root()
wpiutil = os.path.join(wpilib_root, "wpiutil")

# Apply patches to upstream Git repo
os.chdir(upstream_root)
for f in [
"0001-Suppress-warnings-we-can-t-fix.patch",
"0002-Fix-tautological-compare-warning.patch",
]:
for f in ["0001-Suppress-warnings-we-can-t-fix.patch"]:
git_am(os.path.join(wpilib_root, "upstream_utils/fmt_patches", f))

# Delete old install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "frc2/command/ProxyCommand.h"

#include <fmt/core.h>
#include <fmt/format.h>
#include <wpi/deprecated.h>
#include <wpi/sendable/SendableBuilder.h>

Expand Down
1 change: 0 additions & 1 deletion wpilibc/src/dev/native/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

#include <fmt/core.h>
#include <hal/HALBase.h>
#include <wpi/print.h>

Expand Down
2 changes: 1 addition & 1 deletion wpilibc/src/main/native/include/frc/util/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <string>
#include <string_view>

#include <fmt/core.h>
#include <fmt/format.h>
#include <gcem.hpp>
#include <wpi/StringExtras.h>
#include <wpi/ct_string.h>
Expand Down
2 changes: 1 addition & 1 deletion wpilibc/src/main/native/include/frc/util/Color8Bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <string>
#include <string_view>

#include <fmt/core.h>
#include <fmt/format.h>
#include <wpi/StringExtras.h>
#include <wpi/ct_string.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <string>

#include <fmt/core.h>
#include <fmt/format.h>
#include <gtest/gtest.h>
#include <networktables/NetworkTableInstance.h>
#include <networktables/StringTopic.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#include <algorithm>

#include <fmt/core.h>

#include "frc/trajectory/ExponentialProfile.h"
#include "units/math.h"

Expand Down
14 changes: 8 additions & 6 deletions wpimath/src/main/native/include/units/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ namespace units
struct fmt::formatter<units::namespaceName::nameSingular ## _t> \
: fmt::formatter<double> \
{\
template <typename FormatContext>\
auto format(const units::namespaceName::nameSingular ## _t& obj,\
FormatContext& ctx) -> decltype(ctx.out()) \
template <typename FmtContext>\
auto format(\
const units::namespaceName::nameSingular ## _t& obj,\
FmtContext& ctx) const\
{\
auto out = ctx.out();\
out = fmt::formatter<double>::format(obj(), ctx);\
Expand Down Expand Up @@ -2881,9 +2882,10 @@ namespace units
template <>
struct fmt::formatter<units::dimensionless::dB_t> : fmt::formatter<double>
{
template <typename FormatContext>
auto format(const units::dimensionless::dB_t& obj,
FormatContext& ctx) -> decltype(ctx.out())
template <typename FmtContext>
auto format(
const units::dimensionless::dB_t& obj,
FmtContext& ctx) const
{
auto out = ctx.out();
out = fmt::formatter<double>::format(obj(), ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#include <system_error>
#include <utility>

#if __has_include(<fmt/base.h>)
#include <fmt/base.h>
#else
#include <fmt/core.h>
#endif

namespace sleipnir {

Expand Down
1 change: 1 addition & 0 deletions wpiutil/examples/printlog/printlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <fmt/chrono.h>
#include <fmt/format.h>
#include <fmt/ranges.h>

#include "wpi/DataLogReader.h"
#include "wpi/DenseMap.h"
Expand Down
4 changes: 4 additions & 0 deletions wpiutil/src/main/native/include/wpi/print.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#include <system_error>
#include <utility>

#if __has_include(<fmt/base.h>)
#include <fmt/base.h>
#else
#include <fmt/core.h>
#endif

namespace wpi {

Expand Down
Loading

0 comments on commit e650e42

Please sign in to comment.