Closed madebr closed 2 months ago
In src/harness/harness.c around line 182 after
char* root_dir = getenv("DETHRACE_ROOT_DIR");
if (root_dir != NULL) {
LOG_INFO("DETHRACE_ROOT_DIR is set to '%s'", root_dir);
} else {
root_dir = OS_Dirname(argv[0]);
}
I had to add this for macOS app bundle and Windows console support
char* root_dir = getenv("DETHRACE_ROOT_DIR");
if (root_dir != NULL) {
LOG_INFO("DETHRACE_ROOT_DIR is set to '%s'", root_dir);
} else {
root_dir = OS_Dirname(argv[0]);
#ifdef __APPLE__
strcat (root_dir, "/../Resources"); // Pierre-Marie Baty -- macOS .app fix
#endif /* __APPLE__ */
if (root_dir[0] == 0)
strcpy(root_dir, "."); // Pierre-Marie Baty -- consistency check (also Win32 fix)
}
Basically calling chdir("") on Win32 raises an errno (which looks legit to me, what's intriguing here is that it swallows it on POSIX platforms).
The original issue is about Macos finder running applications from /
instead of the directory containing the executable.
You're using a "macosx bundle", which our cmake script does not support at all.
Somebody with an app should modify cmake + sources to add that.
CMake has MACOSX_BUNDLE
.
A complication with macosx bundles is that for legal reasons, we cannot bundle game resources with an app bundle.
Defaulting root_dir to "." when neither the DETHRACE_ROOT_DIR envvar is set nor OS_Dirname(argv[0]) fails to return a directory when argv[0] is just an executable name does prevent the issue described here, actually.
I understand and agree that proprietary game resources can't be distributed in a macOS app bundle, but the end user is still allowed to copy them there. That's what the DosBox .app bundle does. Dethrace could take advantage of that maybe?
I don't use the CMake script. I made my own build script in bourne shell for dethrace for POSIX platforms, so that I can compile the game with just a compiler and a linker as a requirement (and of course the needed system libraries). Sorry for diverging from the mainstream :/
Message ID: @.***>
No need to say sorry. If somebody with a mac and knowledge of CMake comes along, (s)he's free to add this support.
From discord: