fix: compatibility with boost process v2

This commit is contained in:
Marcus Holland-Moritz 2025-04-07 21:02:38 +02:00
parent 93368a4065
commit a622d89f9c
4 changed files with 29 additions and 24 deletions

View File

@ -32,12 +32,14 @@
#include <folly/portability/PThread.h>
#include <folly/portability/Unistd.h>
#if __has_include(<boost/process/v1/search_path.hpp>)
#if __has_include(<boost/process/v2/environment.hpp>) && defined(DWARFS_HAVE_CLOSE_RANGE)
#define BOOST_PROCESS_VERSION 2
#include <boost/process/v2/environment.hpp>
#elif __has_include(<boost/process/v1/search_path.hpp>)
#define BOOST_PROCESS_VERSION 1
#include <boost/process/v1/search_path.hpp>
#define DWARFS_BOOST_PROCESS_SEARCH_PATH_V1 1
#else
#include <boost/process/search_path.hpp>
#define DWARFS_BOOST_PROCESS_SEARCH_PATH_V1 0
#endif
#ifdef __APPLE__
@ -233,12 +235,12 @@ os_access_generic::thread_get_cpu_time(std::thread::id tid,
std::filesystem::path
os_access_generic::find_executable(std::filesystem::path const& name) const {
#if DWARFS_BOOST_PROCESS_SEARCH_PATH_V1
using boost::process::v1::search_path;
#if BOOST_PROCESS_VERSION == 2
return boost::process::v2::environment::find_executable(name.wstring())
.wstring();
#else
using boost::process::search_path;
return boost::process::search_path(name.wstring()).wstring();
#endif
return search_path(name.wstring()).wstring();
}
} // namespace dwarfs

View File

@ -27,6 +27,7 @@
#include <cerrno>
#include <chrono>
#include <concepts>
#include <deque>
#include <filesystem>
#include <fstream>
#include <future>
@ -49,7 +50,15 @@
#endif
#include <boost/asio/io_context.hpp>
#if __has_include(<boost/process/v1/args.hpp>)
#define BOOST_PROCESS_VERSION 1
#include <boost/process/v1/args.hpp>
#include <boost/process/v1/async.hpp>
#include <boost/process/v1/child.hpp>
#include <boost/process/v1/io.hpp>
#else
#include <boost/process.hpp>
#endif
#include <fmt/format.h>
#if FMT_VERSION >= 110000

View File

@ -44,16 +44,6 @@
#include <fcntl.h>
#ifndef _WIN32
#if __has_include(<boost/process/v2/environment.hpp>) && defined(DWARFS_HAVE_CLOSE_RANGE)
#define BOOST_PROCESS_VERSION 2
#include <boost/process/v2/environment.hpp>
#else
#define BOOST_PROCESS_VERSION 1
#include <boost/process/search_path.hpp>
#endif
#endif
#include <fmt/format.h>
#include <dwarfs/config.h>
@ -99,7 +89,7 @@
#include <dwarfs/library_dependencies.h>
#include <dwarfs/logger.h>
#include <dwarfs/mmap.h>
#include <dwarfs/os_access.h>
#include <dwarfs/os_access_generic.h>
#include <dwarfs/performance_monitor.h>
#include <dwarfs/reader/cache_tidy_config.h>
#include <dwarfs/reader/filesystem_options.h>
@ -435,14 +425,10 @@ void check_fusermount(dwarfs_userdata& userdata) {
static constexpr std::string_view const fuse_pkg = "fuse/fuse2";
#endif
#if BOOST_PROCESS_VERSION == 2
auto fusermount =
boost::process::v2::environment::find_executable(fusermount_name);
#else
auto fusermount = boost::process::search_path(std::string(fusermount_name));
#endif
dwarfs::os_access_generic().find_executable(fusermount_name);
if (fusermount.empty() || !boost::filesystem::exists(fusermount)) {
if (fusermount.empty() || !std::filesystem::exists(fusermount)) {
LOG_PROXY(prod_logger_policy, userdata.lgr);
LOG_ERROR << "Could not find `" << fusermount_name << "' in PATH";
LOG_WARN << "Do you need to install the `" << fuse_pkg << "' package?";

View File

@ -31,7 +31,15 @@
#include <vector>
#include <boost/asio/io_context.hpp>
#if __has_include(<boost/process/v1/args.hpp>)
#define BOOST_PROCESS_VERSION 1
#include <boost/process/v1/args.hpp>
#include <boost/process/v1/async.hpp>
#include <boost/process/v1/child.hpp>
#include <boost/process/v1/io.hpp>
#else
#include <boost/process.hpp>
#endif
#include <dwarfs/os_access.h>
#include <dwarfs/tool/pager.h>