Added experimental support for building on Haiku

This commit is contained in:
Leon Styhre 2024-08-10 14:28:24 +02:00
parent 0347a276ea
commit c15eff8994
9 changed files with 106 additions and 14 deletions

View file

@ -132,6 +132,15 @@ elseif(WIN32)
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/external/pugixml/pugixml.dll) if(NOT EXISTS ${PROJECT_SOURCE_DIR}/external/pugixml/pugixml.dll)
message(FATAL_ERROR "-- You need to build the dependencies in ./external first") message(FATAL_ERROR "-- You need to build the dependencies in ./external first")
endif() endif()
elseif(HAIKU)
find_package(FreeImage REQUIRED)
find_package(Freetype REQUIRED)
find_package(HarfBuzz REQUIRED)
find_package(ICU REQUIRED)
find_package(Intl REQUIRED)
find_package(Libgit2 REQUIRED)
find_package(Pugixml REQUIRED)
find_package(SDL2 REQUIRED)
elseif(NOT EMSCRIPTEN AND NOT ANDROID) elseif(NOT EMSCRIPTEN AND NOT ANDROID)
find_package(CURL REQUIRED) find_package(CURL REQUIRED)
find_package(FFmpeg REQUIRED) find_package(FFmpeg REQUIRED)
@ -378,11 +387,7 @@ if(DEINIT_ON_LAUNCH)
endif() endif()
endif() endif()
if(AUR_BUILD OR FLATPAK_BUILD OR RETRODECK OR RPI) if(AUR_BUILD OR FLATPAK_BUILD OR RETRODECK OR RPI OR HAIKU OR CMAKE_SYSTEM_NAME MATCHES FreeBSD)
set(APPLICATION_UPDATER OFF)
endif()
if(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
set(APPLICATION_UPDATER OFF) set(APPLICATION_UPDATER OFF)
endif() endif()
@ -510,6 +515,17 @@ elseif(ANDROID)
${CMAKE_CURRENT_SOURCE_DIR}/external/libgit2/include ${CMAKE_CURRENT_SOURCE_DIR}/external/libgit2/include
${CMAKE_CURRENT_SOURCE_DIR}/external/pugixml/src ${CMAKE_CURRENT_SOURCE_DIR}/external/pugixml/src
${CMAKE_CURRENT_SOURCE_DIR}/external/SDL_Android) ${CMAKE_CURRENT_SOURCE_DIR}/external/SDL_Android)
elseif(HAIKU)
set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include
${CMAKE_CURRENT_SOURCE_DIR}/external/FFmpeg
${FreeImage_INCLUDE_DIRS}
${FREETYPE_INCLUDE_DIRS}
${GIT2_INCLUDE_PATH}
${HarfBuzz_INCLUDE_DIRS}
${ICU_INCLUDE_DIRS}
${PUGIXML_INCLUDE_DIRS}
${SDL2_INCLUDE_DIR})
else() else()
set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS} set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS}
${FFMPEG_INCLUDE_DIRS} ${FFMPEG_INCLUDE_DIRS}
@ -642,6 +658,23 @@ elseif(EMSCRIPTEN)
${PROJECT_SOURCE_DIR}/libFreeImage.a ${PROJECT_SOURCE_DIR}/libFreeImage.a
${PROJECT_SOURCE_DIR}/libfreetype.a ${PROJECT_SOURCE_DIR}/libfreetype.a
${PROJECT_SOURCE_DIR}/libpugixml.a) ${PROJECT_SOURCE_DIR}/libpugixml.a)
elseif(HAIKU)
# This is just a temporary hack to get the application to build on Haiku r1beta4.
set(COMMON_LIBRARIES /boot/system/lib/libavcodec.so.58
/boot/system/lib/libavfilter.so.7
/boot/system/lib/libavformat.so.58
/boot/system/lib/libavutil.so.56
/boot/system/lib/libswresample.so.3
/boot/system/lib/libswscale.so.5
/boot/system/lib/libcurl.so.4
${Intl_LIBRARY}
${FreeImage_LIBRARIES}
${FREETYPE_LIBRARIES}
${GIT2_LIBRARY}
${HarfBuzz_LIBRARIES}
${ICU_LIBRARIES}
${PUGIXML_LIBRARIES}
${SDL2_LIBRARY})
else() else()
set(COMMON_LIBRARIES ${CURL_LIBRARIES} set(COMMON_LIBRARIES ${CURL_LIBRARIES}
${FFMPEG_LIBRARIES} ${FFMPEG_LIBRARIES}
@ -715,21 +748,29 @@ set(dir ${CMAKE_CURRENT_SOURCE_DIR})
set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE) set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE) set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
if (COMPILE_LOCALIZATIONS) if(COMPILE_LOCALIZATIONS)
add_subdirectory(locale) add_subdirectory(locale)
endif() endif()
add_subdirectory(es-pdf-converter) if(NOT HAIKU)
add_subdirectory(es-pdf-converter)
endif()
add_subdirectory(external) add_subdirectory(external)
add_subdirectory(es-core) add_subdirectory(es-core)
add_subdirectory(es-app) add_subdirectory(es-app)
# Make sure that es-pdf-convert is built first, and then that rlottie is built before es-core. # Make sure that es-pdf-convert is built first, and then that rlottie is built before es-core.
# Also set lottie2gif to not be built. # Also set lottie2gif to not be built.
add_dependencies(lunasvg es-pdf-convert) if(NOT HAIKU)
add_dependencies(lunasvg es-pdf-convert)
endif()
if (COMPILE_LOCALIZATIONS) if(COMPILE_LOCALIZATIONS)
add_dependencies(es-pdf-convert localization) if(NOT HAIKU)
add_dependencies(es-pdf-convert localization)
else()
add_dependencies(lunasvg localization)
endif()
endif() endif()
add_dependencies(es-core rlottie) add_dependencies(es-core rlottie)

View file

@ -273,7 +273,9 @@ elseif(APPLE)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/licenses DESTINATION ../Resources) install(DIRECTORY ${CMAKE_SOURCE_DIR}/licenses DESTINATION ../Resources)
elseif(NOT ANDROID) elseif(NOT ANDROID)
install(TARGETS es-de RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) install(TARGETS es-de RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(TARGETS es-pdf-convert RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) if(NOT HAIKU)
install(TARGETS es-pdf-convert RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif()
if(CMAKE_SYSTEM_NAME MATCHES Linux) if(CMAKE_SYSTEM_NAME MATCHES Linux)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/es-de.6.gz install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/es-de.6.gz
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man6) DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man6)

View file

@ -62,6 +62,9 @@ void FindRules::loadFindRules()
#elif defined(__APPLE__) #elif defined(__APPLE__)
filePath = filePath =
ResourceManager::getInstance().getResourcePath(":/systems/macos/es_find_rules.xml", false); ResourceManager::getInstance().getResourcePath(":/systems/macos/es_find_rules.xml", false);
#elif defined(__HAIKU__)
filePath =
ResourceManager::getInstance().getResourcePath(":/systems/haiku/es_find_rules.xml", false);
#else #else
filePath = filePath =
ResourceManager::getInstance().getResourcePath(":/systems/unix/es_find_rules.xml", false); ResourceManager::getInstance().getResourcePath(":/systems/unix/es_find_rules.xml", false);
@ -1006,6 +1009,8 @@ std::vector<std::string> SystemData::getConfigPath()
path = ResourceManager::getInstance().getResourcePath(":/systems/windows/es_systems.xml", true); path = ResourceManager::getInstance().getResourcePath(":/systems/windows/es_systems.xml", true);
#elif defined(__APPLE__) #elif defined(__APPLE__)
path = ResourceManager::getInstance().getResourcePath(":/systems/macos/es_systems.xml", true); path = ResourceManager::getInstance().getResourcePath(":/systems/macos/es_systems.xml", true);
#elif defined(__HAIKU__)
path = ResourceManager::getInstance().getResourcePath(":/systems/haiku/es_systems.xml", true);
#else #else
path = ResourceManager::getInstance().getResourcePath(":/systems/unix/es_systems.xml", true); path = ResourceManager::getInstance().getResourcePath(":/systems/unix/es_systems.xml", true);
#endif #endif

View file

@ -1084,7 +1084,7 @@ void GuiMenu::openSoundOptions()
auto s = new GuiSettings(_("SOUND SETTINGS")); auto s = new GuiSettings(_("SOUND SETTINGS"));
// TODO: Implement system volume support for macOS and Android. // TODO: Implement system volume support for macOS and Android.
#if !defined(__APPLE__) && !defined(__ANDROID__) && !defined(__FreeBSD__) #if !defined(__APPLE__) && !defined(__ANDROID__) && !defined(__FreeBSD__) && !defined(__HAIKU__)
// System volume. // System volume.
// The reason to create the VolumeControl object every time instead of making it a singleton // The reason to create the VolumeControl object every time instead of making it a singleton
// is that this is the easiest way to detect new default audio devices or changes to the // is that this is the easiest way to detect new default audio devices or changes to the
@ -1597,7 +1597,7 @@ void GuiMenu::openOtherOptions()
auto keyboardQuitShortcut = std::make_shared<OptionListComponent<std::string>>( auto keyboardQuitShortcut = std::make_shared<OptionListComponent<std::string>>(
getHelpStyle(), _("KEYBOARD QUIT SHORTCUT"), false); getHelpStyle(), _("KEYBOARD QUIT SHORTCUT"), false);
std::string selectedShortcut {Settings::getInstance()->getString("KeyboardQuitShortcut")}; std::string selectedShortcut {Settings::getInstance()->getString("KeyboardQuitShortcut")};
#if defined(_WIN64) || defined(__unix__) #if defined(_WIN64) || defined(__unix__) || defined(__HAIKU__)
keyboardQuitShortcut->add("ALT + F4", "AltF4", selectedShortcut == "AltF4"); keyboardQuitShortcut->add("ALT + F4", "AltF4", selectedShortcut == "AltF4");
keyboardQuitShortcut->add("CTRL + Q", "CtrlQ", selectedShortcut == "CtrlQ"); keyboardQuitShortcut->add("CTRL + Q", "CtrlQ", selectedShortcut == "CtrlQ");
keyboardQuitShortcut->add("ALT + Q", "AltQ", selectedShortcut == "AltQ"); keyboardQuitShortcut->add("ALT + Q", "AltQ", selectedShortcut == "AltQ");

View file

@ -605,6 +605,11 @@ bool VideoFFmpegComponent::setupAudioFilters()
std::string channelLayout(128, '\0'); std::string channelLayout(128, '\0');
#if defined(__HAIKU__)
// This is just a temporary hack to get the application to build on Haiku r1beta4.
av_get_channel_layout_string(&channelLayout[0], sizeof(channelLayout),
mAudioCodecContext->CHANNELS, mAudioCodecContext->channel_layout);
#else
#if LIBAVUTIL_VERSION_MAJOR >= 58 || \ #if LIBAVUTIL_VERSION_MAJOR >= 58 || \
(LIBAVUTIL_VERSION_MAJOR >= 57 && LIBAVUTIL_VERSION_MINOR >= 28) (LIBAVUTIL_VERSION_MAJOR >= 57 && LIBAVUTIL_VERSION_MINOR >= 28)
// FFmpeg 5.1 and above. // FFmpeg 5.1 and above.
@ -616,6 +621,7 @@ bool VideoFFmpegComponent::setupAudioFilters()
av_get_channel_layout_string(&channelLayout[0], sizeof(channelLayout), av_get_channel_layout_string(&channelLayout[0], sizeof(channelLayout),
mAudioCodecContext->CHANNELS, mAudioCodecContext->channel_layout); mAudioCodecContext->CHANNELS, mAudioCodecContext->channel_layout);
#endif #endif
#endif // __HAIKU__
std::string filterArguments; std::string filterArguments;
filterArguments.append("time_base=") filterArguments.append("time_base=")

View file

@ -12,6 +12,10 @@
// Disable the CImg display capabilities. // Disable the CImg display capabilities.
#define cimg_display 0 #define cimg_display 0
#if defined(__HAIKU__)
#include <sys/time.h>
#endif
#include "CImg.h" #include "CImg.h"
#include <vector> #include <vector>

View file

@ -28,6 +28,10 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#if defined(__HAIKU__)
#include <sys/time.h>
#endif
#include <array> #include <array>
#include <fcntl.h> #include <fcntl.h>
@ -84,7 +88,7 @@ namespace Utils
const std::string& startDirectory, const std::string& startDirectory,
bool runInBackground) bool runInBackground)
{ {
#if defined(__unix__) || defined(__APPLE__) #if defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__)
std::string command = std::string(cmd_utf8) + " 2>&1 &"; std::string command = std::string(cmd_utf8) + " 2>&1 &";
// Launching games while keeping ES-DE running in the background is very crude as for // Launching games while keeping ES-DE running in the background is very crude as for

View file

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!-- This is the ES-DE find rules configuration file for Haiku -->
<ruleList>
<emulator name="OS-SHELL">
<!-- Operating system shell -->
<rule type="systempath">
<entry>bash</entry>
<entry>sh</entry>
</rule>
</emulator>
<emulator name="DOSBOX">
<!-- DOS emulator DOSBox -->
<rule type="systempath">
<entry>DOSBox</entry>
</rule>
</emulator>
</ruleList>

View file

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!-- This is the ES-DE Frontend game systems configuration file for Haiku -->
<systemList>
<system>
<name>dos</name>
<fullname>DOS (PC)</fullname>
<path>%ROMPATH%/dos</path>
<extension>.bat .BAT .com .COM .conf .CONF .cue .CUE .dosz .DOSZ .exe .EXE .iso .ISO .7z .7Z .zip .ZIP</extension>
<command label="DOSBox (Standalone)">%STARTDIR%=%GAMEDIR% %EMULATOR_DOSBOX% %ROM%</command>
<platform>dos</platform>
<theme>dos</theme>
</system>
</systemList>