[raylib] Cleanup, fix platform support (#40209)

This commit is contained in:
Kai Pastor 2024-08-06 09:53:19 +02:00 committed by GitHub
parent 4a405540d6
commit a2367ceec5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 73 additions and 78 deletions

13
ports/raylib/android.diff Normal file
View File

@ -0,0 +1,13 @@
diff --git a/cmake/GlfwImport.cmake b/cmake/GlfwImport.cmake
index d0c23ca..92cd5c3 100644
--- a/cmake/GlfwImport.cmake
+++ b/cmake/GlfwImport.cmake
@@ -30,6 +30,8 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT
include_directories(BEFORE SYSTEM external/glfw/include)
elseif("${PLATFORM}" STREQUAL "DRM")
MESSAGE(STATUS "No GLFW required on PLATFORM_DRM")
+elseif("${PLATFORM}" STREQUAL "Android")
+ list(REMOVE_ITEM LIBS_PRIVATE glfw)
else()
MESSAGE(STATUS "Using external GLFW")
set(GLFW_PKG_DEPS glfw3)

View File

@ -1,29 +0,0 @@
diff --git a/cmake/GlfwImport.cmake b/cmake/GlfwImport.cmake
index 1b94cdf..4cc8f8f 100644
--- a/cmake/GlfwImport.cmake
+++ b/cmake/GlfwImport.cmake
@@ -5,7 +5,7 @@ elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE")
find_package(glfw3 3.3.3 QUIET)
endif()
if (glfw3_FOUND)
- set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
+ set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw3)
endif()
# Explicitly check against "ON", because USE_EXTERNAL_GLFW is a tristate option
@@ -32,3 +32,4 @@ else()
MESSAGE(STATUS "Using external GLFW")
set(GLFW_PKG_DEPS glfw3)
endif()
+set(GLFW_PKG_DEPS glfw3)
diff --git a/cmake/LibraryConfigurations.cmake b/cmake/LibraryConfigurations.cmake
index c156d6b..55c5bca 100644
--- a/cmake/LibraryConfigurations.cmake
+++ b/cmake/LibraryConfigurations.cmake
@@ -104,5 +104,5 @@ endif ()
set(LIBS_PRIVATE ${LIBS_PRIVATE} ${OPENAL_LIBRARY})
if (${PLATFORM} MATCHES "Desktop")
- set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
+ set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw3)
endif ()

View File

@ -1,4 +1,4 @@
if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_LINUX)
if(VCPKG_TARGET_IS_LINUX)
message(
"raylib currently requires the following libraries from the system package manager:
libgl1-mesa-dev
@ -10,14 +10,6 @@ These can be installed on Ubuntu systems via sudo apt install libgl1-mesa-dev li
)
endif()
if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_LINUX)
set(patches fix-linkGlfw.patch)
endif()
if(VCPKG_TARGET_IS_EMSCRIPTEN)
set(ADDITIONAL_OPTIONS "-DPLATFORM=Web")
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO raysan5/raylib
@ -25,45 +17,57 @@ vcpkg_from_github(
SHA512 5956bc1646b99baac6eb1652c4d72e96af874337158672155ba144f131de8a4fd19291a58335a92fcaaa2fc818682f93ff4230af0f815efb8b49f7d2a162e9b0
HEAD_REF master
PATCHES
${patches}
android.diff
)
file(GLOB vendored_headers RELATIVE "${SOURCE_PATH}/src/external"
"${SOURCE_PATH}/src/external/cgltf.h"
# Do not use dirent from vcpkg: It is a different implementation which has
# 'include <windows.h>', leading to duplicate and conflicting definitions.
#"${SOURCE_PATH}/src/external/dirent.h"
"${SOURCE_PATH}/src/external/dr_*.h" # from drlibs
"${SOURCE_PATH}/src/external/miniaudio.h"
"${SOURCE_PATH}/src/external/nanosvg*.h"
"${SOURCE_PATH}/src/external/qoi.h"
"${SOURCE_PATH}/src/external/s*fl.h" # from mmx
"${SOURCE_PATH}/src/external/stb_*"
)
set(optional_vendored_headers
"stb_image_resize2.h" # not yet in vcpkg
)
foreach(header IN LISTS vendored_headers)
unset(vcpkg_file)
find_file(vcpkg_file NAMES "${header}" PATHS "${CURRENT_INSTALLED_DIR}/include" PATH_SUFFIXES mmx nanosvg NO_DEFAULT_PATH NO_CACHE)
if(vcpkg_file)
message(STATUS "De-vendoring '${header}'")
file(COPY "${vcpkg_file}" DESTINATION "${SOURCE_PATH}/src/external")
elseif(header IN_LIST optional_vendored_headers)
message(STATUS "Not de-vendoring '${header}' (absent in vcpkg)")
else()
message(FATAL_ERROR "No replacement for vendored '${header}'")
endif()
endforeach()
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SHARED)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" STATIC)
set(PLATFORM_OPTIONS "")
if(VCPKG_TARGET_IS_ANDROID)
list(APPEND PLATFORM_OPTIONS -DPLATFORM=Android -DUSE_EXTERNAL_GLFW=OFF)
elseif(VCPKG_TARGET_IS_EMSCRIPTEN)
list(APPEND PLATFORM_OPTIONS -DPLATFORM=Web -DUSE_EXTERNAL_GLFW=OFF)
else()
list(APPEND PLATFORM_OPTIONS -DPLATFORM=Desktop -DUSE_EXTERNAL_GLFW=ON)
endif()
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
hidpi SUPPORT_HIGH_DPI
use-audio USE_AUDIO
)
if(VCPKG_TARGET_IS_MINGW)
set(DEBUG_ENABLE_SANITIZERS OFF)
else()
set(DEBUG_ENABLE_SANITIZERS ON)
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_EXAMPLES=OFF
-DSHARED=${SHARED}
-DSTATIC=${STATIC}
-DUSE_EXTERNAL_GLFW=OFF # externl glfw3 causes build errors on Windows
-DCMAKE_POLICY_DEFAULT_CMP0072=NEW # Prefer GLVND
${PLATFORM_OPTIONS}
${FEATURE_OPTIONS}
${ADDITIONAL_OPTIONS}
OPTIONS_DEBUG
-DENABLE_ASAN=${DEBUG_ENABLE_SANITIZERS}
-DENABLE_UBSAN=${DEBUG_ENABLE_SANITIZERS}
-DENABLE_MSAN=OFF
OPTIONS_RELEASE
-DENABLE_ASAN=OFF
-DENABLE_UBSAN=OFF
-DENABLE_MSAN=OFF
MAYBE_UNUSED_VARIABLES
SHARED
STATIC
SUPPORT_HIGH_DPI
)
vcpkg_cmake_install()
@ -74,16 +78,12 @@ vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/${PORT})
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE
${CURRENT_PACKAGES_DIR}/debug/include
${CURRENT_PACKAGES_DIR}/debug/share
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
)
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
vcpkg_replace_string(
${CURRENT_PACKAGES_DIR}/include/raylib.h
"defined(USE_LIBTYPE_SHARED)"
"1 // defined(USE_LIBTYPE_SHARED)"
)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/raylib.h" "defined(USE_LIBTYPE_SHARED)" "1")
endif()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

View File

@ -1,15 +1,24 @@
{
"name": "raylib",
"version": "5.0",
"port-version": 1,
"description": "A simple and easy-to-use library to enjoy videogames programming",
"homepage": "https://github.com/raysan5/raylib",
"license": "Zlib",
"supports": "!uwp",
"supports": "!arm32 & !uwp",
"dependencies": [
"cgltf",
"dirent",
"drlibs",
{
"name": "glfw3",
"platform": "!(windows | emscripten)"
"platform": "!(android | emscripten)"
},
"miniaudio",
"mmx",
"nanosvg",
"qoi",
"stb",
{
"name": "vcpkg-cmake",
"host": true
@ -23,9 +32,6 @@
"use-audio"
],
"features": {
"hidpi": {
"description": "Support high-DPI displays"
},
"use-audio": {
"description": "Build raylib with audio module"
}

View File

@ -7702,7 +7702,7 @@
},
"raylib": {
"baseline": "5.0",
"port-version": 0
"port-version": 1
},
"rbdl": {
"baseline": "3.3.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "6ef397a5c5afb217736842e45d9610d084a1fb2d",
"version": "5.0",
"port-version": 1
},
{
"git-tree": "7cf5ce249c066d11ea5afe9ed15972663992c0f2",
"version": "5.0",