Add a way to disable pipes for the Wine host

For some reason ujam plugins (and other plugins made with the Gorilla
Engine, like the LoopCloud plugins) will throw a `JS_EXEC_FAILED` error
when trying to load the plugin while either of the STDOUT or STDERR
streams is pointing to a pipe. Simply redirecting the output to a file
fixes this. By default we'll write the output to
`<temporary_directory>/yabridge-plugin-output.log`, but you can also set
the new `disable_pipes` option to `"/dev/null"` to completely throw away
all output.

This addresses #47.
This commit is contained in:
Robbert van der Helm
2021-05-18 17:55:39 +02:00
parent 99428ba28e
commit 95badeb1bc
6 changed files with 128 additions and 41 deletions
+17
View File
@@ -24,6 +24,8 @@
#include <toml++/toml.h>
#include <fstream>
#include "utils.h"
namespace fs = boost::filesystem;
Configuration::Configuration() noexcept {}
@@ -84,6 +86,21 @@ Configuration::Configuration(const fs::path& config_path,
} else {
invalid_options.push_back(key);
}
} else if (key == "disable_pipes") {
// This option can be either enabled or disable with a boolean,
// or it can be set to an absolute path
if (const auto parsed_value = value.as_boolean()) {
if (*parsed_value) {
disable_pipes = get_temporary_directory() /
"yabridge-plugin-output.log";
} else {
disable_pipes = std::nullopt;
}
} else if (const auto parsed_value = value.as_string()) {
disable_pipes = parsed_value->get();
} else {
invalid_options.push_back(key);
}
} else if (key == "editor_double_embed") {
if (const auto parsed_value = value.as_boolean()) {
editor_double_embed = parsed_value->get();
+15
View File
@@ -81,6 +81,19 @@ class Configuration {
*/
std::optional<std::string> group;
/**
* If enabled, we'll redirect the plugin's STDOUT and STDERR streams to this
* file instead of using pipes to intersperse it with yabridge's other
* output. This is necessary for _ujam_ plugins to work since they for some
* reason will throw `JS_EXEC_FAILED` errors when either STDOUT or STDERR is
* a pipe.
*
* This option can be set to a boolean, in which case we'll set the path to
* `<temporary_directory>/yabridge-plugin-output.log`, or it can be set to
* an absolute path. (we don't try to expand tildes)
*/
std::optional<boost::filesystem::path> disable_pipes;
/**
* If this is set to `true`, then the plugin editor should be embedded in
* yet another window. This would result in an embedding sequence of
@@ -187,6 +200,8 @@ class Configuration {
s.ext(group, bitsery::ext::StdOptional(),
[](S& s, auto& v) { s.text1b(v, 4096); });
s.ext(disable_pipes, bitsery::ext::StdOptional(),
[](S& s, auto& v) { s.ext(v, bitsery::ext::BoostPath{}); });
s.value1b(editor_double_embed);
s.value1b(editor_force_dnd);
s.value1b(editor_xembed);