diff --git a/CMakeLists.txt b/CMakeLists.txt index b45e42d4..f84bd5ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,8 +228,6 @@ if (WIVRN_BUILD_WIVRNCTL) endif() # Common dependencies -FetchContent_Declare(boostpfr EXCLUDE_FROM_ALL SYSTEM URL https://github.com/boostorg/pfr/archive/refs/tags/2.2.0.tar.gz - URL_HASH SHA256=6f490ec1383de5855dcf801c23f0a967f888eb6e1440b6ca0bf36c12d4ae7ac7) FetchContent_Declare(boost EXCLUDE_FROM_ALL SYSTEM URL https://github.com/boostorg/boost/releases/download/boost-1.89.0/boost-1.89.0-cmake.tar.xz URL_HASH SHA256=67acec02d0d118b5de9eb441f5fb707b3a1cdd884be00ca24b9a73c995511f74) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index a39e2c1c..0a518343 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,10 +1,8 @@ if (WIVRN_USE_SYSTEM_BOOST) add_library(Boost::pfr ALIAS Boost::headers) -elseif (WIVRN_BUILD_CLIENT) +else() set(BOOST_INCLUDE_LIBRARIES locale url pfr) FetchContent_MakeAvailable(boost) -else() - FetchContent_MakeAvailable(boostpfr) endif() if (GIT_DESC) diff --git a/common/utils/csv_logger.h b/common/utils/csv_logger.h new file mode 100644 index 00000000..d67312f8 --- /dev/null +++ b/common/utils/csv_logger.h @@ -0,0 +1,130 @@ +/* + * WiVRn VR streaming + * Copyright (C) 2026 Guillaume Meunier + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include +#include +#include +#include +#include + +#if __has_include() +#define BOOST_HAS_CORE_NAME +#endif + +namespace details +{ +template +struct is_stdarray : public std::false_type +{}; + +template +struct is_stdarray> : public std::true_type +{}; + +template +inline constexpr bool is_stdarray_v = is_stdarray::value; + +template +struct csv_logger_traits; + +template +struct csv_logger_traits && !is_stdarray_v>> +{ +#ifdef BOOST_HAS_CORE_NAME + static void write_header(std::ostream & out, const std::string & name, bool first = true) + { + boost::pfr::for_each_field_with_name(T{}, [&](std::string_view member_name, const auto & value) { + csv_logger_traits>::write_header(out, name + "." + (std::string)member_name, first); + first = false; + }); + } +#endif + + static void write_line(std::ostream & out, const T & value, bool first = true) + { + boost::pfr::for_each_field(value, [&](const auto & member) { + csv_logger_traits>::write_line(out, member, first); + first = false; + }); + } +}; + +template +struct csv_logger_traits>> +{ + static void write_header(std::ostream & out, const std::string & name, bool first = true) + { + for (int i = 0; i < std::tuple_size_v; i++) + { + csv_logger_traits>::write_header(out, name + "[" + std::to_string(i) + "]", first and i == 0); + } + } + + static void write_line(std::ostream & out, const T & value, bool first = true) + { + for (int i = 0; i < std::tuple_size_v; i++) + { + csv_logger_traits>::write_line(out, value[i], first and i == 0); + } + } +}; + +template +struct csv_logger_traits>> +{ + static void write_header(std::ostream & out, std::string_view name, bool first = true) + { + if (not first) + out << ","; + out << name.substr(1); + } + + static void write_line(std::ostream & out, const T & value, bool first = true) + { + if (not first) + out << ","; + out << value; + } +}; + +} // namespace details + +template + requires std::derived_from +class csv_logger +{ + Stream stream; + +public: + template + csv_logger(Args &&... args) : stream(std::forward(args)...) + { +#ifdef BOOST_HAS_CORE_NAME + details::csv_logger_traits::write_header(stream, ""); + stream << std::endl; +#endif + } + + void write(const T & data) + { + details::csv_logger_traits::write_line(stream, data); + stream << std::endl; + } +}; diff --git a/flatpak/io.github.wivrn.wivrn.yml.in b/flatpak/io.github.wivrn.wivrn.yml.in index 58fcad50..35643fb3 100644 --- a/flatpak/io.github.wivrn.wivrn.yml.in +++ b/flatpak/io.github.wivrn.wivrn.yml.in @@ -396,9 +396,9 @@ modules: WIVRN_SRC2 WIVRN_SRC3 - type: archive - url: BOOSTPFR_URL - dest: deps/boostpfr-src - sha256: BOOSTPFR_SHA256 + url: BOOST_URL + dest: deps/boost-src + sha256: BOOST_SHA256 - type: git url: https://gitlab.freedesktop.org/monado/monado tag: MONADO_COMMIT @@ -406,4 +406,3 @@ modules: - type: shell commands: - cd deps/monado-src && ../../patches/apply.sh ../../patches/monado/* - - cd deps/boostpfr-src && ../../patches/apply.sh ../../flatpak/boostpfr-gcc-12-internal-compiler-error.patch diff --git a/tools/gen_flatpak_manifest.py b/tools/gen_flatpak_manifest.py index 7715416b..a8522e17 100755 --- a/tools/gen_flatpak_manifest.py +++ b/tools/gen_flatpak_manifest.py @@ -59,8 +59,8 @@ if __name__ == "__main__": monado_commit = open(os.path.join(root, "monado-rev")).read() - boostpfr_url = cmake.get("boostpfr", "URL") - boostpfr_sha256 = cmake.get("boostpfr", "URL_HASH").split("=")[-1] + boost_url = cmake.get("boost", "URL") + boost_sha256 = cmake.get("boost", "URL_HASH").split("=")[-1] try: git_commit = subprocess.check_output( @@ -93,8 +93,8 @@ if __name__ == "__main__": template = template.replace("WIVRN_GIT_DESC", git_desc) template = template.replace("WIVRN_GIT_COMMIT", git_commit) - template = template.replace("BOOSTPFR_URL", boostpfr_url) - template = template.replace("BOOSTPFR_SHA256", boostpfr_sha256) + template = template.replace("BOOST_URL", boost_url) + template = template.replace("BOOST_SHA256", boost_sha256) template = template.replace("MONADO_COMMIT", monado_commit) with open(os.path.join(args.out, "io.github.wivrn.wivrn.yml"), "w") as f: