mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 11:44:55 +00:00
Fix macOS/Linux issues
- Fixes png lib becoming undefined on macOS - Auto-detect macports png/Qt paths - Fixes typos - Workaround for AppleClang/fmt bug
This commit is contained in:
@@ -116,7 +116,7 @@ static inline void ToUpper(std::string& str) {
|
||||
#if _WIN32
|
||||
using Sstat = struct ::_stat64;
|
||||
#else
|
||||
using SStat = struct stat;
|
||||
using Sstat = struct stat;
|
||||
#endif
|
||||
|
||||
constexpr size_t StrLen(const char* str) { return std::char_traits<char>::length(str); }
|
||||
@@ -313,28 +313,6 @@ inline unsigned long StrToUl(const char* str, char** endPtr, int base) {
|
||||
return strtoul(str, endPtr, base);
|
||||
}
|
||||
|
||||
inline bool CheckFreeSpace(const char* path, size_t reqSz) {
|
||||
#if _WIN32
|
||||
ULARGE_INTEGER freeBytes;
|
||||
wchar_t buf[1024];
|
||||
wchar_t* end;
|
||||
const nowide::wstackstring wpath(path);
|
||||
DWORD ret = GetFullPathNameW(wpath.get(), 1024, buf, &end);
|
||||
if (!ret || ret > 1024)
|
||||
LogModule.report(logvisor::Fatal, FMT_STRING("GetFullPathNameW {}"), path);
|
||||
if (end)
|
||||
end[0] = L'\0';
|
||||
if (!GetDiskFreeSpaceExW(buf, &freeBytes, nullptr, nullptr))
|
||||
LogModule.report(logvisor::Fatal, FMT_STRING("GetDiskFreeSpaceExW {}: {}"), path, GetLastError());
|
||||
return reqSz < freeBytes.QuadPart;
|
||||
#else
|
||||
struct statvfs svfs;
|
||||
if (statvfs(path, &svfs))
|
||||
LogModule.report(logvisor::Fatal, FMT_STRING("statvfs {}: {}"), path, strerror(errno));
|
||||
return reqSz < svfs.f_frsize * svfs.f_bavail;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool PathRelative(const char* path) {
|
||||
if (!path || !path[0])
|
||||
return false;
|
||||
|
||||
@@ -426,7 +426,6 @@ Connection::Connection(int verbosityLevel) {
|
||||
std::string writefds = fmt::format(FMT_STRING("{}"), m_readpipe[1]);
|
||||
std::string vLevel = fmt::format(FMT_STRING("{}"), verbosityLevel);
|
||||
|
||||
/* Try user-specified blender first */
|
||||
if (blenderBin) {
|
||||
execlp(blenderBin->c_str(), blenderBin->c_str(), "--background", "-P", blenderShellPath.c_str(), "--",
|
||||
readfds.c_str(), writefds.c_str(), vLevel.c_str(), blenderAddonPath.c_str(), nullptr);
|
||||
@@ -437,32 +436,6 @@ Connection::Connection(int verbosityLevel) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Try steam */
|
||||
steamBlender = hecl::FindCommonSteamApp("Blender");
|
||||
if (steamBlender.size()) {
|
||||
#ifdef __APPLE__
|
||||
steamBlender += "/blender.app/Contents/MacOS/blender";
|
||||
#else
|
||||
steamBlender += "/blender";
|
||||
#endif
|
||||
execlp(steamBlender.c_str(), steamBlender.c_str(), "--background", "-P", blenderShellPath.c_str(), "--",
|
||||
readfds.c_str(), writefds.c_str(), vLevel.c_str(), blenderAddonPath.c_str(), nullptr);
|
||||
if (errno != ENOENT) {
|
||||
errbuf = fmt::format(FMT_STRING("NOLAUNCH {}"), strerror(errno));
|
||||
_writeStr(errbuf.c_str(), errbuf.size(), m_readpipe[1]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise default blender */
|
||||
execlp(DEFAULT_BLENDER_BIN, DEFAULT_BLENDER_BIN, "--background", "-P", blenderShellPath.c_str(), "--",
|
||||
readfds.c_str(), writefds.c_str(), vLevel.c_str(), blenderAddonPath.c_str(), nullptr);
|
||||
if (errno != ENOENT) {
|
||||
errbuf = fmt::format(FMT_STRING("NOLAUNCH {}"), strerror(errno));
|
||||
_writeStr(errbuf.c_str(), errbuf.size(), m_readpipe[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Unable to find blender */
|
||||
_writeStr("NOBLENDER", 9, m_readpipe[1]);
|
||||
exit(1);
|
||||
@@ -490,15 +463,7 @@ Connection::Connection(int verbosityLevel) {
|
||||
BlenderLog.report(logvisor::Fatal, FMT_STRING("Unable to launch blender: {}"), lineStr.c_str() + 9);
|
||||
} else if (!lineStr.compare(0, 9, "NOBLENDER")) {
|
||||
_closePipe();
|
||||
#if _WIN32
|
||||
BlenderLog.report(logvisor::Fatal, FMT_STRING("Unable to find blender at '{}'"), blenderBin.value());
|
||||
#else
|
||||
if (blenderBin)
|
||||
BlenderLog.report(logvisor::Fatal, FMT_STRING("Unable to find blender at '{}' or '{}'"), blenderBin,
|
||||
DEFAULT_BLENDER_BIN);
|
||||
else
|
||||
BlenderLog.report(logvisor::Fatal, FMT_STRING("Unable to find blender at '{}'"), DEFAULT_BLENDER_BIN);
|
||||
#endif
|
||||
BlenderLog.report(logvisor::Fatal, FMT_STRING("Unable to find blender"));
|
||||
} else if (lineStr == "INVALIDBLENDERVER") {
|
||||
_closePipe();
|
||||
BlenderLog.report(logvisor::Fatal, FMT_STRING("Installed blender version must be >= {}.{}"),
|
||||
|
||||
@@ -74,7 +74,7 @@ std::optional<std::string> FindBlender(int& major, int& minor) {
|
||||
}
|
||||
|
||||
#else
|
||||
if (!RegFileExists(blenderBin)) {
|
||||
if (!RegFileExists(blenderBin->c_str())) {
|
||||
/* Try steam */
|
||||
steamBlender = hecl::FindCommonSteamApp("Blender");
|
||||
if (steamBlender.size()) {
|
||||
@@ -84,15 +84,15 @@ std::optional<std::string> FindBlender(int& major, int& minor) {
|
||||
steamBlender += "/blender";
|
||||
#endif
|
||||
blenderBin = steamBlender.c_str();
|
||||
if (!RegFileExists(blenderBin)) {
|
||||
if (!RegFileExists(blenderBin->c_str())) {
|
||||
blenderBin = DEFAULT_BLENDER_BIN;
|
||||
if (!RegFileExists(blenderBin)) {
|
||||
if (!RegFileExists(blenderBin->c_str())) {
|
||||
blenderBin = nullptr;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
blenderBin = DEFAULT_BLENDER_BIN;
|
||||
if (!RegFileExists(blenderBin)) {
|
||||
if (!RegFileExists(blenderBin->c_str())) {
|
||||
blenderBin = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ std::optional<std::string> FindBlender(int& major, int& minor) {
|
||||
delete[] infoData;
|
||||
}
|
||||
#else
|
||||
std::string command = std::string("\"") + blenderBin + "\" --version";
|
||||
std::string command = std::string("\"") + blenderBin.value() + "\" --version";
|
||||
FILE* fp = popen(command.c_str(), "r");
|
||||
char versionBuf[256];
|
||||
size_t rdSize = fread(versionBuf, 1, 255, fp);
|
||||
|
||||
@@ -28,7 +28,9 @@
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cpp_lib_ranges
|
||||
#include <ranges>
|
||||
#endif
|
||||
#include <logvisor/logvisor.hpp>
|
||||
|
||||
using namespace std::literals;
|
||||
@@ -37,7 +39,7 @@ namespace hecl {
|
||||
unsigned VerbosityLevel = 0;
|
||||
bool GuiMode = false;
|
||||
logvisor::Module LogModule("hecl");
|
||||
constexpr std::string_view Illegals = "<>?\""sv;
|
||||
constexpr std::string_view Illegals = R"(<>?")";
|
||||
|
||||
void SanitizePath(std::string& path) {
|
||||
if (path.empty())
|
||||
|
||||
Reference in New Issue
Block a user