Also add a way to use logging library without Asio

This commit is contained in:
Robbert van der Helm
2022-04-16 19:21:34 +02:00
parent d63b4d2da5
commit 85989f4c1d
5 changed files with 13 additions and 9 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ compiler_options = [
chainloader_compiler_options = [
# We use our process library for sending notifications from the chainloaders,
# but we don't need the Asio pipe support there
'-DPROCESS_NO_ASIO',
'-DWITHOUT_ASIO',
]
# HACK: Some stuff from `windows.h` that we don't need results in conflicting
-2
View File
@@ -16,8 +16,6 @@
#include "common.h"
#include <vestige/aeffectx.h>
#include <chrono>
#include <ctime>
#include <fstream>
+6
View File
@@ -20,12 +20,16 @@
#include <optional>
#include <ostream>
// The chainloader needs to be able to use the logger without pulling in a bunch
// of Boost things
#ifndef WITHOUT_ASIO
#ifdef __WINE__
#include "../wine-host/asio-fix.h"
#endif
#include <asio/read_until.hpp>
#include <asio/streambuf.hpp>
#endif // WITHOUT_ASIO
#include "../utils.h"
@@ -138,6 +142,7 @@ class Logger {
*/
void log(const std::string& message);
#ifndef WITHOUT_ASIO
/**
* Write output from an async pipe to the log on a line by line basis.
* Useful for logging the Wine process's STDOUT and STDERR streams.
@@ -167,6 +172,7 @@ class Logger {
async_log_pipe_lines(pipe, buffer, prefix);
});
}
#endif // WITHOUT_ASIO
/**
* Log a message that should only be printed when the `verbosity` is set to
+2 -2
View File
@@ -314,7 +314,7 @@ Process::StatusResult Process::spawn_get_status() const {
}
}
#ifndef PROCESS_NO_ASIO
#ifndef WITHOUT_ASIO
Process::HandleResult Process::spawn_child_piped(
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
asio::posix::stream_descriptor& stdout_pipe,
@@ -385,7 +385,7 @@ Process::HandleResult Process::spawn_child_piped(
return Handle(child_pid);
}
}
#endif // PROCESS_NO_ASIO
#endif // WITHOUT_ASIO
Process::HandleResult Process::spawn_child_redirected(
const ghc::filesystem::path& filename) const {
+4 -4
View File
@@ -26,13 +26,13 @@
// We also use this header from the chainloaders, and we don't want to pull in
// Asio there
#ifndef PROCESS_NO_ASIO
#ifndef WITHOUT_ASIO
#ifdef __WINE__
#include "../wine-host/asio-fix.h"
#endif
#include <asio/posix/stream_descriptor.hpp>
#endif // PROCESS_NO_ASIO
#endif // WITHOUT_ASIO
// A minimal API akin to Boost.Process for launching and managing processes
// using plain Linux APIs. Needed so we can implement our chainloader without
@@ -240,7 +240,7 @@ class Process {
*/
StatusResult spawn_get_status() const;
#ifndef PROCESS_NO_ASIO
#ifndef WITHOUT_ASIO
/**
* Spawn the process without waiting for its completion, leave STDIN alone,
* create pipes for STDOUT and STDERR, and assign those to the provided
@@ -251,7 +251,7 @@ class Process {
HandleResult spawn_child_piped(
asio::posix::stream_descriptor& stdout_pipe,
asio::posix::stream_descriptor& stderr_pipe) const;
#endif // PROCESS_NO_ASIO
#endif // WITHOUT_ASIO
/**
* Spawn the process without waiting for its completion, leave STDIN alone,