diff --git a/CMakeLists.txt b/CMakeLists.txt index c9293f2dc..e1527bf36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,15 @@ elseif(WIN32) if(NOT EXISTS ${PROJECT_SOURCE_DIR}/external/pugixml/pugixml.dll) message(FATAL_ERROR "-- You need to build the dependencies in ./external first") 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) find_package(CURL REQUIRED) find_package(FFmpeg REQUIRED) @@ -378,11 +387,7 @@ if(DEINIT_ON_LAUNCH) endif() endif() -if(AUR_BUILD OR FLATPAK_BUILD OR RETRODECK OR RPI) - set(APPLICATION_UPDATER OFF) -endif() - -if(CMAKE_SYSTEM_NAME MATCHES FreeBSD) +if(AUR_BUILD OR FLATPAK_BUILD OR RETRODECK OR RPI OR HAIKU OR CMAKE_SYSTEM_NAME MATCHES FreeBSD) set(APPLICATION_UPDATER OFF) endif() @@ -510,6 +515,17 @@ elseif(ANDROID) ${CMAKE_CURRENT_SOURCE_DIR}/external/libgit2/include ${CMAKE_CURRENT_SOURCE_DIR}/external/pugixml/src ${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() set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS} ${FFMPEG_INCLUDE_DIRS} @@ -642,6 +658,23 @@ elseif(EMSCRIPTEN) ${PROJECT_SOURCE_DIR}/libFreeImage.a ${PROJECT_SOURCE_DIR}/libfreetype.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() set(COMMON_LIBRARIES ${CURL_LIBRARIES} ${FFMPEG_LIBRARIES} @@ -715,21 +748,29 @@ set(dir ${CMAKE_CURRENT_SOURCE_DIR}) set(EXECUTABLE_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) endif() -add_subdirectory(es-pdf-converter) +if(NOT HAIKU) + add_subdirectory(es-pdf-converter) +endif() add_subdirectory(external) add_subdirectory(es-core) add_subdirectory(es-app) # 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. -add_dependencies(lunasvg es-pdf-convert) +if(NOT HAIKU) + add_dependencies(lunasvg es-pdf-convert) +endif() -if (COMPILE_LOCALIZATIONS) - add_dependencies(es-pdf-convert localization) +if(COMPILE_LOCALIZATIONS) + if(NOT HAIKU) + add_dependencies(es-pdf-convert localization) + else() + add_dependencies(lunasvg localization) + endif() endif() add_dependencies(es-core rlottie) diff --git a/es-app/CMakeLists.txt b/es-app/CMakeLists.txt index b70e70419..e2b3e7e21 100644 --- a/es-app/CMakeLists.txt +++ b/es-app/CMakeLists.txt @@ -273,7 +273,9 @@ elseif(APPLE) install(DIRECTORY ${CMAKE_SOURCE_DIR}/licenses DESTINATION ../Resources) elseif(NOT ANDROID) 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) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/es-de.6.gz DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man6) diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index e926b9a65..a1b12e422 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -62,6 +62,9 @@ void FindRules::loadFindRules() #elif defined(__APPLE__) filePath = 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 filePath = ResourceManager::getInstance().getResourcePath(":/systems/unix/es_find_rules.xml", false); @@ -1006,6 +1009,8 @@ std::vector SystemData::getConfigPath() path = ResourceManager::getInstance().getResourcePath(":/systems/windows/es_systems.xml", true); #elif defined(__APPLE__) path = ResourceManager::getInstance().getResourcePath(":/systems/macos/es_systems.xml", true); +#elif defined(__HAIKU__) + path = ResourceManager::getInstance().getResourcePath(":/systems/haiku/es_systems.xml", true); #else path = ResourceManager::getInstance().getResourcePath(":/systems/unix/es_systems.xml", true); #endif diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 7d957e948..352042702 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -1084,7 +1084,7 @@ void GuiMenu::openSoundOptions() auto s = new GuiSettings(_("SOUND SETTINGS")); // 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. // 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 @@ -1597,7 +1597,7 @@ void GuiMenu::openOtherOptions() auto keyboardQuitShortcut = std::make_shared>( getHelpStyle(), _("KEYBOARD QUIT SHORTCUT"), false); 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("CTRL + Q", "CtrlQ", selectedShortcut == "CtrlQ"); keyboardQuitShortcut->add("ALT + Q", "AltQ", selectedShortcut == "AltQ"); diff --git a/es-core/src/components/VideoFFmpegComponent.cpp b/es-core/src/components/VideoFFmpegComponent.cpp index 913485686..3143e3f78 100644 --- a/es-core/src/components/VideoFFmpegComponent.cpp +++ b/es-core/src/components/VideoFFmpegComponent.cpp @@ -605,6 +605,11 @@ bool VideoFFmpegComponent::setupAudioFilters() 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 || \ (LIBAVUTIL_VERSION_MAJOR >= 57 && LIBAVUTIL_VERSION_MINOR >= 28) // FFmpeg 5.1 and above. @@ -616,6 +621,7 @@ bool VideoFFmpegComponent::setupAudioFilters() av_get_channel_layout_string(&channelLayout[0], sizeof(channelLayout), mAudioCodecContext->CHANNELS, mAudioCodecContext->channel_layout); #endif +#endif // __HAIKU__ std::string filterArguments; filterArguments.append("time_base=") diff --git a/es-core/src/utils/CImgUtil.h b/es-core/src/utils/CImgUtil.h index 03e4569ed..c20263324 100644 --- a/es-core/src/utils/CImgUtil.h +++ b/es-core/src/utils/CImgUtil.h @@ -12,6 +12,10 @@ // Disable the CImg display capabilities. #define cimg_display 0 +#if defined(__HAIKU__) +#include +#endif + #include "CImg.h" #include diff --git a/es-core/src/utils/PlatformUtil.cpp b/es-core/src/utils/PlatformUtil.cpp index 4fdae727d..27a145373 100644 --- a/es-core/src/utils/PlatformUtil.cpp +++ b/es-core/src/utils/PlatformUtil.cpp @@ -28,6 +28,10 @@ #include #endif +#if defined(__HAIKU__) +#include +#endif + #include #include @@ -84,7 +88,7 @@ namespace Utils const std::string& startDirectory, bool runInBackground) { -#if defined(__unix__) || defined(__APPLE__) +#if defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__) std::string command = std::string(cmd_utf8) + " 2>&1 &"; // Launching games while keeping ES-DE running in the background is very crude as for diff --git a/resources/systems/haiku/es_find_rules.xml b/resources/systems/haiku/es_find_rules.xml new file mode 100644 index 000000000..afaf24c16 --- /dev/null +++ b/resources/systems/haiku/es_find_rules.xml @@ -0,0 +1,17 @@ + + + + + + + bash + sh + + + + + + DOSBox + + + \ No newline at end of file diff --git a/resources/systems/haiku/es_systems.xml b/resources/systems/haiku/es_systems.xml new file mode 100644 index 000000000..6d64f7ba9 --- /dev/null +++ b/resources/systems/haiku/es_systems.xml @@ -0,0 +1,13 @@ + + + + + dos + DOS (PC) + %ROMPATH%/dos + .bat .BAT .com .COM .conf .CONF .cue .CUE .dosz .DOSZ .exe .EXE .iso .ISO .7z .7Z .zip .ZIP + %STARTDIR%=%GAMEDIR% %EMULATOR_DOSBOX% %ROM% + dos + dos + + \ No newline at end of file