Skip to content

Commit 2b78a32

Browse files
committed
ci: setup fmt
1 parent fa31a0e commit 2b78a32

File tree

5 files changed

+86
-77
lines changed

5 files changed

+86
-77
lines changed

.github/workflows/ci.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,20 @@ jobs:
5858
with:
5959
compiler: ${{ matrix.compiler }}
6060
version: ${{ matrix.version }}
61-
update-ld-library-path: true
61+
update-ld-library-path: ${{ matrix.compiler == 'gcc' }}
62+
check-latest: ${{ matrix.compiler == 'clang' }}
6263

6364
- name: Install packages
64-
uses: alandefreitas/cpp-actions/package-install@v1.2.1
65+
uses: alandefreitas/cpp-actions/package-install@v1.3.0
6566
id: package-install
6667
with:
6768
apt-get: ${{ matrix.install }}
68-
vcpkg: libxml2[tools]
69+
vcpkg: fmt libxml2[tools]
6970
cxx: ${{ steps.setup-cpp.outputs.cxx }}
7071
cc: ${{ steps.setup-cpp.outputs.cc }}
7172

7273
- name: CMake Workflow (C++${{ matrix.std }})
73-
uses: alandefreitas/cpp-actions/cmake-workflow@v1.2.1
74+
uses: alandefreitas/cpp-actions/cmake-workflow@v1.3.0
7475
with:
7576
cmake-version: '>=3.20'
7677
cxxstd: ${{ matrix.std }}

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ include(HandleLLVMOptions)
8181
add_definitions(${LLVM_DEFINITIONS})
8282
llvm_map_components_to_libnames(llvm_libs all)
8383
unset(CMAKE_FOLDER)
84+
find_package(fmt REQUIRED CONFIG)
8485

8586
#-------------------------------------------------
8687
#
@@ -131,6 +132,9 @@ else()
131132
endif()
132133
target_include_directories(mrdox SYSTEM PUBLIC ${CLANG_INCLUDE_DIRS})
133134

135+
# fmt
136+
target_link_libraries(mrdox PUBLIC fmt::fmt)
137+
134138
# Windows, Win64
135139
if (WIN32)
136140
target_compile_definitions(

source/-XML/XMLTags.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ nest(int levels)
189189
}
190190
else
191191
{
192-
auto const n = levels * -2;
192+
auto const n = static_cast<std::size_t>(levels * -2);
193193
Assert(n <= indent_.size());
194194
indent_.resize(indent_.size() - n);
195195
}

source/Config.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,23 @@
1919
#include <llvm/Support/YAMLParser.h>
2020
#include <llvm/Support/YAMLTraits.h>
2121

22+
#include <version>
23+
2224
// Check llvm version
2325
#define STRINGIFY(Value) #Value
2426
static_assert(
2527
LLVM_VERSION_MAJOR >= MRDOX_MINIMUM_LLVM_VERSION,
2628
"MrDox requires at least clang " STRINGIFY(MRDOX_MINIMUM_LLVM_VERSION)
2729
", got " LLVM_VERSION_STRING " instead.");
2830

31+
#if ! defined(__cpp_lib_ranges)
32+
#error "Ranges library unavailable"
33+
#endif
34+
35+
#include <ranges>
36+
37+
#include <fmt/format.h>
38+
2939
namespace clang {
3040
namespace mrdox {
3141

source/Support/Debug.hpp

+66-72
Original file line numberDiff line numberDiff line change
@@ -18,78 +18,72 @@
1818
#endif
1919
#include <llvm/Support/raw_ostream.h>
2020

21-
#if __has_include(<format>)
22-
#define MRDOX_HAS_CXX20_FORMAT
23-
#endif
24-
25-
#ifdef MRDOX_HAS_CXX20_FORMAT
26-
#include <format>
27-
#include <string>
28-
#include <mrdox/MetadataFwd.hpp>
29-
30-
template<>
31-
struct std::formatter<clang::mrdox::SymbolID>
32-
: std::formatter<std::string>
33-
{
34-
std::format_context::iterator format(
35-
const clang::mrdox::SymbolID& s,
36-
std::format_context& ctx) const;
37-
};
38-
39-
template<>
40-
struct std::formatter<clang::mrdox::OptionalSymbolID>
41-
: std::formatter<clang::mrdox::SymbolID>
42-
{
43-
std::format_context::iterator format(
44-
const clang::mrdox::OptionalSymbolID& s,
45-
std::format_context& ctx) const;
46-
};
47-
48-
template<>
49-
struct std::formatter<clang::mrdox::InfoType>
50-
: std::formatter<std::string>
51-
{
52-
std::format_context::iterator format(
53-
clang::mrdox::InfoType t,
54-
std::format_context& ctx) const;
55-
};
56-
57-
template<>
58-
struct std::formatter<clang::mrdox::Access>
59-
: std::formatter<std::string>
60-
{
61-
std::format_context::iterator format(
62-
clang::mrdox::Access a,
63-
std::format_context& ctx) const;
64-
};
65-
66-
template<>
67-
struct std::formatter<clang::mrdox::Reference>
68-
: std::formatter<std::string>
69-
{
70-
std::format_context::iterator format(
71-
const clang::mrdox::Reference& r,
72-
std::format_context& ctx) const;
73-
};
74-
75-
template<>
76-
struct std::formatter<clang::mrdox::MemberRef>
77-
: std::formatter<std::string>
78-
{
79-
std::format_context::iterator format(
80-
const clang::mrdox::MemberRef& r,
81-
std::format_context& ctx) const;
82-
};
83-
84-
template<>
85-
struct std::formatter<clang::mrdox::Info>
86-
: std::formatter<std::string>
87-
{
88-
std::format_context::iterator format(
89-
const clang::mrdox::Info& i,
90-
std::format_context& ctx) const;
91-
};
92-
#endif
21+
#include <fmt/format.h>
22+
#include <string>
23+
#include <mrdox/MetadataFwd.hpp>
24+
25+
template<>
26+
struct fmt::formatter<clang::mrdox::SymbolID>
27+
: fmt::formatter<std::string>
28+
{
29+
fmt::format_context::iterator format(
30+
const clang::mrdox::SymbolID& s,
31+
fmt::format_context& ctx) const;
32+
};
33+
34+
template<>
35+
struct fmt::formatter<clang::mrdox::OptionalSymbolID>
36+
: fmt::formatter<clang::mrdox::SymbolID>
37+
{
38+
fmt::format_context::iterator format(
39+
const clang::mrdox::OptionalSymbolID& s,
40+
fmt::format_context& ctx) const;
41+
};
42+
43+
template<>
44+
struct fmt::formatter<clang::mrdox::InfoType>
45+
: fmt::formatter<std::string>
46+
{
47+
fmt::format_context::iterator format(
48+
clang::mrdox::InfoType t,
49+
fmt::format_context& ctx) const;
50+
};
51+
52+
template<>
53+
struct fmt::formatter<clang::mrdox::Access>
54+
: fmt::formatter<std::string>
55+
{
56+
fmt::format_context::iterator format(
57+
clang::mrdox::Access a,
58+
fmt::format_context& ctx) const;
59+
};
60+
61+
template<>
62+
struct fmt::formatter<clang::mrdox::Reference>
63+
: fmt::formatter<std::string>
64+
{
65+
fmt::format_context::iterator format(
66+
const clang::mrdox::Reference& r,
67+
fmt::format_context& ctx) const;
68+
};
69+
70+
template<>
71+
struct fmt::formatter<clang::mrdox::MemberRef>
72+
: fmt::formatter<std::string>
73+
{
74+
fmt::format_context::iterator format(
75+
const clang::mrdox::MemberRef& r,
76+
fmt::format_context& ctx) const;
77+
};
78+
79+
template<>
80+
struct fmt::formatter<clang::mrdox::Info>
81+
: fmt::formatter<std::string>
82+
{
83+
fmt::format_context::iterator format(
84+
const clang::mrdox::Info& i,
85+
fmt::format_context& ctx) const;
86+
};
9387

9488
// Some nice odds and ends such as leak checking
9589
// and redirection to the Visual Studio output window.

0 commit comments

Comments
 (0)