Files
FEX-Emu--FEX/Source/Tools/FEXGetConfig/Main.cpp
T
Ryan Houdek 5fe6afc270 FEXServer: Adds new FEXServer service
This is a relatively invasive change since multiple things needed to
happen at once.

* Socket based logging is removed
  * Logging has been replaced to only support stdout, stderr, and server
  * Server is now default and replaces what FEXLogServer did
  * Server logging now uses a pipe instead of a socket
  * Can be faster than stderr and stdout since the application doesn't
    need to wait on terminal output

* FEXMountDaemon has been removed
  * Functionality has been merged in to FEXServer

* FEXServer is always executed on FEX initialization time
  * Similar in behaviour to Wine's wineserver
  * Can explicitly start this before using FEX for logging purposes
  * Stays around until all instances of FEX exit
  * Will stick around for a short amount of time in case of spurious
    execution

* FEXServer will soon be extended to do more than logging and squashfs
  mounting

* FEX rootfs scripts will need to be updated to support this path
  * Just means rbinding the /tmp folder and forcing a FEXServer instance
    to be alive
* Pressure-vessel works fine in this case since FEXServer will already
  be running
  * It already rbinds the host /tmp folder which is why this works
2022-06-23 07:51:56 -07:00

69 lines
2.1 KiB
C++

#include "ConfigDefines.h"
#include "OptionParser.h"
#include "Common/FEXServerClient.h"
#include "git_version.h"
#include <FEXCore/Config/Config.h>
#include <filesystem>
#include <stdio.h>
#include <string>
int main(int argc, char **argv, char **envp) {
FEXCore::Config::Initialize();
FEXCore::Config::AddLayer(FEXCore::Config::CreateMainLayer());
// No FEX arguments passed through command line
FEXCore::Config::AddLayer(FEXCore::Config::CreateEnvironmentLayer(envp));
FEXCore::Config::Load();
// Load the arguments
optparse::OptionParser Parser = optparse::OptionParser()
.description("Simple application to get a couple of FEX options");
Parser.add_option("--install-prefix")
.action("store_true")
.help("Print the FEX install prefix");
Parser.add_option("--app")
.help("Load an application profile for this application if it exists");
Parser.add_option("--current-rootfs")
.action("store_true")
.help("Print the directory that contains the FEX rootfs. Mounted in the case of squashfs");
Parser.add_option("--version")
.action("store_true")
.help("Print the installed FEX-Emu version");
optparse::Values Options = Parser.parse_args(argc, argv);
if (Options.is_set_by_user("app")) {
// Load the application config if one was provided
auto ProgramName = std::filesystem::path(Options["app"]).filename();
FEXCore::Config::AddLayer(FEXCore::Config::CreateAppLayer(ProgramName, true));
FEXCore::Config::AddLayer(FEXCore::Config::CreateAppLayer(ProgramName, false));
}
// Reload the meta layer
FEXCore::Config::ReloadMetaLayer();
if (Options.is_set_by_user("version")) {
fprintf(stdout, GIT_DESCRIBE_STRING "\n");
}
if (Options.is_set_by_user("install_prefix")) {
fprintf(stdout, FEX_INSTALL_PREFIX "\n");
}
if (Options.is_set_by_user("current_rootfs")) {
int ServerFD = FEXServerClient::ConnectToServer();
if (ServerFD != -1) {
auto RootFS = FEXServerClient::RequestRootFSPath(ServerFD);
if (!RootFS.empty()) {
fprintf(stdout, "%s\n", RootFS.c_str());
}
}
}
return 0;
}