From 7329cfc38fe27e79a93d84ab3f3f4178cc99192b Mon Sep 17 00:00:00 2001 From: Hybras <24651269+hybras@users.noreply.github.com> Date: Wed, 17 Dec 2025 17:23:05 +0000 Subject: [PATCH 1/3] macOS: fall back to install prefix for resources (fixes hybras/homebrew-tap#235) --- README.md | 4 +++- src/platform.cpp | 28 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 44a00558..b39c719f 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,9 @@ Latest release version: https://github.com/uowuo/abaddon/releases/latest The two folders within the `res` folder (`res/res` and `res/css`) are necessary. Windows also uses the `fonts` folder. You can put them directly next to the executable. On Linux, `css` and `res` can also be loaded from -`~/.local/share/abaddon` or `/usr/share/abaddon` +`~/.local/share/abaddon` or `/usr/share/abaddon`. On macOS when installed via package managers +such as Homebrew the install prefix (e.g. `/usr/local/share/abaddon` or the Homebrew Cellar location) +is also checked for resources (fixes hybras/homebrew-tap#235). `abaddon.ini` will also be automatically used if located at `~/.config/abaddon/abaddon.ini` and there is no `abaddon.ini` in the working directory diff --git a/src/platform.cpp b/src/platform.cpp index 726655be..5fbadf49 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -7,9 +7,7 @@ #ifdef __APPLE__ #include #endif -#ifdef __linux__ - #include "util.hpp" -#endif +#include "util.hpp" #include @@ -170,15 +168,33 @@ std::string Platform::FindResourceFolder() { static bool found = false; if (found) return found_path; + // Try bundle resources first (used when running as an .app bundle) CFURLRef resourceURL = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); char resourcePath[PATH_MAX]; if (CFURLGetFileSystemRepresentation(resourceURL, true, (UInt8 *)resourcePath, PATH_MAX)) { if (resourceURL != NULL) { CFRelease(resourceURL); } - found_path = resourcePath; - found = true; - return found_path; + // Only accept bundle path if it actually contains the expected resource layout + if (util::IsFolder(std::string(resourcePath) + "/res") && util::IsFolder(std::string(resourcePath) + "/css")) { + found_path = resourcePath; + found = true; + return found_path; + } + } + + // Fall back to cwd, user dir or install prefix (e.g. Homebrew installs into share/abaddon) + const auto home_env = std::getenv("HOME"); + if (home_env != nullptr) { + const static std::string home_path = std::string(home_env) + "/.local/share/abaddon"; + + for (const auto &path : {"."s, home_path, std::string(ABADDON_DEFAULT_RESOURCE_DIR)}) { + if (util::IsFolder(path + "/res") && util::IsFolder(path + "/css")) { + found_path = path; + found = true; + return found_path; + } + } } spdlog::get("discord")->warn("cant find a resources folder, will try to load from cwd"); From b8316fbe91747139c794c021fbd7911ede166542 Mon Sep 17 00:00:00 2001 From: Hybras <24651269+hybras@users.noreply.github.com> Date: Wed, 17 Dec 2025 19:14:42 +0000 Subject: [PATCH 2/3] Readme grammar --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b39c719f..e7fae58c 100644 --- a/README.md +++ b/README.md @@ -134,9 +134,9 @@ Latest release version: https://github.com/uowuo/abaddon/releases/latest The two folders within the `res` folder (`res/res` and `res/css`) are necessary. Windows also uses the `fonts` folder. You can put them directly next to the executable. On Linux, `css` and `res` can also be loaded from -`~/.local/share/abaddon` or `/usr/share/abaddon`. On macOS when installed via package managers -such as Homebrew the install prefix (e.g. `/usr/local/share/abaddon` or the Homebrew Cellar location) -is also checked for resources (fixes hybras/homebrew-tap#235). +`~/.local/share/abaddon` or `/usr/share/abaddon`. On macOS, when installed via package managers +such as Homebrew, the install prefix (e.g. `/usr/local/share/abaddon` or the Homebrew Cellar location) +is also checked for resources. `abaddon.ini` will also be automatically used if located at `~/.config/abaddon/abaddon.ini` and there is no `abaddon.ini` in the working directory From 4cf55bd097d7b05333a291b5741bc0cc7a5002a1 Mon Sep 17 00:00:00 2001 From: Hybras <24651269+hybras@users.noreply.github.com> Date: Wed, 17 Dec 2025 19:15:14 +0000 Subject: [PATCH 3/3] Simplify macos lookup logic --- src/platform.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/platform.cpp b/src/platform.cpp index 5fbadf49..d43e0562 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -168,19 +168,12 @@ std::string Platform::FindResourceFolder() { static bool found = false; if (found) return found_path; - // Try bundle resources first (used when running as an .app bundle) CFURLRef resourceURL = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); char resourcePath[PATH_MAX]; if (CFURLGetFileSystemRepresentation(resourceURL, true, (UInt8 *)resourcePath, PATH_MAX)) { if (resourceURL != NULL) { CFRelease(resourceURL); } - // Only accept bundle path if it actually contains the expected resource layout - if (util::IsFolder(std::string(resourcePath) + "/res") && util::IsFolder(std::string(resourcePath) + "/css")) { - found_path = resourcePath; - found = true; - return found_path; - } } // Fall back to cwd, user dir or install prefix (e.g. Homebrew installs into share/abaddon) @@ -188,7 +181,7 @@ std::string Platform::FindResourceFolder() { if (home_env != nullptr) { const static std::string home_path = std::string(home_env) + "/.local/share/abaddon"; - for (const auto &path : {"."s, home_path, std::string(ABADDON_DEFAULT_RESOURCE_DIR)}) { + for (const auto &path : {std::string(resourcePath), "."s, home_path, std::string(ABADDON_DEFAULT_RESOURCE_DIR)}) { if (util::IsFolder(path + "/res") && util::IsFolder(path + "/css")) { found_path = path; found = true;