Skip to content

Commit

Permalink
fix failing doc build by using ExternalProcess (not clear why vanilla…
Browse files Browse the repository at this point in the history
… QProcess does not work)
  • Loading branch information
cbielow committed Jul 12, 2024
1 parent 5a4304f commit f623e21
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
19 changes: 17 additions & 2 deletions doc/doxygen/install/install-linux.doxygen
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@
\endcode
to the CMake options, where <tt>/PATH/TO/qt/lib/cmake/Qt6/</tt> depends on your system settings and Qt version.

When configuring %OpenMS, consider setting <tt>WITH_GUI=Off</tt> and
<tt>HAS_XSERVER=Off</tt>, especially as you may not have compiled Qt with
When configuring %OpenMS using CMake, consider setting <tt>-D WITH_GUI=Off</tt> and
<tt>-D HAS_XSERVER=Off</tt>, especially as you may not have compiled Qt with
OpenGL and you may not have an X server.

\include "../doxygen/install/common-cmake-parameters.doxygen"
Expand Down Expand Up @@ -313,6 +313,21 @@
If you want to enable the corresponding tests in CMake, this has to happen <b>before</b> you configure and build the
project.

When running OpenMS executables or building the documentation, it may happen that Qt will cause problems and bail out with
error messages such as:
```
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: linuxfb, wayland, minimalegl, vnc, minimal, wayland-egl, eglfs, vkkhrdisplay.
```

To fix, you can try to set the environment variable `QT_QPA_PLATFORM` to another plugin, such as
```
export QT_QPA_PLATFORM=minimal
```
and re-run the application.

@section running_linux_openms Running OpenMS
If the build from @ref install_linux_openms is ready, you can now run a
GNU/Linux %OpenMS tool by e.g. executing
Expand Down
51 changes: 22 additions & 29 deletions doc/doxygen/parameters/TOPPDocumenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

#include <OpenMS/FORMAT/XMLFile.h>
#include <OpenMS/FORMAT/ParamXMLFile.h>
#include <OpenMS/SYSTEM/ExternalProcess.h>

#include <QtCore/QProcess>
#include <QDir>

#include <iostream>
#include <fstream>
Expand Down Expand Up @@ -220,28 +220,24 @@ bool generate(const ToolListType& tools, const String& prefix, const String& bin
}
else
{
process.start(String(command + " --help").toQString());
process.waitForFinished();

std::string lines = QString(process.readAll()).toStdString();
if (process.error() != QProcess::UnknownError)
{
// error while generation cli docu
ExternalProcess ep([&](const String& s) { f << s; },
[&](const String& s) { f << s; });
String error_msg;
if (ep.run(command.toQString(), QStringList() << "--help", "", false, error_msg, ExternalProcess::IO_MODE::READ_WRITE)
!= ExternalProcess::RETURNSTATE::SUCCESS)
{ // error while generation cli docu
stringstream ss;
ss << "Errors occurred while generating the command line documentation for " << it->first << "!" << endl;
ss << "Output was: \n" << lines << endl;
ss << "Command line was: \n " << command << endl;
ss << "Output was: \n";
ep.setCallbacks([&](const String& s) { ss << s; }, [&](const String& s) { ss << s; });
ep.run(command.toQString(), QStringList() << "--help", "", false, error_msg, ExternalProcess::IO_MODE::READ_WRITE);
ss << "\nCommand line was: \n " << command << endl;
f << ss.str();
cerr << ss.str();
errors_occured = true;
f.close();
continue;
}
else
{
// write output
f << lines;
}
}
f.close();

Expand All @@ -253,20 +249,17 @@ bool generate(const ToolListType& tools, const String& prefix, const String& bin
it->first != "TOPPAS")
{
String tmp_file = File::getTempDirectory() + "/" + File::getUniqueName() + "_" + it->first + ".ini";
String ini_command = command + " -write_ini " + tmp_file;
process.start(ini_command.toQString());
process.waitForFinished();

if (process.error() != QProcess::UnknownError || !File::exists(tmp_file))
{
std::string lines = QString(process.readAll()).toStdString();

// error while generation cli docu
stringstream ss;
ss << "Errors occurred while writing ini file for " << it->first << "!" << endl;
ss << "Output was: \n" << lines << endl;
ss << "Command line was: \n " << ini_command << endl;
cerr << ss.str();
const auto ini_command_args = QStringList() << "-write_ini" << tmp_file.toQString();

ExternalProcess ep([&](const String& s) { f << s; }, [&](const String& s) { f << s; });
String error_msg;
if (ep.run(command.toQString(), ini_command_args, "", false, error_msg,
ExternalProcess::IO_MODE::READ_WRITE)
!= ExternalProcess::RETURNSTATE::SUCCESS
|| ! File::exists(tmp_file))
{ // error while generation cli docu
std::cerr << "Errors occurred while writing ini file for " << it->first << "!" << std::endl;
std::cerr << "Command line was: \n " << command << ini_command_args.join(" ").toStdString() << std::endl;
errors_occured = true;
continue;
}
Expand Down

0 comments on commit f623e21

Please sign in to comment.