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>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-28 19:10:58 +00:00
parent 4353158d60
commit 8e4fccdfc6
2 changed files with 32 additions and 2 deletions

View File

@@ -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

View File

@@ -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