Skip to content

Commit

Permalink
Make run-in-editor detection on macOS backwards-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
dapetcu21 committed Jan 17, 2019
1 parent 9c85452 commit e720f8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions bridge/src/fmod_dynamic_loading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ void FMODBridge::cleanupLibraries() {
}

#else

static bool endsIn(const char * haystack, const char * needle) {
size_t needleLen = strlen(needle);
size_t haystackLen = strlen(haystack);
return (haystackLen >= needleLen && 0 == strcmp(needle, haystack + haystackLen - needleLen));
}

bool FMODBridge::linkLibraries() {
if (FMODBridge::dlHandleLL && FMODBridge::dlHandleST) {
return true;
Expand Down Expand Up @@ -245,6 +252,7 @@ bool FMODBridge::linkLibraries() {

#if defined(__APPLE__)
#define FMB_PLATFORM "osx"
#define FMB_PLATFORM_ALT "darwin"
#define FMB_EXT ""
#elif defined(__linux__)
#define FMB_PLATFORM "linux"
Expand All @@ -263,9 +271,12 @@ bool FMODBridge::linkLibraries() {
#if defined(FMB_PLATFORM) && defined(FMB_ARCH)
#define FMB_EDITOR_SUFFIX SEP "build" SEP FMB_ARCH "-" FMB_PLATFORM SEP "dmengine" FMB_EXT

static const size_t suffixLen = strlen(FMB_EDITOR_SUFFIX);
size_t exePathLen = strlen(exePath);
if (exePathLen >= suffixLen && 0 == strcmp(FMB_EDITOR_SUFFIX, exePath + exePathLen - suffixLen)) {
#ifdef FMB_PLATFORM_ALT
#define FMB_EDITOR_SUFFIX_ALT SEP "build" SEP FMB_ARCH "-" FMB_PLATFORM_ALT SEP "dmengine" FMB_EXT
if (endsIn(exePath, FMB_EDITOR_SUFFIX) || endsIn(exePath, FMB_EDITOR_SUFFIX_ALT)) {
#else
if (endsIn(exePath, FMB_EDITOR_SUFFIX)) {
#endif
LOGI("Running in the editor. Will attempt to load libraries from project");

const char* projPath = dirname(dirname(dirname(exePath)));
Expand Down
Binary file modified fmod/lib/x86_64-osx/libfmodbridge.a
Binary file not shown.

0 comments on commit e720f8b

Please sign in to comment.