Skip to content

Commit

Permalink
app-emulation/FEX: Add FEX-2409-r2
Browse files Browse the repository at this point in the history
Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
  • Loading branch information
Sasha Finkelstein committed Sep 15, 2024
1 parent c024a60 commit 6f266d1
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app-emulation/FEX/FEX-2409-r1.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ src_configure() {
-DENABLE_CCACHE=False
-DENABLE_LTO=$(if tc-is-lto; then echo True; else echo False; fi)
-DUSE_FEXCONFIG_TOOLKIT=${fexconfig_toolkit}
-DBUILD_THUNKS=$(usex thunks True False)
-DBUILD_THUNKS=$(usex thunks)
-DX86_CFLAGS="${X86_CFLAGS}"
-DX86_CXXFLAGS="${X86_CXXFLAGS}"
-DX86_LDFLAGS="${X86_LDFLAGS}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ JEMALLOC_GLIBC_HASH="888181c5f7072ab1bd7aa7aca6d9f85816a95c43"
# TODO: unvendor this when this version will be available in gentoo
FMTLIB_V="11.0.2"
CPP_OPTPARSE_HASH="eab4212ae864ba64306f0fe87f102e66cb5a3617"
VIXL_HASH="a90f5d5020c305d03d3182dcc90a31321cc7a661"
ROBIN_MAP_HASH="d5683d9f1891e5b04e3e3b2192b5349dc8d814ea"
IMGUI_HASH="4c986ecb8d2807087fd8e34894d1e7a138bc2f1d"

Expand All @@ -25,9 +24,10 @@ SRC_URI="
https://github.com/FEX-Emu/jemalloc/archive/${JEMALLOC_GLIBC_HASH}.tar.gz -> jemalloc-glibc-${JEMALLOC_GLIBC_HASH}.tar.gz
https://github.com/fmtlib/fmt/archive/refs/tags/${FMTLIB_V}.tar.gz -> libfmt-${FMTLIB_V}.tar.gz
https://github.com/Sonicadvance1/cpp-optparse/archive/${CPP_OPTPARSE_HASH}.tar.gz -> cpp-optparse-${CPP_OPTPARSE_HASH}.tar.gz
https://github.com/FEX-Emu/vixl/archive/${VIXL_HASH}.tar.gz -> vixl-${VIXL_HASH}.tar.gz
https://github.com/FEX-Emu/robin-map/archive/${ROBIN_MAP_HASH}.tar.gz -> robin-map-${ROBIN_MAP_HASH}.tar.gz
https://github.com/Sonicadvance1/imgui/archive/${IMGUI_HASH}.tar.gz -> imgui-${IMGUI_HASH}.tar.gz
imgui? (
https://github.com/Sonicadvance1/imgui/archive/${IMGUI_HASH}.tar.gz -> imgui-${IMGUI_HASH}.tar.gz
)
thunks? (
https://github.com/KhronosGroup/Vulkan-Headers/archive/${VULKAN_HEADERS_HASH}.tar.gz -> Vulkan-Headers-${VULKAN_HEADERS_HASH}.tar.gz
)
Expand Down Expand Up @@ -61,7 +61,7 @@ RDEPEND="
)
qt6? (
dev-qt/qtbase:6[gui,wayland(-),widgets,X(-)]
dev-qt/qtquick3d
dev-qt/qtdeclarative:6
)
thunks? (
x11-libs/libX11
Expand All @@ -71,6 +71,8 @@ RDEPEND="
media-libs/libglvnd
x11-libs/libxcb
)
app-emulation/fex-rootfs-gentoo
app-emulation/fex-rootfs-mesa-asahi
"
DEPEND="
>=sys-kernel/linux-headers-6.8
Expand All @@ -79,12 +81,13 @@ DEPEND="

PATCHES="
${FILESDIR}/${P}-unvendor-xxhash.patch
${FILESDIR}/${P}-unvendor-vixl.patch
${FILESDIR}/${P}-unvendor-drm-headers.patch
${FILESDIR}/${P}-tiny-json-as-static.patch
${FILESDIR}/${P}-fmt-as-static.patch
${FILESDIR}/${P}-imgui-as-static.patch
${FILESDIR}/${PN}-thunks-toolchain-paths.patch
${FILESDIR}/${PN}-thunkgen-gcc-install-dir.patch
${FILESDIR}/${P}-system-rootfs-path.patch
"

IUSE="crossdev-toolchain fexconfig imgui qt5 qt6 +thunks"
Expand Down Expand Up @@ -209,10 +212,9 @@ src_unpack() {
jemalloc "jemalloc-${JEMALLOC_HASH}"
jemalloc_glibc "jemalloc-${JEMALLOC_GLIBC_HASH}"
fmt "fmt-${FMTLIB_V}"
vixl "vixl-${VIXL_HASH}"
robin-map "robin-map-${ROBIN_MAP_HASH}"
imgui "imgui-${IMGUI_HASH}"
)
use imgui && deps[imgui]="imgui-${IMGUI_HASH}"
use thunks && deps[Vulkan-Headers]="Vulkan-Headers-${VULKAN_HEADERS_HASH}"
for dep in "${!deps[@]}"; do
rmdir "${S}/External/${dep}" || die
Expand Down Expand Up @@ -252,6 +254,7 @@ THUNK_HEADERS="
"

src_prepare() {
use imgui && eapply "${FILESDIR}/${P}-imgui-as-static.patch"
cmake_src_prepare
sed -i -e "s:__REPLACE_ME_WITH_HEADER_DIR__:${THUNK_INC_DIR}:" ThunkLibs/GuestLibs/CMakeLists.txt || die
mkdir "${THUNK_INC_DIR}" || die
Expand Down Expand Up @@ -306,7 +309,7 @@ src_configure() {
-DENABLE_CCACHE=False
-DENABLE_LTO=$(if tc-is-lto; then echo True; else echo False; fi)
-DUSE_FEXCONFIG_TOOLKIT=${fexconfig_toolkit}
-DBUILD_THUNKS=$(usex thunks True False)
-DBUILD_THUNKS=$(usex thunks)
-DX86_CFLAGS="${X86_CFLAGS}"
-DX86_CXXFLAGS="${X86_CXXFLAGS}"
-DX86_LDFLAGS="${X86_LDFLAGS}"
Expand Down
1 change: 0 additions & 1 deletion app-emulation/FEX/Manifest
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ DIST jemalloc-7ae889695b8bebdc67c004c2c9c8d2e57748d2ab.tar.gz 847970 BLAKE2B 03f
DIST jemalloc-glibc-888181c5f7072ab1bd7aa7aca6d9f85816a95c43.tar.gz 825240 BLAKE2B 63ed3d08a6f0532520b859ebfaf0b3842dad804018014990c9c2e0c75786e44f5d5d0743f003446497aa3961e4712ca213650ec4bfe145850b393b9d888c0034 SHA512 89944779596d541fa941896186cb5d9c00e32e483002619429da5b37e5a6f59e1181c7878513da5b33e3680fb93d1488841e5e64c83c949127009f6741df6c62
DIST libfmt-11.0.2.tar.gz 700956 BLAKE2B c1f7998e68770bbb93ab7211a18b4930727699b340b2f2e15dedc83e55ff02400cfd363abaec1bf63a0165f8c21cc515a4aa23c4f3bc2e65b6fbc041781f0379 SHA512 47ff6d289dcc22681eea6da465b0348172921e7cafff8fd57a1540d3232cc6b53250a4625c954ee0944c87963b17680ecbc3ea123e43c2c822efe0dc6fa6cef3
DIST robin-map-d5683d9f1891e5b04e3e3b2192b5349dc8d814ea.tar.gz 70652 BLAKE2B 03ca6c6c333661ece0ac818d43eee37ead3e0a0acb71c45df201bff30715db89b8f2be3f5bac0991379327f2fac4273ba1bd3d6c4102e5a472a7c7567fae4651 SHA512 23fe18c7d2dda9bc4216201a7e5935c8dc9f51066173e95d514360e3310c994c4dc7786a33f43cb7d15dcceb913375a48b8c02529eacde58c0a80f0e91e9b94d
DIST vixl-a90f5d5020c305d03d3182dcc90a31321cc7a661.tar.gz 26040160 BLAKE2B 293c835d82d4092018e9f88285eaf97021976363719ea2ba7785ee6f8d9d5f2dc11071b2820b79d0bf1ee4059a3686bc9286454afb7cc6bae63aaab189be3890 SHA512 17c636bfc6c6eee193718d3b4b013c2ce6fb074e6d2e06dafe719cbd18773a6e8aa7a745ffb72900655db44d1abe5939848557424e30e6a9c9fdac95ced00350
131 changes: 131 additions & 0 deletions app-emulation/FEX/files/FEX-2409-system-rootfs-path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
diff --git a/Source/Tools/FEXQonfig/Main.cpp b/Source/Tools/FEXQonfig/Main.cpp
index 5f17dfbd9..fe27db867 100644
--- a/Source/Tools/FEXQonfig/Main.cpp
+++ b/Source/Tools/FEXQonfig/Main.cpp
@@ -189,9 +189,12 @@ static void ConfigInit(fextl::string ConfigFilename) {
RootFSModel::RootFSModel() {
INotifyFD = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);

- fextl::string RootFS = FEXCore::Config::GetDataDirectory() + "RootFS/";
- FolderFD = inotify_add_watch(INotifyFD, RootFS.c_str(), IN_CREATE | IN_DELETE);
- if (FolderFD != -1) {
+ fextl::string RootFSUser = FEXCore::Config::GetDataDirectory() + "RootFS/";
+ fextl::string RootFSSystem = "/usr/share/fex-emu/RootFS/";
+
+ FolderFDUser = inotify_add_watch(INotifyFD, RootFSUser.c_str(), IN_CREATE | IN_DELETE);
+ FolderFDSystem = inotify_add_watch(INotifyFD, RootFSSystem.c_str(), IN_CREATE | IN_DELETE);
+ if ((FolderFDSystem != -1) || (FolderFDUser != -1)) {
Thread = std::thread {&RootFSModel::INotifyThreadFunc, this};
} else {
qWarning() << "Could not set up inotify. RootFS folder won't be monitored for changes.";
@@ -209,24 +212,34 @@ RootFSModel::~RootFSModel() {
Thread.join();
}

-void RootFSModel::Reload() {
- beginResetModel();
- removeRows(0, rowCount());
-
- fextl::string RootFS = FEXCore::Config::GetDataDirectory() + "RootFS/";
- std::vector<QString> NamedRootFS {};
- for (auto& it : std::filesystem::directory_iterator(RootFS)) {
+void RootFSModel::ProcessRootfsDir(const fextl::string& Dir, std::vector<QString>& FsList) {
+ std::error_code ec;
+ for (auto& it : std::filesystem::directory_iterator(Dir, ec)) {
if (it.is_directory()) {
- NamedRootFS.push_back(QString::fromStdString(it.path().filename()));
+ FsList.push_back(QString::fromStdString(it.path()));
} else if (it.is_regular_file()) {
// If it is a regular file then we need to check if it is a valid archive
if (it.path().extension() == ".sqsh" && FEX::FormatCheck::IsSquashFS(fextl::string_from_path(it.path()))) {
- NamedRootFS.push_back(QString::fromStdString(it.path().filename()));
+ FsList.push_back(QString::fromStdString(it.path()));
} else if (it.path().extension() == ".ero" && FEX::FormatCheck::IsEroFS(fextl::string_from_path(it.path()))) {
- NamedRootFS.push_back(QString::fromStdString(it.path().filename()));
+ FsList.push_back(QString::fromStdString(it.path()));
}
}
}
+ if (ec && ec != std::errc::no_such_file_or_directory) {
+ throw std::filesystem::filesystem_error("", Dir, ec);
+ }
+}
+
+void RootFSModel::Reload() {
+ beginResetModel();
+ removeRows(0, rowCount());
+
+ fextl::string RootFSUser = FEXCore::Config::GetDataDirectory() + "RootFS/";
+ std::vector<QString> NamedRootFS {};
+ ProcessRootfsDir(RootFSUser, NamedRootFS);
+ fextl::string RootFSSystem = "/usr/share/fex-emu/RootFS/";
+ ProcessRootfsDir(RootFSSystem, NamedRootFS);
std::sort(NamedRootFS.begin(), NamedRootFS.end(), [](const QString& a, const QString& b) { return QString::localeAwareCompare(a, b) < 0; });
for (auto& Entry : NamedRootFS) {
appendRow(new QStandardItem(Entry));
@@ -243,6 +256,13 @@ QUrl RootFSModel::getBaseUrl() const {
return QUrl::fromLocalFile(QString::fromStdString(FEXCore::Config::GetDataDirectory().c_str()) + "RootFS/");
}

+QList<QString> RootFSModel::getStandardPrefixes() const {
+ return QList({
+ QString::fromStdString(FEXCore::Config::GetDataDirectory().c_str()) + "RootFS/",
+ QString::fromStdString("/usr/share/fex-emu/RootFS/")
+ });
+}
+
void RootFSModel::INotifyThreadFunc() {
while (!ExitRequest.try_wait()) {
constexpr size_t DATA_SIZE = (16 * (sizeof(struct inotify_event) + NAME_MAX + 1));
diff --git a/Source/Tools/FEXQonfig/Main.h b/Source/Tools/FEXQonfig/Main.h
index a70cbb1e9..389371887 100644
--- a/Source/Tools/FEXQonfig/Main.h
+++ b/Source/Tools/FEXQonfig/Main.h
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: MIT
+#include <FEXCore/fextl/string.h>
+
#include <QStandardItemModel>
#include <QQmlApplicationEngine>

@@ -41,9 +43,11 @@ class RootFSModel : public QStandardItemModel {
std::latch ExitRequest {1};

int INotifyFD;
- int FolderFD;
+ int FolderFDUser;
+ int FolderFDSystem;

void INotifyThreadFunc();
+ void ProcessRootfsDir(const fextl::string& Dir, std::vector<QString>& FsList);

public:
RootFSModel();
@@ -55,6 +59,7 @@ public slots:
bool hasItem(const QString&) const;

QUrl getBaseUrl() const;
+ QList<QString> getStandardPrefixes() const;
};

class ConfigRuntime : public QObject {
diff --git a/Source/Tools/FEXQonfig/main.qml b/Source/Tools/FEXQonfig/main.qml
index c8cb01aa8..d22c4fd30 100644
--- a/Source/Tools/FEXQonfig/main.qml
+++ b/Source/Tools/FEXQonfig/main.qml
@@ -369,7 +369,14 @@ ApplicationWindow {
component RootFSRadioDelegate: RadioButton {
property var name

- text: name
+ text: (() => {
+ for (const base of RootFSModel.getStandardPrefixes()) {
+ if (name.startsWith(base)) {
+ return name.substring(base.length)
+ }
+ }
+ return name
+ })()
checked: rootfsList.selectedItem === name

onToggled: {

0 comments on commit 6f266d1

Please sign in to comment.