From 8e4fccdfc6dfd012ea34a0cd21e47af12194d051 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Oct 2025 19:10:58 +0000 Subject: [PATCH] build: apply ENet FreeBSD patch during cmake configuration - Create proper patch file for ENet FreeBSD support - Apply patch automatically during CMake configuration on FreeBSD - Avoid modifying submodule files directly Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> --- cmake/dependencies/common.cmake | 30 +++++++++++++++++++ ...eebsd.patch => enet-freebsd-support.patch} | 4 +-- 2 files changed, 32 insertions(+), 2 deletions(-) rename patches/{enet_freebsd.patch => enet-freebsd-support.patch} (96%) diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake index 24a808837..8674342da 100644 --- a/cmake/dependencies/common.cmake +++ b/cmake/dependencies/common.cmake @@ -7,6 +7,36 @@ include(dependencies/Boost_Sunshine) # submodules # moonlight common library set(ENET_NO_INSTALL ON CACHE BOOL "Don't install any libraries built for enet") + +# Apply FreeBSD patch to ENet if on FreeBSD +if(FREEBSD) + set(ENET_PATCH_FILE "${CMAKE_SOURCE_DIR}/patches/enet-freebsd-support.patch") + set(ENET_SOURCE_FILE "${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/enet/unix.c") + + # Check if patch needs to be applied + execute_process( + COMMAND patch -p0 -N --dry-run -i ${ENET_PATCH_FILE} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/enet + RESULT_VARIABLE PATCH_DRY_RUN_RESULT + OUTPUT_QUIET + ERROR_QUIET + ) + + # Apply patch if it hasn't been applied yet + if(PATCH_DRY_RUN_RESULT EQUAL 0) + message(STATUS "Applying FreeBSD patch to ENet") + execute_process( + COMMAND patch -p0 -N -i ${ENET_PATCH_FILE} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/enet + RESULT_VARIABLE PATCH_RESULT + ) + + if(NOT PATCH_RESULT EQUAL 0) + message(FATAL_ERROR "Failed to apply FreeBSD patch to ENet") + endif() + endif() +endif() + add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/enet") # web server diff --git a/patches/enet_freebsd.patch b/patches/enet-freebsd-support.patch similarity index 96% rename from patches/enet_freebsd.patch rename to patches/enet-freebsd-support.patch index 51e65706e..530ec105b 100644 --- a/patches/enet_freebsd.patch +++ b/patches/enet-freebsd-support.patch @@ -1,8 +1,8 @@ diff --git a/unix.c b/unix.c -index 1234567..abcdefg 100644 +index 3d57e9d..c2318ca 100644 --- a/unix.c +++ b/unix.c -@@ -373,6 +373,14 @@ enet_socket_create (ENetSocketType type, int af) +@@ -373,6 +373,14 @@ enet_socket_create (int af, ENetSocketType type) } #endif