Skip to content

Commit c17bfae

Browse files
committed
WIP: add workaround for older Boost versions without process v2
Not sure whether Boost 1.811.0 is the correct version to make the cut, because the changelog of Boost Process is ... sparse.
1 parent fd669b8 commit c17bfae

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

code/html_generation.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@
2121
#include "html_generation.hpp"
2222
#include <fstream>
2323
#include <iostream>
24-
#include <boost/asio/io_context.hpp>
25-
#include <boost/process/v2/process.hpp>
26-
#include <boost/process/v2/posix/fork_and_forget_launcher.hpp>
24+
#include <boost/version.hpp>
25+
#if BOOST_VERSION <= 108100
26+
#include <boost/process.hpp>
27+
#else
28+
#include <boost/asio/io_context.hpp>
29+
#include <boost/process/v2/process.hpp>
30+
#include <boost/process/v2/posix/fork_and_forget_launcher.hpp>
31+
#endif
2732
#include "browser_detection.hpp"
2833
#include "Config.hpp"
2934
#include "paths.hpp"
@@ -69,12 +74,24 @@ void openFirstIndexFile(const FolderMap& fm, const std::string& html_dir)
6974
}
7075
// Open file via Boost Process.
7176
std::cout << "Opening " << fullFileName << " in browser ...\n";
72-
boost::asio::io_context context;
7377
std::vector<std::string> params = additional_parameters(browser.value().type);
78+
#if BOOST_VERSION <= 108100
79+
std::string command = browser.value().path.string();
80+
for (const auto& param: params)
81+
{
82+
command += " " + param;
83+
}
84+
command += " " + fullFileName;
85+
boost::process::child child(command);
86+
child.detach();
87+
#else
88+
// After Boost 1.81.0 use process v2 API.
89+
boost::asio::io_context context;
7490
params.push_back(fullFileName);
7591
auto launcher = boost::process::v2::posix::fork_and_forget_launcher();
7692
boost::process::v2::process proc(context, browser.value().path.string(), params);
7793
proc.detach();
94+
#endif
7895
}
7996

8097
int generateHtmlFiles(const MessageDatabase& mdb, const FolderMap& fm, const HTMLOptions htmlOptions)

0 commit comments

Comments
 (0)