mirror of
https://github.com/patchzyy/wiicompiled
synced 2026-09-10 17:16:47 -04:00
final linux support necessary changes to build a working application
This commit is contained in:
@@ -213,6 +213,16 @@ function(mkw_configure_product target)
|
||||
dbghelp user32 winmm ws2_32 iphlpapi secur32 crypt32 windowsapp setupapi winusb)
|
||||
|
||||
set_target_properties(${target} PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||
else()
|
||||
# mkw_runtime_common is an OBJECT library: WiiCompiled/RetroRewind only pull in its .o
|
||||
# files via $<TARGET_OBJECTS:>, which does not propagate mkw_runtime_common's own
|
||||
# target_link_libraries (object libraries don't carry usage requirements to a consumer
|
||||
# that isn't itself linked against as a target). fiber_manager.cpp's co_* calls live in
|
||||
# those objects, so the actual executable link needs mkw::libco directly, same as it
|
||||
# needs it independently of that first `if(WIN32)` branch above.
|
||||
target_link_libraries(${target} PRIVATE mkw::libco)
|
||||
endif()
|
||||
if(WIN32)
|
||||
foreach(runtime_dll libc++.dll libunwind.dll)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_CXX_COMPILER}" "--print-file-name=${runtime_dll}"
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#else
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
struct RuntimeUserConfig {
|
||||
@@ -168,7 +171,22 @@ inline std::optional<std::filesystem::path> ExecutableDirectory() {
|
||||
buffer.resize(buffer.size() * 2);
|
||||
}
|
||||
#else
|
||||
return std::nullopt;
|
||||
// /proc/self/exe is a Linux-specific magic symlink to the running executable; readlink()
|
||||
// does not NUL-terminate and silently truncates if the buffer is too small, so this grows
|
||||
// the buffer until the result no longer fills it completely, the same doubling strategy as
|
||||
// the Windows branch above uses for GetModuleFileNameW.
|
||||
std::string buffer(256, '\0');
|
||||
for (;;) {
|
||||
const ssize_t length = readlink("/proc/self/exe", buffer.data(), buffer.size());
|
||||
if (length < 0) {
|
||||
return std::nullopt;
|
||||
}
|
||||
if (static_cast<size_t>(length) < buffer.size()) {
|
||||
buffer.resize(static_cast<size_t>(length));
|
||||
return std::filesystem::path(buffer).parent_path();
|
||||
}
|
||||
buffer.resize(buffer.size() * 2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -209,6 +227,15 @@ inline std::filesystem::path ApplicationDataDirectory() {
|
||||
CoTaskMemFree(rawPath);
|
||||
return directory;
|
||||
}
|
||||
#else
|
||||
// XDG Base Directory spec equivalent of FOLDERID_LocalAppData: $XDG_DATA_HOME if set and
|
||||
// non-empty, otherwise its default of $HOME/.local/share.
|
||||
if (const char* xdgDataHome = std::getenv("XDG_DATA_HOME"); xdgDataHome && *xdgDataHome) {
|
||||
return std::filesystem::path(xdgDataHome) / kApplicationDirectoryName;
|
||||
}
|
||||
if (const char* home = std::getenv("HOME"); home && *home) {
|
||||
return std::filesystem::path(home) / ".local" / "share" / kApplicationDirectoryName;
|
||||
}
|
||||
#endif
|
||||
return std::filesystem::current_path() / kApplicationDirectoryName;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,13 @@
|
||||
#include <sstream>
|
||||
#include <unordered_map>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#endif
|
||||
|
||||
MemoryInline::PageEntry MemoryInline::g_pageTable[MemoryInline::kPageCount]{};
|
||||
uintptr_t MemoryInline::g_fullPageBias[MemoryInline::kPageCount]{};
|
||||
|
||||
Reference in New Issue
Block a user