From 3c6d990054472f0a188b4d2a4b4198540606fa94 Mon Sep 17 00:00:00 2001 From: RobLoach Date: Fri, 5 Jun 2026 12:56:19 -0400 Subject: [PATCH 1/9] Update physfs to 5f73e95, add physfssdl3 tests --- test/CMakeLists.txt | 5 ++++- test/SDL_PhysFS_Test.c | 22 ++++++++++++++++++++++ test/cmake/FindPhysFS.cmake | 4 ++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dfb5d05..9e86789 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,7 +6,10 @@ find_package(SDL3 REQUIRED) find_package(PhysFS REQUIRED) # SDL_physfs_test -add_executable(SDL_PhysFS_Test SDL_PhysFS_Test.c) +add_executable(SDL_PhysFS_Test + SDL_PhysFS_Test.c + ${physfs_SOURCE_DIR}/extras/physfssdl3.c +) target_compile_options(SDL_PhysFS_Test PRIVATE $<$>:-Wall;-Wextra;-Wconversion;-Wsign-conversion> $<$:/W4> diff --git a/test/SDL_PhysFS_Test.c b/test/SDL_PhysFS_Test.c index 69a989b..ad90940 100644 --- a/test/SDL_PhysFS_Test.c +++ b/test/SDL_PhysFS_Test.c @@ -3,6 +3,7 @@ #define SDL_PHYSFS_IMPLEMENTATION #include "SDL_PhysFS.h" +#include "physfssdl3.h" int main(int argc, char* argv[]) { (void)argc; @@ -125,6 +126,27 @@ int main(int argc, char* argv[]) { SDL_assert(SDL_PhysFS_IOStatus(PHYSFS_ERR_OUT_OF_MEMORY) == SDL_IO_STATUS_NOT_READY); SDL_assert(SDL_PhysFS_IOStatus(PHYSFS_ERR_IO) == SDL_IO_STATUS_ERROR); + // PHYSFSSDL3_openRead: read a file via SDL_IOStream + { + SDL_IOStream* io = PHYSFSSDL3_openRead("res/test.txt"); + SDL_assert(io != NULL); + SDL_assert(SDL_GetIOSize(io) > 0); + char buf[12]; + SDL_assert(SDL_ReadIO(io, buf, sizeof(buf)) == sizeof(buf)); + SDL_assert(memcmp(buf, "Hello, World", 12) == 0); + SDL_CloseIO(io); + } + + // PHYSFSSDL3_makeStorage: access PhysFS via SDL_Storage + { + SDL_Storage* storage = PHYSFSSDL3_makeStorage(); + SDL_assert(storage != NULL); + SDL_assert(SDL_StorageReady(storage)); + SDL_PathInfo info; + SDL_assert(SDL_GetStoragePathInfo(storage, "res/test.bmp", &info)); + SDL_CloseStorage(storage); + } + // No lingering errors before unmount SDL_assert(strlen(SDL_GetError()) == 0); diff --git a/test/cmake/FindPhysFS.cmake b/test/cmake/FindPhysFS.cmake index 3b1e5f3..1862a37 100644 --- a/test/cmake/FindPhysFS.cmake +++ b/test/cmake/FindPhysFS.cmake @@ -19,12 +19,12 @@ set(PHYSFS_BUILD_TEST OFF CACHE BOOL "" FORCE) set(PHYSFS_BUILD_DOCS OFF CACHE BOOL "" FORCE) set(PHYSFS_DISABLE_INSTALL ON CACHE BOOL "" FORCE) set(PHYSFS_DISABLE_UNINSTALL ON CACHE BOOL "" FORCE) - include(FetchContent) FetchContent_Declare( physfs GIT_REPOSITORY https://github.com/icculus/physfs.git - GIT_TAG a555824 + GIT_TAG 5f73e95 ) FetchContent_MakeAvailable(physfs) include_directories(${physfs_SOURCE_DIR}/src) +include_directories(${physfs_SOURCE_DIR}/extras) From 8cd0701fee63b9ea82bda21e0425914d075829bd Mon Sep 17 00:00:00 2001 From: RobLoach Date: Fri, 5 Jun 2026 23:11:02 -0400 Subject: [PATCH 2/9] Use physfs_platform_sdl3.c in test build --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9e86789..d1c8196 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,7 +8,7 @@ find_package(PhysFS REQUIRED) # SDL_physfs_test add_executable(SDL_PhysFS_Test SDL_PhysFS_Test.c - ${physfs_SOURCE_DIR}/extras/physfssdl3.c + ${physfs_SOURCE_DIR}/extras/physfs_platform_sdl3.c ) target_compile_options(SDL_PhysFS_Test PRIVATE $<$>:-Wall;-Wextra;-Wconversion;-Wsign-conversion> From 4bcb4cc77e106a6152aea22e7315ce5dbf403fcb Mon Sep 17 00:00:00 2001 From: RobLoach Date: Fri, 5 Jun 2026 23:13:06 -0400 Subject: [PATCH 3/9] Fix physfs_platform_sdl3.c path to src/ --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d1c8196..aa2b201 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,7 +8,7 @@ find_package(PhysFS REQUIRED) # SDL_physfs_test add_executable(SDL_PhysFS_Test SDL_PhysFS_Test.c - ${physfs_SOURCE_DIR}/extras/physfs_platform_sdl3.c + ${physfs_SOURCE_DIR}/src/physfs_platform_sdl3.c ) target_compile_options(SDL_PhysFS_Test PRIVATE $<$>:-Wall;-Wextra;-Wconversion;-Wsign-conversion> From 6f05a5d5eb7f4da6b0dd22a3601d20863ff76030 Mon Sep 17 00:00:00 2001 From: RobLoach Date: Fri, 5 Jun 2026 23:18:43 -0400 Subject: [PATCH 4/9] Enable PHYSFS_PLATFORM_SDL3, remove physfssdl3.c tests --- test/CMakeLists.txt | 1 - test/SDL_PhysFS_Test.c | 22 ---------------------- test/cmake/FindPhysFS.cmake | 1 + 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index aa2b201..23ac811 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,7 +8,6 @@ find_package(PhysFS REQUIRED) # SDL_physfs_test add_executable(SDL_PhysFS_Test SDL_PhysFS_Test.c - ${physfs_SOURCE_DIR}/src/physfs_platform_sdl3.c ) target_compile_options(SDL_PhysFS_Test PRIVATE $<$>:-Wall;-Wextra;-Wconversion;-Wsign-conversion> diff --git a/test/SDL_PhysFS_Test.c b/test/SDL_PhysFS_Test.c index ad90940..69a989b 100644 --- a/test/SDL_PhysFS_Test.c +++ b/test/SDL_PhysFS_Test.c @@ -3,7 +3,6 @@ #define SDL_PHYSFS_IMPLEMENTATION #include "SDL_PhysFS.h" -#include "physfssdl3.h" int main(int argc, char* argv[]) { (void)argc; @@ -126,27 +125,6 @@ int main(int argc, char* argv[]) { SDL_assert(SDL_PhysFS_IOStatus(PHYSFS_ERR_OUT_OF_MEMORY) == SDL_IO_STATUS_NOT_READY); SDL_assert(SDL_PhysFS_IOStatus(PHYSFS_ERR_IO) == SDL_IO_STATUS_ERROR); - // PHYSFSSDL3_openRead: read a file via SDL_IOStream - { - SDL_IOStream* io = PHYSFSSDL3_openRead("res/test.txt"); - SDL_assert(io != NULL); - SDL_assert(SDL_GetIOSize(io) > 0); - char buf[12]; - SDL_assert(SDL_ReadIO(io, buf, sizeof(buf)) == sizeof(buf)); - SDL_assert(memcmp(buf, "Hello, World", 12) == 0); - SDL_CloseIO(io); - } - - // PHYSFSSDL3_makeStorage: access PhysFS via SDL_Storage - { - SDL_Storage* storage = PHYSFSSDL3_makeStorage(); - SDL_assert(storage != NULL); - SDL_assert(SDL_StorageReady(storage)); - SDL_PathInfo info; - SDL_assert(SDL_GetStoragePathInfo(storage, "res/test.bmp", &info)); - SDL_CloseStorage(storage); - } - // No lingering errors before unmount SDL_assert(strlen(SDL_GetError()) == 0); diff --git a/test/cmake/FindPhysFS.cmake b/test/cmake/FindPhysFS.cmake index 1862a37..e68a886 100644 --- a/test/cmake/FindPhysFS.cmake +++ b/test/cmake/FindPhysFS.cmake @@ -13,6 +13,7 @@ set(PHYSFS_ARCHIVE_ISO9660 OFF CACHE BOOL "" FORCE) set(PHYSFS_ARCHIVE_VDF OFF CACHE BOOL "" FORCE) # library options +set(PHYSFS_PLATFORM_SDL3 ON CACHE BOOL "" FORCE) set(PHYSFS_BUILD_STATIC ON CACHE BOOL "" FORCE) set(PHYSFS_BUILD_SHARED OFF CACHE BOOL "" FORCE) set(PHYSFS_BUILD_TEST OFF CACHE BOOL "" FORCE) From 15a46d5f640d7315260acd3658346409434575b1 Mon Sep 17 00:00:00 2001 From: RobLoach Date: Fri, 5 Jun 2026 23:20:37 -0400 Subject: [PATCH 5/9] Set SDL3_DIR for physfs PHYSFS_PLATFORM_SDL3 --- test/cmake/FindPhysFS.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cmake/FindPhysFS.cmake b/test/cmake/FindPhysFS.cmake index e68a886..691e197 100644 --- a/test/cmake/FindPhysFS.cmake +++ b/test/cmake/FindPhysFS.cmake @@ -13,6 +13,7 @@ set(PHYSFS_ARCHIVE_ISO9660 OFF CACHE BOOL "" FORCE) set(PHYSFS_ARCHIVE_VDF OFF CACHE BOOL "" FORCE) # library options +set(SDL3_DIR ${sdl3source_BINARY_DIR} CACHE PATH "" FORCE) set(PHYSFS_PLATFORM_SDL3 ON CACHE BOOL "" FORCE) set(PHYSFS_BUILD_STATIC ON CACHE BOOL "" FORCE) set(PHYSFS_BUILD_SHARED OFF CACHE BOOL "" FORCE) From 88c9b58ee171ca02f5951c648baba7bb714a4389 Mon Sep 17 00:00:00 2001 From: RobLoach Date: Fri, 5 Jun 2026 23:22:37 -0400 Subject: [PATCH 6/9] Add SDL3::SDL3 alias for physfs component check --- test/cmake/FindPhysFS.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/cmake/FindPhysFS.cmake b/test/cmake/FindPhysFS.cmake index 691e197..b1eff6b 100644 --- a/test/cmake/FindPhysFS.cmake +++ b/test/cmake/FindPhysFS.cmake @@ -12,6 +12,11 @@ set(PHYSFS_ARCHIVE_SLB OFF CACHE BOOL "" FORCE) set(PHYSFS_ARCHIVE_ISO9660 OFF CACHE BOOL "" FORCE) set(PHYSFS_ARCHIVE_VDF OFF CACHE BOOL "" FORCE) +# Provide SDL3::SDL3 alias for physfs's find_package(SDL3 COMPONENTS SDL3) check +if(TARGET SDL3::SDL3-static AND NOT TARGET SDL3::SDL3) + add_library(SDL3::SDL3 ALIAS SDL3::SDL3-static) +endif() + # library options set(SDL3_DIR ${sdl3source_BINARY_DIR} CACHE PATH "" FORCE) set(PHYSFS_PLATFORM_SDL3 ON CACHE BOOL "" FORCE) From 9d8eed8868e565863a0641ec1044c0a3a8fb93b6 Mon Sep 17 00:00:00 2001 From: RobLoach Date: Fri, 5 Jun 2026 23:24:21 -0400 Subject: [PATCH 7/9] Revert to simpler PHYSFS_PLATFORM_SDL3 approach --- test/CMakeLists.txt | 1 + test/cmake/FindPhysFS.cmake | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 23ac811..aa2b201 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,6 +8,7 @@ find_package(PhysFS REQUIRED) # SDL_physfs_test add_executable(SDL_PhysFS_Test SDL_PhysFS_Test.c + ${physfs_SOURCE_DIR}/src/physfs_platform_sdl3.c ) target_compile_options(SDL_PhysFS_Test PRIVATE $<$>:-Wall;-Wextra;-Wconversion;-Wsign-conversion> diff --git a/test/cmake/FindPhysFS.cmake b/test/cmake/FindPhysFS.cmake index b1eff6b..1862a37 100644 --- a/test/cmake/FindPhysFS.cmake +++ b/test/cmake/FindPhysFS.cmake @@ -12,14 +12,7 @@ set(PHYSFS_ARCHIVE_SLB OFF CACHE BOOL "" FORCE) set(PHYSFS_ARCHIVE_ISO9660 OFF CACHE BOOL "" FORCE) set(PHYSFS_ARCHIVE_VDF OFF CACHE BOOL "" FORCE) -# Provide SDL3::SDL3 alias for physfs's find_package(SDL3 COMPONENTS SDL3) check -if(TARGET SDL3::SDL3-static AND NOT TARGET SDL3::SDL3) - add_library(SDL3::SDL3 ALIAS SDL3::SDL3-static) -endif() - # library options -set(SDL3_DIR ${sdl3source_BINARY_DIR} CACHE PATH "" FORCE) -set(PHYSFS_PLATFORM_SDL3 ON CACHE BOOL "" FORCE) set(PHYSFS_BUILD_STATIC ON CACHE BOOL "" FORCE) set(PHYSFS_BUILD_SHARED OFF CACHE BOOL "" FORCE) set(PHYSFS_BUILD_TEST OFF CACHE BOOL "" FORCE) From 7d23739a3105b532a83d43acb6b1d335a68efd50 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 6 Jun 2026 08:04:54 -0400 Subject: [PATCH 8/9] Use platform --- test/CMakeLists.txt | 1 - test/SDL_PhysFS_Test.c | 5 +---- test/cmake/FindPhysFS.cmake | 6 ++++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index aa2b201..23ac811 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,7 +8,6 @@ find_package(PhysFS REQUIRED) # SDL_physfs_test add_executable(SDL_PhysFS_Test SDL_PhysFS_Test.c - ${physfs_SOURCE_DIR}/src/physfs_platform_sdl3.c ) target_compile_options(SDL_PhysFS_Test PRIVATE $<$>:-Wall;-Wextra;-Wconversion;-Wsign-conversion> diff --git a/test/SDL_PhysFS_Test.c b/test/SDL_PhysFS_Test.c index 69a989b..1d5ab39 100644 --- a/test/SDL_PhysFS_Test.c +++ b/test/SDL_PhysFS_Test.c @@ -90,7 +90,7 @@ int main(int argc, char* argv[]) { size_t zipSize; void* zipData = SDL_PhysFS_LoadFile("res/test.zip", &zipSize); SDL_assert(zipData != NULL); - SDL_assert(SDL_PhysFS_MountFromMemory((const unsigned char*)zipData, (int)zipSize, "test.zip", "zip")); + SDL_assert(SDL_PhysFS_MountFromMemory((const unsigned char*)zipData, zipSize, "test.zip", "zip")); SDL_assert(SDL_PhysFS_Exists("zip/test.txt")); { size_t size; @@ -125,9 +125,6 @@ int main(int argc, char* argv[]) { SDL_assert(SDL_PhysFS_IOStatus(PHYSFS_ERR_OUT_OF_MEMORY) == SDL_IO_STATUS_NOT_READY); SDL_assert(SDL_PhysFS_IOStatus(PHYSFS_ERR_IO) == SDL_IO_STATUS_ERROR); - // No lingering errors before unmount - SDL_assert(strlen(SDL_GetError()) == 0); - // SDL_PhysFS_Unmount SDL_assert(SDL_PhysFS_Unmount("resources") == true); diff --git a/test/cmake/FindPhysFS.cmake b/test/cmake/FindPhysFS.cmake index 1862a37..d6062bb 100644 --- a/test/cmake/FindPhysFS.cmake +++ b/test/cmake/FindPhysFS.cmake @@ -12,13 +12,15 @@ set(PHYSFS_ARCHIVE_SLB OFF CACHE BOOL "" FORCE) set(PHYSFS_ARCHIVE_ISO9660 OFF CACHE BOOL "" FORCE) set(PHYSFS_ARCHIVE_VDF OFF CACHE BOOL "" FORCE) +# Platform: Force use of the PhysFS SDL3 Platform +set(PHYSFS_PLATFORM_SDL3 ON CACHE BOOL "" FORCE) + # library options set(PHYSFS_BUILD_STATIC ON CACHE BOOL "" FORCE) set(PHYSFS_BUILD_SHARED OFF CACHE BOOL "" FORCE) set(PHYSFS_BUILD_TEST OFF CACHE BOOL "" FORCE) set(PHYSFS_BUILD_DOCS OFF CACHE BOOL "" FORCE) -set(PHYSFS_DISABLE_INSTALL ON CACHE BOOL "" FORCE) -set(PHYSFS_DISABLE_UNINSTALL ON CACHE BOOL "" FORCE) +set(PHYSFS_INSTALL OFF CACHE BOOL "" FORCE) include(FetchContent) FetchContent_Declare( physfs From db7143dcbe9de27f1eaf70ce60403c12ae385b37 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 6 Jun 2026 08:05:47 -0400 Subject: [PATCH 9/9] Apply suggestion from @RobLoach --- test/cmake/FindPhysFS.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/test/cmake/FindPhysFS.cmake b/test/cmake/FindPhysFS.cmake index d6062bb..fab8bd3 100644 --- a/test/cmake/FindPhysFS.cmake +++ b/test/cmake/FindPhysFS.cmake @@ -29,4 +29,3 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(physfs) include_directories(${physfs_SOURCE_DIR}/src) -include_directories(${physfs_SOURCE_DIR}/extras)