-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1204 from Sonicadvance1/pressure_vessel_option_pr…
…ogram Adds new FEXGetConfig program
- Loading branch information
Showing
5 changed files
with
144 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
#pragma once | ||
#include <string> | ||
|
||
namespace FEX::RootFS { | ||
// Updates the RootFS path in the case of squashfs | ||
// Doesn't mount the rootfs if it doesn't exist | ||
// Returns true if the rootfs is accessible regularly, mounted or folder | ||
bool UpdateRootFSPath(); | ||
// Returns where the rootfs lock file lives even if the squashfs isn't mounted | ||
std::string GetRootFSLockFile(); | ||
// Checks if the rootfs lock exists | ||
bool CheckLockExists(std::string const &LockPath); | ||
bool Setup(char **const envp); | ||
void Shutdown(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
set(NAME FEXGetConfig) | ||
set(SRCS Main.cpp) | ||
|
||
add_executable(${NAME} ${SRCS}) | ||
|
||
list(APPEND LIBS Common CommonCore) | ||
|
||
install(TARGETS ${NAME} | ||
RUNTIME | ||
DESTINATION bin | ||
COMPONENT runtime) | ||
|
||
target_link_libraries(${NAME} PRIVATE ${LIBS} ${STATIC_PIE_OPTIONS}) | ||
|
||
target_include_directories(${NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Source/) | ||
target_include_directories(${NAME} PRIVATE ${CMAKE_BINARY_DIR}/generated) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include "ConfigDefines.h" | ||
#include "OptionParser.h" | ||
#include "Common/Config.h" | ||
#include "Common/RootFSSetup.h" | ||
#include "git_version.h" | ||
#include <FEXCore/Config/Config.h> | ||
|
||
#include <filesystem> | ||
|
||
int main(int argc, char **argv, char **envp) { | ||
FEXCore::Config::Initialize(); | ||
FEXCore::Config::AddLayer(std::make_unique<FEX::Config::MainLoader>()); | ||
// No FEX arguments passed through command line | ||
FEXCore::Config::AddLayer(std::make_unique<FEX::Config::EnvLoader>(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("--current-rootfs-lock") | ||
.action("store_true") | ||
.help("SquashFS lock file if squashfs is mounted"); | ||
|
||
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(std::make_unique<FEX::Config::AppLoader>(ProgramName, true)); | ||
FEXCore::Config::AddLayer(std::make_unique<FEX::Config::AppLoader>(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_lock")) { | ||
auto LockFile = FEX::RootFS::GetRootFSLockFile(); | ||
if (FEX::RootFS::CheckLockExists(LockFile)) { | ||
fprintf(stdout, "%s\n", LockFile.c_str()); | ||
} | ||
} | ||
|
||
if (Options.is_set_by_user("current_rootfs")) { | ||
// Ensure RootFS is setup before config options try to pull CONFIG_ROOTFS | ||
auto Status = FEX::RootFS::UpdateRootFSPath(); | ||
|
||
if (Status) { | ||
FEX_CONFIG_OPT(LDPath, ROOTFS); | ||
fprintf(stdout, "%s\n", LDPath().c_str()); | ||
} | ||
} | ||
|
||
return 0; | ||
} |