Skip to content

Commit efe3bd5

Browse files
author
modality
committed
fix(build): make format includes portable for CI
- Add portable format wrapper: fmt::format on macOS, std::format on Linux - Add MacPorts clang-18 detection to format.sh and tidy.sh - Fix tidy.sh bash portability (mapfile → while read) On macOS (where std::format is unavailable), uses fmt library. On Linux, creates fmt namespace alias to std::format.
1 parent 5c191ec commit efe3bd5

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

‎examples/tck_edge_node.cpp‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
#include "tck_edge_node.hpp"
22

33
#include <chrono>
4-
#include <format>
54
#include <iostream>
65
#include <thread>
76

8-
#include <fmt/format.h>
7+
// Portable format: use fmt on macOS (lacks std::format), std::format elsewhere
8+
#if defined(SPARKPLUG_USE_FMT) || defined(__APPLE__)
9+
# include <fmt/format.h>
10+
#else
11+
# include <format>
12+
namespace fmt {
13+
using std::format;
14+
}
15+
#endif
916

1017
namespace sparkplug::tck {
1118

‎tests/test_command_handling.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
// tests/test_command_handling.cpp
22
#include <fmt/format.h>
33
// Tests for command handling (NCMD/DCMD)
4+
5+
// Portable format: use fmt on macOS (lacks std::format), std::format elsewhere
6+
#if defined(SPARKPLUG_USE_FMT) || defined(__APPLE__)
7+
# include <fmt/format.h>
8+
#else
9+
# include <format>
10+
namespace fmt {
11+
using std::format;
12+
}
13+
#endif
414
#include <atomic>
515
#include <cassert>
616
#include <iostream>

‎tests/test_compliance.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
// tests/test_compliance.cpp
22
#include <fmt/format.h>
33
// Sparkplug 2.2 Compliance Tests
4+
5+
// Portable format: use fmt on macOS (lacks std::format), std::format elsewhere
6+
#if defined(SPARKPLUG_USE_FMT) || defined(__APPLE__)
7+
# include <fmt/format.h>
8+
#else
9+
# include <format>
10+
namespace fmt {
11+
using std::format;
12+
}
13+
#endif
414
#include <atomic>
515
#include <cassert>
616
#include <iostream>

‎tests/test_device_apis.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
// tests/test_device_apis.cpp
22
#include <fmt/format.h>
33
// Tests for device-level Sparkplug B APIs (DBIRTH/DDATA/DDEATH)
4+
5+
// Portable format: use fmt on macOS (lacks std::format), std::format elsewhere
6+
#if defined(SPARKPLUG_USE_FMT) || defined(__APPLE__)
7+
# include <fmt/format.h>
8+
#else
9+
# include <format>
10+
namespace fmt {
11+
using std::format;
12+
}
13+
#endif
414
#include <atomic>
515
#include <cassert>
616
#include <iostream>

0 commit comments

Comments
 (0)