Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default folder for resources and css on macOS is really odd and no configure option available to set the right path #293

Open
barracuda156 opened this issue Apr 19, 2024 · 5 comments

Comments

@barracuda156
Copy link
Contributor

Why would anyone want to dump some random support files into ${prefix}/bin together with the binary? But this is where they are looked for, since apparently the build system ignores ABADDON_RESOURCE_DIR on macOS, and instead uses a relative .. So nothing gets found on the app launch.

The same will happen on any *BSD, since there is no macro for them, so “unknown OS” will be used, which is again ..

This is arguably a strange default, but at least, perhaps, let the user set the correct location?

@barracuda156
Copy link
Contributor Author

@uowuo Could we make something sensible with this? I have it working now, but I did not succeed in making it recognize ${prefix}/share/abaddon path for resources – and had to dump the binary together with those two folders into a dedicated prefix. This is undesirable, though I could perhaps hack around that by adding a wrapper which would run from ${prefix}/bin and pull everything from wherever.

@ouwou
Copy link
Member

ouwou commented Apr 23, 2024

this is the part responsible for getting the resources directory

abaddon/src/platform.cpp

Lines 159 to 179 in 5e382b1

std::string Platform::FindResourceFolder() {
static std::string found_path;
static bool found = false;
if (found) return found_path;
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;
}
spdlog::get("discord")->warn("cant find a resources folder, will try to load from cwd");
found_path = ".";
found = true;
return found_path;
}

i didnt write it, but i think the macos code there is for when its in a .app form?
i can change it to check ABADDON_RESOURCE_DIR too. what would be the right way to determine ${prefix} in your examples? on linux its $XDG_DATA_HOME (usually $HOME/.local/share). same thing?

@barracuda156
Copy link
Contributor Author

barracuda156 commented Apr 24, 2024

i didnt write it, but i think the macos code there is for when its in a .app form?

Possibly (this is not something I understand well), but the build does not produce an app bundle.

If ABADDON_RESOURCE_DIR can be passed to CMake so that is recognized and used by the build, that will solve the problem.
As a default value, I would expect a path relative to CMAKE_INSTALL_PREFIX (which is either chosen by a package system or manually by a user). Usually it will be ${CMAKE_INSTALL_PREFIX}/share/${name} for resources, or something similar. (As long as custom setting is possible, default behavior does not matter too much.)

If you would like the default installation to go into home folder, that can be done then by making it a default value for CMAKE_INSTALL_PREFIX if it is not specified by a user.

P. S. I had to use wrappers to make this work, it is kinda ugly (though the first one, for libstdc++ case, is unavoidable):
https://github.com/macports/macports-ports/blob/d6a202a84122d1faa7105f2a360506343a93b81c/net/abaddon/Portfile#L107-L140

@TheMorc
Copy link
Contributor

TheMorc commented Apr 26, 2024

Ouch, blame me haha. It's all been set up to work for it being packaged and me having no proper experience did it in a way that worked for me.

@barracuda156
Copy link
Contributor Author

I guess we need need this either to be configurable or the code to search for both (bundle paths and normal Unix paths).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants