packages: switch to clang

This commit is contained in:
2024-09-04 18:22:07 +08:00
parent 301df4f58c
commit 55cc1de138
11 changed files with 33 additions and 33 deletions

View File

@@ -167,28 +167,25 @@
config = { archive = false; branch = "production"; };
devShells.x86_64-linux = let inherit (inputs.self.packages.x86_64-linux) pkgs; in
{
biu = pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; }
biu = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
{
inputsFrom = [ pkgs.localPackages.biu ];
packages = [ pkgs.clang-tools_18 ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
};
hpcstat = pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; }
hpcstat = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
{
inputsFrom = [ (inputs.self.packages.x86_64-linux.hpcstat.override { version = null; }) ];
packages = [ pkgs.clang-tools_18 ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
};
sbatch-tui = pkgs.mkShell
sbatch-tui = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
{
inputsFrom = [ pkgs.localPackages.sbatch-tui ];
packages = [ pkgs.clang-tools_18 ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
};
ufo = pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; }
ufo = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
{
inputsFrom = [ (inputs.self.packages.x86_64-linux.ufo.override { version = null; }) ];
packages = [ pkgs.ccls ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
};
chn-bsub = pkgs.mkShell

View File

@@ -1,3 +0,0 @@
CompileFlags:
Add: [ -Wall, -Wextra, -std=c++23 ]
Compiler: g++

View File

@@ -24,14 +24,16 @@ find_package(TgBot REQUIRED)
find_path(LIBBACKTRACE_INCLUDE_DIR backtrace.h REQUIRED)
find_library(LIBBACKTRACE_LIBRARY NAMES backtrace REQUIRED)
find_package(HDF5 REQUIRED)
find_package(concurrencpp REQUIRED)
add_library(biu src/common.cpp src/hdf5.cpp src/logger.cpp src/string.cpp)
target_include_directories(biu PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> ${NAMEOF_INCLUDE_DIR} ${ZPP_BITS_INCLUDE_DIR}
${LIBBACKTRACE_INCLUDE_DIR})
target_link_libraries(biu PUBLIC magic_enum::magic_enum fmt::fmt Boost::headers Boost::iostreams Boost::filesystem
range-v3::range-v3 Eigen3::Eigen HighFive TgBot::TgBot ${LIBBACKTRACE_LIBRARY} hdf5::hdf5)
set_property(TARGET biu PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON)
range-v3::range-v3 Eigen3::Eigen HighFive TgBot::TgBot ${LIBBACKTRACE_LIBRARY} hdf5::hdf5 concurrencpp::concurrencpp)
target_compile_features(biu PUBLIC cxx_std_23)
target_compile_options(biu PUBLIC -Wno-gnu-string-literal-operator-template)
install(TARGETS biu EXPORT biuTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

View File

@@ -11,3 +11,4 @@ find_package(TgBot REQUIRED)
find_path(LIBBACKTRACE_INCLUDE_DIR backtrace.h REQUIRED)
find_library(LIBBACKTRACE_LIBRARY NAMES backtrace REQUIRED)
find_package(HDF5 REQUIRED)
find_package(concurrencpp REQUIRED)

View File

@@ -1,11 +1,11 @@
{
stdenv, cmake, lib,
magic-enum, fmt, boost, eigen, range-v3, nameof, zpp-bits, highfive, tgbot-cpp, libbacktrace, hdf5
magic-enum, fmt, boost, eigen, range-v3, nameof, zpp-bits, highfive, tgbot-cpp, libbacktrace, hdf5, concurrencpp
}: stdenv.mkDerivation rec
{
name = "biu";
src = ./.;
buildInputs = [ magic-enum fmt boost range-v3 nameof zpp-bits eigen highfive tgbot-cpp libbacktrace hdf5 ];
buildInputs = [ magic-enum fmt boost range-v3 nameof zpp-bits eigen highfive tgbot-cpp libbacktrace hdf5 concurrencpp ];
propagatedBuildInputs = buildInputs;
nativeBuildInputs = [ cmake ];
doCheck = true;

View File

@@ -2,7 +2,7 @@
# include <regex>
# include <optional>
# include <filesystem>
# include <generator>
# include <concurrencpp/concurrencpp.h>
# include <type_traits>
# include <fmt/format.h>
# include <magic_enum_all.hpp>
@@ -103,8 +103,8 @@ namespace biu
template <typename T> T deserialize(const std::string& serialized_data);
template <typename T> T deserialize(const std::vector<std::byte>& serialized_data);
template <typename Array> std::generator<std::pair<Array, std::size_t>> sequence(Array from, Array to);
template <typename Array> std::generator<std::pair<Array, std::size_t>> sequence(Array to);
template <typename Array> concurrencpp::generator<std::pair<Array, std::size_t>> sequence(Array from, Array to);
template <typename Array> concurrencpp::generator<std::pair<Array, std::size_t>> sequence(Array to);
}
using common::hash, common::unused, common::block_forever, common::is_interactive, common::env, common::int128_t,
common::uint128_t, common::Empty, common::CaseInsensitiveStringLessComparator, common::RemoveMemberPointer,

View File

@@ -48,7 +48,7 @@ namespace biu::common
return deserialize<T>(std::vector<std::byte>{begin, end});
}
template <typename Array> std::generator<std::pair<Array, std::size_t>> sequence(Array from, Array to)
template <typename Array> concurrencpp::generator<std::pair<Array, std::size_t>> sequence(Array from, Array to)
{
# ifndef NDEBUG
assert(from.size() == to.size());
@@ -64,7 +64,7 @@ namespace biu::common
};
do { co_yield {current, total}; } while (make_next(0));
}
template <typename Array> std::generator<std::pair<Array, std::size_t>> sequence(Array to)
template <typename Array> concurrencpp::generator<std::pair<Array, std::size_t>> sequence(Array to)
{
auto from = to;
for (std::size_t i = 0; i < from.size(); i++) from[i] = 0;

View File

@@ -137,13 +137,15 @@ namespace biu::eigen
else return std::make_pair
(
Vector::CompileTimeTraits::RowsAtCompileTime * Vector::CompileTimeTraits::ColsAtCompileTime,
[](const Vector&) consteval { return true; }
// consteval need c++23 P2280
[](const Vector&) { return true; }
);
// 如果固定的那个维度等于 1那么为动态大小大小取决于另外一个没有固定的维度
// 否则,大小等于这个维度,另一个维度是否为 1 留作之后检查
else if constexpr (Vector::CompileTimeTraits::RowsAtCompileTime != Eigen::Dynamic)
if constexpr (Vector::CompileTimeTraits::RowsAtCompileTime == 1)
return std::make_pair(dynamicSize, [](const Vector&) consteval { return true; });
// consteval need c++23 P2280
return std::make_pair(dynamicSize, [](const Vector&) { return true; });
else
return std::make_pair
(
@@ -152,7 +154,8 @@ namespace biu::eigen
);
else if constexpr (Vector::CompileTimeTraits::ColsAtCompileTime != Eigen::Dynamic)
if constexpr (Vector::CompileTimeTraits::ColsAtCompileTime == 1)
return std::make_pair(dynamicSize, [](const Vector&) consteval { return true; });
// consteval need c++23 P2280
return std::make_pair(dynamicSize, [](const Vector&) { return true; });
else
return std::make_pair
(
@@ -181,7 +184,6 @@ namespace biu::eigen
);
}
};
// decomposition declarations can't be constexpr
constexpr auto size = get_size.template operator()<ToSize>();
# ifndef NDEBUG
@@ -269,9 +271,10 @@ template <typename Matrix> constexpr auto Eigen::serialize(auto & archive, Matri
// second call
else
{
using archive_type = std::remove_cvref_t<decltype(archive)>;
typename Matrix::Index nRow, nCol;
std::vector<typename Matrix::Scalar> data;
if constexpr (archive.kind() == zpp::bits::kind::out)
if constexpr (archive_type::kind() == zpp::bits::kind::out)
{ nRow = matrix.rows(); nCol = matrix.cols(); data = std::vector(matrix.data(), matrix.data() + matrix.size()); }
zpp::bits::errc result;
if constexpr (Matrix::CompileTimeTraits::RowsAtCompileTime == Eigen::Dynamic)
@@ -282,7 +285,7 @@ template <typename Matrix> constexpr auto Eigen::serialize(auto & archive, Matri
else nCol = Matrix::CompileTimeTraits::ColsAtCompileTime;
result = archive(data);
if (result.code != std::errc{}) [[unlikely]] return result;
if constexpr (archive.kind() == zpp::bits::kind::in)
if constexpr (archive_type::kind() == zpp::bits::kind::in)
matrix = Eigen::Map<const Matrix>(data.data(), nRow, nCol);
return result;
}

View File

@@ -4,7 +4,7 @@
# include <string>
# include <string_view>
# include <iostream>
# include <generator>
# include <concurrencpp/concurrencpp.h>
# include <biu/concepts.hpp>
# include <biu/smartref.hpp>
@@ -41,7 +41,7 @@ namespace biu
// Find specific content in a string. Return unmatched content before the match and the match result every
// time. If match reached the end, the second returned value will be std::sregex_iterator().
std::generator<std::pair<std::string_view, std::sregex_iterator>> find
concurrencpp::generator<std::pair<std::string_view, std::sregex_iterator>> find
(SmartRef<const std::string> data, SmartRef<const std::regex> regex);
std::string replace
(const std::string& data, const std::regex& regex, std::function<std::string(const std::smatch&)> function);

View File

@@ -2,7 +2,7 @@
namespace biu
{
std::generator<std::pair<std::string_view, std::sregex_iterator>> string::find
concurrencpp::generator<std::pair<std::string_view, std::sregex_iterator>> string::find
(SmartRef<const std::string> data, SmartRef<const std::regex> regex)
{
Logger::Guard log;

View File

@@ -60,22 +60,22 @@ inputs: rec
{ src = inputs.topInputs.kylin-virtual-keyboard; };
biu = inputs.pkgs.callPackage ./biu
{
inherit nameof zpp-bits tgbot-cpp;
stdenv = inputs.pkgs.gcc14Stdenv;
inherit nameof zpp-bits tgbot-cpp concurrencpp;
stdenv = inputs.pkgs.clang18Stdenv;
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; };
{ inherit sqlite-orm date biu openxlsx; stdenv = inputs.pkgs.clang18Stdenv; };
openxlsx = inputs.pkgs.callPackage ./openxlsx.nix { src = inputs.topInputs.openxlsx; };
sqlite-orm = inputs.pkgs.callPackage ./sqlite-orm.nix { src = inputs.topInputs.sqlite-orm; };
mkPnpmPackage = inputs.pkgs.callPackage ./mkPnpmPackage.nix {};
sbatch-tui = inputs.pkgs.callPackage ./sbatch-tui { inherit biu; stdenv = inputs.pkgs.gcc14Stdenv; };
sbatch-tui = inputs.pkgs.callPackage ./sbatch-tui { inherit biu; stdenv = inputs.pkgs.clang18Stdenv; };
ufo = inputs.pkgs.callPackage ./ufo
{
inherit concurrencpp biu matplotplusplus zpp-bits;
tbb = inputs.pkgs.tbb_2021_11;
stdenv = inputs.pkgs.gcc14Stdenv;
stdenv = inputs.pkgs.clang18Stdenv;
};
chn-bsub = inputs.pkgs.callPackage ./chn-bsub { inherit biu; };
winjob = inputs.pkgs.callPackage ./winjob { stdenv = inputs.pkgs.gcc14Stdenv; };