mirror of
https://github.com/CHN-beta/nixos.git
synced 2024-10-22 23:39:02 +08:00
packages.ufo: fix build
This commit is contained in:
parent
45a1c4520b
commit
295153fa64
@ -1157,16 +1157,17 @@
|
||||
"openxlsx": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1722960074,
|
||||
"narHash": "sha256-KaexHI/Bl3aChkt2glN2oRJREYqFSOAO0Qn6pPccSXw=",
|
||||
"lastModified": 1716560554,
|
||||
"narHash": "sha256-Aqn1830lG4g7BbwEeePhvGawLarmrIMnF2MXROTUBCw=",
|
||||
"owner": "troldal",
|
||||
"repo": "OpenXLSX",
|
||||
"rev": "06425d541d09907799e93a4226691126bd60af5e",
|
||||
"rev": "f85f7f1bd632094b5d78d4d1f575955fc3801886",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "troldal",
|
||||
"repo": "OpenXLSX",
|
||||
"rev": "f85f7f1bd632094b5d78d4d1f575955fc3801886",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
@ -61,7 +61,7 @@
|
||||
kylin-virtual-keyboard = { url = "git+https://gitee.com/openkylin/kylin-virtual-keyboard.git"; flake = false; };
|
||||
cjktty = { url = "github:CHN-beta/cjktty-patches"; flake = false; };
|
||||
zxorm = { url = "github:CHN-beta/zxorm"; flake = false; };
|
||||
openxlsx = { url = "github:troldal/OpenXLSX"; flake = false; };
|
||||
openxlsx = { url = "github:troldal/OpenXLSX?rev=f85f7f1bd632094b5d78d4d1f575955fc3801886"; flake = false; };
|
||||
sqlite-orm = { url = "github:fnc12/sqlite_orm"; flake = false; };
|
||||
sockpp = { url = "github:fpagliughi/sockpp"; flake = false; };
|
||||
git-lfs-transfer = { url = "github:charmbracelet/git-lfs-transfer"; flake = false; };
|
||||
|
@ -53,3 +53,7 @@ add_executable(test-common test/common.cpp)
|
||||
target_link_libraries(test-common PRIVATE biu)
|
||||
set_property(TARGET test-common PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON)
|
||||
add_test(NAME test-common COMMAND test-common)
|
||||
add_executable(test-format test/format.cpp)
|
||||
target_link_libraries(test-format PRIVATE biu)
|
||||
set_property(TARGET test-format PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON)
|
||||
add_test(NAME test-format COMMAND test-format)
|
||||
|
57
packages/biu/fmt.patch
Normal file
57
packages/biu/fmt.patch
Normal file
@ -0,0 +1,57 @@
|
||||
diff --git a/include/fmt/std.h b/include/fmt/std.h
|
||||
index 1e69b8b2..ae485344 100644
|
||||
--- a/include/fmt/std.h
|
||||
+++ b/include/fmt/std.h
|
||||
@@ -211,7 +211,7 @@ template <typename Char>
|
||||
struct formatter<std::thread::id, Char> : basic_ostream_formatter<Char> {};
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
-#ifdef __cpp_lib_optional
|
||||
+#ifdef __cpp_lib_optional_
|
||||
FMT_BEGIN_NAMESPACE
|
||||
FMT_EXPORT
|
||||
template <typename T, typename Char>
|
||||
diff --git a/test/std-test.cc b/test/std-test.cc
|
||||
index bcc7bd5f..24981d87 100644
|
||||
--- a/test/std-test.cc
|
||||
+++ b/test/std-test.cc
|
||||
@@ -56,7 +56,7 @@ TEST(ranges_std_test, format_quote_path) {
|
||||
std::vector<std::filesystem::path>{"path1/file1.txt", "path2/file2.txt"};
|
||||
EXPECT_EQ(fmt::format("{}", vec),
|
||||
"[\"path1/file1.txt\", \"path2/file2.txt\"]");
|
||||
-# ifdef __cpp_lib_optional
|
||||
+# ifdef __cpp_lib_optional_
|
||||
auto o = std::optional<std::filesystem::path>("path/file.txt");
|
||||
EXPECT_EQ(fmt::format("{}", o), "optional(\"path/file.txt\")");
|
||||
EXPECT_EQ(fmt::format("{:?}", o), "optional(\"path/file.txt\")");
|
||||
@@ -109,7 +109,7 @@ TEST(std_test, source_location) {
|
||||
#endif
|
||||
|
||||
TEST(std_test, optional) {
|
||||
-#ifdef __cpp_lib_optional
|
||||
+#ifdef __cpp_lib_optional_
|
||||
EXPECT_EQ(fmt::format("{}", std::optional<int>{}), "none");
|
||||
EXPECT_EQ(fmt::format("{}", std::pair{1, "second"}), "(1, \"second\")");
|
||||
EXPECT_EQ(fmt::format("{}", std::vector{std::optional{1}, std::optional{2},
|
||||
@@ -184,7 +184,7 @@ class my_class {
|
||||
};
|
||||
} // namespace my_nso
|
||||
TEST(std_test, optional_format_as) {
|
||||
-#ifdef __cpp_lib_optional
|
||||
+#ifdef __cpp_lib_optional_
|
||||
EXPECT_EQ(fmt::format("{}", std::optional<my_nso::my_number>{}), "none");
|
||||
EXPECT_EQ(fmt::format("{}", std::optional{my_nso::my_number::one}),
|
||||
"optional(\"first\")");
|
||||
diff --git a/test/xchar-test.cc b/test/xchar-test.cc
|
||||
index 312e632b..6210e244 100644
|
||||
--- a/test/xchar-test.cc
|
||||
+++ b/test/xchar-test.cc
|
||||
@@ -590,7 +590,7 @@ TEST(std_test_xchar, complex) {
|
||||
}
|
||||
|
||||
TEST(std_test_xchar, optional) {
|
||||
-# ifdef __cpp_lib_optional
|
||||
+# ifdef __cpp_lib_optional_
|
||||
EXPECT_EQ(fmt::format(L"{}", std::optional{L'C'}), L"optional(\'C\')");
|
||||
EXPECT_EQ(fmt::format(L"{}", std::optional{std::wstring{L"wide string"}}),
|
||||
L"optional(\"wide string\")");
|
@ -3,6 +3,7 @@
|
||||
# include <optional>
|
||||
# include <filesystem>
|
||||
# include <generator>
|
||||
# include <type_traits>
|
||||
# include <fmt/format.h>
|
||||
# include <magic_enum_all.hpp>
|
||||
|
||||
|
@ -1,16 +1,12 @@
|
||||
# pragma once
|
||||
# include <variant>
|
||||
# include <optional>
|
||||
# include <experimental/memory>
|
||||
# include <fmt/ostream.h>
|
||||
# include <biu/string.hpp>
|
||||
# include <biu/concepts.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
namespace concepts
|
||||
{ template <typename T, typename Char = char> concept Formattable = fmt::is_formattable<T, Char>::value; }
|
||||
using concepts::Formattable;
|
||||
|
||||
namespace detail_
|
||||
{
|
||||
template <typename Char, Char... c> struct FormatLiteralHelper : protected BasicStaticString<Char, c...>
|
||||
@ -32,14 +28,14 @@ namespace biu
|
||||
template <typename Wrap> requires requires() {typename Wrap::element_type;}
|
||||
struct UnderlyingTypeOfOptionalWrap<Wrap>
|
||||
{using Type = std::remove_cvref_t<typename Wrap::element_type>;};
|
||||
template <typename T> struct FormatterReuseProxy
|
||||
template <typename T, typename Char> struct FormatterReuseProxy
|
||||
{
|
||||
constexpr auto parse(fmt::format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>;
|
||||
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx)
|
||||
-> typename fmt::basic_format_parse_context<Char>::iterator;
|
||||
};
|
||||
template <typename T>
|
||||
template <typename T, typename Char>
|
||||
requires (!SpecializationOf<T, std::weak_ptr> && std::default_initializable<fmt::formatter<T>>)
|
||||
struct FormatterReuseProxy<T> : fmt::formatter<T> {};
|
||||
struct FormatterReuseProxy<T, Char> : fmt::formatter<T, Char> {};
|
||||
}
|
||||
inline namespace stream_operators
|
||||
{
|
||||
@ -51,19 +47,19 @@ namespace biu
|
||||
namespace fmt
|
||||
{
|
||||
template <typename Char, biu::detail_::OptionalWrap Wrap> struct formatter<Wrap, Char>
|
||||
: biu::detail_::FormatterReuseProxy<typename biu::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type>
|
||||
: biu::detail_::FormatterReuseProxy<typename biu::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type, Char>
|
||||
{
|
||||
template <typename FormatContext> auto format(const Wrap& wrap, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>;
|
||||
template <typename FormatContext> auto format(const Wrap& wrap, FormatContext& ctx) const
|
||||
-> typename FormatContext::iterator;
|
||||
};
|
||||
|
||||
template <typename Char, biu::Enumerable T> struct formatter<T, Char>
|
||||
{
|
||||
bool full = false;
|
||||
constexpr auto parse(fmt::format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>;
|
||||
template <typename FormatContext> auto format(const T& value, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>;
|
||||
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx)
|
||||
-> typename fmt::basic_format_parse_context<Char>::iterator;
|
||||
template <typename FormatContext> auto format(const T& value, FormatContext& ctx) const
|
||||
-> typename FormatContext::iterator;
|
||||
};
|
||||
|
||||
template <typename Char, typename... Ts> struct formatter<std::variant<Ts...>, Char>
|
||||
|
@ -1,9 +1,11 @@
|
||||
# pragma once
|
||||
# include <nameof.hpp>
|
||||
# include <biu/format.hpp>
|
||||
# include <fmt/core.h>
|
||||
# include <fmt/ranges.h>
|
||||
# include <fmt/std.h>
|
||||
# include <fmt/ostream.h>
|
||||
# include <fmt/xchar.h>
|
||||
# include <nameof.hpp>
|
||||
# include <biu/format.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
@ -14,9 +16,9 @@ namespace biu
|
||||
detail_::FormatLiteralHelper<Char, c...> literals::operator""_f()
|
||||
{ return {}; }
|
||||
|
||||
template <typename T> constexpr
|
||||
auto detail_::FormatterReuseProxy<T>::parse(fmt::format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>
|
||||
template <typename T, typename Char> constexpr
|
||||
auto detail_::FormatterReuseProxy<T, Char>::parse(fmt::basic_format_parse_context<Char>& ctx)
|
||||
-> typename fmt::basic_format_parse_context<Char>::iterator
|
||||
{
|
||||
if (ctx.begin() != ctx.end() && *ctx.begin() != '}')
|
||||
throw fmt::format_error
|
||||
@ -35,7 +37,8 @@ namespace biu
|
||||
{
|
||||
if (holds_alternative<T>(value))
|
||||
{
|
||||
if constexpr (biu::Formattable<T, Char>) os << "({}: {})"_f(nameof::nameof_full_type<T>(), get<T>(value));
|
||||
if constexpr (fmt::is_formattable<T, Char>::value)
|
||||
os << "({}: {})"_f(nameof::nameof_full_type<T>(), get<T>(value));
|
||||
else os << "({}: {})"_f(nameof::nameof_full_type<T>(), "non-null unformattable value");
|
||||
}
|
||||
};
|
||||
@ -47,15 +50,16 @@ namespace biu
|
||||
namespace fmt
|
||||
{
|
||||
template <typename Char, biu::detail_::OptionalWrap Wrap> template <typename FormatContext>
|
||||
auto formatter<Wrap, Char>::format(const Wrap& wrap, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>
|
||||
auto formatter<Wrap, Char>::format(const Wrap& wrap, FormatContext& ctx) const
|
||||
-> typename FormatContext::iterator
|
||||
{
|
||||
using value_t = biu::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type;
|
||||
auto format_value_type = [&, this](const value_t& value)
|
||||
{
|
||||
if constexpr (!biu::Formattable<value_t, Char>) return fmt::format_to(ctx.out(), "non-null unformattable value");
|
||||
if constexpr (!fmt::is_formattable<value_t, Char>::value)
|
||||
return fmt::format_to(ctx.out(), "non-null unformattable value");
|
||||
else if constexpr (std::default_initializable<formatter<value_t>>)
|
||||
biu::detail_::FormatterReuseProxy<value_t>::format(value, ctx);
|
||||
biu::detail_::FormatterReuseProxy<value_t, Char>::format(value, ctx);
|
||||
else fmt::format_to(ctx.out(), "{}", value);
|
||||
};
|
||||
fmt::format_to(ctx.out(), "(");
|
||||
@ -75,8 +79,8 @@ namespace fmt
|
||||
return fmt::format_to(ctx.out(), ")");
|
||||
}
|
||||
|
||||
template <typename Char, biu::Enumerable T> constexpr auto formatter<T, Char>::parse(format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&format_parse_context::begin), format_parse_context>
|
||||
template <typename Char, biu::Enumerable T> constexpr auto formatter<T, Char>::parse
|
||||
(fmt::basic_format_parse_context<Char>& ctx) -> typename fmt::basic_format_parse_context<Char>::iterator
|
||||
{
|
||||
auto it = ctx.begin();
|
||||
if (it != ctx.end() && *it == 'f') { full = true; it++; }
|
||||
@ -85,8 +89,7 @@ namespace fmt
|
||||
}
|
||||
|
||||
template <typename Char, biu::Enumerable T> template <typename FormatContext>
|
||||
auto formatter<T, Char>::format(const T& value, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>
|
||||
auto formatter<T, Char>::format(const T& value, FormatContext& ctx) const -> typename FormatContext::iterator
|
||||
{
|
||||
if (full) return fmt::format_to(ctx.out(), "{}::{}", nameof::nameof_type<T>(), nameof::nameof_enum(value));
|
||||
else return fmt::format_to(ctx.out(), "{}", nameof::nameof_enum(value));
|
||||
|
14
packages/biu/test/format.cpp
Normal file
14
packages/biu/test/format.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
# include <biu.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace biu::literals;
|
||||
|
||||
std::optional<int> a = 3;
|
||||
using b = biu::detail_::UnderlyingTypeOfOptionalWrap<decltype(a)>::Type;
|
||||
std::cout << "{}\n"_f(nameof::nameof_full_type<b>());
|
||||
std::cout << "{}\n"_f(biu::concepts::CompletedType<fmt::formatter<int, char>>);
|
||||
std::cout << "{}\n"_f(biu::concepts::CompletedType<fmt::formatter<std::shared_ptr<int>, char>>);
|
||||
std::cout << "{}\n"_f(fmt::is_formattable<int>::value);
|
||||
std::cout << "{}\n"_f(a);
|
||||
}
|
@ -58,7 +58,12 @@ inputs: rec
|
||||
mumax = inputs.pkgs.callPackage ./mumax.nix { src = inputs.topInputs.mumax; };
|
||||
kylin-virtual-keyboard = inputs.pkgs.libsForQt5.callPackage ./kylin-virtual-keyboard.nix
|
||||
{ src = inputs.topInputs.kylin-virtual-keyboard; };
|
||||
biu = inputs.pkgs.callPackage ./biu { inherit nameof zpp-bits; stdenv = inputs.pkgs.gcc14Stdenv; };
|
||||
biu = inputs.pkgs.callPackage ./biu
|
||||
{
|
||||
inherit nameof zpp-bits;
|
||||
stdenv = inputs.pkgs.gcc14Stdenv;
|
||||
fmt = inputs.pkgs.fmt_11.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./biu/fmt.patch ]; });
|
||||
};
|
||||
zxorm = inputs.pkgs.callPackage ./zxorm.nix { src = inputs.topInputs.zxorm; };
|
||||
hpcstat = inputs.pkgs.callPackage ./hpcstat
|
||||
{ inherit sqlite-orm date biu openxlsx; stdenv = inputs.pkgs.gcc14Stdenv; };
|
||||
|
Loading…
Reference in New Issue
Block a user