mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-22 15:37:53 -05:00
possibly mac native binaries
This commit is contained in:
parent
b148c3957a
commit
f9a6333c94
2 changed files with 30 additions and 2 deletions
|
@ -66,7 +66,10 @@ Result<> Mod::Impl::setup() {
|
||||||
CCFileUtils::get()->addSearchPath(searchPathRoot.string().c_str());
|
CCFileUtils::get()->addSearchPath(searchPathRoot.string().c_str());
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto binariesDir = searchPathRoot / m_metadata.getID() / "binaries" / PlatformID::toShortString(GEODE_PLATFORM_TARGET);
|
// binaries on macos are merged, so make the platform binaries merged as well
|
||||||
|
auto const binaryPlatformId = PlatformID::toShortString(GEODE_PLATFORM_TARGET GEODE_MACOS(, true));
|
||||||
|
|
||||||
|
auto const binariesDir = searchPathRoot / m_metadata.getID() / "binaries" / binaryPlatformId;
|
||||||
if (std::filesystem::exists(binariesDir))
|
if (std::filesystem::exists(binariesDir))
|
||||||
LoaderImpl::get()->addNativeBinariesPath(binariesDir);
|
LoaderImpl::get()->addNativeBinariesPath(binariesDir);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <loader/ModImpl.hpp>
|
#include <loader/ModImpl.hpp>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <loader/LogImpl.hpp>
|
#include <loader/LogImpl.hpp>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
using namespace geode::prelude;
|
using namespace geode::prelude;
|
||||||
|
|
||||||
|
@ -132,7 +133,31 @@ bool Loader::Impl::userTriedToLoadDLLs() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loader::Impl::addNativeBinariesPath(std::filesystem::path const& path) {
|
void Loader::Impl::addNativeBinariesPath(std::filesystem::path const& path) {
|
||||||
log::warn("LoaderImpl::addNativeBinariesPath not implement on this platform, not adding path {}", path.string());
|
// this takes advantage of dyld using already loaded binaries when loading relative shared libraries
|
||||||
|
// however, this also means that the binaries are loaded, which could have some weird side effects
|
||||||
|
// but if you could use dlopen (and thus control when libraries are loaded), then you wouldn't be using this, would you?
|
||||||
|
|
||||||
|
for (const auto& entry : std::filesystem::directory_iterator(path)) {
|
||||||
|
if (!entry.is_regular_file()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& entry_path = entry.path();
|
||||||
|
|
||||||
|
if (entry_path.extension() != ".dylib") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto handle = dlopen(entry_path.string().c_str(), RTLD_LAZY);
|
||||||
|
|
||||||
|
if (!handle) {
|
||||||
|
auto err = dlerror();
|
||||||
|
log::warn("failed to load native binary at {}: dlerror returned ({})", entry_path.string(), err);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
dlclose(handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Loader::Impl::getGameVersion() {
|
std::string Loader::Impl::getGameVersion() {
|
||||||
|
|
Loading…
Reference in a new issue