From 5c765a9520a8fb073271f68d410aef3b7d0a3fb3 Mon Sep 17 00:00:00 2001 From: casey langen Date: Sat, 24 Dec 2022 19:03:46 -0800 Subject: [PATCH] A couple tweaks to support compiling against Haiku without changes. --- .cmake/ConfigureCurses.cmake | 11 ++++++++--- src/musikcore/support/Common.cpp | 17 ++++++++++++++++- src/musikcube/Main.cpp | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.cmake/ConfigureCurses.cmake b/.cmake/ConfigureCurses.cmake index d2d1d0776..09dca7bcf 100644 --- a/.cmake/ConfigureCurses.cmake +++ b/.cmake/ConfigureCurses.cmake @@ -1,5 +1,10 @@ -if (EXISTS "/etc/arch-release" OR EXISTS "/etc/manjaro-release" OR NO_NCURSESW) - add_definitions (-DNO_NCURSESW) -elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD" ) +if( + NO_NCURSESW OR + EXISTS "/etc/arch-release" OR + EXISTS "/etc/manjaro-release" OR + CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR + CMAKE_SYSTEM_NAME MATCHES "OpenBSD" OR + CMAKE_SYSTEM_NAME MATCHES "Haiku" +) add_definitions (-DNO_NCURSESW) endif() \ No newline at end of file diff --git a/src/musikcore/support/Common.cpp b/src/musikcore/support/Common.cpp index f943452ff..fd4277bdc 100644 --- a/src/musikcore/support/Common.cpp +++ b/src/musikcore/support/Common.cpp @@ -54,6 +54,8 @@ #include #elif __APPLE__ #include +#elif __HAIKU__ + #include #else #include #include @@ -133,12 +135,25 @@ namespace musik { namespace core { fs::path command = fs::absolute(fs::path(fs::u8path(argv[0]))); realpath(command.u8string().c_str(), pathbuf); delete[] argv; + #elif defined __HAIKU__ + image_info ii; + int32_t c = 0; + while (get_next_image_info(0, &c, &ii) == B_OK) { + if (ii.type == B_APP_IMAGE) { + if (strlen(ii.name)) { + std::string fn(ii.name); + result = u8path(fn).parent_path().u8string(); + } + } + } #else std::string pathToProc = u8fmt("/proc/%d/exe", (int) getpid()); readlink(pathToProc.c_str(), pathbuf, PATH_MAX); #endif - result.assign(pathbuf); + if (!result.size() && strlen(pathbuf)) { + result.assign(pathbuf); + } size_t last = result.find_last_of("/"); result = result.substr(0, last); /* remove filename component */ #endif diff --git a/src/musikcube/Main.cpp b/src/musikcube/Main.cpp index 848c1fa8f..8d4902404 100644 --- a/src/musikcube/Main.cpp +++ b/src/musikcube/Main.cpp @@ -114,7 +114,7 @@ int main(int argc, char* argv[]) { auto consoleLogger = new ConsoleLogger(Window::MessageQueue()); - std::vector debuggerBackends = { + std::vector debuggerBackends = { new debug::SimpleFileBackend(), consoleLogger };