From abb7b35011a9000aba093fff8f23193a7c8e7bde Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Thu, 19 May 2022 00:25:02 -0400 Subject: [PATCH 1/9] CMakeLists: Add option to produce a Steam build --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1085d51c92..f3b6140158 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,7 @@ option(ENABLE_VULKAN "Enables vulkan video backend" ON) option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence, show the current game on Discord" ON) option(USE_MGBA "Enables GBA controllers emulation using libmgba" ON) option(ENABLE_AUTOUPDATE "Enables support for automatic updates" ON) +option(STEAM "Creates a build for Steam" ON) # Maintainers: if you consider blanket disabling this for your users, please # consider the following points: @@ -937,6 +938,10 @@ else() message(STATUS "libsystemd not found, disabling traversal server watchdog support") endif() +if(STEAM) + add_definitions(-DSTEAM) +endif() + if (WIN32) include_directories(Externals/WIL/include) include_directories(Externals/OpenAL/include) From 52d7a6f56a904a0bada2aa338f79f18d8284a47c Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Fri, 18 Feb 2022 13:50:27 -0500 Subject: [PATCH 2/9] CMakeLists: Enable LINUX_LOCAL_DEV on Steam builds for Linux The Sys folder should be included along with the executable. --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3b6140158..3a22ed7534 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -428,8 +428,10 @@ if(ENABLE_LTO) endif() endif() -if(UNIX AND LINUX_LOCAL_DEV) - add_definitions(-DLINUX_LOCAL_DEV) +if(UNIX) + if(LINUX_LOCAL_DEV OR (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND STEAM)) + add_definitions(-DLINUX_LOCAL_DEV) + endif() endif() # BSDs put packages in /usr/local instead of /usr, so we need to From e679502a5d947e99f606fb8389fbb806b347f05a Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Fri, 18 Feb 2022 13:56:42 -0500 Subject: [PATCH 3/9] GLX: Guard against redefinition of PFNGLXSWAPINTERVALEXTPROC This type is already declared in glxext.h in the Steam Runtime. --- Source/Core/Common/GL/GLInterface/GLX.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Common/GL/GLInterface/GLX.cpp b/Source/Core/Common/GL/GLInterface/GLX.cpp index 930994a992..b04296d096 100644 --- a/Source/Core/Common/GL/GLInterface/GLX.cpp +++ b/Source/Core/Common/GL/GLInterface/GLX.cpp @@ -13,7 +13,11 @@ typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSPROC)(Display*, GLXFBConfig, GLXContext, Bool, const int*); + +#ifndef GLX_EXT_swap_control typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*, GLXDrawable, int); +#endif + typedef int (*PFNGLXSWAPINTERVALMESAPROC)(unsigned int); static PFNGLXCREATECONTEXTATTRIBSPROC glXCreateContextAttribs = nullptr; From 6b05f5cca8a84937fb647875c99c34448c235933 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Sun, 20 Feb 2022 03:09:53 -0500 Subject: [PATCH 4/9] DolphinQt: Set the executable's rpath to a lib directory in $ORIGIN on Steam builds for Linux We will store our Qt shared libraries here. --- Source/Core/DolphinQt/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 4867d30e9d..79e7105db6 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -606,6 +606,22 @@ else() install(TARGETS dolphin-emu RUNTIME DESTINATION ${bindir}) endif() +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND STEAM) + # Set that we want ORIGIN in FLAGS. + # We also want RPATH, not RUNPATH, so disable the new tags. + target_link_options(dolphin-emu + PRIVATE + LINKER:-z,origin + LINKER:--disable-new-dtags + ) + + # For Steam Runtime builds, our Qt shared libraries will be in a "lib" folder. + set_target_properties(dolphin-emu PROPERTIES + BUILD_WITH_INSTALL_RPATH true + INSTALL_RPATH "\$ORIGIN/lib" + ) +endif() + if(USE_MGBA) target_sources(dolphin-emu PRIVATE GBAHost.cpp From 77fb5fa7dcdd9b3bb1da82c2e5b40cdf05638de3 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Sun, 20 Feb 2022 18:24:35 -0500 Subject: [PATCH 5/9] DolphinQt: Copy all Qt libraries into Binaries output folder on Steam builds for Linux --- Source/Core/DolphinQt/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 79e7105db6..25b2452aa2 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -620,6 +620,12 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND STEAM) BUILD_WITH_INSTALL_RPATH true INSTALL_RPATH "\$ORIGIN/lib" ) + + add_custom_command(TARGET dolphin-emu POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib" + COMMAND cp -P "${QT_DIR}/../../*.so*" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${QT_DIR}/../../../plugins/platforms" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/platforms" + ) endif() if(USE_MGBA) From 5c4122ec2a0b66b9a717b7be7512504064f566e5 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Sun, 20 Feb 2022 18:29:40 -0500 Subject: [PATCH 6/9] DolphinQt: Copy Sys into Binaries output folder on Steam builds for Linux --- Source/Core/DolphinQt/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 25b2452aa2..6d7a95e524 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -626,6 +626,19 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND STEAM) COMMAND cp -P "${QT_DIR}/../../*.so*" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib" COMMAND ${CMAKE_COMMAND} -E copy_directory "${QT_DIR}/../../../plugins/platforms" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/platforms" ) + + # Mark all data files as resources + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/Data/Sys") + file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/Data" "${CMAKE_SOURCE_DIR}/Data/Sys/*") + foreach(res ${resources}) + target_sources(dolphin-emu PRIVATE "${CMAKE_SOURCE_DIR}/Data/${res}") + source_group("Resources" FILES "${CMAKE_SOURCE_DIR}/Data/${res}") + endforeach() + + # Copy Sys folder + add_custom_command(TARGET dolphin-emu POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/Data/Sys" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Sys" + ) endif() if(USE_MGBA) From 09875c640331bab3d4b36b84ecb8d5bcdccc54f9 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Sun, 20 Feb 2022 22:28:37 -0500 Subject: [PATCH 7/9] DolphinQt: Copy qt.conf into Binaries output folder on Steam builds for Linux --- Source/Core/DolphinQt/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 6d7a95e524..6b24b3e68a 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -627,6 +627,12 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND STEAM) COMMAND ${CMAKE_COMMAND} -E copy_directory "${QT_DIR}/../../../plugins/platforms" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/platforms" ) + # Copy qt.conf + target_sources(dolphin-emu PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/qt.conf") + add_custom_command(TARGET dolphin-emu POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qt.conf" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf" + ) + # Mark all data files as resources set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/Data/Sys") file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/Data" "${CMAKE_SOURCE_DIR}/Data/Sys/*") From df22439826997b29e7ec587c13c4beb0862bce58 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Sun, 15 May 2022 04:02:01 -0400 Subject: [PATCH 8/9] FS: Reshuffle Rename to fix steamrt unit test failure --- Source/Core/Core/IOS/FS/HostBackend/FS.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp index ef1e983b2a..27daeeafb1 100644 --- a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp +++ b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp @@ -552,16 +552,20 @@ ResultCode HostFileSystem::Rename(Uid uid, Gid gid, const std::string& old_path, } } - // Finally, remove the child from the old parent and move it to the new parent. FstEntry* new_entry = GetFstEntryForPath(new_path); + new_entry->name = split_new_path.file_name; + + // Finally, remove the child from the old parent and move it to the new parent. const auto it = std::find_if(old_parent->children.begin(), old_parent->children.end(), GetNamePredicate(split_old_path.file_name)); if (it != old_parent->children.end()) { - *new_entry = *it; + new_entry->data = it->data; + new_entry->children = it->children; + old_parent->children.erase(it); } - new_entry->name = split_new_path.file_name; + SaveFst(); return ResultCode::Success; From 2648837d8c173c23af515f5804ca2db9b20950a9 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Sun, 22 May 2022 01:19:44 -0400 Subject: [PATCH 9/9] CMakeLists: Add flag to disable usage of shared libpng --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a22ed7534..bf5c46b436 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ if(NOT ANDROID) endif() option(USE_SHARED_ENET "Use shared libenet if found rather than Dolphin's soon-to-compatibly-diverge version" OFF) +option(USE_SHARED_LIBPNG "Use shared libpng if found" ON) option(USE_UPNP "Enables UPnP port mapping support" ON) option(ENABLE_NOGUI "Enable NoGUI frontend" ON) option(ENABLE_QT "Enable Qt (Default)" ON) @@ -413,6 +414,9 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin") find_library(IOB_LIBRARY IOBluetooth) find_library(IOK_LIBRARY IOKit) find_library(OPENGL_LIBRARY OpenGL) + + # We don't want to use shared libpng. + set(USE_SHARED_LIBPNG OFF) endif() if(ENABLE_LTO) @@ -786,7 +790,7 @@ else() set(LZO lzo2) endif() -if(NOT APPLE) +if(USE_SHARED_LIBPNG) check_lib(PNG libpng png png.h QUIET) endif() if (PNG_FOUND)