Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ if (MINGW OR WIN32)
link_libraries(ws2_32)
endif ()

if (HAIKU)
link_libraries(be)
link_libraries(network)
endif ()

if (WIN32)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_definitions(NOMINMAX)
Expand Down Expand Up @@ -71,7 +76,8 @@ if (NOT (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
target_precompile_headers(abaddon PRIVATE <gtkmm.h> src/abaddon.hpp src/util.hpp)
endif ()

if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.1"))
if (NOT HAIKU AND
((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.1")))
target_link_libraries(abaddon stdc++fs)
endif ()

Expand Down
3 changes: 2 additions & 1 deletion cmake/Findatkmm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ find_path(ATKMM_CONFIG_INCLUDE_DIR
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${ATKMM_LIBRARY_NAME}/include)
PATH_SUFFIXES ${ATKMM_LIBRARY_NAME}/include
${ATKMM_LIBRARY_NAME})

find_library(ATKMM_LIBRARY
NAMES ${ATKMM_LIBRARY_NAME}
Expand Down
4 changes: 3 additions & 1 deletion cmake/Findgdkmm.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(gdkmm_LIBRARY_NAME gdkmm-3.0)
set(gtkmm_LIBRARY_NAME gtkmm-3.0)

find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
Expand All @@ -23,7 +24,8 @@ find_path(gdkmm_CONFIG_INCLUDE_DIR
/usr/lib
/usr/local/lib
/opt/local/lib
PATH_SUFFIXES ${gdkmm_LIBRARY_NAME}/include)
PATH_SUFFIXES ${gdkmm_LIBRARY_NAME}/include
${gtkmm_LIBRARY_NAME})

find_library(gdkmm_LIBRARY
NAMES ${gdkmm_LIBRARY_NAME}
Expand Down
3 changes: 2 additions & 1 deletion cmake/Findglibmm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ find_path(GLIBMM_INCLUDE_DIR
find_path(GLIBMM_CONFIG_INCLUDE_DIR
NAMES glibmmconfig.h
HINTS ${GLIBMM_LIBRARY_HINTS}
PATH_SUFFIXES ${GLIBMM_LIBRARY_NAME}/include)
PATH_SUFFIXES ${GLIBMM_LIBRARY_NAME}/include
${GLIBMM_LIBRARY_NAME})

find_library(GLIBMM_LIBRARY
NAMES ${GLIBMM_LIBRARY_NAME}
Expand Down
4 changes: 2 additions & 2 deletions cmake/Findgtkmm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ find_path(GTKMM_INCLUDE_DIR
find_path(GTKMM_CONFIG_INCLUDE_DIR
NAMES gtkmmconfig.h
HINTS ${GTKMM_LIBRARY_HINTS}
PATH_SUFFIXES ${GTKMM_LIBRARY_NAME}/include)
PATH_SUFFIXES ${GTKMM_LIBRARY_NAME} ${GTKMM_LIBRARY_NAME}/include)

find_library(GTKMM_LIB
NAMES ${GTKMM_LIBRARY_NAME}
gtkmm
HINTS ${GTKMM_LIBRARY_HINTS}
HINTS ${GTKMM_LIBRARY_HINTS} ${GTKMM_INCLUDE_DIR}
PATH_SUFFIXES ${GTKMM_LIBRARY_NAME}
${GTKMM_LIBRARY_NAME}/include)

Expand Down
3 changes: 2 additions & 1 deletion cmake/Findsigc++.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ find_path(SIGC++_INCLUDE_DIR
find_path(SIGC++_CONFIG_INCLUDE_DIR
NAMES sigc++config.h
HINTS ${SIGC++_LIBRARY_HINTS}
PATH_SUFFIXES ${SIGC++_LIBRARY_NAME}/include)
PATH_SUFFIXES ${SIGC++_LIBRARY_NAME}/include
${SIGC++_LIBRARY_NAME})

find_library(SIGC++_LIBRARY
NAMES ${SIGC++_LIBRARY_FILE}
Expand Down
69 changes: 69 additions & 0 deletions src/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,75 @@ std::string Platform::FindStateCacheFolder() {
return home_path;
}

#elif __HAIKU__
#include <Directory.h>
#include <Entry.h>
#include <FindDirectory.h>
#include <fs_info.h>

std::string Platform::FindResourceFolder() {
static std::string found_path;
static bool found = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you never set this to true

if(found) return found_path;

// try the path of the packaged resource folder
dev_t volume = dev_for_path("/boot");
char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH] = {};
find_directory(B_SYSTEM_DATA_DIRECTORY, volume, false, buffer, sizeof(buffer));
strcat(buffer, "/abaddon/");

// check if the directory exists
BEntry entry(buffer);
if(entry.Exists() && entry.IsDirectory()) {
found = true;
found_path = std::string(buffer);
return found_path;
}

// otherwise, fall back to the cwd
spdlog::get("discord")->warn("cant find a resources folder, will try to load from cwd");
found_path = ".";
found = true;
return found_path;
}

std::string Platform::FindConfigFile() {
const auto cfg = std::getenv("ABADDON_CONFIG");
if (cfg != nullptr) return cfg;

static std::string found_path;
static bool found = false;
if (found) return found_path;

// generate the path of the config directory. If it does not exist, create it
dev_t volume = dev_for_path("/boot");
char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH] = {};
find_directory(B_USER_SETTINGS_DIRECTORY, volume, false, buffer, sizeof(buffer));
strcat(buffer, "/abaddon/");
create_directory(buffer, 0777);

strcat(buffer, "abaddon.ini");
found_path = std::string(buffer);
return found_path;
}

std::string Platform::FindStateCacheFolder() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesnt create the directory

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also moved the cache to the user directory instead of the system directory (in practice, Haiku is a single-user system, so it should not matter, but the cache cotains user-specific data)

static std::string found_path;
static bool found = false;
if (found) return found_path;

dev_t volume = dev_for_path("/boot");
char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
find_directory(B_USER_CACHE_DIRECTORY, volume, false, buffer, sizeof(buffer));
strcat(buffer, "/abaddon/");
create_directory(buffer, 0777);


found_path = std::string(buffer);
found = true;
return found_path;
}


#else
std::string Platform::FindResourceFolder() {
Expand Down